Solving a differential equation - From SageManifold

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?

edit retag close merge delete

Sort by ยป oldest newest most voted

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)

more