Beispiel #1
0
def test_rmul():
    #set_main(sys.modules[__name__])
    MV.setup('x y z')
    make_symbols('a b c')
    assert 5 * x == x * 5
    assert HALF * x == x * HALF
    assert a * x == x * a
Beispiel #2
0
def test_rmul():
    #set_main(sys.modules[__name__])
    MV.setup('x y z')
    make_symbols('a b c')
    assert 5*x == x*5
    assert HALF*x == x*HALF
    assert a*x == x*a
Beispiel #3
0
def make_vector(a,n = 3):
    if type(a) == types.StringType:
        sym_str = ''
        for i in range(n):
            sym_str += a+str(i)+' '
        sym_lst = make_symbols(sym_str)
        sym_lst.append(ZERO)
        sym_lst.append(ZERO)
        a = MV(sym_lst,'vector')
    return(F(a))
Beispiel #4
0
def make_vector(a, n=3):
    if type(a) == types.StringType:
        sym_str = ''
        for i in range(n):
            sym_str += a + str(i) + ' '
        sym_lst = make_symbols(sym_str)
        sym_lst.append(ZERO)
        sym_lst.append(ZERO)
        a = MV(sym_lst, 'vector')
    return (F(a))
Beispiel #5
0
def test_noneuclidian():
    global s,c,Binv,M,S,C,alpha
    #set_main(sys.modules[__name__])
    metric = '0 # #,'+ \
             '# 0 #,'+ \
             '# # 1,'
    MV.setup('X Y e',metric,debug=0)
    MV.set_str_format(1)
    L = X^Y^e
    B = L*e
    Bsq = (B*B)()
    BeBr =B*e*B.rev()
    make_symbols('s c Binv M S C alpha')
    Bhat = Binv*B # Normalize translation generator
    R = c+s*Bhat # Rotor R = exp(alpha*Bhat/2)
    Z = R*X*R.rev()
    Z.expand()
    Z.collect([Binv,s,c,XdotY])
    W = Z|Y
    W.expand()
    W.collect([s*Binv])
    M = 1/Bsq
    W.subs(Binv**2,M)
    W.simplify()
    Bmag = sympy.sqrt(XdotY**2-2*XdotY*Xdote*Ydote)
    W.collect([Binv*c*s,XdotY])
    W.subs(2*XdotY**2-4*XdotY*Xdote*Ydote,2/(Binv**2))
    W.subs(2*c*s,S)
    W.subs(c**2,(C+1)/2)
    W.subs(s**2,(C-1)/2)
    W.simplify()
    W.subs(1/Binv,Bmag)

    W = W().expand()
    #print '(R*X*R.rev()).Y =',W
    Wd = collect(W,[C,S],exact=True,evaluate=False)
    #print 'Wd =',Wd
    Wd_1 = Wd[ONE]
    Wd_C = Wd[C]
    Wd_S = Wd[S]
    #print '|B| =',Bmag
    Wd_1 = Wd_1.subs(Bmag,1/Binv)
    Wd_C = Wd_C.subs(Bmag,1/Binv)
    Wd_S = Wd_S.subs(Bmag,1/Binv)
    #print 'Wd[ONE] =',Wd_1
    #print 'Wd[C] =',Wd_C
    #print 'Wd[S] =',Wd_S
    lhs = Wd_1+Wd_C*C
    rhs = -Wd_S*S
    lhs = lhs**2
    rhs = rhs**2
    W = (lhs-rhs).expand()
    W = (W.subs(1/Binv**2,Bmag**2)).expand()
    #print 'W =',W
    W = (W.subs(S**2,C**2-1)).expand()
    W = collect(W,[C**2,C],evaluate=False)
    #print 'W =',W
    a = W[C**2]
    b = W[(C**2)**(sympify(1)/2)]
    c = W[ONE]
    #print 'a =',a
    #print 'b =',b
    #print 'c =',c
    D = (b**2-4*a*c).expand()
    #print 'Setting to 0 and solving for C gives:'
    #print 'Descriminant D = b^2-4*a*c =',D
    C = (-b/(2*a)).expand()
    #print 'C = cosh(alpha) = -b/(2*a) =',C

    """
    Wd = collect(W,[C,S],evaluate=False)
    lhs = Wd[ONE]+Wd[C]*C
    rhs = -Wd[S]*S
    lhs = lhs**2
    rhs = rhs**2
    W = (lhs-rhs).expand()
    W = (W.subs(S**2,C**2-1)).expand()
    W = collect(W,[C**2,C],evaluate=False)
    a = W[C**2]
    b = W[abs(C)]
    c = W[ONE]
    D = (b**2-4*a*c).expand()
    C = (-b/(2*a)).expand()
    """
    assert C == 1-XdotY/(Xdote*Ydote)
Beispiel #6
0
def test_noneuclidian():
    global s, c, Binv, M, S, C, alpha
    #set_main(sys.modules[__name__])
    metric = '0 # #,'+ \
             '# 0 #,'+ \
             '# # 1,'
    MV.setup('X Y e', metric, debug=0)
    MV.set_str_format(1)
    L = X ^ Y ^ e
    B = L * e
    Bsq = (B * B)()
    BeBr = B * e * B.rev()
    make_symbols('s c Binv M S C alpha')
    Bhat = Binv * B  # Normalize translation generator
    R = c + s * Bhat  # Rotor R = exp(alpha*Bhat/2)
    Z = R * X * R.rev()
    Z.expand()
    Z.collect([Binv, s, c, XdotY])
    W = Z | Y
    W.expand()
    W.collect([s * Binv])
    M = 1 / Bsq
    W.subs(Binv**2, M)
    W.simplify()
    Bmag = sympy.sqrt(XdotY**2 - 2 * XdotY * Xdote * Ydote)
    W.collect([Binv * c * s, XdotY])
    W.subs(2 * XdotY**2 - 4 * XdotY * Xdote * Ydote, 2 / (Binv**2))
    W.subs(2 * c * s, S)
    W.subs(c**2, (C + 1) / 2)
    W.subs(s**2, (C - 1) / 2)
    W.simplify()
    W.subs(1 / Binv, Bmag)

    W = W().expand()
    #print '(R*X*R.rev()).Y =',W
    Wd = collect(W, [C, S], exact=True, evaluate=False)
    #print 'Wd =',Wd
    Wd_1 = Wd[ONE]
    Wd_C = Wd[C]
    Wd_S = Wd[S]
    #print '|B| =',Bmag
    Wd_1 = Wd_1.subs(Bmag, 1 / Binv)
    Wd_C = Wd_C.subs(Bmag, 1 / Binv)
    Wd_S = Wd_S.subs(Bmag, 1 / Binv)
    #print 'Wd[ONE] =',Wd_1
    #print 'Wd[C] =',Wd_C
    #print 'Wd[S] =',Wd_S
    lhs = Wd_1 + Wd_C * C
    rhs = -Wd_S * S
    lhs = lhs**2
    rhs = rhs**2
    W = (lhs - rhs).expand()
    W = (W.subs(1 / Binv**2, Bmag**2)).expand()
    #print 'W =',W
    W = (W.subs(S**2, C**2 - 1)).expand()
    W = collect(W, [C**2, C], evaluate=False)
    #print 'W =',W
    a = W[C**2]
    b = W[(C**2)**(sympify(1) / 2)]
    c = W[ONE]
    #print 'a =',a
    #print 'b =',b
    #print 'c =',c
    D = (b**2 - 4 * a * c).expand()
    #print 'Setting to 0 and solving for C gives:'
    #print 'Descriminant D = b^2-4*a*c =',D
    C = (-b / (2 * a)).expand()
    #print 'C = cosh(alpha) = -b/(2*a) =',C
    """
    Wd = collect(W,[C,S],evaluate=False)
    lhs = Wd[ONE]+Wd[C]*C
    rhs = -Wd[S]*S
    lhs = lhs**2
    rhs = rhs**2
    W = (lhs-rhs).expand()
    W = (W.subs(S**2,C**2-1)).expand()
    W = collect(W,[C**2,C],evaluate=False)
    a = W[C**2]
    b = W[abs(C)]
    c = W[ONE]
    D = (b**2-4*a*c).expand()
    C = (-b/(2*a)).expand()
    """
    assert C == 1 - XdotY / (Xdote * Ydote)
 """
 X and Y are conformal mappings of two vectors on the Poincare disk
 """
 L = X^Y^e
 """
 B is the bivector generator of translations on the circle defined by L
 """
 B = L*e
 Bsq = (B*B)()
 print 'L = X^Y^e is a non-euclidian line'
 print 'B = L*e =',B
 BeBr =B*e*B.rev()
 print 'B*e*B.rev() =',BeBr
 print 'B^2 =',Bsq
 print 'L^2 =',(L*L)()
 make_symbols('s c Binv M S C alpha')
 """
 s = sinh(alpha/2)
 c = cosh(alpha/2)
 Binv = 1/sqrt(B*B)  It can be shown that B*B > 0
 """
 Bhat = Binv*B # Normalize translation generator
 R = c+s*Bhat # Rotor R = exp(alpha*Bhat/2)
 print 's = sinh(alpha/2) and c = cosh(alpha/2)'
 print 'R = exp(alpha*B/(2*|B|)) =',R
 Z = R*X*R.rev()
 Z.expand()
 Z.collect([Binv,s,c,XdotY])
 print 'R*X*R.rev() =',Z
 #W = Z^Y
 W = Z|Y
 """
     X and Y are conformal mappings of two vectors on the Poincare disk
     """
 L = X ^ Y ^ e
 """
     B is the bivector generator of translations on the circle defined by L
     """
 B = L * e
 Bsq = (B * B)()
 print 'L = X^Y^e is a non-euclidian line'
 print 'B = L*e =', B
 BeBr = B * e * B.rev()
 print 'B*e*B.rev() =', BeBr
 print 'B^2 =', Bsq
 print 'L^2 =', (L * L)()
 make_symbols('s c Binv M S C alpha')
 """
     s = sinh(alpha/2)
     c = cosh(alpha/2)
     Binv = 1/sqrt(B*B)  It can be shown that B*B > 0
     """
 Bhat = Binv * B  # Normalize translation generator
 R = c + s * Bhat  # Rotor R = exp(alpha*Bhat/2)
 print 's = sinh(alpha/2) and c = cosh(alpha/2)'
 print 'R = exp(alpha*B/(2*|B|)) =', R
 Z = R * X * R.rev()
 Z.expand()
 Z.collect([Binv, s, c, XdotY])
 print 'R*X*R.rev() =', Z
 #W = Z^Y
 W = Z | Y