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?