Ask Your Question
1

Solving a differential equation - From SageManifold

asked 2018-08-13 13:05:22 -0600

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?

edit retag flag offensive close merge delete

1 answer

Sort by Β» oldest newest most voted
2

answered 2018-08-13 13:25:20 -0600

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)
edit flag offensive delete link more

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: 2018-08-13 13:05:22 -0600

Seen: 89 times

Last updated: Aug 13 '18