# Separation of Variables in spherical coordinates

with the Laplace equation in spherical coordiantes:

$$ \frac{1}{r^2}\frac{\partial}{\partial r}\left (r^2 \frac{\partial V}{\partial r}\right )+ 
   \frac{1}{r^2\sin \theta}\frac{\partial}{\partial \theta} \left (\sin \theta \frac{\partial V}{\partial \theta}\right )+
   \frac{1}{r^2\sin^2 \theta}\frac{\partial^2 V}{\partial \phi^2}
   =0
$$

we are assuming azimuthal symmetry here and ths V is independent of $\phi$, even though the general care is solveable as well and it simplifies to:

$$ \frac{\partial}{\partial r}\left (r^2 \frac{\partial V}{\partial r}\right )+ 
   \frac{1}{\sin \theta}\frac{\partial}{\partial \theta} \left (\sin \theta \frac{\partial V}{\partial \theta}\right )
   =0
$$

Again we are looking for solutions as products:
    
$$ V(r,\theta) = R(r)\Theta(\theta)$$

Separating of variables gives us:
    
$$ \frac 1 R \frac{\partial}{\partial r}\left (r^2 \frac{\partial R}{\partial r}\right )= 
   -\frac{1}{\Theta\sin \theta}\frac{\partial}{\partial \theta} \left (\sin \theta \frac{\partial \Theta}{\partial \theta}\right ) $$
   
which can only be equal if the left side and the right side are constants (since they each only depend on $r$ or $\theta$ respectively)

So we are setting constants for the left side:

    
$$ \frac 1 R \frac{\partial}{\partial r}\left (r^2 \frac{\partial R}{\partial r}\right )=
   l(l+1)$$
   
and for the right side:
$$ \frac{1}{\Theta\sin \theta}\frac{\partial}{\partial \theta} \left (\sin \theta \frac{\partial \Theta}{\partial \theta}\right ) = - l(l+1) $$

and thus have converted a PDE in two ODEs.

### Solving the left side:


```python
from sympy.interactive import printing # use latex for printing
printing.init_printing(use_latex=True)
from sympy import Function, dsolve, Eq, Derivative, sin, cos, symbols # import necessary methods
from sympy.abc import theta # import variables
```


```python
r, l = symbols('r l',positive=True)
R = Function('R',real=True)
s1_ode = Eq(Derivative((r**2*Derivative(R(r),r,1)), r, 1)-l*(l+1)*R(r))
s1_ode
```


```python
sol1 = dsolve(s1_ode, R(r))
sol1
```

### Solving the right side


```python
t, l = symbols('theta l')
T = Function('Theta',real=True)
s2_ode = Eq(Derivative(sin(t)*Derivative(T(t),t,1), t, 1)+l*(l+1)*sin(t)*T(t))
s2_ode
```


```python
sol2 = dsolve(s2_ode, T(t))
sol2
```

### Legendre Polynomials


```python
from sympy.plotting import plot
from sympy import legendre, pi
%matplotlib inline
```


```python
t = symbols('theta',positive=True)
P0 = lambda t: legendre(0,t)
P1 = lambda t: legendre(1,t)
P2 = lambda t: legendre(2,t)
P3 = lambda t: legendre(3,t)
P4 = lambda t: legendre(4,t)
```


```python
P0(cos(t))
```


```python
P1(cos(t))
```


```python
P2(cos(t))
```


```python
P3(cos(t))
```


```python
P4(cos(t))
```


```python
plot(P0(cos(t)),P1(cos(t)),P2(cos(t)),P3(cos(t)),P4(cos(t)),(t,0,pi))
```

Legendre polynomials with the argument $\cos\theta$ are the solutions for the right side:

$$ \Theta(\theta) = P_l(\cos\theta) $$

Which gives the most general separabe solution to Laplace equation (for physics):

$$ V(r,\theta)=\sum_{l=0}^{\infty}\left (A_l r^l+\frac{B_l}{r^{l+1}}\right ) P_l(\cos\theta) $$


```python

```

728e796ea385c93ce0a06a56e98ca71b2ca235a3
ipynb
Jupyter Notebook
Separation of Variable, spherical coordinates.ipynb
laserlab/403_SeparationOfVariable
2d14c20239559c9dfaa5ef9875d22ff0a1784e30
CC0-1.0
Separation of Variable, spherical coordinates.ipynb
laserlab/403_SeparationOfVariable
2d14c20239559c9dfaa5ef9875d22ff0a1784e30
CC0-1.0
Separation of Variable, spherical coordinates.ipynb
laserlab/403_SeparationOfVariable
2d14c20239559c9dfaa5ef9875d22ff0a1784e30
CC0-1.0
2020-12-26T03:02:13.000Z
2021-06-10T23:02:08.000Z
Qwen/Qwen-72B
1. YES
2. YES