Re: Re: Automatic expansion of Log[a^n] for a,n explicit positive integers?
- To: mathgroup at smc.vnet.net
- Subject: [mg28241] Re: [mg28229] Re: [mg28180] Automatic expansion of Log[a^n] for a,n explicit positive integers?
- From: Chris Johnson <cjohnson at shell.faradic.net>
- Date: Fri, 6 Apr 2001 01:52:50 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Harald, You could use this function: lg[z_?IntegerQ] := Plus @@ Apply[#2 Log[#1] &, FactorInteger[z], 2] I tried to incorporate this into the definition of Log by: Unprotect[Log]; Log[z_?IntegerQ] := Plus @@ Apply[#2Log[#1] &, FactorInteger[z], 2]; Protect[Log]; But I get a recursion error. I hope someone else might be able to suggest a way to avoid this. Putting Hold around the Log in the pure function leaves the Hold in the output. I hoped I could first define Log[z_?PrimeQ] := Log[z] to catch the Prime case, but this also leads to recursion. Chris On Thu, 5 Apr 2001, Tomas Garza wrote: > If you are only concerned about powers of 2, then you may define the > functiion lg and use it always instead of Log: > > In[1]:= > lg[n_] := If[Mod[n, 2] == 0, IntegerExponent[n, 2]*Log[2], Log[n]] > > Then, e.g., > > In[1]:= > {lg[2], lg[4], lg[8], lg[16], lg[32], lg[3]} > Out[1]= > {Log[2], 2 Log[2], 3 Log[2], 4 Log[2], 5 Log[2], Log[3]} > > Tomas Garza > Mexico City > ----- Original Message ----- > From: "Harald Anlauf" <anlauf at hep.tu-darmstadt.de> To: mathgroup at smc.vnet.net > To: mathgroup at smc.vnet.net > Subject: [mg28241] [mg28229] [mg28180] Automatic expansion of Log[a^n] for a,n explicit positive > integers? > > > > Hi, > > > > is there a way to force Mathematica 4.0 to always expand expressions like > > > > Log[4], Log[8], Log[16], etc. to 2*Log[2] etc. > > > > automatically? > > > > It is very annoying to have such logarithms expanded manually each > > time they pop up again... > > > > PowerExpand[] apparently does not help/work. > > > > -- > > Ciao, > > -ha > > > >