Ask Your Question
0

How to express (-t^2 + x^2 + y^2 + z^2) as (x_μ)^2 ?

asked 2023-11-26 09:41:36 +0100

GPN gravatar image

Hi Manifolds experts

I'm a newbie to Sage Manifolds; I find it fascinating, thanks! I have searched for the answer in the forum and documentation but so far without success.

In the code below, I wrote out x^2 in full as -t^2 + x^2 + y^2 + z^2. Is there a way to write it as something like x^2 or g[_μν] x[^μ] x[^ν] ? I tried but couldn't find how and got syntax errors.

Also: is there a way to make the output show the denominator as something like x^2 or g[_μν] x[^μ] x[^ν] ?

Here is my code:

from sage.all import *
%display latex

M = Manifold(4, 'M', latex_name=r'\mathcal{M}', structure='Lorentzian')
X.<t,x,y,z> = M.chart()

F = M.scalar_field(1/(-t^2 + x^2 + y^2 + z^2))
dF = diff(F)
dF.apply_map(factor)
display(dF.display())

I am using SageMath version 9.5, Release Date: 2022-01-30. My OS is Ubuntu 22.04 (itself on WSL2 on Windows 11 latest).

Thank you GPN

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2023-11-26 11:29:26 +0100

achrzesz gravatar image

Make the following modification:

%display latex
M = Manifold(4, 'M', latex_name=r'\mathcal{M}', structure='Lorentzian')
X.<t,x,y,z> = M.chart()
F = M.scalar_field(1/(-t^2 + x^2 + y^2 + z^2))
dF = diff(F)
dF.apply_map(factor)
xm = var('xm', latex_name=r"x_\mu")
dF.apply_map(lambda u: u.substitute({t^2-x^2-y^2-z^2:xm}))
dF.disp()
edit flag offensive delete link more

Comments

@achrzesz thank you. That does solve the second question (how to show x^2 in the output). Is there also an answer to the first question (how to write x^2 as the input expression in a compact way, such as g[_μν] x[^μ] x[^ν]) ?

Many thanks

GPN

GPN gravatar imageGPN ( 2023-11-26 11:40:54 +0100 )edit

A more compact introduction of squared metric is:

M = Manifold(4, 'M')
X.<t,x,y,z> = M.chart()
g = M.lorentzian_metric('g')
g[0,0], g[1,1], g[2,2], g[3,3] = -1, 1, 1, 1
w=M.vector_field([X[0],X[1],X[2],X[3]])
F = M.scalar_field(1/(g(w,w).expr()))
dF = diff(F)
dF.apply_map(factor)
xm = var('xm', latex_name=r"x_\mu")
dF.apply_map(lambda u: u.substitute({t^2-x^2-y^2-z^2:-xm}))
dF.disp()
achrzesz gravatar imageachrzesz ( 2023-11-26 13:56:57 +0100 )edit

cool! @achrzesz

GPN gravatar imageGPN ( 2023-11-26 16:08:17 +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-11-26 09:41:36 +0100

Seen: 470 times

Last updated: Nov 26 '23