PowerExpand[Log[a b]]
Log[a] + Log[b]
How can I do the opposite, i.e. combine Log[a] + Log[b] into Log[a b]?
Thanks
Themis
Cheers -- Sjoerd
there's no unexpand but to know that PowerExpand uses heavy assumptions
per default is useful. This should be a warning too that the results of
PowerExpand not in general true. See for instance what
PowerExpand[Log[a b], Assumptions -> Element[{a, b}, Complexes]]
gives:
2*I*Pi*Floor[1/2 - Arg[a]/(2*Pi) - Arg[b]/(2*Pi)] + Log[a] +
Log[b]
Your expansion is valid for instance for
PowerExpand[Log[a b], Assumptions -> a > 0 && b > 0]
and therefore
FullSimplify[%, Assumptions -> a > 0 && b > 0]
gives again
Log[a b]
To see where exactly the log rule works you could do maybe
Reduce[2*I*Pi*Floor[1/2 - Arg[a]/(2*Pi) - Arg[b]/(2*Pi)] == 0, {a, b}]
Cheers
Patrick
expandLog[expr_] := Module[{rule1, rule2, a, b, x},
rule1 = Log[a_*b_] -> Log[a] + Log[b];
rule2 = Log[a_^x_] -> x*Log[a];
(expr /. rule1) /. rule2
];
collectLog[expr_] := Module[{rule1, rule2, a, b, x},
rule1 = Log[a_] + Log[b_] -> Log[a*b];
rule2 = x_*Log[a_] -> Log[a^x];
(expr /. rule1) /. rule2 /. rule1 /. rule2
];
Then:
Log[Sin[x]*Cos[y]] // expandLog
Log[Cos[y]] + Log[Sin[x]]
Log[a + b] + Log[c + d] // collectLog
Log[(a + b) (c + d)]
Have fun, Alexei
I can use PowerExapnd to expand a Log:
PowerExpand[Log[a b]]
Log[a] + Log[b]
How can I do the opposite, i.e. combine Log[a] + Log[b] into Log[a b]?
Thanks
Themis
--
Alexei Boulbitch, Dr. habil.
Senior Scientist
Material Development
IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 CONTERN
Luxembourg
Tel: +352 2454 2566
Fax: +352 2454 3566
Mobile: +49 (0) 151 52 40 66 44
e-mail: alexei.b...@iee.lu
--
This e-mail may contain trade secrets or privileged, undisclosed or
otherwise confidential information. If you are not the intended
recipient and have received this e-mail in error, you are hereby
notified that any review, copying or distribution of it is strictly
prohibited. Please inform us immediately and destroy the original
transmittal from your system. Thank you for your co-operation.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 5410 (20100830) __________
The message was checked by ESET NOD32 Antivirus.
Then, e.g.
In[2]:= y Log[2]+Log[x^2]-Log[z]
Out[2]= y Log[2]+Log[x^2]-Log[z]
In[3]:= %//.logRep
Out[3]= Log[(2^y x^2)/z]
Simon
PowerExpand treats its expressions assuming all variables are positive.
Normally Log[ab]==Log[a]+Log[b] is not always tru, e.g.
0=Log[(-1)(-1)]!=Log[-1]+Log[-1]==2Pi I
So you have to declare the variables as positives (if your domains are right):
In[1]:= Simplify[Log[a]+Log[b], Assumptions->a>0&&b>0]
Out[1]= Log[ab]
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
log(a)+log(b)+log(c)
% //. Log[x_] + Log[y_] -> Log[x*y]
log(a b c)
Bob Hanlon
---- Themis Matsoukas <tmats...@me.com> wrote:
=============
try:
In[1]:= FullSimplify[Log[a]+Log[b],a>0<b]
Out[1]= Log[a b]
Peter
1: Tell mathematica that the arguments are positive numbers:
FullSimplify[2 Log[a] + 3 Log[b], Assumptions -> {a > 0, b > 0, c > 0}]
Log[a^2 b^3]
2: Use a replacement rule
2 Log[a] + 3 Log[b] //. a_ Log[b_] + c_ Log[d_] -> Log[b^a d^c]
Log[a^2 b^3]
Thanks to all.
Themis