Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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}\)]\))] ]
share|improve this question
    
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]} –  kale May 28 '13 at 16:12
    
unfortunately not :( –  Andrew Kor May 28 '13 at 16:47
3  
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.. –  Jacob Akkerboom May 28 '13 at 19:17
2  
I have gone through it and there is a comma in the third line from the bottom that doesn't belong there. –  Jacob Akkerboom May 28 '13 at 19:25
    
@JacobAkkerboom, sorry for the typo. I've corrected it. If you copy-paste into Math. notebook it should work properly (I checked). –  Andrew Kor May 29 '13 at 7:57
show 1 more comment

2 Answers

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)
share|improve this answer
    
Thanks a lot!!! –  Andrew Kor May 29 '13 at 11:09
add comment

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])
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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