[Date Index]
[Thread Index]
[Author Index]
Re: an expression with logs
*To*: mathgroup at smc.vnet.net
*Subject*: [mg75385] Re: an expression with logs
*From*: Norbert Marxer <marxer at mec.li>
*Date*: Fri, 27 Apr 2007 05:29:13 -0400 (EDT)
*References*: <f0n78d$qdg$1@smc.vnet.net>
On 25 Apr., 11:33, dimitris <dimmec... at yahoo.com> wrote:
> Hello.
>
> In[27]:=
> oo = 5*Log[4/3] - 3*Log[3/2] - Log[2];
>
> I want oo to take the form 4*(3*Log[2] - 2*Log[3])
>
> I can think one workaround like
>
> In[43]:=
> PowerExpand[oo]
> Collect[%, {Log[2], Log[3]}]
> % /. Log[4] -> 2*Log[2]
> Factor[%]
>
> Out[43]=
> -Log[2] - 3*(-Log[2] + Log[3]) + 5*(-Log[3] + Log[4])
>
> Out[44]=
> 2*Log[2] - 8*Log[3] + 5*Log[4]
>
> Out[45]=
> 12*Log[2] - 8*Log[3]
>
> Out[46]=
> 4*(3*Log[2] - 2*Log[3])
>
> But I am sure there is something smarter and more compact.
>
> Any ideas?
>
> Dimitris
Hello
This version should work on arbitrary rational and integer numbers.
(Note that I didn't test it thoroughly though).
f1 := #1 /. Log[Rational[x_, y_]] :>
Log[x] - Log[y] &
f2 := #1 /. Log[x_Integer] :>
Plus @@ f3 /@ FactorInteger[x] &
f3[{x_, y_}] := y*Log[x];
f := Expand[f2[f1[#1]]] &
Then
f[Log[24]]
f[5*Log[4/3] - 3*Log[3/2] - Log[2]]
f[Log[(3*4^3)/5^2]]
will give you
3*Log[2] + Log[3]
12*Log[2] - 8*Log[3]
6*Log[2] + Log[3] - 2*Log[5]
Best Regards
Norbert Marxer
Prev by Date:
**Re: How to make a loop for this problem!**
Next by Date:
**Re: How to make a loop for this problem!**
Previous by thread:
**an expression with logs**
Next by thread:
**how to create a subclass**
| |