1
$\begingroup$

I have the following term in an expression

$$\frac{q_B' \sin2q_B}{P_B Q_B^2}(2 Q_B P_B - \sin^2 q_B \Pi_B) q_1 q_1'$$

the prime denotes differentiation w.r.t a coordinate. Some additional definitions relative to the example are the following: The following expressions are not part of the code, they are the definitions, but for some reason I was unable to post unless I make the following code. Sorry about that...

$$\Pi_B = P_B(1 + q_B'^2) - 2 Q_B \sin^2 q_B \\
    P_B = 4f_B^2 + \sin^4 q_B\\
    Q_B = f_B'^2 + \sin^2 q_B (1 + q_B'^2)\\
    v_B = \frac{Q_B}{P_B}$$

I want to extract as a common factor the following

$$\frac{1}{\sqrt{\det X_B}}$$

with $\sqrt{\det X_B}$ being given by the following:

$$\sqrt{\det X_B} = \cosh^4p e^{3r} \sin^2x_1 \sin x_2 \sqrt{(f_B'^2 + (1 + q_B'^2) \sin^2 q_B)(4 f_B^2 + \sin^4q_B)}$$

and have whatever remains from the original expression times $q_1 q_1'$.

Here is my code

    PB = 4 fB^2  + Sin[qB]^4;

    QB = fBp^2 + Sin[qB]^2 (1 + qBp^2) ;

    vB = QB/PB;

    \Pi = PB (1 + qBp^2) - 2 QB Sin[qB]^2;

    gAdS4 = DiagonalMatrix[{1, -Exp[2 r], Exp[2 r], Exp[2 r]}];

    gS3 = DiagonalMatrix[{1, Sin[x1]^2, Sin[x1]^2 Sin[x2]^2}];

    Det[gS3]

    Sin[x1]^4 Sin[x2]^2

    Det[gAdS4]

    -E^(6 r)

    (*We want to define Sqrt[det(XB)]. We choose to name it XB.*)

     Cosh[p]^4 Sqrt[Det[gAdS4]] Sqrt[Det[gS3]] Sqrt[PB QB]

    Sqrt[-E^(6 r)]
      Cosh[p]^4 Sqrt[(fBp^2 + (1 + qBp^2) Sin[qB]^2) (4 fB^2 + 
        Sin[qB]^4)] Sqrt[Sin[x1]^4 Sin[x2]^2]

     Sqrt[-E^(6 r)]
       Cosh[p]^4 Sqrt[(fBp^2 + (1 + qBp^2) Sin[qB]^2) (4 fB^2 + 
         Sin[qB]^4)] Sqrt[Sin[x1]^4 Sin[x2]^2];

    XB = Cosh[p]^4 E^(3 r)
        Sin[x1]^2 Sin[
        x2] Sqrt[(fBp^2 + (1 + qBp^2) Sin[qB]^2) (4 fB^2 + Sin[qB]^4)];

    (qBp Sin[2 qB])/(PB QB^2) (2 PB QB - Sin[qB]^2 \[CapitalPi]B) q1 q1p /. 
      Sin[2 qB] -> 2 Sin[qB] Cos[qB];

And after I make the replacement you can see above for the trig function, I tried using the Collect command, the Factor, and the Coefficient and none of it worked. An example, when I used the collect-command.

    (2 q1 q1p qBp Cos[qB] Sin[
          qB] (2 (fBp^2 + (1 + qBp^2) Sin[qB]^2) (4 fB^2 + Sin[qB]^4) - 
           Sin[qB]^2 (-2 Sin[
                qB]^2 (fBp^2 + (1 + qBp^2) Sin[qB]^2) + (1 + 
                 qBp^2) (4 fB^2 + Sin[qB]^4))))/((fBp^2 + (1 + qBp^2) Sin[
             qB]^2)^2 (4 fB^2 + Sin[qB]^4)) // Collect[#, 1/XB] &;

And the result of the above

    (2 q1 q1p qBp Cos[qB] Sin[
        qB] (2 (fBp^2 + (1 + qBp^2) Sin[qB]^2) (4 fB^2 + Sin[qB]^4) - 
         Sin[qB]^2 (-2 Sin[
              qB]^2 (fBp^2 + (1 + qBp^2) Sin[qB]^2) + (1 + 
               qBp^2) (4 fB^2 + Sin[qB]^4))))/((fBp^2 + (1 + qBp^2) Sin[
           qB]^2)^2 (4 fB^2 + Sin[qB]^4))

I would appreciate any help.

Apologies if something like that has been asked in the past, but I couldn't find anything relevant.

Thank you in advance.

P.S: Since there was a comment saying that the statement is not clear, let me give an oversimplified expample.

This is what I would like to do

$AC + BD = B (\frac{AC}{B} + D)$

but using the expressions above. Practically, B here is the square root.

$\endgroup$
  • $\begingroup$ It is very difficult to understand what are you doing. However, you may use the following trick. Try to evaluate a construct: (HoldForm[factor]*Func[expression/factor])//ReleaseHold. Here expression is the expression you want to transform, factor is the factor you want to take out, and Func is a function, such as Simplify or Expand or alike. $\endgroup$ – Alexei Boulbitch Dec 10 '17 at 17:55
  • $\begingroup$ Sorry if my post is a bit opaque. I tried to write it down in the best way that I could. Thanks for the tip. I really appreciate it. $\endgroup$ – Konstantinos Dec 10 '17 at 17:57
  • $\begingroup$ @Boulbitch I don't know if the simple example, makes things clearer. $\endgroup$ – Konstantinos Dec 10 '17 at 18:15
  • $\begingroup$ Yes, I recommend to make an example, the simplest possible, but containing the problem that you are after. This will certainly help. However, below I will try to give a simple answer within the example of the very last line of your expressions above. $\endgroup$ – Alexei Boulbitch Dec 11 '17 at 8:35
1
$\begingroup$

As a preliminary answer I will try to discuss your question within the example of the next transformation: A*C+B*D -> B(A*C/B+D) as stays in the end of your question.

In principle, here there may be two different cases.

1) It is the case in which the expression A*C/B+D will either spontaneously simplify, such that the result will differ from plain A*C/B+D, or will not change its form after the transform you will find below. In this case the trick to do what you want is to first form the expression A*C/B+D and let it simplify. And then you can multiply the expression by B. For example, let us from the expression

expr1=a*c+b*d;

form a new one:

    expr2=Expand[expr1/b]

    (*  (a c)/b + d  *)

Then the construct:

 expr3 = b*expr2

(*  b ((a c)/b + d)   *)

gives the desired result.

This, however, rarely works, since often Mma may immediately transform the expression to a form, most simple according to its internal criterion.

However, there are cases, when you can help Mma to make a sort of an "irreversible" transformation, such as Transformation[A*C/B+D]. The word "irreversible" means here that after the transform Mma will not recognize how to change it back. If this transformation "irreversibly" changes the expression, the further multiplication by B will not lead to the reverse transform.

To give a simple example, let us consider the following expression:

expr1 = a + ((b*x)/y)^(2*a/3) + ((c*x)/y)^(2*a/3);

enter image description here

and let us take a factor (x/y)^(2*a/3) out of the brackets. If we simply form a new expression:

expr2 = expr1/(x/y)^(2*a/3);

and then form the product:

(x/y)^(2*a/3)*expr2,

we simply return to the initial expression. However, let us apply an irreversible transformation to expr2. In this case, it may be PowerExpand:

 expr3 = PowerExpand[expr2]

(*  x^(-2 a/3) y^(2 a/3) (a + b^(2 a/3) x^(2 a/3) y^(-2 a/3) + 
   c^(2 a/3) x^(2 a/3) y^(-2 a/3))   *)

Now the expression

    expr4 = (x/y)^(2*a/3)*expr3

(*  x^(-2 a/3) (x/y)^(2 a/3) y^(2 a/3) (a + b^(2 a/3) x^(2 a/3) y^(-2 a/3) + 
   c^(2 a/3) x^(2 a/3) y^(-2 a/3))   *)

enter image description here

contains the desired term as a factor.

I do not know any clear rule, what function to take as the "irreversible" Transformation. My experience shows that one may use such functions as Expand, Together, Apart, Cancel and PowerExpand. But other functions may sometimes do the job even better. It depends upon the expression in question.

You can formalize this and make a function that will act this way. For example

out[expr_, factor_, transform_] := (Hold[factor]*transform[expr/factor]) // ReleaseHold

Let me note that there is a package "Presentations" of David Park, that contains a function "FactorOut" which acts more or less like the function written above. The one from Presentations is somewhat more powerful. This package contains many functions useful for manipulations with expressions and I strongly recommend it.

2) The second is the case in which no transformation introduces irreversible changes, and Mma always returns you the initial expression. Nevertheless, sometimes you only need the form with B outside the brackets to make a final representation of the equation. That is, you are not going to manipulate it further, but you need just to have it visible in a desired form. In this case try the following:

HoldForm[factor]*transform[expr/factor] 

Have fun!

$\endgroup$
  • $\begingroup$ Thank you for taking time to give such a detailed answer. $\endgroup$ – Konstantinos Dec 11 '17 at 10:41

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.