1
$\begingroup$

I am not receiving True for Log[a/b]==Log[a]-Log[b]. Is there a way around this problem?

$\endgroup$
8
  • 3
    $\begingroup$ Is this statement true always? What happens when b is complex, or b == 0? $\endgroup$ Commented May 29, 2022 at 23:25
  • $\begingroup$ @DrMrstheMonarch Oh good point! Is there a way to add conditions to FullSimplify? $\endgroup$
    – MathIsHard
    Commented May 29, 2022 at 23:26
  • $\begingroup$ Look up assumptions in the docs :) $\endgroup$ Commented May 29, 2022 at 23:26
  • 5
    $\begingroup$ It is sufficient to use Simplify, e.g. Simplify[Log[a/b] == Log[a] - Log[b], a != 0 && b > 0] $\endgroup$
    – Artes
    Commented May 29, 2022 at 23:32
  • 5
    $\begingroup$ Log[a/b] == Log[a] - Log[b] // PowerExpand $\endgroup$
    – Alan
    Commented May 29, 2022 at 23:34

1 Answer 1

3
$\begingroup$
  1. 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
  1. 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]  *)
  1. 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!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.