︠ N.<a1,a2,a3,a4,b1,b2,b3,b4,a,b> = QQ[] H.<i,j,k> = QuaternionAlgebra(Frac(N),-1,-1) p = a1 + a2 * i + a3 * j + a4 * k q = b1 + b2 * i + b3 * j + b4 * k r=(1-a-2b)(1-pq+ap) r.norm()
1 | initial version |
︠ N.<a1,a2,a3,a4,b1,b2,b3,b4,a,b> = QQ[] H.<i,j,k> = QuaternionAlgebra(Frac(N),-1,-1) p = a1 + a2 * i + a3 * j + a4 * k q = b1 + b2 * i + b3 * j + b4 * k r=(1-a-2b)(1-pq+ap) r.norm()
︠
EDIT︠ED: (never start with the code, always put the wanted question also in the posted question, not only in the title.)
N.<a1,a2,a3,a4,b1,b2,b3,b4,a,b> = QQ[]
H.<i,j,k> = QuaternionAlgebra(Frac(N),-1,-1)
p = a1 + a2 * i + a3 * j + a4 * k
q = b1 + b2 * i + b3 * j + b4 * k
r=(1-a-2b)(1-pq+ap)
r.norm()r=(1-a-2*b)*(1-p*q+a*p)
r.norm()