| Hosted by CoCalc | Download
Kernel: Python 3 (system-wide)
import sympy from galgebra.ga import Ga from galgebra.printer import latex from IPython.display import Math # tell sympy to use our printing by default sympy.init_printing(latex_printer=latex, use_latex='mathjax')
g = sympy.Matrix([[9,-2,3], [-2,6,2], [3,2,3] ]) uvw = (u,v,w) = sympy.symbols('u v w', real=True) g3d = Ga('a_1 a_2 a_3', g=g, coords=uvw) a1,a2,a3 = g3d.mv()
a1|a3
3\begin{equation*} 3 \end{equation*}
V = (a1^a3)*(a1^a3^a2) V
12a118a2+24a3\begin{equation*} -12 \boldsymbol{a}_{1} -18 \boldsymbol{a}_{2} + 24 \boldsymbol{a}_{3} \end{equation*}
V.norm()

182\displaystyle 18 \sqrt{2}

(a1^a3).norm()

32\displaystyle 3 \sqrt{2}

B = a1^a3 B**2
18\begin{equation*} -18 \end{equation*}
T = a1^a3^a2 B*T
12a118a2+24a3\begin{equation*} -12 \boldsymbol{a}_{1} -18 \boldsymbol{a}_{2} + 24 \boldsymbol{a}_{3} \end{equation*}
B|T
12a118a2+24a3\begin{equation*} -12 \boldsymbol{a}_{1} -18 \boldsymbol{a}_{2} + 24 \boldsymbol{a}_{3} \end{equation*}
(1/2)*(B*T-T*B)
0\begin{equation*} 0 \end{equation*}
(B|B)*a2 - (B|(a1^a2))*a3 + (B|(a3^a2))*a1
12a118a2+24a3\begin{equation*} -12 \boldsymbol{a}_{1} -18 \boldsymbol{a}_{2} + 24 \boldsymbol{a}_{3} \end{equation*}
A = sympy.Matrix([[-1,2,1], [2,-1,1], [2,1,1]]) A

[121211211]\displaystyle \left[\begin{array}{ccc}-1 & 2 & 1\\2 & -1 & 1\\2 & 1 & 1\end{array}\right]

A.inv()

[13161201212235612]\displaystyle \left[\begin{array}{ccc}- \frac{1}{3} & - \frac{1}{6} & \frac{1}{2}\\0 & - \frac{1}{2} & \frac{1}{2}\\\frac{2}{3} & \frac{5}{6} & - \frac{1}{2}\end{array}\right]

e1 = -(1/3)*a1 + (2/3)*a3 e2 = -(1/6)*a1 -(1/2)*a2 + (5/6)*a3 e3 = (1/2)*a1 + (1/2)*a2 - (1/2)*a3
e1.norm(),e2.norm(),e3.norm()

(1.0, 1.0, 1.0)\displaystyle \left( 1.0, \ 1.0, \ 1.0\right)

e1|e2, e1|e3, e2|e3
(5.55111512312578e-17, -2.22044604925031e-16, 1.38777878078145e-16)
B.exp()
cos(32)+2sin(32)6a1a3\begin{equation*} \cos{\left (3 \sqrt{2} \right )} + \frac{\sqrt{2} \sin{\left (3 \sqrt{2} \right )}}{6} \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{3} \end{equation*}
B
a1a3\begin{equation*} \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{3} \end{equation*}
i = B/B.norm() i
26a1a3\begin{equation*} \frac{\sqrt{2}}{6} \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{3} \end{equation*}
pi = sympy.pi sympy.cos(pi)

1\displaystyle -1

(i*pi).exp()
1\begin{equation*} -1 \end{equation*}
theta = sympy.symbols('theta') theta

θ\displaystyle \theta

R = ((1/2)*theta*i).exp() R
cos(0.5θ)+2sin(0.5θ)6a1a3\begin{equation*} \cos{\left (0.5 \theta \right )} + \frac{\sqrt{2} \sin{\left (0.5 \theta \right )}}{6} \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{3} \end{equation*}
R.rev()
cos(0.5θ)2sin(0.5θ)6a1a3\begin{equation*} \cos{\left (0.5 \theta \right )} - \frac{\sqrt{2} \sin{\left (0.5 \theta \right )}}{6} \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{3} \end{equation*}
Q = R.rev()*(a1^a2)*R Q
(2sin(1.0θ)2+cos(1.0θ))a1a2+(2sin(1.0θ)34cos(1.0θ)3+43)a1a332sin(1.0θ)2a2a3\begin{equation*} \left ( - \frac{\sqrt{2} \sin{\left (1.0 \theta \right )}}{2} + \cos{\left (1.0 \theta \right )}\right ) \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{2} + \left ( - \frac{\sqrt{2} \sin{\left (1.0 \theta \right )}}{3} - \frac{4 \cos{\left (1.0 \theta \right )}}{3} + \frac{4}{3}\right ) \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{3} - \frac{3 \sqrt{2} \sin{\left (1.0 \theta \right )}}{2} \boldsymbol{a}_{2}\wedge \boldsymbol{a}_{3} \end{equation*}
I = (a1^a2^a3)/(a1^a2^a3).norm() I
16a1a2a3\begin{equation*} \frac{1}{6} \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{2}\wedge \boldsymbol{a}_{3} \end{equation*}
(a1^a2).inv()
150a1a2\begin{equation*} - \frac{1}{50} \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{2} \end{equation*}
1/(a1^a2)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-53-12ee0e7071ee> in <module> ----> 1 1/(a1^a2) TypeError: unsupported operand type(s) for /: 'int' and 'Mv'
I.rev()
16a1a2a3\begin{equation*} - \frac{1}{6} \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{2}\wedge \boldsymbol{a}_{3} \end{equation*}
q = Q*I.rev() q
(2sin(1.0θ)cos(1.0θ)83)a14a2+(3cos(1.0θ)+163)a3\begin{equation*} \left ( - \sqrt{2} \sin{\left (1.0 \theta \right )} - \cos{\left (1.0 \theta \right )} - \frac{8}{3}\right ) \boldsymbol{a}_{1} -4 \boldsymbol{a}_{2} + \left ( 3 \cos{\left (1.0 \theta \right )} + \frac{16}{3}\right ) \boldsymbol{a}_{3} \end{equation*}
q|Q
0\begin{equation*} 0 \end{equation*}
Q^q
(50sin(0.5θ)4350sin(0.5θ)2325cos(2.0θ)12+12512)a1a2a3\begin{equation*} \left ( \frac{50 {\sin{\left (0.5 \theta \right )}}^{4}}{3} - \frac{50 {\sin{\left (0.5 \theta \right )}}^{2}}{3} - \frac{25 \cos{\left (2.0 \theta \right )}}{12} + \frac{125}{12}\right ) \boldsymbol{a}_{1}\wedge \boldsymbol{a}_{2}\wedge \boldsymbol{a}_{3} \end{equation*}
(Q^q).norm()

50\displaystyle 50

B1 = a1^a2 B2 = a1^a3 B1 = B1/B1.norm() B2 = B2/B2.norm() B1|B2
45\begin{equation*} - \frac{4}{5} \end{equation*}
def ang(u,v): u1 = u/u.norm() v1 = v/v.norm() return u1|v1
ang(a2,a3)
23\begin{equation*} \frac{\sqrt{2}}{3} \end{equation*}
b1 = 2.977*e1 + 0.253*e2 + 0.272*e3 b2 = -0.892*e1 + 2.261*e2 + 0.305*e3 b3 = 0.946*e1 + 1.335*e2 - 0.569*e3
import numpy as np import scipy.linalg as la def getG(L): G = sympy.eye(len(L)) for i in range(len(L)): for j in range(len(L)): G[i,j] = (L[i]|L[j]).blade_coefs()[0].round(1) return G def getA(g): evals,P = la.eig(g) evals = evals.real sqrtD = np.diag(np.sqrt(evals)) A = sqrtD @ P.transpose() return A
getG((b1,b2,b3))

[9.02.03.02.06.02.03.02.03.0]\displaystyle \left[\begin{array}{ccc}9.0 & -2.0 & 3.0\\-2.0 & 6.0 & 2.0\\3.0 & 2.0 & 3.0\end{array}\right]

b1 = 2.977*e1 + 0.253*e2 + 0.272*e3 b2 = -0.892*e1 + 2.261*e2 + 0.305*e3 b3 = 0.946*e1 + 1.335*e2 - 0.569*e3 A = getA(G) c1 = A[0,0]*e1 + A[1,0]*e2 + A[2,0]*e3 c2 = A[0,1]*e1 + A[1,1]*e2 + A[2,1]*e3 c3 = A[0,2]*e1 + A[1,2]*e2 + A[2,2]*e3 G,getG((b1,b2,b3)),getG((c1,c2,c3))
(array([[ 9, -2, 3], [-2, 6, 2], [ 3, 2, 3]]), Matrix([ [ 9.0, -2.0, 3.0], [-2.0, 6.0, 2.0], [ 3.0, 2.0, 3.0]]), Matrix([ [ 9.0, -2.0, 3.0], [-2.0, 6.0, 2.0], [ 3.0, 2.0, 3.0]]))
G
array([[ 9, -2, 3], [-2, 6, 2], [ 3, 2, 3]])
getG((b1,b2,b3))

[9.02.03.02.06.02.03.02.03.0]\displaystyle \left[\begin{array}{ccc}9.0 & -2.0 & 3.0\\-2.0 & 6.0 & 2.0\\3.0 & 2.0 & 3.0\end{array}\right]

getG((c1,c2,c3))

[9.02.03.02.06.02.03.02.03.0]\displaystyle \left[\begin{array}{ccc}9.0 & -2.0 & 3.0\\-2.0 & 6.0 & 2.0\\3.0 & 2.0 & 3.0\end{array}\right]

c1
0.713467162359075a1+1.61504773129891a22.78876795273444a3\begin{equation*} 0.713467162359075 \boldsymbol{a}_{1} + 1.61504773129891 \boldsymbol{a}_{2} -2.78876795273444 \boldsymbol{a}_{3} \end{equation*}
b1
0.8985a1+0.00950000000000001a2+2.0595a3\begin{equation*} -0.8985 \boldsymbol{a}_{1} + 0.00950000000000001 \boldsymbol{a}_{2} + 2.0595 \boldsymbol{a}_{3} \end{equation*}
np.set_printoptions(precision=3) A
array([[-0.272, -0.305, 0.569], [-2.977, 0.892, -0.946], [ 0.253, 2.261, 1.335]])
type(A)
numpy.ndarray
type(sympy.eye(3))
sympy.matrices.dense.MutableDenseMatrix
print(A)
[[-0.272 -0.305 0.569] [-2.977 0.892 -0.946] [ 0.253 2.261 1.335]]