MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Automatic expansion of Log[a^n] for a,n explicit positive integers?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28243] Re: [mg28229] Re: [mg28180] Automatic expansion of Log[a^n] for a,n explicit positive integers?
  • From: Harald Anlauf <anlauf at hep.tu-darmstadt.de>
  • Date: Fri, 6 Apr 2001 01:52:51 -0400 (EDT)
  • References: <Pine.LNX.4.21.0104051007450.27588-100000@shell.faradic.net>
  • Sender: owner-wri-mathgroup at wolfram.com

>>>>> "Chris" == Chris Johnson <cjohnson at shell.faradic.net> writes:

Chris> You could use this function:

Chris> lg[z_?IntegerQ] := Plus @@ Apply[#2 Log[#1] &, FactorInteger[z], 2]

Chris> I tried to incorporate this into the definition of Log by:

Chris> Unprotect[Log];
Chris> Log[z_?IntegerQ] := Plus @@ Apply[#2Log[#1] &, FactorInteger[z], 2];
Chris> Protect[Log];

Chris> But I get a recursion error.  I hope someone else might be able to suggest
Chris> a way to avoid this.  Putting Hold around the Log in the pure function
Chris> leaves the Hold in the output.  I hoped I could first define

Chris> Log[z_?PrimeQ] := Log[z] 

Chris> to catch the Prime case, but this also leads to recursion.

You were very close, indeed!

Mianlai Zhou <lailai at carmen.nikhef.nl> wrote me that he solved this problem
by:

Unprotect[Log]
Log[n_Integer?Positive /; !PrimeQ[n]] :=
    Plus @@ (#2 Log[#1] & @@@ FactorInteger[n])
Protect[Log]

I haven't checked the performance degradation that this might involve, tho.

Cheers,
-Harald


  • Prev by Date: Re: Help with Fold/outer one-liner (II)
  • Next by Date: Re: InputAliases
  • Previous by thread: Re: Re: Automatic expansion of Log[a^n] for a,n explicit positive integers?
  • Next by thread: Re: Re: Automatic expansion of Log[a^n] for a,n explicit positive integers?