1
$\begingroup$

I'm trying to follow an explanation for extracting a metric tensor from a metric formula and having trouble following the mathematical explanation. I'm sure I would understand it better if written in a language I understand. In Mathematica, how would you create the metric tensor from this formula?$$ds^2=d\theta^2+\sin^2\theta \, d\phi^2$$

$\endgroup$
2
  • 3
    $\begingroup$ To be more specific: CoefficientArrays[dθ^2 + Sin[θ]^2 dϕ^2, {dθ, dϕ}] // Last // MatrixForm $\endgroup$
    – xzczd
    Commented Oct 1, 2023 at 1:24
  • $\begingroup$ Maybe this paper is of interest, although it deals with an application in probability theory. $\endgroup$ Commented Oct 1, 2023 at 10:37

2 Answers 2

0
$\begingroup$

Its very simple, its the coefficient matrix of second derivatives with respect to the list of differentials

  (1/2 Outer[(D[d\[Theta]^2 + Sin[\[Theta]] d\[Phi]^2, #1, #2] &),#,#]&)[
       {d\[Theta],d\[Phi]}]

   {{1,0},{0,Sin[\[Theta]]}}
$\endgroup$
1
  • $\begingroup$ I like this answer. It appears to capture the task at hand: taking a metric formula and breaking it up into its components through differentiation. $\endgroup$ Commented Oct 2, 2023 at 1:47
2
$\begingroup$

The metric in the form you've written computes the distance between two points separated by infinitesimal distances. In your case, you've only specified two parameters so you're working in a 2-d case. This particular metric describes the surface of a sphere. The basis for your metric is comprised from two "one-forms" - in this case the differentials, ${d\theta,d\phi}$. The choice of basis depends on your choice of coordinate system.

The expression is written $ds^2=g_{\mu\nu} dx^\mu dx^\nu$, with repeated indices summed over if one if upper and the other lower, and with $dx^{i}=d\theta$ or $d\phi$, so all the metric components are zero except for $g_{\theta\theta} = 1$ and $g_{\phi\phi}= sin(\theta)^2$. In Mathematica code, you could write this as

EDIT: This is a better way to code it; use two lists of differentials instead of one with squared terms.

In[2]:= {Dt[th], Dt[phi]} . DiagonalMatrix[{1, Sin[th]^2}] . {Dt[th], Dt[phi]}
(*Out[2]= Dt[th]^2 + Dt[phi]^2 Sin[th]^2 *)

The differentials represent distances between two points you're concerned with in the coordinate system you've selected. For example, if P1 has coordinates $(\theta_1,\phi_1)$ and P2 has coordinates $(\theta_1+d\theta, \phi_1+d\phi)$, your metric gives you the square of the interval/distance between points P1 and P2. For finite separations, perform an integral over the infinitesimals.

$\endgroup$

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