1
$\begingroup$

I have a function produce this equation:

(-4*dt^2*(c3 + a3*t)^2*t0^4 + dxC^2*(t0^2 + t1^2)^2 + dxM^2*(t0^2 + t1^2)^2 + dxY^2*(t0^2 + t1^2)^2)/(4*t0^4)

Is there any way to force this to be:

(-dt^2)*(c3 + a3*t)^2 + (dxC^2*(t0^2 + t1^2)^2)/(4*t0^4) +
(dxM^2*(t0^2 + t1^2)^2)/(4*t0^4) + (dxY^2*(t0^2 + t1^2)^2)/(4*t0^4)

I'm hoping to construct a metric tensor from this and it's much easier to see how things factor out this way.

$\endgroup$
3
$\begingroup$

Try this:

expr = (-4*dt^2*(c3 + a3*t)^2*t0^4 + dxC^2*(t0^2 + t1^2)^2 + 
 dxM^2*(t0^2 + t1^2)^2 + dxY^2*(t0^2 + t1^2)^2)/(4*t0^4)//FullSimplify

Collect[expr, {dxC, dxM, dxY}, FullSimplify]
(*-dt^2 (c3 + a3 t)^2 + (dxC^2 (t0^2 + t1^2)^2)/(4 t0^4) + (dxM^2 (t0^2 + t1^2)^2)/(4 t0^4) + (dxY^2 (t0^2 + t1^2)^2)/(4 t0^4)*)

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ That's freaking awesome. I had jury-rigged something using the Coefficient function, but that's much more elegant. $\endgroup$
    – Quarkly
    Dec 2 '21 at 14:17

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.