Solving a 2nd order, nonlinear ODE involving trigonometric terms using FDM

64 Views Asked by At

I'm rather new to solving ODEs/PDEs numerically and am trying to solve a 2nd order, nonlinear ODE involving trigonometric terms using finite-differences. The ODE has the followign form: $$ \frac{d^2y}{dx^2} = a \cdot \sin(y) + b \cdot \cos(y) $$ I would like to numerically solve this in matrix operation form: $$ A \cdot \vec{y} = \vec{b} $$ Discretizing using the standard FDM-stencil: $$ \frac{y_{i+1} - 2y_i + y_{i-1}}{\Delta x^2} = a \cdot \sin(y_i) + b \cdot \sin(y_i) $$ But because of the trigonometric terms either $A$ or $\vec{b}$ must be dependent on $\vec{y}$. For example: $$ \frac{1}{\Delta x^2} \begin{pmatrix} 1 & -2 & 1 & 0 &\cdots \\ & \ddots & \ddots & \ddots & \\ \cdots & 0 & 1 & -2 & 1 \end{pmatrix} \cdot \begin{pmatrix} y_{i-1} \\ y_i \\ y_{i+1} \\ \vdots \end{pmatrix} = \begin{pmatrix} a \cdot \sin(y_{i-1}) + b \cdot \sin(y_{i-1}) \\ a \cdot \sin(y_i) + b \cdot \sin(y_i) \\ a \cdot \sin(y_{i+1}) + b \cdot \sin(y_{i+1}) \\ \vdots \end{pmatrix} $$ The only solution I could think of is an iteration loop $j$, where I give a starting guess for $\vec{y}$ into $\vec{b}$ and then use $\vec{y}_j - \vec{y}_{j-1}$ as a residual to iterate.

What would be the best strategy to this problem? Is it possible to avoid iterating?

EDIT: added the discretization I thought of

1

There are 1 best solutions below

0
On BEST ANSWER

$$y'' = a \, \sin(y) + b \, \cos(y)$$ Switching variables $$-\frac {x''}{[x']^3}= a \, \sin(y) + b \, \cos(y)$$ Reduction of order $p=x'$ $$ -\frac {p'}{p^3}= a \, \sin(y) + b \, \cos(y)$$ Integration $$p=\pm \frac{1}{\sqrt{2 (b \sin (y)-a \cos (y))+c_1}}=x'$$ Integrate again and you have an explicit solution for $x(y)$ which is impossibel to inverse.

But, numerically, staying with $p=x'$, you face a first order equation.