Ask Your Question

Symbolic Differential Equation Substitution

asked 2020-01-27 13:24:30 +0200

anonymous user


updated 2020-01-28 07:08:35 +0200

Hi, I have a symbolic partial differential equation like $\nabla^2 P(t,r,\theta,\phi) = 0$. Now I want to substitute the following anzast $P(t,r,\theta,\phi) = e^{-i\omega t} f(r) Y^{m}_{l}(\theta,\phi)$ where the last terms is spherical bessel function. When I wrote,

%display latex
M = Manifold(4, 'M', structure='Lorentzian')
X.<t,r,th,phi> = M.chart(r"t r:(0,+oo) th:(0,pi):\theta phi:(0,2*pi):\phi ")

g = M.metric()
g[0,0] = 1-2/r
g[1,1] = -1/(1-2/r)
g[2,2] = -r^2
g[3,3] = -(r*sin(th))^2

w = var('w')
T = e^(-i*w*t)

f = M.scalar_field(function('f')(r), name='f')

l = var('l')
m = var('m')
Y = spherical_harmonic(l,m,th,phi)

P = T*f*Y

eq1 = (dalembertian(P).expr()) == 0

I should get an expression independent of $\theta,\phi$ since the angular part of the equation cancel itself because by definition spherical harmonics satisfies it's own differential equation (see Wolfram-Spherical Harmonics for example). Now when I check manually using

Q = (1/(sin(th))*diff(sin(th)*diff(Y,th),th)+1/((sin(th))^2)*diff(diff(Y,phi),phi)+l*(l+1)*Y)


I got FALSE. To force Sage to use this relation, I tried things like,


but they did not work either. The problem roots from the following line,


gives expression in terms of higher-order harmonics and Sage is unable to simplify expressions using recursion relations of the spherical harmonics. I also looked at the following integrals


but again Sage is unable to evaluate the types of integral unless we plug specific $l,m$. My question is there any way to define spherical harmonics without using a built-in spherical_harmonic() function (like power series) so that Sage would be able to simplify "its differential equation" involving spherical harmonics to automatically zero.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-01-28 14:48:21 +0200

eric_g gravatar image

updated 2020-01-28 14:58:01 +0200

Unfortunately, the built-in function spherical_harmonic() has many issues, as discussed in this post (see also ticket #25034).

As suggested in the above post, a workaround is to use the function spin_weighted_spherical_harmonic() of the SageMath package kerrgeodesic_gw with a zero weight, so that you get the standard spherical harmonics. A limitation is that this works only for specific values of $(l, m)$, i.e. you cannot keep $l$ and $m$ as symbolic variables. See here for the documentation and examples of use of spin_weighted_spherical_harmonic() . Installing kerrgeodesic_gw in SageMath is easy: open a terminal and run

sage -pip install kerrgeodesic_gw

NB: on CoCalc, you have to add the option --user:

sage -pip install --user kerrgeodesic_gw
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

1 follower


Asked: 2020-01-27 13:09:05 +0200

Seen: 204 times

Last updated: Jan 28 '20