2
$\begingroup$

Please, see better this question, since it displays the problem better, i.e., more specifically.

I have complicated function:

F[s2_, Ss_, t1_, m_, m2_] := 
 Evaluate[-6 ((s2^6 + (Ss - 7 t1) s2^5 + (-4 Ss^2 + 13 t1 Ss + 
            16 t1^2) s2^4 + 
         2 (Ss^3 - 13 t1 Ss^2 - 10 t1^2 Ss - 8 t1^3) s2^3 + 
         t1 (18 Ss^3 + 6 t1 Ss^2 - 4 t1^2 Ss + 7 t1^3) s2^2 + 
         t1^2 (18 Ss^3 + 22 t1 Ss^2 + 11 t1^2 Ss - t1^3) s2 + 
         Ss t1^3 (2 Ss^2 + 2 t1 Ss - t1^2)) m^6 - 
      Ss (s2 - t1) ((11 t1 - 2 Ss) s2^4 + 
         2 (Ss^2 - 16 t1 Ss - 7 t1^2) s2^3 + 
         6 (4 Ss^2 t1 - t1^3) s2^2 + 
         2 t1^2 (15 Ss^2 + 16 t1 Ss + 5 t1^2) s2 + 
         t1^3 (4 Ss^2 + 2 t1 Ss - t1^2)) m^4 + 
      Ss^2 (s2 - t1)^2 (s2^4 - (Ss + 9 t1) s2^3 + 
         3 (3 Ss - t1) t1 s2^2 + t1^2 (15 Ss + 11 t1) s2 + 
         Ss t1^3) m^2 + 
      Ss^3 (s2 - t1)^3 t1 (s2^2 - 4 t1 s2 + t1^2)) Log[((-m^2 + m2^2 +
         s2 - Sqrt[m^4 - 2 (m2^2 + s2) m^2 + (m2^2 - s2)^2]) (s2 - 
        t1))/(2 s2)] s2^3 + 
   6 ((s2^6 + (Ss - 7 t1) s2^5 + (-4 Ss^2 + 13 t1 Ss + 
            16 t1^2) s2^4 + 
         2 (Ss^3 - 13 t1 Ss^2 - 10 t1^2 Ss - 8 t1^3) s2^3 + 
         t1 (18 Ss^3 + 6 t1 Ss^2 - 4 t1^2 Ss + 7 t1^3) s2^2 + 
         t1^2 (18 Ss^3 + 22 t1 Ss^2 + 11 t1^2 Ss - t1^3) s2 + 
         Ss t1^3 (2 Ss^2 + 2 t1 Ss - t1^2)) m^6 - 
      Ss (s2 - t1) ((11 t1 - 2 Ss) s2^4 + 
         2 (Ss^2 - 16 t1 Ss - 7 t1^2) s2^3 + 
         6 (4 Ss^2 t1 - t1^3) s2^2 + 
         2 t1^2 (15 Ss^2 + 16 t1 Ss + 5 t1^2) s2 + 
         t1^3 (4 Ss^2 + 2 t1 Ss - t1^2)) m^4 + 
      Ss^2 (s2 - t1)^2 (s2^4 - (Ss + 9 t1) s2^3 + 
         3 (3 Ss - t1) t1 s2^2 + t1^2 (15 Ss + 11 t1) s2 + 
         Ss t1^3) m^2 + 
      Ss^3 (s2 - t1)^3 t1 (s2^2 - 4 t1 s2 + t1^2)) Log[((-m^2 + m2^2 +
         s2 + Sqrt[m^4 - 2 (m2^2 + s2) m^2 + (m2^2 - s2)^2]) (s2 - 
        t1))/(2 s2)] s2^3]

The factors in the front of two logarithms are the same, so it can be written in more compact form, i.e. in the form ...Log[.../...]. I tried to implement this by using

Collect[F[s2,Ss,t1,m,m2],_Log]

or by writing exact function

collectLog = {a_*Log[x_] + a_*Log[y_] :> a*Log[x y], 
   b_*Log[x_] - b_*Log[y_] :> b*Log[x/y]};

and then

F[s2,Ss,t1,m,m2] //. collectLog

but these don't work.

How to force Mathematica to collect the logs for the given function?

$\endgroup$
8
  • 1
    $\begingroup$ Does'nt Simplify give you what you want? $\endgroup$
    – eldo
    Aug 1 '17 at 10:38
  • $\begingroup$ @eldo : evel FullSimplify doesn't... It just collects the multipliers, expressing my function as ...(Log[...] - Log[...]). $\endgroup$ Aug 1 '17 at 10:48
  • 1
    $\begingroup$ Both Simplify and FullSimplify seem to work fine for me (giving bigfactor * (Log[stuff] + Log[morestuff]). Is it a version thing? I'm on MMA 10.4. $\endgroup$ Aug 1 '17 at 11:04
  • $\begingroup$ @aardvark2012 : however, it still doesn't collect the logs to the form Log[a/b]. This is what I want, sorry for unclarity. I updated the question. $\endgroup$ Aug 1 '17 at 11:13
  • 1
    $\begingroup$ Simplify[...long expression...] /. -Log[x_] + Log[y_] -> Log[y/x] works for me $\endgroup$
    – yohbs
    Aug 1 '17 at 14:13
1
$\begingroup$

Another way is to define a function with required properties which will not have the limiting rules of Log on argument values:

ln /: ln[x_] + ln[y_] := ln[x y]
ln /: ln[x_] - ln[y_] := ln[x/y]

The usage is something like

FullSimplify[F[s2,Ss,t1,m,m2]/. Log[$_] -> ln[$]] /. ln[$_] -> Log[$]
$\endgroup$
2
  • $\begingroup$ Does this in principle require so much time as for the construction FullSimplify[] /. -Log[x_] +Log[y_] :> Log[y/x], how do you think? $\endgroup$ Aug 2 '17 at 9:03
  • $\begingroup$ @JohnTaylor Idk. Perhaps on a complicated expression one FullSimplfy is redundant and dropping it will speed up the evaluation. $\endgroup$
    – Andrew
    Aug 2 '17 at 11:00
1
$\begingroup$

This is a partial answer in that it doesn't actually solve the problem, but might give you some pointers.

The problem is that Simplify doesn't know what you're taking the Log of. For example,

Simplify[Log[a] - Log[b]]

Log[a] - Log[b]

But

Assuming[b > 0, Simplify[Log[a] - Log[b]]]

Log[a/b]

I haven't been able to get the same result with your F. Using Reduce to find the conditions for which your argument of Log is positive, and then building in those conditions with Assuming doesn't seem work. Though there might be another way.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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