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.