Multiplication of tensor elements
First, without tensor fields:
reset()
H=function('H',imag_part_func=0)(x)
term1=(1/2)*sqrt(2)*sqrt(I*H)
term2=(1/2)*sqrt(2)*sqrt(-I*H)
result=(term1*term2).canonicalize_radical()
print(result)
This gives the result: -1/2*H(x)
However, when term1
and term2
are the elements of tensors as in
reset()
Man=Manifold(4, 'Man', r'\mathcal{M}')
BL.<t,r,th,ph> = Man.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
H=function('H',imag_part_func=0)(x)
term1=(1/2)*sqrt(2)*sqrt(I*H)
term2=(1/2)*sqrt(2)*sqrt(-I*H)
T1=Man.tensor_field(0,1,[0,0,term1,0])
T2=Man.tensor_field(0,1,[0,0,term2,0])
result=T1[2]*T2[2]
print(result)
I get, 1/2*I*H(x)
I need to get -1/2*H(x)
as in the first case. I can solve my problem by using .expr()
for the elements of the tensor:
reset()
Man=Manifold(4, 'Man', r'\mathcal{M}')
BL.<t,r,th,ph> = Man.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
H=function('H',imag_part_func=0)(x)
term1=(1/2)*sqrt(2)*sqrt(I*H)
term2=(1/2)*sqrt(2)*sqrt(-I*H)
T1=Man.tensor_field(0,1,[0,0,term1,0])
T2=Man.tensor_field(0,1,[0,0,term2,0])
result=(T1[2].expr()*T2[2].expr()).canonicalize_radical()
print(result)
But is there a way to get the result I needed without .expr()
? I think I am missing something about the tensor fields.
Compare with this version
Thank you. When I try the following:
I get
1/2*I*H(x)
. Without canonicalize_radical(), I get1/2*sqrt(-H(x))*sqrt(H(x))
. So, the sqrt simplification of SageManifolds is the origin of my problem, right?Notice that
canonicalize_radical
is not always right. In this case the sign ofH
is needed to simplify. What is worse, Sage is not good when some assumptions are needd, especially in functions definitions. I belive that SageManifolds is right in my code. Presence of x in your code makes a difference.Thank you. Is there a way to set assumptions that yield my desired result
-1/2*H(x)
?The problem is that
SageManifolds
andcanonicalize_radical
make different choice of square root. I think that your method of usingexpr
to force thecanonicalize_radical
choice is OK (but not in accordance with SageManifolds)