# The generalized product rule ( Leibniz Formula )

If f and g are n-times differentiable functions, then :

$(fg)^{'} = fg^{'} + gf^{'}$

Now, we would like to find out a generalized expression for the n-th derivative of fg. In order to arrive at that formulation lets calculate a few derivatives to see whether we can find a pattern:

$(fg)^{'} = fg^{'} + gf^{'}$

$(fg)^{''} = \left(fg^{'} + gf^{'}\right)^{'} = fg^{''} + 2 f^{'}g^{'} + gf^{''}$

$(fg)^{'''} = \left(fg^{''} + 2 f^{'}g^{'} + gf^{''} \right)^{'} = fg^{'''} + 3 f^{''}g^{'} + 3 f^{'}g^{''} + gf^{'''}$

$(fg)^{''''} = fg^{''''} + 4 f^{'''}g^{'} + 6f^{''}g^{''} + 4 f^{'}g^{'''} + gf^{''''}$

$\vdots$

You must have noticed a pattern in the above expressions. The coefficients seem are the one in the binomial expansion of $(x+y)^n$

Therefore we can write the expression for the n-derivative of fg as the following expression:

$(fg)^n = \sum\limits_{i=0}^{n} \binom{n}{i} f^{(i)}g^{(n-i)}$
where (i) means to differentiate i-times.

This is also known as Leibniz Formula.

** This plays an important role when we start discussing about the Associated Legendre Differential Equation.

# Legendre Differential Equation(#4) : A friendly introduction

When you are working with Spherical harmonics, then the Legendre Differential Equation does not appear in its natural form i.e

$(1-x^2)y^{''} -2xy^{'} + l(l+1)y = 0$

Instead, it appears in this form:

$\frac{d^2 y}{d\theta^2} + \frac{cos\theta}{sin\theta} \frac{dy}{d\theta} + l(l+1)y = 0$

It seems daunting but the above is the same as the LDE. We can arrive at it by taking $x = cos(\theta)$ and proceeding as follows:

$\frac{dy}{dx} = \frac{dy}{d(cos\theta)} = \frac{-1}{sin\theta}\frac{dy}{d \theta}$

$\frac{d^2 y}{dx^2} = \frac{d}{d(cos\theta)}\left( \frac{-1}{sin\theta}\frac{dy}{d \theta} \right) = \frac{-1}{sin\theta}\frac{d}{d \theta}\left( \frac{-1}{sin\theta}\frac{dy}{d \theta} \right)$

Now, applying chain rule, we obtain that

$\frac{d^2 y}{dx^2} = \frac{-1}{sin\theta} \left( \frac{-1}{sin\theta} \frac{d^2 y}{d\theta^2} - \frac{cos\theta}{sin^2 \theta} \frac{dy}{d\theta} \right)$

Now simplifying the above expression, we obtain that:

$\frac{d^2 y}{dx^2} = \frac{1}{sin^2\theta} \left( \frac{d^2 y}{d\theta^2} + \frac{cos\theta}{sin\theta} \frac{dy}{d\theta} \right)$

Plugging in the values of $\frac{dy}{dx}$ and $\frac{d^2 y}{dx^2}$ into the Legendre Differential Equation,

$(1-x^2)y^{''} -2xy^{'} + l(l+1)y = 0$

$(1-cos^2 \theta)y^{''} -2cos\theta y^{'} + l(l+1)y = 0$

$\frac{1- cos^2 \theta}{sin^2 \theta} \left( \frac{d^2 y}{d\theta^2} + \frac{cos\theta}{sin\theta}\frac{dy}{d\theta} \right) +\frac{2cos\theta}{sin\theta} \frac{dy}{d\theta} + l(l+1)y = 0$

Now if we do some algebra and simplify the trigonometric identities, we will arrive at the following expression for the Legendre Differential Equation:

$\frac{d^2 y}{d\theta^2} + \frac{cos\theta}{sin\theta} \frac{dy}{d\theta} + l(l+1)y = 0$

If we take the solution for the LDE as $f(x)$, then the solution to the LDE in the above form is merely $f(cos\theta)$.

# Legendre Differential Equation(#3): A friendly introduction

This post is just a note on the notation that is used across internet sources and books while referring to the LDE.

$(1-x^2)y^{''} - 2xy^{'} + l(l+1) y = 0$

If one takes $p(x) = 1-x^2$, then it follows that $p^{'}(x) = -2x$. The differential equation can be rewritten as follows:

$p(x)y^{''} + p^{'}(x)y^{'} + l(l+1) y = 0$

Now the first two terms must seem familiar to you from the chain rule. ( $(py)^{'} = py^{'} + yp^{'}$ ). Ergo,

$(py^{'})^{'} + l(l+1)y = 0$

or

$\frac{d}{dx}(p \frac{dy}{dx}) + l(l+1)y = 0$

Now, putting back the value of p :

$\frac{d}{dx}\left((1-x^2) \frac{dy}{dx} \right) + l(l+1)y = 0$

And you will see this form of the LDE also in many places and I thought it was worth mentioning how one ended up in that form.

# Legendre Differential Equation(#2): A friendly introduction

Now there is something about the Legendre differential equation that drove me crazy. What is up with the l(l+1) !!!

$(1-x^2)y^{''} -2xy^{'} + l(l+1)y = 0$

To understand why let’s take this form of the LDE and arrive at the above:

$(1-x^2)y^{''} -2xy^{'} + \lambda y = 0$

$y = \sum\limits_{n=0}^{\infty} a_n x^n$

If we do a power series expansion and following the same steps as the previous post, we end up with the following recursion relation.

$(n+2)(n+1)a_{n+2} = (\lambda -n(n+1))a_n$

or

$a_{n+2} = a_n \frac{\lambda - n(n+1)}{(n+1)(n+2)}$

Here’s the deal: We want a convergent solution for our differential solution. This means that as $n \rightarrow l , a_{n+2} \rightarrow 0$.

Hence we obtain that

$\lambda = l(l+1)$

# Legendre Differential equation (#1) : A friendly introduction

In this series of posts about Legendre differential equation, I would like to de-construct the differential equation down to the very bones. The motivation for this series is to put all that I know about the LDE in one place and also maybe help someone as a result.

The Legendre differential equation is the following:

$(1-x^2)y^{''} -2xy^{'} + l(l+1)y = 0$

where $y^{'} = \frac{dy}{dx}$ and $y^{''} = \frac{d^{2}y}{dx}$

We will find solutions for this differential equation using the power series expansion i.e
$y = \sum\limits_{n=0}^{\infty} a_n x^n$

$y^{'} = \sum\limits_{n=0}^{\infty} na_n x^{n-1}$

$y^{''} = \sum\limits_{n=0}^{\infty} n(n-1)a_n x^{n-2}$

We will plug in these expressions for the derivatives into the differential equation.

$l(l+1)y = l(l+1)\sum\limits_{n=0}^{\infty} a_n x^n$ – (i)

$-2xy^{'} = -2\sum\limits_{n=0}^{\infty} na_n x^{n}$ – (ii)

$(1-x^2)y^{''} = (1-x^2)\sum\limits_{n=0}^{\infty} n(n-1)a_n x^{n-2}$

$= \sum\limits_{n=0}^{\infty} n(n-1)a_n x^{n-2} - \sum\limits_{n=0}^{\infty} n(n-1)a_n x^{n}$ – (iii)

** Note: Begin

$\sum\limits_{n=0}^{\infty} n(n-1)a_n x^{n-2}$

Let’s take $\lambda = n-2$.
As n -> $0$. , $\lambda$ -> $-2$.
As n -> $\infty$, $\lambda$ -> $\infty$.

$\sum\limits_{\lambda = -2}^{\infty} (\lambda+2)(\lambda+1)a_n x^{\lambda}$

$= 0 + 0 + \sum\limits_{\lambda = 0}^{\infty} (\lambda+2)(\lambda+1)a_n x^{\lambda}$

Again performing a change of variables from $\lambda$ to n.

$= \sum\limits_{n= 0}^{\infty} (n+2)(n+1)a_n x^{n}$

** Note: End

(iii) can now be written as follows.

$\sum\limits_{n=0}^{\infty} x^n \left((n+1)(n+2)a_{n+2} - n(n-1)a_n \right)$ – (iv)

(i)+(ii)+(iv).

$\sum\limits_{n=0}^{\infty} x^n \left((n+2)(n+1)a_{n+2} - (l(l+1)-n(n+1))a_n \right)$

x = 0 is a trivial solution and therefore we get the indicial equation:

$(n+2)(n+1)a_{n+2} - (l(l+1)-n(n+1))a_n = 0$

$(n+2)(n+1)a_{n+2} = (l^2 - n^2 + l - n)a_n = 0$

$(n+2)(n+1)a_{n+2} = ((l-n)(l+n)+ l - n)a_n = 0$

$(n+2)(n+1)a_{n+2} = (l-n)(l+n+1)a_n = 0$

We get the following recursion relation on the coefficients of the power series expansion.

$a_{n+2} = a_n \frac{(l+n+1)(l-n)}{(n+1)(n+2)}$

Next post: What do these coefficients mean ?