In [1]:
from __future__ import print_function
from sympy import Symbol, symbols, sin, cos, Rational, expand, simplify, collect, S
from galgebra.printer import Eprint, Get_Program, Print_Function, Format
from galgebra.ga import Ga, one, zero
from galgebra.mv import Nga
Format()

In [2]:
X = (x, y, z) = symbols('x y z')
o3d = Ga('e_x e_y e_z', g=[1, 1, 1], coords=X)
(ex, ey, ez) = o3d.mv()
grad = o3d.grad

In [3]:
c = o3d.mv('c', 'scalar')

In [4]:
a = o3d.mv('a', 'vector')
b = o3d.mv('b', 'vector')

In [5]:
A = o3d.mv('A','mv')
B = o3d.mv('B','mv')

The inner product of blades in GAlgebra is zero if either operand is a scalar:

$$\begin{split}\begin{aligned} {\boldsymbol{A}}_{r}{\wedge}{\boldsymbol{B}}_{s} &\equiv {\left <{{\boldsymbol{A}}_{r}{\boldsymbol{B}}_{s}} \right >_{r+s}} \\ {\boldsymbol{A}}_{r}\cdot{\boldsymbol{B}}_{s} &\equiv {\left \{ { \begin{array}{cc} r\mbox{ and }s \ne 0: & {\left <{{\boldsymbol{A}}_{r}{\boldsymbol{B}}_{s}} \right >_{{\left |{r-s}\right |}}} \\ r\mbox{ or }s = 0: & 0 \end{array}} \right \}} \end{aligned}\end{split}$$

This definition comes from David Hestenes and Garret Sobczyk, “Clifford Algebra to Geometric Calculus,” Kluwer Academic Publishers, 1984.

In some other literature, the inner product is defined without the exceptional case for scalar part and the definition above is known as "the modified Hestenes inner product" (this name comes from the source code of GAViewer).


In [6]:
c|a


Out[6]:
\begin{equation*} 0 \end{equation*}

In [7]:
a|c


Out[7]:
\begin{equation*} 0 \end{equation*}

In [8]:
c|A


Out[8]:
\begin{equation*} 0 \end{equation*}

In [9]:
A|c


Out[9]:
\begin{equation*} 0 \end{equation*}

$ab=a \wedge b + a \cdot b$ holds for vectors:


In [10]:
a*b


Out[10]:
\begin{equation*} \left ( a^{x} b^{x} + a^{y} b^{y} + a^{z} b^{z}\right ) + \left ( a^{x} b^{y} - a^{y} b^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( a^{x} b^{z} - a^{z} b^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( a^{y} b^{z} - a^{z} b^{y}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [11]:
a^b


Out[11]:
\begin{equation*} \left ( a^{x} b^{y} - a^{y} b^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( a^{x} b^{z} - a^{z} b^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( a^{y} b^{z} - a^{z} b^{y}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [12]:
a|b


Out[12]:
\begin{equation*} a^{x} b^{x} + a^{y} b^{y} + a^{z} b^{z} \end{equation*}

In [13]:
(a*b)-(a^b)-(a|b)


Out[13]:
\begin{equation*} 0 \end{equation*}

$aA=a \wedge A + a \cdot A$ holds for the products between vectors and multivectors:


In [14]:
a*A


Out[14]:
\begin{equation*} \left ( A^{x} a^{x} + A^{y} a^{y} + A^{z} a^{z}\right ) + \left ( A a^{x} - A^{xy} a^{y} - A^{xz} a^{z}\right ) \boldsymbol{e}_{x} + \left ( A a^{y} + A^{xy} a^{x} - A^{yz} a^{z}\right ) \boldsymbol{e}_{y} + \left ( A a^{z} + A^{xz} a^{x} + A^{yz} a^{y}\right ) \boldsymbol{e}_{z} + \left ( A^{xyz} a^{z} - A^{x} a^{y} + A^{y} a^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( - A^{xyz} a^{y} - A^{x} a^{z} + A^{z} a^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( A^{xyz} a^{x} - A^{y} a^{z} + A^{z} a^{y}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} + \left ( A^{xy} a^{z} - A^{xz} a^{y} + A^{yz} a^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [15]:
a^A


Out[15]:
\begin{equation*} A a^{x} \boldsymbol{e}_{x} + A a^{y} \boldsymbol{e}_{y} + A a^{z} \boldsymbol{e}_{z} + \left ( - A^{x} a^{y} + A^{y} a^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( - A^{x} a^{z} + A^{z} a^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( - A^{y} a^{z} + A^{z} a^{y}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} + \left ( A^{xy} a^{z} - A^{xz} a^{y} + A^{yz} a^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [16]:
a|A


Out[16]:
\begin{equation*} \left ( A^{x} a^{x} + A^{y} a^{y} + A^{z} a^{z}\right ) + \left ( - A^{xy} a^{y} - A^{xz} a^{z}\right ) \boldsymbol{e}_{x} + \left ( A^{xy} a^{x} - A^{yz} a^{z}\right ) \boldsymbol{e}_{y} + \left ( A^{xz} a^{x} + A^{yz} a^{y}\right ) \boldsymbol{e}_{z} + A^{xyz} a^{z} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} - A^{xyz} a^{y} \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + A^{xyz} a^{x} \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [17]:
(a*A)-(a^A)-(a|A)


Out[17]:
\begin{equation*} 0 \end{equation*}

$AB=A \wedge B + A \cdot B$ does NOT hold for the products between multivectors and multivectors:


In [18]:
A*B


Out[18]:
\begin{equation*} \left ( A B - A^{xyz} B^{xyz} - A^{xy} B^{xy} - A^{xz} B^{xz} + A^{x} B^{x} - A^{yz} B^{yz} + A^{y} B^{y} + A^{z} B^{z}\right ) + \left ( A B^{x} - A^{xyz} B^{yz} + A^{xy} B^{y} + A^{xz} B^{z} + A^{x} B - A^{yz} B^{xyz} - A^{y} B^{xy} - A^{z} B^{xz}\right ) \boldsymbol{e}_{x} + \left ( A B^{y} + A^{xyz} B^{xz} - A^{xy} B^{x} + A^{xz} B^{xyz} + A^{x} B^{xy} + A^{yz} B^{z} + A^{y} B - A^{z} B^{yz}\right ) \boldsymbol{e}_{y} + \left ( A B^{z} - A^{xyz} B^{xy} - A^{xy} B^{xyz} - A^{xz} B^{x} + A^{x} B^{xz} - A^{yz} B^{y} + A^{y} B^{yz} + A^{z} B\right ) \boldsymbol{e}_{z} + \left ( A B^{xy} + A^{xyz} B^{z} + A^{xy} B - A^{xz} B^{yz} + A^{x} B^{y} + A^{yz} B^{xz} - A^{y} B^{x} + A^{z} B^{xyz}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( A B^{xz} - A^{xyz} B^{y} + A^{xy} B^{yz} + A^{xz} B + A^{x} B^{z} - A^{yz} B^{xy} - A^{y} B^{xyz} - A^{z} B^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( A B^{yz} + A^{xyz} B^{x} - A^{xy} B^{xz} + A^{xz} B^{xy} + A^{x} B^{xyz} + A^{yz} B + A^{y} B^{z} - A^{z} B^{y}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} + \left ( A B^{xyz} + A^{xyz} B + A^{xy} B^{z} - A^{xz} B^{y} + A^{x} B^{yz} + A^{yz} B^{x} - A^{y} B^{xz} + A^{z} B^{xy}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [19]:
A|B


Out[19]:
\begin{equation*} \left ( - A^{xyz} B^{xyz} - A^{xy} B^{xy} - A^{xz} B^{xz} + A^{x} B^{x} - A^{yz} B^{yz} + A^{y} B^{y} + A^{z} B^{z}\right ) + \left ( - A^{xyz} B^{yz} + A^{xy} B^{y} + A^{xz} B^{z} - A^{yz} B^{xyz} - A^{y} B^{xy} - A^{z} B^{xz}\right ) \boldsymbol{e}_{x} + \left ( A^{xyz} B^{xz} - A^{xy} B^{x} + A^{xz} B^{xyz} + A^{x} B^{xy} + A^{yz} B^{z} - A^{z} B^{yz}\right ) \boldsymbol{e}_{y} + \left ( - A^{xyz} B^{xy} - A^{xy} B^{xyz} - A^{xz} B^{x} + A^{x} B^{xz} - A^{yz} B^{y} + A^{y} B^{yz}\right ) \boldsymbol{e}_{z} + \left ( A^{xyz} B^{z} + A^{z} B^{xyz}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( - A^{xyz} B^{y} - A^{y} B^{xyz}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( A^{xyz} B^{x} + A^{x} B^{xyz}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [20]:
(A*B)-(A^B)-(A|B)


Out[20]:
\begin{equation*} \left ( - A^{xz} B^{yz} + A^{yz} B^{xz}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( A^{xy} B^{yz} - A^{yz} B^{xy}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( - A^{xy} B^{xz} + A^{xz} B^{xy}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [21]:
(A<B)+(A|B)+(A>B)-A*B


Out[21]:
\begin{equation*} \left ( A B - 2 A^{xyz} B^{xyz} - 2 A^{xy} B^{xy} - 2 A^{xz} B^{xz} + 2 A^{x} B^{x} - 2 A^{yz} B^{yz} + 2 A^{y} B^{y} + 2 A^{z} B^{z}\right ) + \left ( - A^{xyz} B^{yz} + A^{xy} B^{y} + A^{xz} B^{z} - A^{yz} B^{xyz} - A^{y} B^{xy} - A^{z} B^{xz}\right ) \boldsymbol{e}_{x} + \left ( A^{xyz} B^{xz} - A^{xy} B^{x} + A^{xz} B^{xyz} + A^{x} B^{xy} + A^{yz} B^{z} - A^{z} B^{yz}\right ) \boldsymbol{e}_{y} + \left ( - A^{xyz} B^{xy} - A^{xy} B^{xyz} - A^{xz} B^{x} + A^{x} B^{xz} - A^{yz} B^{y} + A^{y} B^{yz}\right ) \boldsymbol{e}_{z} + \left ( A^{xyz} B^{z} + A^{xz} B^{yz} - A^{x} B^{y} - A^{yz} B^{xz} + A^{y} B^{x} + A^{z} B^{xyz}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( - A^{xyz} B^{y} - A^{xy} B^{yz} - A^{x} B^{z} + A^{yz} B^{xy} - A^{y} B^{xyz} + A^{z} B^{x}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( A^{xyz} B^{x} + A^{xy} B^{xz} - A^{xz} B^{xy} + A^{x} B^{xyz} - A^{y} B^{z} + A^{z} B^{y}\right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} + \left ( - A^{xy} B^{z} + A^{xz} B^{y} - A^{x} B^{yz} - A^{yz} B^{x} + A^{y} B^{xz} - A^{z} B^{xy}\right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}

In [ ]: