Wolfram Alpha:

```The Metric Tensor
-----------------

The metric tensor, tells you how to compute the
distance between any two points in a given space.
Basically, it makes corrections to Pythagoras'
theorem when transforming from one coordinate
system to another.  In other words, it ensures
that the inner product between 2 vectors (a scalar)
is invariant under the transformation).

In the Cartesian coordinate system we can write
Pythagoras' theorem as:

ds2 = (dx0)2 + (dx1)2 + (dx3)2

= δμνdxμdxν where δμν = 1 when μ = ν
= 0 when μ ≠ ν

Where dx are infinetesimaly small displacement
vectors.  We choose them to be infinitesimally
small so that they may be considered to be point
like.

Now, suppose we move to a different coordinate
system, x'.  For example, x' could be a curvilinear
coordinate system.  We can make use of,

δx'μ ≈ (∂x'μ/∂xν)δxν

which in the limit δx'ν -> 0 gives:

dx'μ = (∂x'μ/∂xν)dxν

Therefore, to convert to the x' system:

(ds)2 = δμν(∂xμ/∂x'ρ)(∂xν/∂x'σ)dx'ρdx'σ

= gρσ(x')dx'ρdxσ

Where gρσ(x') is the METRIC TENSOR in the prime
system.

gρσ(x') = δμν(∂xμ/∂x'ρ)(∂xν/∂x'σ).

Note that the metric tensor is a function of position
and in curved space will vary from point to point.
In flat space the metric tensor does not vary from
point to point.  The metric for flat space is the
MINKOWSKI metric, ημν.

As already stated, the metric produces a scalar and
generalizes the idea of the inner product of vectors.
For any basis we can write:

v = v1e1 + v2e2 ...

= vμeμ

Where vμ are the contravariant components of the
vector, v.

If we take the dot product of v with eν we get:

v.eν = vμeμ.eν

Now compute the dot product, v.v:

v.v = vμeμ.vνeν

= vμvνeμ.eν

Replace the v's with dx's to get:

= dxμdxμeμ.eν

= gμνdxμdxν

Therefore, gμν = eμ.eν

The metric tensor is symmetric.  That is, terms the
metric are reflected across the diagonal.  This is
easily seen from the fact that (∂xμ/∂x'ρ)(∂xν/∂x'σ) =
(∂xν/∂x'σ)(∂xμ/∂x'ρ).  Off diagonal elements of the
metric tensor simply say that the chosen coordinate
system is not orthogonal.

In 2 dimensions, this looks like:

-        -  -    - -     -
| g00  g01 || dx'0 || dx'0 | = ds2
| g10  g11 || dx'1 || dx'1 |
-        -  -    - -     -

ds2 = g00(dx0)2 + g01(dx1)2 + g10(dx0)2 + g11(dx1)2

= g00(dx0)2 + 2g01(dx1)2 + g11(dx1)2

If the bases are orthogonal then:

-       -  -    -  -    -
| g00  0  || dx'0 || dx'0 | = ds2
|  0  g11 || dx'1 || dx'1 |
-       -  -    -  -    -

ds2 = g00dx'0dx'0 + g11dx'1dx'1

= (∂x0/∂x'0)(∂x0/∂x'0)(dx'0)2

+ (∂x1/∂x'1)(∂x1/∂x'1)(dx'1)2

= (∂xμ/∂x'ρ)(∂xν/∂x'σ)dx'ρdx'σ

Example:  The Minkowski (flat space) metric in polar
coordinates.

x = rcosθ

y = rsinθ

∂x/∂r = cosθ

∂y/∂r = sinθ

grr = (∂x/∂r)(∂x/∂r) + (∂y/∂r)(∂y/∂r)

= cos2θ + sin2θ

= 1

∂x/∂θ = -rsinθ

∂y/∂θ = rcosθ

gθθ = (∂x/∂θ)(∂x/∂θ) + (∂y/∂θ)(∂y/∂θ)

= (-rsinθ)(-rsinθ) + (rcosθ)(rcosθ)

= r2sin2θ + r2cos2θ

= r2

-    -
gμν = | 1 0  |
| 0 r2 |
-    -

Relationship to the Jacobian Matrix, J
--------------------------------------

The above matrix equations are equivalent to:

-         -  -        - -    -
| dx'0 dx'1 || g00  g01 || dx'0 | = ds2
-         - | g10  g11 || dx'1 |
-        - -    -

Or, in the orthogonal case:

-         -  -       -  -    -
| dx'0 dx'1 || g00  0  || dx'0 | = ds2
-         - |  0  g11 || dx'1 |
-       -  -    -

This can be written as:

ds2 = (dx'μ)Tdx'μ

≡ dx'μdx'μ  (the inner product)

= (Jdxμ)T(Jdxμ)

= (dxμ)TJTJdxμ

= (dxμ)Tgdxμ where g = JTJ

Therefore, we can also find the metric by finding
the product JTJ.

-                -
J = | ∂x0/∂x'0 ∂x0/∂x'1 |
| ∂x1/∂x'0 ∂x1/∂x'1 |
-                -
-                -
JT = | ∂x0/∂x'0 ∂x1/∂x'0 |
| ∂x0/∂x'1 ∂x1/∂x'1 |
-                -

Example:  The Minkowski (flat space) metric in polar
coordinates.

x = rcosθ and y = rsinθ

-           -
J = | ∂x/∂r ∂x/∂θ |
| ∂y/∂r ∂y/∂θ |
-           -
-           -
= | cosθ -rsinθ |
| sinθ  rcosθ |
-           -
-            -
JT = | cosθ    sinθ |
| -rsinθ rcosθ |
-            -
-                                    -
gij = JTJ = | cos2θ+sin2θ     -rsinθcosθ+rsinθcosθ  |
| -rcosθsinθ+rcosθsinθ  r2sin2θ+r2cos2θ |
-                                    -
-    -
= | 1 0  |
| 0 r2 |
-    -

Metric Tensor Under Coordinate Transformation
---------------------------------------------

The length, ds, should remain the same after a
coordinate transformation.  Therefore,

gmn(x)dxmdxn = grs(x')dx'rdx's

dxm = (∂xm/∂x'r)dx'r

dxn = (∂xn/∂x's)dx's

gmn(x)(∂xm/∂x'r)dx'r(∂xn/∂x's)dx's = grs(x')dx'rdx's

By comparison:

gmn(x)(∂xm/∂x'r)(∂xn/∂x's) = grs(x')

We can also see this directly by generalizing δmn
to gmn and write:

ds2 = gmn(x)dxmdxn

So by comparison we see that:

grs(x') = gmn(x)(∂xm/∂x'r)(∂xn/∂x's)

Inverse Metric Tensor
---------------------

gμν can be considered to be the inverse of gμν.  We can
write:

gρσgσα = δρα.

Where

-     -
I = | 1 0 0 | = δρα  (the Kronecker Delta in matrix form)
| 0 1 0 |
| 0 0 1 |
-     -

gρσ(x') = gμν(x)(∂x'ρ/∂xμ)(∂x'σ/∂xν)

gσα(x') = gμν(x)(∂xμ/∂x'σ)(∂xν/∂x'α)

gρσ(x')gσα(x') = gμν(x)(∂x'ρ/∂xμ)(∂x'σ/∂xν)gμν(x)(∂xμ/∂x'σ)(∂xν/∂x'α)

= δρα

In polar coordinates:

-    -       -     -
| 1 0  |-1 = | 1  0   |
| 0 r2 |     | 0 1/r2 |
-    -       -     -

Note: The inverse of a diagonal matrix is obtained
by replacing each element in the diagonal with
its reciprocal.  Thus,

grr = (grr)-1 = (1)-1 = 1

gθθ = (gθθ)-1 = (r2)-1 = 1/r2

Note that going from polar to cartesian coordinates
is the inverse of going from cartesian to polar
coordinate.  We can see this as follows:

gxx = (∂r/∂x)(∂r/∂x) + (∂θ/∂x)(∂θ/∂x)

gyy = (∂r/∂y)(∂r/∂y) + (∂θ/∂y)(∂θ/∂y)

r2 = x2 + y2

tanθ = y/x

∂r/∂x = x/√(x2 + y2) = x/r

∂r/∂y = y/√(x2 + y2) = y/r

∂θ/∂x = -y/(x2 + y2) = -y/r2

∂θ/∂y = x/(x2 + y2) = x/r2

-           -  -        -
JTJ = |  x/r   y/r  || x/r -y/r2 |
| -y/r2  x/r2 || y/r  x/r2 |
-           -  -        -

-             -
= | 1      0      |
| 0 1/(x2 + y2) |
-             -

-      -
= | 1   0  |
| 0 1/r2 |
-      -

Summary of Useful Metrics
-------------------------

```