def test_make_grad(self): ga, e_1, e_2, e_3 = Ga.build('e*1|2|3', g=[1, 1, 1], coords=symbols('x y z')) r = ga.mv(ga.coord_vec) assert ga.make_grad(r) == ga.grad assert ga.make_grad(r, cmpflg=True) == ga.rgrad x = ga.mv('x', 'vector') B = ga.mv('B', 'bivector') dx = ga.make_grad(x) dB = ga.make_grad(B) # GA4P, eq. (6.29) for a in [ga.mv(1), e_1, e_1 ^ e_2]: r = a.i_grade assert dx * (x ^ a) == (ga.n - r) * a assert dx * (x * a) == ga.n * a # derivable via the product rule assert dx * (x * x) == 2 * x assert dx * (x * x * x) == (2 * x) * x + (x * x) * ga.n assert dB * (B * B) == 2 * B assert dB * (B * B * B) == (2 * B) * B + (B * B) * ga.n # an arbitrary chained expression to check we do not crash assert dB * dx * (B * x) == -3 assert dx * dB * (x * B) == -3 assert dx * dB * (B * x) == 9 assert dB * dx * (x * B) == 9
def make_vector(a, n=3, ga=None): if isinstance(a, str): v = zero for i in range(n): a_i = Symbol(a + str(i + 1)) v += a_i * ga.basis[i] v = ga.mv(v) return (F(v)) else: return (F(a))
def make_vector(a, n=3, ga=None): if isinstance(a,str): v = zero for i in range(n): a_i = Symbol(a+str(i+1)) v += a_i*ga.basis[i] v = ga.mv(v) return(F(v)) else: return(F(a))