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

[ ]:
# sp2: Geometric algebra for unit sphere in R^3 using spherical coordinates.
# Mathematics coordinate order: (phi,theta)

# 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()
[ ]:
# sp2: Geometric algebra for unit sphere in R^3 using spherical coordinates.
# Mathematics coordinate order: (phi,theta)

# Set up sp2
basis = 'e_phi e_theta'
coords = (phi,th) = symbols('phi theta', real=True)
g = [sin(phi)*cos(th), sin(phi)*sin(th), cos(phi)]
sp2 = Ga('\mathbf{e}', g=None , coords=coords, \
        X=[sin(phi)*cos(th), sin(phi)*sin(th), cos(phi)], norm=True)

(ephi, eth) = sp2.mv()
(rphi, rth) = sp2.mvr()

# Derivatives
grad    = sp2.grad
# from galgebra.dop import *
# pdphi = Pdop(phi)
# pdth  = Pdop(th)
[ ]:
grad
[ ]: