0
$\begingroup$

I am trying to solve non-linear systems and since I can't download matlab on this device, I was wondering if there is a way I can set it up in excel.

I know the formula for x$^{k+1}$=x$^k$-[Df(x)]$^-$f(x$^k$) but I realize to try and get a solution ∥x$_k$-x$_{k+1}$∥ $\le$ $10^{6}$ for each becomes very tedious and very prone to error if done manually.

x$^2$+x$^2$y-xz+6=0
e$^x$+e$^y$-z=0
x$^2$-2xz-4=0

use initial guess

$$ \begin{bmatrix} -1 \\ -2 \\ 1 \\ \end{bmatrix} $$

and I know the jacobian is $$ \begin{bmatrix} 2x_2xy-z & x^2 & -x \\ e^x & e^y & -1 \\ 2x-2z & 0 & -2x \\ \end{bmatrix} $$

$\endgroup$
  • 2
    $\begingroup$ You could use octave (even online using ideone), python+numpy, or plenty of other languages to do this. Your case is easier, as you know $y^2=3x^2$, and so $8x^3=1$. $\endgroup$ – David May 10 '16 at 3:25
  • 1
    $\begingroup$ @anna_xox: I get $(x,y,z)=(−1.79494,−2.98308,0.216774)$. $\endgroup$ – Moo May 10 '16 at 4:29
  • $\begingroup$ I got those values too, but then when I iterated one more time i got x=1.7953127 which is not within the margin of error of $10{-6}$, unless I did it wrong. $\endgroup$ – stackdsewew May 10 '16 at 4:36
  • 1
    $\begingroup$ Sounds like you have some issue with tool or it has issues with stopping criteria. I generated 15 iterates, it converged on the fourth and all others are identical. $\endgroup$ – Moo May 10 '16 at 4:54
  • $\begingroup$ Actually got it! thanks $\endgroup$ – stackdsewew May 10 '16 at 5:19
1
$\begingroup$

This is not an answer but it is too long for a comment.

Solving nonlinear equations using Newton-Raphson can be quite a long iterative process depending on the quality of the initial guesses.

When you face systems like the one in your post, you can easily reduce the dimension of the problem eliminating as many variables as you can for linear or polynomila expressions. For example, in your case$$x^2 y+x^2-x z+6=0\tag 1$$ $$e^x+e^y-z=0 \tag 2$$ $$x^2-2 x z-4\tag 3$$ Use $(3)$ to get $$z=\frac{x^2-4}{2 x}\tag 4$$ Plug this in $(1)$ to get $$y=-\frac{x^2+16}{2 x^2}\tag 5$$ So, only remains equation $(2)$ which writes $$e^{-(\frac{8}{x^2}+\frac{1}{2})}+e^x-\frac{x}{2}+\frac{2}{x}=0$$ Assuming $x\neq 0$, multiply by $x$ and then look for the zero of $$g(x)=x\Big(e^{-(\frac{8}{x^2}+\frac{1}{2})}+e^x\Big)-\frac{x^2}2+2=0$$ which is much better conditionned.

Using Newton method with $x_0=-1$ as in your problem, the successive iterates will be $$x_1=-2.12801532799644$$ $$x_2=-1.82837114694732$$ $$x_3=-1.79536109066658$$ $$x_4=-1.79493929006255$$ $$x_5=-1.79493922117722$$ which is the solution for fifteen significant figures.

Now, reuse $(4)$ and $(5)$ to get $y=-2.9830787435267$ and $z=0.21677424591829$.

$\endgroup$

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.