Newton-Raphson Non-Linear Tridiagonal

jacobiannewton raphsonnonlinear systemtaylor expansion

I have the following problem where I am asked to solve a system of nonlinear equations. I am positive that I have to use Newton-Raphson with the Jacobian. My problem is that I don't fully understand the notation. This problem has $u_{i}$, $u_{i-1}$, $u_{i+1}$, are those supposed to be your $x,y,z$? If so, how do the conditions on the side of each equation apply?

The problem can be seen below:

$$\begin{align*}-3u_i+u_{i+1}&-0.5h^2u_i^3=-1.005 & i=1\\u_{i-1}-3u_i+u_{i+1}&-0.5h^2u_i^3=-0.005 &2\leq i\leq n-1\\u_{i-1}-3u_i&-0.5h^2u_i^3=-1.005 &i=n\end{align*}$$ Use $h=0.1$ and $n=30$.

The problem can also be seen here

Best Answer

I will work this out for a smaller $n = 3$, so you can see the process. Using the given iteration formula, we have

$$\begin{align}-3 u_1+u_2 -0.005 u_1^3 +1.005 = 0 \\-u_1-3 u_2+u_3 -0.005 u_2^3+0.005 = 0 \\ u_2-3 u_3 -0.005 u_3^3 +1.005 = 0 \end{align}$$

The regular Newton-Raphson method is initialized with a starting point $u_0$ and then you iterate $\tag 1 u_{n+1}=u_n-\dfrac{f(u_n)}{f'(u_n)}$

In higher dimensions, there is an exact analog. We define

$$F\left(\begin{bmatrix}u_1\\u_2\\u_3\end{bmatrix}\right) = \begin{bmatrix}f_1(u_1,u_2,u_3) \\ f_2(u_1,u_2,u_3) \\ f_3(u_1,u_2,u_3) \end{bmatrix} = \begin{bmatrix}-3 u_1+u_2 -0.005 u_1^3 +1.005 \\ -u_1-3 u_2+u_3 -0.005 u_2^3+0.005 \\ u_2-3 u_3 -0.005 u_3^3 +1.005 \end{bmatrix} = \begin{bmatrix}0\\0\\0\end{bmatrix}$$

The derivative of this system is the $3x3$ Jacobian given by

$$J(u_1,u_2,u_3) = \begin{bmatrix} \dfrac{\partial u_1}{\partial f_1} & \dfrac{\partial u_2}{\partial f_1} & \dfrac{\partial u_3}{\partial f_1}\\ \dfrac{\partial u_1}{\partial f_2} & \dfrac{\partial u_2}{\partial f_2} & \dfrac{\partial u_3}{\partial f_2} \\ \dfrac{\partial u_1}{\partial f_3} & \dfrac{\partial u_2}{\partial f_3} & \dfrac{\partial u_3}{\partial f_3}\end{bmatrix} = \begin{bmatrix} -0.015 u_1^2-3 & 1 & 0 \\ -1 & -0.015 u_2^2-3 & 1 \\ 0 & 1 & -0.015 u_3^2-3 \end{bmatrix}$$

The function $G$ is defined as

$$G(u) = u - J(u)^{-1}F(u)$$

and the functional Newton-Raphson method for nonlinear systems is given by the iteration procedure that evolves from selecting an initial $u^{(0)}$ and generating for $k \ge 1$ (compare this to $(1)$),

$$u^{(k)} = G(u^{(k-1)}) = u^{(k-1)} - \dfrac{F(u^{(k-1)})}{J(u^{(k-1)})} = u^{(k-1)} - J(u^{(k-1)})^{-1}F(u^{(k-1)}).$$

We can write this as

$$\begin{bmatrix}u_1^{(k)}\\u_2^{(k)}\\u_3^{(k)}\end{bmatrix} = \begin{bmatrix}u_1^{(k-1)}\\u_2^{(k-1)}\\u_3^{(k-1)}\end{bmatrix} + \begin{bmatrix}v_1^{(k-1)}\\v_2^{(k-1)}\\v_3^{(k-1)}\end{bmatrix}$$

where

$$\begin{bmatrix}v_1^{(k-1)}\\v_2^{(k-1)}\\v_3^{(k-1)}\end{bmatrix}= -\left(J\left(u_1^{(k-1)},u_2^{(k-1)}, u_3^{(k-1)}\right)\right)^{-1}F\left(u_1^{(k-1)},u_2^{(k-1)},u_3^{(k-1)}\right)$$

Using the starting vector

$$u^{(0)} = \begin{bmatrix}u_1^{(0)}\\u_2^{(0)}\\u_3^{(0)}\end{bmatrix} = \begin{bmatrix}0\\0\\0\end{bmatrix}$$

You end up with (the iteration converges very quickly in this case)

$$\begin{bmatrix}u_1\\u_2\\u_3\end{bmatrix} = \begin{bmatrix} 0.33549261976670497\\ 0.00166666665895062\\ 0.33549261976670497 \end{bmatrix}$$

Of course, for a different starting vector you may get a different solution or no solution at all.

Note: It is worth noting that the way you code this up should provide a solution for any sized $n$, that is, your code should easily generalize regardless of $n$, while adhering to the constraints of the numerical methods you are using, and that is likely the point of this exercise. This means that your code should be able to define everything you need from the iteration formulas themselves. You just enter $n$ and the rest should be automated.

Update for the case $n = 4$, the iteration formula gives

$$\begin{align}-3 u_1+u_2 -0.005 u_1^3 +1.005 = 0 \\ u_1 - 3 u_2 + u_3 -0.005 u_2^3+0.005 = 0 \\ u_2-3 u_3 + u_4 -0.005 u_3^3 +0.005 = 0 \\ u_3 - 3 u_4 -0.005 u_4^3 + 1.005 = 0\end{align}$$

Related Question