1
$\begingroup$

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

$\endgroup$
0
$\begingroup$

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}$$

$\endgroup$
  • $\begingroup$ So, basically, the $u_{i+1}$ is just another way of saying $u_{2}$. I was confused about that. I thought it had something to do with iteration. $\endgroup$ – carlosremove Nov 6 '18 at 5:42
  • $\begingroup$ Each of those depends on the size of $n$. $i$ is just an iterator. Clear? Note, because $n=3$, that is why that was a $u_2$. it is important to understand this. I would recommend writing out the system for the case $n=4$ and see how my result changes. $\endgroup$ – Moo Nov 6 '18 at 5:51
  • $\begingroup$ Not so clear if I am honest. Isn't $n = 30$? But then how is $i=n$ and $i=1$ $\endgroup$ – carlosremove Nov 6 '18 at 6:22
  • $\begingroup$ Think of $i$ as an iteration. Yes, $n = 30$, but you are still trying to understand how all this works. The first equation is true regardless of $n$. The last equation is only true for how large $n$ is. The middle equation is the for all other values of $n$. So for example, for $n = 4$, you get one equation from the first equation, two equations from the second and one equation from the third. $\endgroup$ – Moo Nov 6 '18 at 12:27
  • $\begingroup$ I know this is asking for a lot, but could you possibly write out the equations for $n=4$, so I can fully understand $n$. Basically, the whole system will change and you will end up with more $u$ values, right? Thank you so much by the way. You're really helping me. $\endgroup$ – carlosremove Nov 8 '18 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.