Ask Your Question
1

Solving a differential equation - From SageManifold

asked 6 years ago

Dox gravatar image

I'm interested in solving a differential equation obtained from a calculation from sagemanifold. I'll give a simple example, but the reason is that in general the equations are not as simple and one can introduce errors copying the equations.

I'd like to solve the equation given by the Ricci flat condition (for a certain affine connection).

reset()
M = Manifold(4, 'M', latex_name=r"\mathcal{M}")
U.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
nab = M.affine_connection('nabla', r'\nabla'); nab

k = var('k', latex_name=r'\kappa')
s = sqrt(1 - k * r**2)
f = function('f')(t)
g = function('g')(t)
h = function('h')(t)

nab[0,0,0] = f
nab[0,1,1] = g / (1 - k * r**2)
nab[0,2,2] = r**2 * g
nab[0,3,3] = r**2 * sin(th)**2 * g
nab[1,0,1] = h
nab[1,1,0] = h
nab[1,1,1] = k * r / (1 - k * r**2)
nab[1,2,2] = k * r**3 - r
nab[1,3,3] = (k * r **3 - r) * sin(th)**2
nab[2,0,2] = h
nab[2,1,2] = 1 / r
nab[2,2,0] = h
nab[2,2,1] = 1 / r
nab[2,3,3] = - cos(th) * sin(th)
nab[3,0,3] = h
nab[3,1,3] = 1 / r
nab[3,2,3] = cos(th) / sin(th)
nab[3,3,0] = h
nab[3,3,1] = 1 / r
nab[3,3,2] = cos(th) / sin(th)
nab.display()

Ric = M.tensor_field(0,2, 'R', latex_name=r'R')
Ric = nab.ricci()
print("Ricci tensor")
Ric.display_comp()

Now, the Ric[0,0] component yield a simple equation, and can be solved by the command

desolve(diff(h,t) + h**2 - f*h, h, ivar=t, contrib_ode=True)

However, I'd like to be able of telling Sage the following

desolve( Ric[0,0], h, ivar=t, contrib_ode=True)

but it seems that there is an incompatibility of types here...

type(diff(h,t) + h**2 - f*h)

returns <๐š๐šข๐š™๐šŽ'๐šœ๐šŠ๐š๐šŽ.๐šœ๐šข๐š–๐š‹๐š˜๐š•๐š’๐šŒ.๐šŽ๐šก๐š™๐š›๐šŽ๐šœ๐šœ๐š’๐š˜๐š—.๐™ด๐šก๐š™๐š›๐šŽ๐šœ๐šœ๐š’๐š˜๐š—'>, while

type(Ric[0,0])

returns <๐šŒ๐š•๐šŠ๐šœ๐šœ'๐šœ๐šŠ๐š๐šŽ.๐š–๐šŠ๐š—๐š’๐š๐š˜๐š•๐š๐šœ.๐šŒ๐š‘๐šŠ๐š›๐šโŽฏ๐š๐šž๐š—๐šŒ.๐™ฒ๐š‘๐šŠ๐š›๐š๐™ต๐šž๐š—๐šŒ๐š๐š’๐š˜๐š—๐š๐š’๐š—๐šโŽฏ๐š ๐š’๐š๐š‘โŽฏ๐šŒ๐šŠ๐š๐šŽ๐š๐š˜๐š›๐šข.๐šŽ๐š•๐šŽ๐š–๐šŽ๐š—๐šโŽฏ๐šŒ๐š•๐šŠ๐šœ๐šœ'>


Question:

What can I do to use the results from sagemanifolds to solve the differential equation?

Preview: (hide)

1 Answer

Sort by ยป oldest newest most voted
2

answered 6 years ago

rburing gravatar image

Use Ric[0,0].expr() to convert Ric[0,0] to the desired symbolic expression:

desolve(Ric[0,0].expr(), h, ivar=t, contrib_ode=True)
Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 6 years ago

Seen: 1,068 times

Last updated: Aug 13 '18