       Re: Simplify Log[ab] - Log[b] to Log[a] ?

• To: mathgroup at smc.vnet.net
• Subject: [mg16050] Re: Simplify Log[ab] - Log[b] to Log[a] ?
• From: dreissBLOOP at bloop.earthlink.net (David Reiss)
• Date: Mon, 22 Feb 1999 01:44:31 -0500
• References: <7ao3po\$rv0@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```In article <7ao3po\$rv0 at smc.vnet.net>, "Simon Allfrey"
<simon at allfrey13.freeserve.co.uk> wrote:

> How do I persuade Mathematica to simplify
>
> Log[a b] - Log[b] to Log[a]?
>
> when processing algebraic expressions?

In your simple example you could do the following
with pattern matching in a repalcement rule:

In:=
rules = {Log[x_ y_] :> Log[x] + Log[y]}

Out=
{Log[(x_) (y_)] :> Log[x] + Log[y]}

In:=
Log[a*b] - Log[b] /. rules

Out=
Log[a]

In the following case you need to use ReplaceRepeated (//.)
so that the rule is applied until the expression no longer
changes:

In:=
Log[a*b*c] - Log[b] - Log[c] /. rules

Out=
Log[a] - Log[b] - Log[c] + Log[b c]

In:=
Log[a*b*c] - Log[b] - Log[c] //. rules

Out=
Log[a]

However, since a and b can be rather complicated,
and because in such a case the product, a b, might
be represented in its FullForm by something other
than Times[a, b], you need to write transformation
rules that cover all cases of interest.

In:=
FullForm[a*b]

Out//FullForm=
Times[a, b]

Note that the following doesn't simplify to the
degree that you want:

In:=
Log[a*b/c] - Log[b] /. rules

Out=
b
Log[a] - Log[b] + Log[-]
c

This is because the FullForm of (a b/c) does not correspond
to the rule:

In:=
FullForm[a*b/c]

Out//FullForm=
Times[a, b, Power[c, -1]]

In:=
FullForm[b/c]

Out//FullForm=
Times[b, Power[c, -1]]

But, if we include another rule to cover this case,
it does work:

In:=
rules = {Log[(x_)*(y_)] :> Log[x] + Log[y],
Log[(x_)/(y_)] :> Log[x] - Log[y]}

Out=
{Log[(x_) (y_)] :> Log[x] + Log[y],

Log[x_/y_] :> Log[x] - Log[y]}

In:=
Log[a*b/c] - Log[b] //. rules

Out=
1
Log[a] + Log[-]
c

--

----------------------------------------

Scientific Arts:
Creative Services and Consultation
for the Applied and Pure Sciences

David Reiss
Email: dreiss at !SPAMscientificarts.com

----------------------------------------

Remove the !SPAM to send email

```

• Prev by Date: Re: Simplify Log[ab] - Log[b] to Log[a] ?
• Next by Date: Reset In[ ] & Out[ ]
• Previous by thread: Re: Simplify Log[ab] - Log[b] to Log[a] ?
• Next by thread: Re: Simplify Log[ab] - Log[b] to Log[a] ?