1

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

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
MathIsHard
  • 559
  • 2
  • 6

1 Answers1

3
  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!

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96