4
$\begingroup$

I would like to make a matrix out out of the following expression:

$$ (\Omega^2 (2 d\theta^2 + d\phi^2 - d\phi^2 \cos(2 \theta) \coth(\chi)^2) + (2 d\Omega^2 + (2 d\theta^2 + d\phi^2 - 2 d\chi^2) \Omega^2) \textrm{csch}(\chi)^2)/(2 \Omega^2) $$

so that I get for the 11-components all terms that belong to $d\Omega^2$, for the 22-component all the terms belonging to $d\chi^2$, etc. (As there are no 'cross-terms', the matrix in this case should be diagonal). How do I go about this in Mathematica?


Code for copying:

(Ω^2 (2 dθ^2 + dϕ^2 - dϕ^2 Cos[2 θ] Coth[χ]^2) +
 (2 dΩ^2 + (2 dθ^2 + dϕ^2 - 2 dχ^2) Ω^2) Csch[χ]^2)/(2 Ω^2)
$\endgroup$
  • $\begingroup$ Please include the expression in Mathematica code for easy manipulation. Thanks $\endgroup$ – Mr.Wizard Aug 7 '13 at 13:58
  • $\begingroup$ Of course, here you go: ([CapitalOmega]^2 (2 d[Theta]^2 + d[Phi]^2 - d[Phi]^2 Cos[ 2 [Theta]] Coth[[Chi]]^2) + (2 d[CapitalOmega]^2 + (2 d\ [Theta]^2 + d[Phi]^2 - 2 d[Chi]^2) [CapitalOmega]^2) Csch[[Chi]]^2)/(2 \ [CapitalOmega]^2) $\endgroup$ – user25477 Aug 7 '13 at 14:11
  • $\begingroup$ You can edit your question to add such information. $\endgroup$ – Mr.Wizard Aug 7 '13 at 14:12
2
$\begingroup$

With the expression and the variables defined

expression =   1/(2 Ω^2) (Ω^2 (2 dθ^2 + dϕ^2 - dϕ^2 Cos[2 θ] Coth[χ]^2) +
              (2 dΩ^2 + (2 dθ^2 + dϕ^2 - 2 dχ^2) Ω^2) Csch[χ]^2);

differentials = {dχ, dθ, dϕ, dΩ};

You can get what you asked by calling

CoefficientArrays[expression, differentials][[3]] // Normal // MatrixForm
| improve this answer | |
$\endgroup$

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.