0

My task is to solve this differential equation: $$(1−x^2)\frac{d^2y}{dx^2}−2x\frac{dy}{dx}+p(p+1)2y=0,y(0) = y₀, y(a)=yǎ$$ I need to solve it numerically using linear equations with a tridiagonal matrix. I am struggling with the first step - creating this tridiagonal matrix. Any help is appreciated.

Jacos
  • 3

1 Answers1

2

I am not entirely sure if I understand correctly what it is you want to do, but I presume you need to use some sort of finite difference scheme.

Numerically you want to discretize an interval into let's say N points with spacing $\Delta x$. Your variable $x$ will now be a "vector" with N entries like $[x_1, x_2, \ldots, x_N]^T$. You'll still have to deal with the derivatives now. If you look at the finite difference scheme: $$y_i''= \frac{y_{i+1}-2y_i+y_{i-1}}{\Delta x}$$ The second derivative therefore is really represented as "matrix" - it really should be that way since the derivative is a linear operator!

This is a tridiagonal matrix and with a bit of notational abuse: $$\frac{\mathrm{d^2}}{\mathrm{d}x^2} \rightarrow \frac{1}{(\Delta x)^2} \begin{bmatrix} -2 & 1 & & 0\\ 1 & -2 & \ddots & \\ & \ddots & \ddots & 1\\ 0 & & 1 & -2 \end{bmatrix} $$ You'll also need to do this for the first derivative. Then rewrite this as an eigenvalue equation: $$\hat{L} y = \lambda y,$$ where the operator $$\hat{L} = (1-x^2)\frac{\mathrm{d^2}}{\mathrm{d}x^2} - 2x \frac{\mathrm{d}}{\mathrm{d}x}$$ is represented as a tridiagonal matrix and you'll need to solve for eigenfunctions. Hints:

  • Watch out for the boundary conditions!
  • Be careful when dealing with $x$, represent it as a diagonal matrix (It'd be better to use index notation in order to avoid confusion).

I hope this helps!