# PyStein Example

This notebook demonstrates a simple use of the `pystein` package. See the [documentation](https://pystein.readthedocs.io/en/latest/) for more.

## Imports


```python
import sympy
from sympy.diffgeom import Manifold, Patch

from pystein import coords, metric, curvature
from pystein.utilities import tensor_pow as tpow
```

## Create a Metric: $S^2$

First create the manifold and patch object, though these won't be used much yet `sympy.diffgeom` intends to add features for them later.


```python
M = Manifold('M', dim=2)
P = Patch('origin', M)
```

Define the coordinates for the sphere ($\theta, \phi$), as well as a constant $a$


```python
theta, phi, a = sympy.symbols('theta phi a', nonnegative=True)
cs = coords.CoordSystem('spherical', P, [theta, phi])
cs
```

Next, we extract the one-forms from the coordinate system. We will construct a two-form in terms of these coordinate one-forms.


```python
dtheta, dphi = cs.base_oneforms()
```

Construct the twoform


```python
ds2 = a**2 * (tpow(dtheta, 2) + sympy.sin(theta)**2 * tpow(dphi, 2))
```

Construct the metric:


```python
# Construct a metric from the two form
g = metric.Metric(twoform=ds2)
g
```

## Compute Curvature Components

Components can be computed individually:


```python
curvature.christoffel_symbol_component(0, 1, 0, g)
```

Or the common components can be computed all at once:


```python
christoffels, riemanns, riccis = curvature.compute_components(g, non_trivial=True)
```


```python
christoffels[0]
```

The components can be displayed concisely as a single $\LaTeX$ equation:


```python
curvature.display_components(christoffels)
```

7c277d6ffed1c0f3503c4c4c9cb8949c9a84935e
ipynb
Jupyter Notebook
notebooks/example.ipynb
JWKennington/CourseGR1
ba81a1bf0427210c14d4e97c8f2cf8a345297812
MIT
notebooks/example.ipynb
JWKennington/CourseGR1
ba81a1bf0427210c14d4e97c8f2cf8a345297812
MIT
notebooks/example.ipynb
JWKennington/CourseGR1
ba81a1bf0427210c14d4e97c8f2cf8a345297812
MIT
Qwen/Qwen-72B
1. YES
2. YES