Re: Automatic expansion of Log[a^n] for a, n explicit positive integers?
- To: mathgroup at smc.vnet.net
- Subject: [mg28265] Re: [mg28180] Automatic expansion of Log[a^n] for a, n explicit positive integers?
- From: BobHanlon at aol.com
- Date: Fri, 6 Apr 2001 01:53:15 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Here are two alternatives depending on how you want the function to behave
for other cases.
loga[b_:E, x_Integer?Positive] :=
Plus @@ (#[[2]]*Log[b, #[[1]]]& /@ FactorInteger[x]);
loga[b_:E, x_] := Log[b, x];
logb[b_:E, x_Integer?Positive] := Module[{fi = FactorInteger[x]},
If[Length[fi] == 1, fi[[1,2]]*Log[b, fi[[1,1]]], Log[b, x]]];
logb[b_:E, x_] := Log[b, x];
Table[{k, loga[k], logb[k]}, {k, 10}] // TableForm
Bob Hanlon
In a message dated 2001/4/3 2:46:08 AM, anlauf at hep.tu-darmstadt.de writes:
>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.
>