Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?