Ask Your Question
1

Multiplication of tensor elements

asked 2023-07-09 06:09:52 +0100

tolga gravatar image

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.

edit retag flag offensive close merge delete

Comments

1

Compare with this version

from sage.manifolds.utilities import simplify_sqrt_real
H=function('H',imag_part_func=0)()
term1=(1/2)*sqrt(2)*sqrt(I*H)
term2=(1/2)*sqrt(2)*sqrt(-I*H)
simplify_sqrt_real(term1*term2)

1/2*abs(H())

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)()
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])
T1[2]*T2[2]

1/2*abs(H())
achrzesz gravatar imageachrzesz ( 2023-07-09 09:53:39 +0100 )edit

Thank you. When I try the following:

from sage.manifolds.utilities import simplify_sqrt_real
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=simplify_sqrt_real(term1*term2)
print(result.canonicalize_radical())

I get 1/2*I*H(x). Without canonicalize_radical(), I get 1/2*sqrt(-H(x))*sqrt(H(x)). So, the sqrt simplification of SageManifolds is the origin of my problem, right?

tolga gravatar imagetolga ( 2023-07-09 10:06:02 +0100 )edit
1

Notice that canonicalize_radical is not always right. In this case the sign of H 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.

achrzesz gravatar imageachrzesz ( 2023-07-09 10:39:25 +0100 )edit

Thank you. Is there a way to set assumptions that yield my desired result -1/2*H(x)?

tolga gravatar imagetolga ( 2023-07-09 10:57:53 +0100 )edit
1

The problem is that SageManifolds and canonicalize_radical make different choice of square root. I think that your method of using expr to force the canonicalize_radical choice is OK (but not in accordance with SageManifolds)

achrzesz gravatar imageachrzesz ( 2023-07-09 12:01:32 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-07-11 15:26:53 +0100

achrzesz gravatar image

Try this version:

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=BL.function('H')(t,r,th,ph)  
assume (H<0)
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])
res=T1[2]*T2[2]
res

-1/2*H
edit flag offensive delete link more

Comments

@achrzesz, thank you!

tolga gravatar imagetolga ( 2023-07-11 19:53:29 +0100 )edit

Last question: Is there a way to define the function H as a differentiable function (i.e. diff(H,r) is not zero) of only the coordinate r, not all t, r, th, ph?

tolga gravatar imagetolga ( 2023-07-12 10:04:32 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-07-09 06:09:52 +0100

Seen: 225 times

Last updated: Jul 11 '23