I am not receiving True for Log[a/b]==Log[a]-Log[b]. Is there a way around this problem?
Asked
Active
Viewed 120 times
1
J. M.'s missing motivation
- 124,525
- 11
- 401
- 574
MathIsHard
- 559
- 2
- 6
1 Answers
3
- One can use a standard Mma approach of working with logarithms. It is PowerExpand.
PowerExpand treats its expressions assuming all variables are positive. Normally
Log[ab] == Log[a] + Log[b]
is not always true, e.g.
0 = Log[(-1) (-1)] != Log[-1] + Log[-1] == 2 Pi*I
One can use Simplify together with the declaration of the variables as positive (if it is true):
Simplify[Log[a] + Log[b], Assumptions -> a > 0 && b > 0](* Log[a b] *)
PowerExpand[Log[a*b], Assumptions -> a > 0 < b]
(* Log[a] + Log[b] *)
In general
PowerExpand[Log[a b], Assumptions -> Element[{a, b}, Complexes]]
(* 2 I [Pi] Floor[1/2 - Arg[a]/(2 [Pi]) - Arg[b]/(2 [Pi])] + Log[a] + Log[b] *)
- If I know that the variables are positive, and want to transform logarithms I use the following functions:
expandLog[expr_] := Module[{rule1, rule2, a, b, x, g}, rule1 = Log[a_b_] -> Log[a] + Log[b]; rule2 = Log[a_^x_] -> xLog[a]; g[x_] := (x /. rule1) /. rule2; FixedPoint[g, expr] ];
and
collectLog[expr_] := Module[{rule1a, rule1b, rule2, g, a, b, x},
rule1a = Log[a_] + Log[b_] -> Log[a*b];
rule1b = Log[a_] - Log[b_] -> Log[a/b];
rule2 = x_*Log[a_] -> Log[a^x];
g[x_] := x /. rule1a /. rule1b /. rule2;
FixedPoint[g, expr]
];
They enable me to transform logarithms according to my wish. Try them.
Have fun!
Alexei Boulbitch
- 39,397
- 2
- 47
- 96
Simplify, e.g.Simplify[Log[a/b] == Log[a] - Log[b], a != 0 && b > 0]– Artes May 29 '22 at 23:32Log[a/b] == Log[a] - Log[b] // PowerExpand– Alan May 29 '22 at 23:34PowerExpandand the documentation says it in a similar situation "Expand a power of a product; the result may not be correct everywhere:" – user64494 May 30 '22 at 05:23