1
$\begingroup$

Crossposted at SciComp SE


I'm very new to finite difference method and I am just introduced to methods of solving differential equation using finite difference method via sparse matrix method.

I find that the main idea is to approximate the differentials by central differences and writing the differential equation at different points in domain and making sparse matrices out of them.

For example, take the following 1-D boundary value problem: $$ \begin{cases} \dfrac{d^2 f(x)}{dx^2} = f(x)\\ f(0)=1,\\ f(2) = e^2. \end{cases} $$

At different points in domain with $h= 0.25$ (minimum step size), $$ \begin{cases} f(0) = 1\\ \\ \dfrac{f(0) - 2f(0.25) + f(0.5)}{h^2} - f(0.25) = 0 \\ \dfrac{f(0.25) - 2f(0.5) + f(0.75)}{h^2} - f(0.5) = 0\\ \dfrac{f(0.5) - 2f(0.75) + f(1)}{h^2} - f(0.75) = 0\\ \qquad\vdots \\ \\ f(2) = e^2 \end{cases} $$ Rewriting the above set of equations in sparse matrices, i.e. as the linear equation $A\cdot f = b$, $$ \begin{pmatrix} 1 & 0 & 0 & 0 & \cdots & 0\\ 1/h^2 & (-2/h^2 -1) & 1/h^2 & 0 & \cdots & 0\\ 0 & 1/h^2 & (-2/h^2 -1) & 1/h^2 & \cdots & \vdots\\ 0 & 0 & 1/h^2 & (-2/h^2 -1) & \cdots &\\ \vdots & \vdots & \vdots & \vdots &\ddots & 1/h^2\\ 0 &0 &\cdots & \cdots & 1/h^2 & 1\\ \end{pmatrix} \cdot \begin{pmatrix} f(0)\\ f(0.25)\\ f(0.5)\\ \vdots\\ f(2)\\ \end{pmatrix} = \begin{pmatrix} 1\\ 0\\ 0\\ \vdots\\ e^2\\ \end{pmatrix}\,, $$ then the solution becomes $f = A^{-1} \cdot b $.

Even for nonlinear differential equations, the method takes the similar footing and these sparse matrices are to be built first before going through iteration methods for solving nonlinear systems.

Now, the question that I have now is, what about differential equations that involves sin and cos of the unknown function?
For example: $$ \frac{d^2 f(x)}{dx^2} + \sin( f(x) ) = 0 $$ or system that involves inverse, for example $$ \frac{d^2 f(x)}{dx^2} + \frac{1}{1+f(x)} f(x) = 0 \; ? $$ How do we tackle problems like these using finite difference sparse matrix methods?

$\endgroup$

1 Answer 1

0
$\begingroup$

To solve an ODE of type $ y''=f(y) $ you start by multiplying both sides by $2y'$ so that you get $$ 2y'y''=2 y' f(y)\quad\text{which gives}\quad y'^2 =F(y), \ \text{where}\quad F'=2f, $$ then assuming that $F$ takes positive values (or complex values avoiding an half-line starting from zero such as $(-\infty, 0]$), you find that $$ y'=F(y)^{1/2}=g(y), \tag{1}$$ which is a separable equation, non-linear in general, but first-order. However you have for $G'=1/g$ $$ G(y)=c. $$ Also it should be possible to use a finite-difference method for the first-order non-linear equation (1).

$\endgroup$

Not the answer you're looking for? Browse other questions tagged .