1
$\begingroup$

Is it possible to apply "Collect" command (to put Log's in particular combination) to factor out (pattern) a particular form from the full expression.

For example, consider the following expression:

Log[a] + Log[b] - Log[c] + Log[d] - Log[f]

And I need to get a

Log[ab/c] - Log[f/d]

How one can do it??

Thanks in advance!!

A.

EDIT

My concrete example is:

Given this expression:

-(1/2) Log[(
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\) 
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\) 
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\))] (Log[(
    Subscript[t, 1] Subscript[t, 3])/(
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\) μ^2)] - 1/ϵ)

and applying ExpanAll[PowerExpand[%]] leads to

Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)]/(2 ϵ) + 
 Log[μ] Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] + Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)]/(2 ϵ) + 
 Log[μ] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] + 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] + 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)]^2 - Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)]/(2 ϵ) - 
 Log[μ] Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] - 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] - Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)]/(2 ϵ) - 
 Log[μ] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] - 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] - 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[Subscript[t, 1]] - 
 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[Subscript[t, 1]] + 
 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] Log[Subscript[t, 1]] + 
 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] Log[Subscript[t, 1]] - 
 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[Subscript[t, 3]] - 
 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[Subscript[t, 3]] + 
 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] Log[Subscript[t, 3]] + 
 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] Log[Subscript[t, 3]]

How to get from the last expression (a very long) the first (combined) one?

I know, that I need to factor out this factor

Log[(
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\) 
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\) 
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\))]

Naively:

Collect[expression, Log[(
    \!\(\*SubscriptBox[\(s\), \({1, 2}\)]\) 
    \!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(
    \!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\) 
    \!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\))] ]
$\endgroup$
6
  • $\begingroup$ Will this work? Log[a] + Log[b] - Log[c] + Log[d] - Log[f] //. {Log[x_] + Log[y_] -> Log[x y], Log[x_] - Log[y_] -> Log[x/y]} $\endgroup$
    – kale
    May 28, 2013 at 16:12
  • $\begingroup$ unfortunately not :( $\endgroup$ May 28, 2013 at 16:47
  • 3
    $\begingroup$ For me it says that the big expression in the edit section is incomplete. It is not formatted in such a way that I will enjoy going through it.. $\endgroup$ May 28, 2013 at 19:17
  • 2
    $\begingroup$ I have gone through it and there is a comma in the third line from the bottom that doesn't belong there. $\endgroup$ May 28, 2013 at 19:25
  • $\begingroup$ @JacobAkkerboom, sorry for the typo. I've corrected it. If you copy-paste into Math. notebook it should work properly (I checked). $\endgroup$ May 29, 2013 at 7:57

2 Answers 2

3
$\begingroup$

I don't think you can do it with Collect, but one thing you could do is to express, say, $s_{\{1,2\}}$ in terms of the factor you want to pull out, and use replacement rules to transform the expression.

I've altered the notation here as subscripts and Greek letters are hard to read in InputForm.

Starting with your expanded expression

expr = Log[s12]/(2 e) + Log[m] Log[s12] - Log[s345]/(2 e) - 
 Log[m] Log[s345] + Log[s45]/(2 e) + Log[m] Log[s45] + 
 1/2 Log[s12] Log[s45] - 1/2 Log[s345] Log[s45] + Log[s45]^2/2 - 
 Log[s456]/(2 e) - Log[m] Log[s456] - 1/2 Log[s45] Log[s456] - 
 1/2 Log[s12] Log[t1] + 1/2 Log[s345] Log[t1] - 
 1/2 Log[s45] Log[t1] + 1/2 Log[s456] Log[t1] - 
 1/2 Log[s12] Log[t3] + 1/2 Log[s345] Log[t3] - 
 1/2 Log[s45] Log[t3] + 1/2 Log[s456] Log[t3]

Express s12 in terms of the factor you want to extract (represented here by the symbol factor)

Simplify @ PowerExpand[expr /. s12 -> Exp[factor] s345 s456/s45]
(factor (1 + 2 e Log[m] + e Log[s45] - e Log[t1] - e Log[t3]))/(2 e)

Then just replace factor with the actual expression

% /. factor -> Log[(s12 s45)/(s345 s456)]
(Log[(s12 s45)/(s345 s456)] *
   (1 + 2 e Log[m] + e Log[s45] - e Log[t1] - e Log[t3]))/(2 e)
$\endgroup$
0
0
$\begingroup$

One way would be as follows. Here is your expression:

 expr1 = Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)]/(2 \[Epsilon]) +  
   Log[\[Mu]] Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] + Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)]/(2 \[Epsilon]) +  
   Log[\[Mu]] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] + 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] + 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)]^2 - Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)]/(2 \[Epsilon]) -  
   Log[\[Mu]] Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] - 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] - Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)]/(2 \[Epsilon]) -  
   Log[\[Mu]] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] - 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] - 1/2 Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[Subscript[t, 1]] -  
   1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[Subscript[t, 1]] +
    1/2 Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] Log[Subscript[t, 1]] +  
   1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] Log[Subscript[t, 1]] -  
   1/2 Log[
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\)] Log[Subscript[t, 3]] -  
   1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] Log[Subscript[t, 3]] +  
   1/2 Log[
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\)] Log[Subscript[t, 3]] + 
   1/2 Log[
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\)] Log[Subscript[t, 3]];

Let us simplify it assuming that some of your variables are positive:

    expr2 = Simplify[expr1, {
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\) > 0, 
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\) > 0, 
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\) > 0, 
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\) > 0}]

(*  The result: 
(Log[(
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\) 
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\) 
\!\(\*SubscriptBox[\(s\), \({4, 5, 6}\)]\))] (1 + 
   2 \[Epsilon] Log[\[Mu]] + \[Epsilon] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] - \[Epsilon] Log[Subscript[t,
      1]] - \[Epsilon] Log[Subscript[t, 3]]))/(2 \[Epsilon])           *)

Now let us take the subexpression that had not beed transformed yet:

expr2[[4]]


(*  1 + 2 \[Epsilon] Log[\[Mu]] + \[Epsilon] Log[
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\)] - \[Epsilon] Log[Subscript[t,
    1]] - \[Epsilon] Log[Subscript[t, 3]]
*)

Let us call the Rest of it subExp1 and transform it separately:

subExp1 = 
 Simplify[Simplify[
    expr2[[4]] // Rest, {Subscript[t, 1] > 0, 
     Subscript[t, 3] > 0, \[Mu] > 0, 
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\) > 0, \[Epsilon] > 0}] /. 
   Times[2, Log[x_]] -> Log[x^2], \[Mu] > 0] 

(* \[Epsilon] Log[(\[Mu]^2 
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(
  Subscript[t, 1] Subscript[t, 3])] *)

Now let us collect them together:

ReplacePart[expr1, {4} -> 1 + subExp1]

The result is below:

(Log[(
\!\(\*SubscriptBox[\(s\), \({1, 2}\)]\) 
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(
\!\(\*SubscriptBox[\(s\), \({3, 4, 5}\)]\) 
\!\(\*SubscriptBox[\(s\), \({4, 5, 
     6}\)]\))] (1 + \[Epsilon] Log[(\[Mu]^2 
\!\(\*SubscriptBox[\(s\), \({4, 5}\)]\))/(
     Subscript[t, 1] Subscript[t, 3])]))/(2 \[Epsilon])
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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