In [1]:

from sympy import *




In [2]:

init_session()




IPython console for SymPy 1.0 (Python 3.5.2-64-bit) (ground types: python)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
>>> init_printing()

Documentation can be found at http://docs.sympy.org/1.0/




In [4]:

r, theta, phi, kappa, alpha = symbols('r theta phi kappa alpha')
R, Theta = symbols('R Theta', cls=Function)
u = f(r, theta)




In [5]:

eq = 1/r**2*diff(r**2*u.diff(r), r) + 1/(r**2*sin(theta))*diff(sin(theta)*u.diff(theta), theta) + kappa**2*u




In [6]:

aux = expand(r**2*eq.subs(f(r, theta), R(r)*Theta(theta)).doit()/(R(r)*Theta(theta)))




In [7]:

aux




Out[7]:

$$\kappa^{2} r^{2} + \frac{r^{2} \frac{d^{2}}{d r^{2}} R{\left (r \right )}}{R{\left (r \right )}} + \frac{2 r \frac{d}{d r} R{\left (r \right )}}{R{\left (r \right )}} + \frac{\frac{d^{2}}{d \theta^{2}} \Theta{\left (\theta \right )}}{\Theta{\left (\theta \right )}} + \frac{\cos{\left (\theta \right )} \frac{d}{d \theta} \Theta{\left (\theta \right )}}{\Theta{\left (\theta \right )} \sin{\left (\theta \right )}}$$




In [8]:

eq1 = Theta(theta).diff(theta, 2) + cos(theta)/sin(theta)*Theta(theta).diff(theta) - alpha**2*Theta(theta)
eq1




Out[8]:

$$- \alpha^{2} \Theta{\left (\theta \right )} + \frac{d^{2}}{d \theta^{2}} \Theta{\left (\theta \right )} + \frac{\frac{d}{d \theta} \Theta{\left (\theta \right )}}{\sin{\left (\theta \right )}} \cos{\left (\theta \right )}$$




In [9]:

eq2 = expand(aux - eq1/Theta(theta))
eq2 = expand(eq2*R(r))
eq2




Out[9]:

$$\alpha^{2} R{\left (r \right )} + \kappa^{2} r^{2} R{\left (r \right )} + r^{2} \frac{d^{2}}{d r^{2}} R{\left (r \right )} + 2 r \frac{d}{d r} R{\left (r \right )}$$




In [11]:

print(eq2)




alpha**2*R(r) + kappa**2*r**2*R(r) + r**2*Derivative(R(r), r, r) + 2*r*Derivative(R(r), r)




In [ ]: