A common problem I have with Mathematica is needing to manipulate the arguments of logarithms. Typically, I need to take ratios of the log arguments Mathematica gives me by default.
That's to say I perform operations similar to
In[24]:= Log[x] - Log[y] /. Log[w_] - Log[v_] -> Log[w/v]
Out[24]= Log[x/y]
However, in a general situation, the logs may appear with complicated prefactors. By using Collect[]
, I can pull out any common symbolic factors, but Mathematica still keeps numbers with the logs. Trying to do a replace similar to the one above fails
In[25]:= 2 Log[mgl] - 2 Log[mi] /. a_ Log[w_] - a_ Log[v_] -> a Log[w/v]
Out[25]= 2 Log[mgl] - 2 Log[mi]
Going term by term, I was able to move the numerical log prefactor inside the log as an exponent, e.g.
In[27]:= 2 Log[mgl] /. {a_ Log[w_] -> Log[w^a]}
Out[27]= Log[mgl^2]
and can then combine logs pairwise to get the ratio I want.
In[29]:= Log[mgl^2] + Log[1/mi^2] /. Log[w_] + Log[v_] -> Log[w v]
Out[29]= Log[mgl^2/mi^2]
However, the ratio now contains an exponent that I would prefer to move out front. This step fails.
In[28]:= Log[mgl^2/mi^2] /. Log[x_^a_/y_^a_] -> a Log[x/y]
Out[28]= Log[mgl^2/mi^2]
Where I would have wanted 2*Log[mgl/mi]
.
Are there any suggestions for manipulating these log arguments to get ratios of single powers?
Thank you.