This page was generated from doc/tutorials/sp2sp3.nblink.

[1]:
# A geometric algebra for the unit sphere in R^3
# as a submanifold of R^3 with spherical coordintes.

# Make SymPy available to this program:
import sympy
from sympy import *

# Make GAlgebra available to this program:
from galgebra.ga import *
from galgebra.mv import *
from galgebra.printer import Fmt, GaPrinter, Format
    # Fmt:       sets the way that a multivector's basis expansion is output.
    # GaPrinter: makes GA output a little more readable.
    # Format:    turns on latex printer.
from galgebra.gprinter import gFormat, gprint
gFormat()
$\displaystyle \DeclareMathOperator{\Tr}{Tr}$$ $$\DeclareMathOperator{\Adj}{Adj}$$ $$\newcommand{\bfrac}[2]{\displaystyle\frac{#1}{#2}}$$ $$\newcommand{\lp}{\left (}$$ $$\newcommand{\rp}{\right )}$$ $$\newcommand{\paren}[1]{\lp {#1} \rp}$$ $$\newcommand{\half}{\frac{1}{2}}$$ $$\newcommand{\llt}{\left <}$$ $$\newcommand{\rgt}{\right >}$$ $$\newcommand{\abs}[1]{\left |{#1}\right | }$$ $$\newcommand{\pdiff}[2]{\bfrac{\partial {#1}}{\partial {#2}}}$$ $$\newcommand{\npdiff}[3]{\bfrac{\partial^{#3} {#1}}{\partial {#2}^{#3}}}$$ $$\newcommand{\lbrc}{\left \{}$$ $$\newcommand{\rbrc}{\right \}}$$ $$\newcommand{\W}{\wedge}$$ $$\newcommand{\prm}[1]{{#1}^{\prime}}$$ $$\newcommand{\ddt}[1]{\bfrac{d{#1}}{dt}}$$ $$\newcommand{\R}{\dagger}$$ $$\newcommand{\deriv}[3]{\bfrac{d^{#3}#1}{d{#2}^{#3}}}$$ $$\newcommand{\grade}[2]{\left < {#1} \right >_{#2}}$$ $$\newcommand{\f}[2]{{#1}\lp {#2} \rp}$$ $$\newcommand{\eval}[2]{\left . {#1} \right |_{#2}}$$ $$\newcommand{\bs}[1]{\boldsymbol{#1}}$$ $$\newcommand{\grad}{\bs{\nabla}}$
[2]:
# A geometric algebra for the unit sphere in R^3
# as a submanifold of R^3 with spherical coordintes.

# sp3: Base manifold
sp3coords = (r, phi, theta) = symbols('r phi theta', real=True)
sp3 = Ga('e', g=None, coords=sp3coords, \
    X=[r*sin(phi)*cos(theta), r*sin(phi)*sin(theta), r*cos(phi)], norm=True)
(er, ephi, etheta) = sp3.mv()

# sp2: Submanifold
sp2coords = (p,t) = symbols('phi theta', real=True) # they output as Greek phi and theta
  # Parameterize the unit sphere using the spherical coordinates of sp3:
sp2param = [1, p, t]
  # Map the sp3 coordinates of the sphere to its sp2 coordinates:
sp2 = sp3.sm(sp2param, sp2coords, norm=True)

(ep, et) = sp2.mv()
(rp, rt) = sp2.mvr()

# Derivatives
grad  = sp2.grad
from galgebra.dop import *
pdph = Pdop(p)
pdth = Pdop(t)
[3]:
gprint(grad)
$\displaystyle \boldsymbol{e}_{\phi } \frac{\partial}{\partial \phi } + \boldsymbol{e}_{\theta } \frac{1}{\sin{\left (\phi \right )}} \frac{\partial}{\partial \theta } $
[ ]: