如何用Z3中的Octonion数进行计算

时间:2013-05-20 10:32:42

标签: z3

在上一篇文章quaternions中,提供了一个代码,用于使用Z3计算四元数。在这篇文章中提供了一个代码Octonion来计算Z3中的八进制数。

使用“Octonion代码”解决了以下示例:

代码:

x = Octonion("x")
s = Tactic('qfnra-nlsat').solver()
s.add(x*x + 2  == 0)
print(s.check())
m = s.model()
print m    

输出:

sat
[x.i3 = 1/2,
x.i7 = -1/2,
x.i2 = -1/2,
x.i5 = 1,
x.i1 = 0,
x.r = 0,
x.i6 = -1/2,
x.i4 = 0]

使用Maple验证了此结果。

其他例子:

代码:

x = Octonion("x")
y = Octonion("y")
s = Tactic('qfnra-nlsat').solver()
s.add(x*y + 30  == 0, x - y - y == 10)
print(s.check())
m = s.model()
print m

输出:

sat
[y.i3 = 1/2,
y.i7 = -1/2,
y.i2 = -1/2,
y.i5 = 1,
y.i1 = -1,
y.r = -5/2,
y.i6 = 1/2,
y.i4 = -2.3979157616?,
x.i7 = -1,
x.i6 = 1,
x.i5 = 2,
x.i4 = -4.7958315233?,
x.i3 = 1,
x.i2 = -1,
x.i1 = -2,
x.r = 5]

其他例子:

证明

x * y != y * x

代码:

x = Octonion("x")
y = Octonion("y")
a1, b1, c1, d1, e1, f1, g1, h1 = Reals('a1 b1 c1 d1 e1 f1 g1 h1')
a2, b2, c2, d2, e2, f2, g2, h2 = Reals('a2 b2 c2 d2 e2 f2 g2 h2')

x.r =  a1
x.i1 = b1
x.i2 = c1
x.i3 = d1
x.i4 = e1
x.i5 = f1
x.i6 = g1
x.i7 = h1
y.r =  a2
y.i1 = b2
y.i2 = c2
y.i3 = d2
y.i4 = e2
y.i5 = f2
y.i6 = g2
y.i7 = h2
print simplify((x * y - y * x).r)
print simplify((x * y - y * x).i1)
print simplify((x * y - y * x).i2)
print simplify((x * y - y * x).i3)
print simplify((x * y - y * x).i4)
print simplify((x * y - y * x).i5) 
print simplify((x * y - y * x).i6)
print simplify((x * y - y * x).i7)

输出:

 0
-2·c1·e2 + -2·f1·g2 + 2·f2·g1 + 2·c2·e1 + 2·d2·h1 + -2·d1·h2
 2·d2·f1 + -2·g1·h2 + 2·g2·h1 + -2·b2·e1 + -2·d1·f2 + 2·b1·e2
 2·c1·f2 + 2·b1·h2 + -2·b2·h1 + 2·e2·g1 + -2·e1·g2 + -2·c2·f1
-2·d2·g1 + 2·b2·c1 + 2·d1·g2 + -2·b1·c2 + -2·f1·h2 + 2·f2·h1
-2·b2·g1 + 2·e1·h2 + -2·c1·d2 + 2·b1·g2 + -2·e2·h1 + 2·c2·d1
 2·d2·e1 + 2·b2·f1 + -2·d1·e2 + -2·c2·h1 + -2·b1·f2 + 2·c1·h2
-2·b1·d2 + -2·e1·f2 + -2·c1·g2 + 2·c2·g1 + 2·e2·f1 + 2·b2·d1

其他例子:证明

(x * y) * z != x * (y * z)

代码:

x = Octonion("x")
y = Octonion("y")
z = Octonion("z")
a1, b1, c1, d1, e1, f1, g1, h1 = Reals('a1 b1 c1 d1 e1 f1 g1 h1')
a2, b2, c2, d2, e2, f2, g2, h2 = Reals('a2 b2 c2 d2 e2 f2 g2 h2')
a3, b3, c3, d3, e3, f3, g3, h3 = Reals('a3 b3 c3 d3 e3 f3 g3 h3')
x.r =  a1
x.i1 = b1
x.i2 = c1
x.i3 = d1
x.i4 = e1
x.i5 = f1
x.i6 = g1
x.i7 = h1
y.r =  a2
y.i1 = b2
y.i2 = c2
y.i3 = d2
y.i4 = e2
y.i5 = f2
y.i6 = g2
y.i7 = h2
z.r =  a3
z.i1 = b3
z.i2 = c3
z.i3 = d3
z.i4 = e3
z.i5 = f3
z.i6 = g3
z.i7 = h3
print simplify(((x * y) * z - x * (y * z)).r, som = True)
print "end r"
print simplify(((x * y) * z - x * (y * z)).i1, som = True)
print "end i1"
print simplify(((x * y) * z - x * (y * z)).i2, som = True)
print "end i2"
print simplify(((x * y) * z - x * (y * z)).i3, som = True)
print "end i3"
print simplify(((x * y) * z - x * (y * z)).i4, som = True)
print "end i4"
print simplify(((x * y) * z - x * (y * z)).i5, som = True) 
print "end i5"
print simplify(((x * y) * z - x * (y * z)).i6, som = True)
print "end i6"
print simplify(((x * y) * z - x * (y * z)).i7, som = True)
print "end i7"

输出:

0
end r

-2·d2·e3·f1 + 2·e3·g1·h2 + -2·e3·g2·h1 + 2·d1·e3·f2 +-2·e1·g3·h2 + 2·c1·d2·g3 +
2·e2·g3·h1 + -2·c2·d1·g3 + 2·d2·e1·f3 + -2·d1·e2·f3 +-2·c2·f3·h1 + 2·c1·f3·h2 +
-2·c3·d2·g1 + 2·c3·d1·g2 + -2·c3·f1·h2 + 2·c3·f2·h1 +-2·d3·e1·f2 + -2·c1·d3·g2 +
2·c2·d3·g1 + 2·d3·e2·f1 + -2·c1·f2·h3 + -2·e2·g1·h3 + 2·e1·g2·h3 + 2·c2·f1·h3
end i1

-2·b2·d3·g1 + 2·d3·e1·h2 + 2·b1·d3·g2 + -2·d3·e2·h1 + -2·d2·e1·h3 + -2·b2·f1·h3 +
2·d1·e2·h3 + 2·b1·f2·h3 +-2·b1·d2·g3 + -2·e1·f2·g3 + 2·e2·f1·g3 + 2·b2·d1·g3 +
2·b3·d2·g1 + -2·b3·d1·g2 + 2·b3·f1·h2 + -2·b3·f2·h1 + -2·b1·f3·h2 + 2·b2·f3·h1 +
-2·e2·f3·g1 + 2·e1·f3·g2 + -2·e3·f1·g2 + 2·e3·f2·g1 + 2·d2·e3·h1 +-2·d1·e3·h2
end i2

-2·f3·g1·h2 + 2·f3·g2·h1 + -2·b2·e1·f3 + 2·b1·e2·f3 + -2·c1·e2·h3 +-2·f1·g2·h3 +
2·f2·g1·h3 + 2·c2·e1·h3 + 2·b3·e1·f2 + 2·b3·c1·g2 +-2·b3·c2·g1 + -2·b3·e2·f1 +
2·b2·e3·f1 +-2·c2·e3·h1 +  -2·b1·e3·f2 + 2·c1·e3·h2 + -2·b2·c1·g3 + 2·b1·c2·g3 +
2·f1·g3·h2 + -2·f2·g3·h1 + 2·b2·c3·g1 + -2·c3·e1·h2 + -2·b1·c3·g2 +  2·c3·e2·h1
end i3

-2·b2·d3·f1 + 2·c2·d3·h1 +2·b1·d3·f2 + -2·c1·d3·h2 + 2·b3·d2·f1 +-2·b3·g1·h2 +
2·b3·g2·h1 +-2·b3·d1·f2 +2·c1·f2·g3 +2·b1·g3·h2 +-2·b2·g3·h1 + -2·c2·f1·g3 +
2·c3·f1·g2 + -2·c3·f2·g1 +-2·c3·d2·h1 +2·c3·d1·h2 +2·b2·g1·h3 +2·c1·d2·h3 +
-2·b1·g2·h3 +-2·c2·d1·h3 +-2·b1·d2·f3 +-2·c1·f3·g2 +2·c2·f3·g1 +2·b2·d1·f3
end i4

-2·b3·d2·e1 + 2·b3·d1·e2 + 2·b3·c2·h1 + -2·b3·c1·h2 + -2·d2·g1·h3 + 2·b2·c1·h3 +
 2·d1·g2·h3 +-2·b1·c2·h3 +2·d3·g1·h2 +-2·d3·g2·h1 +2·b2·d3·e1 +-2·b1·d3·e2 +
-2·c1·e2·g3 + 2·c2·e1·g3 +2·d2·g3·h1 +-2·d1·g3·h2 +2·b1·d2·e3 + 2·c1·e3·g2 +
-2·c2·e3·g1 +-2·b2·d1·e3 +2·b1·c3·h2 +-2·b2·c3·h1 +2·c3·e2·g1 +-2·c3·e1·g2
 end i5

 2·b2·c1·d3 +-2·b1·c2·d3 +-2·d3·f1·h2 +2·d3·f2·h1 +2·b3·e1·h2 +-2·b3·c1·d2 +
 -2·b3·e2·h1 +2·b3·c2·d1 +-2·c1·e3·f2 +-2·b1·e3·h2 +2·b2·e3·h1 +2·c2·e3·f1 +
 2·b1·c3·d2 +2·c3·e1·f2 +-2·c3·e2·f1 +-2·b2·c3·d1 +2·c1·e2·f3 +-2·c2·e1·f3 +
 -2·d2·f3·h1 +2·d1·f3·h2 +2·d2·f1·h3 +-2·b2·e1·h3 +-2·d1·f2·h3 + 2·b1·e2·h3
 end i6

 2·c1·d3·e2 +2·d3·f1·g2 +-2·d3·f2·g1 +-2·c2·d3·e1 +2·d2·f3·g1 +-2·b2·c1·f3 +
 -2·d1·f3·g2 +2·b1·c2·f3 +-2·d2·f1·g3 +2·b2·e1·g3 +2·d1·f2·g3 +-2·b1·e2·g3 +
 2·c3·d2·e1 +2·b2·c3·f1 +-2·c3·d1·e2 +-2·b1·c3·f2 +-2·b2·e3·g1 +-2·c1·d2·e3 +
 2·b1·e3·g2 +2·c2·d1·e3 +2·b3·c1·f2 +2·b3·e2·g1 +-2·b3·e1·g2 +-2·b3·c2·f1
 end i7

在线here

运行此示例

其他例子:证明八进制形成另一种代数,就是说:

x * (x * y) = (x * x) * y
(y * x) * x = y * (x * x)

代码:

x = Octonion("x")
y = Octonion("y")

a1, b1, c1, d1, e1, f1, g1, h1 = Reals('a1 b1 c1 d1 e1 f1 g1 h1')
a2, b2, c2, d2, e2, f2, g2, h2 = Reals('a2 b2 c2 d2 e2 f2 g2 h2')

x.r =  a1
x.i1 = b1
x.i2 = c1
x.i3 = d1
x.i4 = e1
x.i5 = f1
x.i6 = g1
x.i7 = h1
y.r =  a2
y.i1 = b2
y.i2 = c2
y.i3 = d2
y.i4 = e2
y.i5 = f2
y.i6 = g2
y.i7 = h2

print simplify(((x * x) * y - x * (x * y)).r, som = True)

print simplify(((x * x) * y - x * (x * y)).i1, som = True)

print simplify(((x * x) * y - x * (x * y)).i2, som = True)

print simplify(((x * x) * y - x * (x * y)).i3, som = True)

print simplify(((x * x) * y - x * (x * y)).i4, som = True)

print simplify(((x * x) * y - x * (x * y)).i5, som = True) 

print simplify(((x * x) * y - x * (x * y)).i6, som = True)

print simplify(((x * x) * y - x * (x * y)).i7, som = True)
print " Proved that x(xy) = (xx)y"

print simplify(((y * x) * x - y * (x * x)).r, som = True)

print simplify(((y * x) * x - y * (x * x)).i1, som = True)

print simplify(((y * x) * x - y * (x * x)).i2, som = True)

print simplify(((y * x) * x - y * (x * x)).i3, som = True)

print simplify(((y * x) * x - y * (x * x)).i4, som = True)

print simplify(((y * x) * x - y * (x * x)).i5, som = True) 

print simplify(((y * x) * x - y * (x * x)).i6, som = True)

print simplify(((y * x) * x - y * (x * x)).i7, som = True)
print " Proved that (yx)x = y(xx)"

输出:

0
0
0
0
0
0
0
0
Proved that x(xy) = (xx)y
0
0
0
0
0
0
0
0
Proved that (yx)x = y(xx)

在线here

运行此示例

其他例子:证明八进制符合Moufang身份:

z * (x * (z * y)) = ((z * x) * z) * y
x * (z * (y * z)) = ((x * z) * y) * z
(z * x) * (y * z) = (z * (x * y)) * z
(z * x) * (y * z) = z * ((x * y) * z)

代码:

x = Octonion("x")
y = Octonion("y")
z = Octonion("z")
a1, b1, c1, d1, e1, f1, g1, h1 = Reals('a1 b1 c1 d1 e1 f1 g1 h1')
a2, b2, c2, d2, e2, f2, g2, h2 = Reals('a2 b2 c2 d2 e2 f2 g2 h2')
a3, b3, c3, d3, e3, f3, g3, h3 = Reals('a3 b3 c3 d3 e3 f3 g3 h3')
x.r =  a1
x.i1 = b1
x.i2 = c1
x.i3 = d1
x.i4 = e1
x.i5 = f1
x.i6 = g1
x.i7 = h1
y.r =  a2
y.i1 = b2
y.i2 = c2
y.i3 = d2
y.i4 = e2
y.i5 = f2
y.i6 = g2
y.i7 = h2
z.r =  a3
z.i1 = b3
z.i2 = c3
z.i3 = d3
z.i4 = e3
z.i5 = f3
z.i6 = g3
z.i7 = h3
print simplify((z * (x * (z * y)) -((z * x) * z) * y).r, som = True)

print simplify((z * (x * (z * y)) -((z * x) * z) * y).i1, som = True)

print simplify((z * (x * (z * y)) -((z * x) * z) * y).i2, som = True)

print simplify((z * (x * (z * y)) -((z * x) * z) * y).i3, som = True)

print simplify((z * (x * (z * y)) -((z * x) * z) * y).i4, som = True)

print simplify((z * (x * (z * y)) -((z * x) * z) * y).i5, som = True) 

print simplify((z * (x * (z * y)) -((z * x) * z) * y).i6, som = True)

print simplify((z * (x * (z * y)) -((z * x) * z) * y).i7, som = True)
print "Proved that z(x(zy)) = ((zx)z)y"

print simplify((x * (z * (y * z)) -((x * z) * y) * z).r, som = True)

print simplify((x * (z * (y * z)) -((x * z) * y) * z).i1, som = True)

print simplify((x * (z * (y * z)) -((x * z) * y) * z).i2, som = True)

print simplify((x * (z * (y * z)) -((x * z) * y) * z).i3, som = True)

print simplify((x * (z * (y * z)) -((x * z) * y) * z).i4, som = True)

print simplify((x * (z * (y * z)) -((x * z) * y) * z).i5, som = True) 

print simplify((x * (z * (y * z)) -((x * z) * y) * z).i6, som = True)

print simplify((x * (z * (y * z)) -((x * z) * y) * z).i7, som = True)
print "Proved that x(z(yz)) = ((xz)y)z"

print simplify(((z * x) * (y * z) - (z * (x * y))*z).r, som = True)

print simplify(((z * x) * (y * z) - (z * (x * y))*z).i1, som = True)

print simplify(((z * x) * (y * z) - (z * (x * y))*z).i2, som = True)

print simplify(((z * x) * (y * z) - (z * (x * y))*z).i3, som = True)

print simplify(((z * x) * (y * z) - (z * (x * y))*z).i4, som = True)

print simplify(((z * x) * (y * z) - (z * (x * y))*z).i5, som = True) 

print simplify(((z * x) * (y * z) - (z * (x * y))*z).i6, som = True)

print simplify(((z * x) * (y * z) - (z * (x * y))*z).i7, som = True)
print "Proved that (zx)(yz) = (z(xy))z"

print simplify(((z * x) * (y * z) - z * ((x * y) * z)).r, som = True)

print simplify(((z * x) * (y * z) -  z * ((x * y) * z)).i1, som = True)

print simplify(((z * x) * (y * z) -  z * ((x * y) * z)).i2, som = True)

print simplify(((z * x) * (y * z) -  z * ((x * y) * z)).i3, som = True)

print simplify(((z * x) * (y * z) -  z * ((x * y) * z)).i4, som = True)

print simplify(((z * x) * (y * z) -  z * ((x * y) * z)).i5, som = True) 

print simplify(((z * x) * (y * z) -  z * ((x * y) * z)).i6, som = True)

print simplify(((z * x) * (y * z) -  z * ((x * y) * z)).i7, som = True)
print "Proved that (zx)(yz) = z((xy)z)"

输出:

0
0
0
0
0
0
0
0
Proved that z(x(zy)) = ((zx)z)y
0
0
0
0
0
0
0
0
Proved that x(z(yz)) = ((xz)y)z
0
0
0
0
0
0
0
0
Proved that (zx)(yz) = (z(xy))z
0
0
0
0
0
0
0
0
Proved that (zx)(yz) = z((xy)z)

在线here

运行此示例

其他例子:证明八进制

A = (1 + e1)/sqrt(2)
B = (1 + e2)/sqrt(2) 
C = (1 + e3)/sqrt(2) 

生成辫子组的代表,也就是说,我们有

ABA = BAB 
ACA = CAC 
BCB = CBC.

代码:

A = Octonion('A')
B = Octonion('B')
C = Octonion('C')
A.r = 1/Sqrt(2)
A.i1 = 1/Sqrt(2)
A.i2 = 0
A.i3 = 0
A.i4 = 0
A.i5 = 0
A.i6 = 0
A.i7 = 0
B.r = 1/Sqrt(2)
B.i1 = 0
B.i2 = 1/Sqrt(2)
B.i3 = 0
B.i4 = 0
B.i5 = 0
B.i6 = 0
B.i7 = 0
C.r = 1/Sqrt(2)
C.i1 = 0
C.i2 = 0
C.i3 = 1/Sqrt(2)
C.i4 = 0
C.i5 = 0
C.i6 = 0
C.i7 = 0
print simplify((A*B*A-B*A*B).r)
print simplify((A*B*A-B*A*B).i1)
print simplify((A*B*A-B*A*B).i2)
print simplify((A*B*A-B*A*B).i3)
print simplify((A*B*A-B*A*B).i4)
print simplify((A*B*A-B*A*B).i5)
print simplify((A*B*A-B*A*B).i6)
print simplify((A*B*A-B*A*B).i7)
print "Proved : ABA = BAB:"
print simplify((A*C*A-C*A*C).r)
print simplify((A*C*A-C*A*C).i1)
print simplify((A*C*A-C*A*C).i2)
print simplify((A*C*A-C*A*C).i3)
print simplify((A*C*A-C*A*C).i4)
print simplify((A*C*A-C*A*C).i5)
print simplify((A*C*A-C*A*C).i6)
print simplify((A*C*A-C*A*C).i7)
print "Proved : ACA = CAC:"
print simplify((B*C*B-C*B*C).r)
print simplify((B*C*B-C*B*C).i1)
print simplify((B*C*B-C*B*C).i2)
print simplify((B*C*B-C*B*C).i3)
print simplify((B*C*B-C*B*C).i4)
print simplify((B*C*B-C*B*C).i5)
print simplify((B*C*B-C*B*C).i6)
print simplify((B*C*B-C*B*C).i7)
print "Proved : BCB = CBC:"

输出:

0
0
0
0
0
0
0
0
Proved : ABA = BAB:
0
0
0
0
0
0
0
0
Proved : ACA = CAC:
0
0
0
0
0
0
0
0
Proved : BCB = CBC:

在线here

运行此示例

其他例子:证明八进制

A = (1 + e4)/sqrt(2)
B = (1 + e5)/sqrt(2) 
C = (1 + e6)/sqrt(2) 

生成辫子组的代表,也就是说,我们有

ABA = BAB 
ACA = CAC 
BCB = CBC

代码:

A = Octonion('A')
B = Octonion('B')
C = Octonion('C')
A.r = 1/Sqrt(2)
A.i1 = 0
A.i2 = 0
A.i3 = 0
A.i4 = 1/Sqrt(2)
A.i5 = 0
A.i6 = 0
A.i7 = 0
B.r = 1/Sqrt(2)
B.i1 = 0
B.i2 = 0
B.i3 = 0
B.i4 = 0
B.i5 = 1/Sqrt(2)
B.i6 = 0
B.i7 = 0
C.r = 1/Sqrt(2)
C.i1 = 0
C.i2 = 0
C.i3 = 0
C.i4 = 0
C.i5 = 0
C.i6 = 1/Sqrt(2)
C.i7 = 0
print simplify((A*B*A-B*A*B).r)
print simplify((A*B*A-B*A*B).i1)
print simplify((A*B*A-B*A*B).i2)
print simplify((A*B*A-B*A*B).i3)
print simplify((A*B*A-B*A*B).i4)
print simplify((A*B*A-B*A*B).i5)
print simplify((A*B*A-B*A*B).i6)
print simplify((A*B*A-B*A*B).i7)
print "Proved : ABA = BAB:"
print simplify((A*C*A-C*A*C).r)
print simplify((A*C*A-C*A*C).i1)
print simplify((A*C*A-C*A*C).i2)
print simplify((A*C*A-C*A*C).i3)
print simplify((A*C*A-C*A*C).i4)
print simplify((A*C*A-C*A*C).i5)
print simplify((A*C*A-C*A*C).i6)
print simplify((A*C*A-C*A*C).i7)
print "Proved : ACA = CAC:"
print simplify((B*C*B-C*B*C).r)
print simplify((B*C*B-C*B*C).i1)
print simplify((B*C*B-C*B*C).i2)
print simplify((B*C*B-C*B*C).i3)
print simplify((B*C*B-C*B*C).i4)
print simplify((B*C*B-C*B*C).i5)
print simplify((B*C*B-C*B*C).i6)
print simplify((B*C*B-C*B*C).i7)
print "Proved : BCB = CBC:"

输出:

0
0
0
0
0
0
0
0
Proved : ABA = BAB:
0
0
0
0
0
0
0
0
Proved : ACA = CAC:
0
0
0
0
0
0
0
0
Proved : BCB = CBC:    

在线here

运行此示例

其他例子:证明八进制

A = (1 + e5)/sqrt(2)
B = (1 + e6)/sqrt(2) 
C = (1 + e7)/sqrt(2) 

生成辫子组的代表,也就是说,我们有

ABA = BAB 
ACA = CAC 
BCB = CBC

代码:

A = Octonion('A')
B = Octonion('B')
C = Octonion('C')
A.r = 1/Sqrt(2)
A.i1 = 0
A.i2 = 0
A.i3 = 0
A.i4 = 0
A.i5 = 1/Sqrt(2)
A.i6 = 0
A.i7 = 0
B.r = 1/Sqrt(2)
B.i1 = 0
B.i2 = 0
B.i3 = 0
B.i4 = 0
B.i5 = 0
B.i6 = 1/Sqrt(2)
B.i7 = 0
C.r = 1/Sqrt(2)
C.i1 = 0
C.i2 = 0
C.i3 = 0
C.i4 = 0
C.i5 = 0
C.i6 = 0
C.i7 = 1/Sqrt(2)
print simplify((A*B*A-B*A*B).r)
print simplify((A*B*A-B*A*B).i1)
print simplify((A*B*A-B*A*B).i2)
print simplify((A*B*A-B*A*B).i3)
print simplify((A*B*A-B*A*B).i4)
print simplify((A*B*A-B*A*B).i5)
print simplify((A*B*A-B*A*B).i6)
print simplify((A*B*A-B*A*B).i7)
print "Proved : ABA = BAB:"
print simplify((A*C*A-C*A*C).r)
print simplify((A*C*A-C*A*C).i1)
print simplify((A*C*A-C*A*C).i2)
print simplify((A*C*A-C*A*C).i3)
print simplify((A*C*A-C*A*C).i4)
print simplify((A*C*A-C*A*C).i5)
print simplify((A*C*A-C*A*C).i6)
print simplify((A*C*A-C*A*C).i7)
print "Proved : ACA = CAC:"
print simplify((B*C*B-C*B*C).r)
print simplify((B*C*B-C*B*C).i1)
print simplify((B*C*B-C*B*C).i2)
print simplify((B*C*B-C*B*C).i3)
print simplify((B*C*B-C*B*C).i4)
print simplify((B*C*B-C*B*C).i5)
print simplify((B*C*B-C*B*C).i6)
print simplify((B*C*B-C*B*C).i7)
print "Proved : BCB = CBC:"    

输出:

0
0
0
0
0
0
0
0
Proved : ABA = BAB:
0
0
0
0
0
0
0
0
Proved : ACA = CAC:
0
0
0
0
0
0
0
0
Proved : BCB = CBC:

在线here

运行此示例

其他例子:证明八进制

A = (1 + e1)/sqrt(2)         E = (1 + e5)/sqrt(2)
B = (1 + e2)/sqrt(2)         F = (1 + e6)/sqrt(2)
C = (1 + e3)/sqrt(2)         G = (1 + e7)/sqrt(2)
D = (1 + e4)/sqrt(2) 

生成辫子组的代表,也就是说,我们有

ABA = BAB     ACA = CAC     BCB = CBC    ADA = DAD     BDB = DBD
CDC = DCD     AEA = EAE     BEB = EBE    CEC = ECE     DED = EDE
AFA = FAF     BFB = FBF     CFC = FCF    DFD = FDF     EFE = FEF
AGA = GAG     BGB = GBG     CGC = GCG    DGD = GDg     EGE = GEG     FGF = GFG

代码:

A = Octonion('A')
B = Octonion('B')
C = Octonion('C')
D = Octonion('D')
E = Octonion('E')
F = Octonion('F')
G = Octonion('G')
A.r = 1/Sqrt(2)
A.i1 = 1/Sqrt(2)
A.i2 = 0
A.i3 = 0
A.i4 = 0
A.i5 = 0
A.i6 = 0
A.i7 = 0
B.r = 1/Sqrt(2)
B.i1 = 0
B.i2 = 1/Sqrt(2)
B.i3 = 0
B.i4 = 0
B.i5 = 0
B.i6 = 0
B.i7 = 0
C.r = 1/Sqrt(2)
C.i1 = 0
C.i2 = 0
C.i3 = 1/Sqrt(2)
C.i4 = 0
C.i5 = 0
C.i6 = 0
C.i7 = 0
D.r = 1/Sqrt(2)
D.i1 = 0
D.i2 = 0
D.i3 = 0
D.i4 = 1/Sqrt(2)
D.i5 = 0
D.i6 = 0
D.i7 = 0
E.r = 1/Sqrt(2)
E.i1 = 0
E.i2 = 0
E.i3 = 0
E.i4 = 0
E.i5 = 1/Sqrt(2)
E.i6 = 0
E.i7 = 0
F.r = 1/Sqrt(2)
F.i1 = 0
F.i2 = 0
F.i3 = 0
F.i4 = 0
F.i5 = 0
F.i6 = 1/Sqrt(2)
F.i7 = 0
G.r = 1/Sqrt(2)
G.i1 = 0
G.i2 = 0
G.i3 = 0
G.i4 = 0
G.i5 = 0
G.i6 = 0
G.i7 = 1/Sqrt(2)
print simplify((A*B*A-B*A*B).r)
print simplify((A*B*A-B*A*B).i1)
print simplify((A*B*A-B*A*B).i2)
print simplify((A*B*A-B*A*B).i3)
print simplify((A*B*A-B*A*B).i4)
print simplify((A*B*A-B*A*B).i5)
print simplify((A*B*A-B*A*B).i6)
print simplify((A*B*A-B*A*B).i7)
print "Proved : ABA = BAB:"
print simplify((A*C*A-C*A*C).r)
print simplify((A*C*A-C*A*C).i1)
print simplify((A*C*A-C*A*C).i2)
print simplify((A*C*A-C*A*C).i3)
print simplify((A*C*A-C*A*C).i4)
print simplify((A*C*A-C*A*C).i5)
print simplify((A*C*A-C*A*C).i6)
print simplify((A*C*A-C*A*C).i7)
print "Proved : ACA = CAC:"
print simplify((B*C*B-C*B*C).r)
print simplify((B*C*B-C*B*C).i1)
print simplify((B*C*B-C*B*C).i2)
print simplify((B*C*B-C*B*C).i3)
print simplify((B*C*B-C*B*C).i4)
print simplify((B*C*B-C*B*C).i5)
print simplify((B*C*B-C*B*C).i6)
print simplify((B*C*B-C*B*C).i7)
print "Proved : BCB = CBC:"
print simplify((A*D*A-D*A*D).r)
print simplify((A*D*A-D*A*D).i1)
print simplify((A*D*A-D*A*D).i2)
print simplify((A*D*A-D*A*D).i3)
print simplify((A*D*A-D*A*D).i4)
print simplify((A*D*A-D*A*D).i5)
print simplify((A*D*A-D*A*D).i6)
print simplify((A*D*A-D*A*D).i7)
print "Proved : ADA = DAD:"
print simplify((B*D*B-D*B*D).r)
print simplify((B*D*B-D*B*D).i1)
print simplify((B*D*B-D*B*D).i2)
print simplify((B*D*B-D*B*D).i3)
print simplify((B*D*B-D*B*D).i4)
print simplify((B*D*B-D*B*D).i5)
print simplify((B*D*B-D*B*D).i6)
print simplify((B*D*B-D*B*D).i7)
print "Proved : BDB = DBD:"
print simplify((C*D*C-D*C*D).r)
print simplify((C*D*C-D*C*D).i1)
print simplify((C*D*C-D*C*D).i2)
print simplify((C*D*C-D*C*D).i3)
print simplify((C*D*C-D*C*D).i4)
print simplify((C*D*C-D*C*D).i5)
print simplify((C*D*C-D*C*D).i6)
print simplify((C*D*C-D*C*D).i7)
print "Proved : CDC = DCD:"
print simplify((A*E*A-E*A*E).r)
print simplify((A*E*A-E*A*E).i1)
print simplify((A*E*A-E*A*E).i2)
print simplify((A*E*A-E*A*E).i3)
print simplify((A*E*A-E*A*E).i4)
print simplify((A*E*A-E*A*E).i5)
print simplify((A*E*A-E*A*E).i6)
print simplify((A*E*A-E*A*E).i7)
print "Proved : AEA = EAE:"
print simplify((B*E*B-E*B*E).r)
print simplify((B*E*B-E*B*E).i1)
print simplify((B*E*B-E*B*E).i2)
print simplify((B*E*B-E*B*E).i3)
print simplify((B*E*B-E*B*E).i4)
print simplify((B*E*B-E*B*E).i5)
print simplify((B*E*B-E*B*E).i6)
print simplify((B*E*B-E*B*E).i7)
print "Proved : BEB = EBE:"
print simplify((C*E*C-E*C*E).r)
print simplify((C*E*C-E*C*E).i1)
print simplify((C*E*C-E*C*E).i2)
print simplify((C*E*C-E*C*E).i3)
print simplify((C*E*C-E*C*E).i4)
print simplify((C*E*C-E*C*E).i5)
print simplify((C*E*C-E*C*E).i6)
print simplify((C*E*C-E*C*E).i7)
print "Proved : CEC = ECE:"
print simplify((D*E*D-E*D*E).r)
print simplify((D*E*D-E*D*E).i1)
print simplify((D*E*D-E*D*E).i2)
print simplify((D*E*D-E*D*E).i3)
print simplify((D*E*D-E*D*E).i4)
print simplify((D*E*D-E*D*E).i5)
print simplify((D*E*D-E*D*E).i6)
print simplify((D*E*D-E*D*E).i7)
print "Proved : DED = EDE:"
print simplify((A*F*A-F*A*F).r)
print simplify((A*F*A-F*A*F).i1)
print simplify((A*F*A-F*A*F).i2)
print simplify((A*F*A-F*A*F).i3)
print simplify((A*F*A-F*A*F).i4)
print simplify((A*F*A-F*A*F).i5)
print simplify((A*F*A-F*A*F).i6)
print simplify((A*F*A-F*A*F).i7)
print "Proved : AFA = FAF:"
print simplify((B*F*B-F*B*F).r)
print simplify((B*F*B-F*B*F).i1)
print simplify((B*F*B-F*B*F).i2)
print simplify((B*F*B-F*B*F).i3)
print simplify((B*F*B-F*B*F).i4)
print simplify((B*F*B-F*B*F).i5)
print simplify((B*F*B-F*B*F).i6)
print simplify((B*F*B-F*B*F).i7)
print "Proved : BFB = FBF:"
print simplify((C*F*C-F*C*F).r)
print simplify((C*F*C-F*C*F).i1)
print simplify((C*F*C-F*C*F).i2)
print simplify((C*F*C-F*C*F).i3)
print simplify((C*F*C-F*C*F).i4)
print simplify((C*F*C-F*C*F).i5)
print simplify((C*F*C-F*C*F).i6)
print simplify((C*F*C-F*C*F).i7)
print "Proved : CFC = FCF:"
print simplify((D*F*D-F*D*F).r)
print simplify((D*F*D-F*D*F).i1)
print simplify((D*F*D-F*D*F).i2)
print simplify((D*F*D-F*D*F).i3)
print simplify((D*F*D-F*D*F).i4)
print simplify((D*F*D-F*D*F).i5)
print simplify((D*F*D-F*D*F).i6)
print simplify((D*F*D-F*D*F).i7)
print "Proved : DFD = FDF:"
print simplify((E*F*E-F*E*F).r)
print simplify((E*F*E-F*E*F).i1)
print simplify((E*F*E-F*E*F).i2)
print simplify((E*F*E-F*E*F).i3)
print simplify((E*F*E-F*E*F).i4)
print simplify((E*F*E-F*E*F).i5)
print simplify((E*F*E-F*E*F).i6)
print simplify((E*F*E-F*E*F).i7)
print "Proved : EFE = FEF:"
print simplify((A*G*A-G*A*G).r)
print simplify((A*G*A-G*A*G).i1)
print simplify((A*G*A-G*A*G).i2)
print simplify((A*G*A-G*A*G).i3)
print simplify((A*G*A-G*A*G).i4)
print simplify((A*G*A-G*A*G).i5)
print simplify((A*G*A-G*A*G).i6)
print simplify((A*G*A-G*A*G).i7)
print "Proved : AGA = GAG:"
print simplify((B*G*B-G*B*G).r)
print simplify((B*G*B-G*B*G).i1)
print simplify((B*G*B-G*B*G).i2)
print simplify((B*G*B-G*B*G).i3)
print simplify((B*G*B-G*B*G).i4)
print simplify((B*G*B-G*B*G).i5)
print simplify((B*G*B-G*B*G).i6)
print simplify((B*G*B-G*B*G).i7)
print "Proved : BGB = GBG:"
print simplify((C*G*C-G*C*G).r)
print simplify((C*G*C-G*C*G).i1)
print simplify((C*G*C-G*C*G).i2)
print simplify((C*G*C-G*C*G).i3)
print simplify((C*G*C-G*C*G).i4)
print simplify((C*G*C-G*C*G).i5)
print simplify((C*G*C-G*C*G).i6)
print simplify((C*G*C-G*C*G).i7)
print "Proved : CGC = GCG:"
print simplify((D*G*D-G*D*G).r)
print simplify((D*G*D-G*D*G).i1)
print simplify((D*G*D-G*D*G).i2)
print simplify((D*G*D-G*D*G).i3)
print simplify((D*G*D-G*D*G).i4)
print simplify((D*G*D-G*D*G).i5)
print simplify((D*G*D-G*D*G).i6)
print simplify((D*G*D-G*D*G).i7)
print "Proved : DGD = GDG:"
print simplify((E*G*E-G*E*G).r)
print simplify((E*G*E-G*E*G).i1)
print simplify((E*G*E-G*E*G).i2)
print simplify((E*G*E-G*E*G).i3)
print simplify((E*G*E-G*E*G).i4)
print simplify((E*G*E-G*E*G).i5)
print simplify((E*G*E-G*E*G).i6)
print simplify((E*G*E-G*E*G).i7)
print "Proved : EGE = GEG:"
print simplify((F*G*F-G*F*G).r)
print simplify((F*G*F-G*F*G).i1)
print simplify((F*G*F-G*F*G).i2)
print simplify((F*G*F-G*F*G).i3)
print simplify((F*G*F-G*F*G).i4)
print simplify((F*G*F-G*F*G).i5)
print simplify((F*G*F-G*F*G).i6)
print simplify((F*G*F-G*F*G).i7)
print "Proved : FGF = GFG:"

输出:

0
0
0
0
0
0
0
0
Proved : ABA = BAB:
0
0
0
0
0
0
0
0
Proved : ACA = CAC:
0
0
0
0
0
0
0
0
Proved : BCB = CBC:
0
0
0
0
0
0
0
0
Proved : ADA = DAD:
0
0
0
0
0
0
0
0
Proved : BDB = DBD:
0
0
0
0
0
0
0
0
Proved : CDC = DCD:
0
0
0
0
0
0
0
0
Proved : AEA = EAE:
0
0
0
0
0
0
0
0
Proved : BEB = EBE:
0
0
0
0
0
0
0
0
Proved : CEC = ECE:
0
0
0
0
0
0
0
0
Proved : DED = EDE:
0
0
0
0
0
0
0
0
Proved : AFA = FAF:
0
0
0
0
0
0
0
0
Proved : BFB = FBF:
0
0
0
0
0
0
0
0
Proved : CFC = FCF:
0
0
0
0
0
0
0
0
Proved : DFD = FDF:
0
0
0
0
0
0
0
0
Proved : EFE = FEF:
0
0
0
0
0
0
0
0
Proved : AGA = GAG:
0
0
0
0
0
0
0
0
Proved : BGB = GBG:
0
0
0
0
0
0
0
0
Proved : CGC = GCG:
0
0
0
0
0
0
0
0
Proved : DGD = GDG:
0
0
0
0
0
0
0
0
Proved : EGE = GEG:
0
0
0
0
0
0
0
0
Proved : FGF = GFG:

在线here

运行此示例

其他示例:证明形式的可逆八进制

x = a + a1*e1 + a2*e2 + a3*e3 + a4*e4 + a5*e5 + a6*e6

我们有那个

x / x  = 1 

在线here

运行此示例

请告诉我您对Octonion代码的看法以及如何改进Octonion代码。非常感谢。

1 个答案:

答案 0 :(得分:1)

  

请告诉我您对Octonion代码的看法以及如何改进Octonion代码。非常感谢。

我认为这个问题的恰当答案是非常好。