# help needed understanding basics of solving non linear equations using newtons method

• December 5th 2009, 06:10 PM
maniacraghu
help needed understanding basics of solving non linear equations using newtons method
hi guys..
I have problem in combustion kinetics which requires solving four non-linear equations with 7variables. I have reduced the number of variables to 4 but am not sure how to solve this using the newton raphson method... could someone help me by illustrating the method with a detailed example...

i am trying to solve the equations in matlab.

First find the Jacobian:

Now Newton's method proceeds from a initial approximation of guess: to the next approximation using by solving:

for , then the next estimate is:

.

Then the general itteration step is:

solve:

for , then the next estimate is:

.

In Matlab the equation J dP= P is solved using a statement of the form:

dP=J\P

if I recall correctly
--------------------------------------------------------------------------
my difficulty lies in understanding how the iteration process proceeds.... also
could some one illustrate this with an example...

my equations are
F=[m*(0.0588-x(1,1))-(6.19*10^9*exp((-15098)./x(4,1)))*30*0.0021*(101325/(8314*x(4,1))).^1.75*x(1,1).^0.1*(0.233*x(2,1)).^1 .65;
m*(0.9412-x(2,1))-(4.76/3.5)*(6.19*10^9*exp((-15098)/x(4,1)))*30*0.0021*(101325/(8314*x(4,1))).^1.75*x(1,1).^0.1*(0.233*x(2,1)).^1 .65;
1-x(1,1)-x(2,1)-x(3,1);
x(1,1)*(-84.667)+x(3,1)*(-241.845)-0.0588*(-84.667)-0.9412+32*(x(4,1)-298)
];

here i need to find x(:,1) as m varies from 0 to 0.2 and plot a graph of m vs x

thanks to anyone who is willing to go the way...
• December 5th 2009, 06:22 PM
lvleph
It appears that a lot of your post is missing. The multivariate newton method is
$x_n = x_{n-1} - JF^{-1} F(x_{n-1})$.
So, you will want an initial guess $x_0$ then solve the system above for $x_1$. Procede in the same manner to find $x_2,\dots,\x_n$ until it converges. You will determine convergence using a norm, maybe $\frac{\|x_n - x_{n-1}\|_{\infty}}{\|x_{n-1}\|_{\infty}} \le tol$ would be your convergence criterion.

EDIT: Attached is a newton method I developed for a class.
• December 5th 2009, 06:32 PM
maniacraghu
one more help
could you show the method with a simple example..i am not one of those easy grasping guys
• December 5th 2009, 06:38 PM
lvleph
This should help, and it is cool.
• December 5th 2009, 11:15 PM
maniacraghu
doubt
now when two variables are involved in a set of non linear equations say
f1= x^2+y^2-2
f2=x^2-y^2
F=[f1;f2]
jacobianf=[2x 2y;2x -2y]
thus h= jacobianf^-1*(-F)
...

this being the case how will x and y be incremented using h
• December 6th 2009, 07:57 AM
lvleph
delete
• December 6th 2009, 08:28 AM
lvleph
You will create a vector $X = \begin{pmatrix}x \\ y\end{pmatrix}$ and a vector for your function $F = \begin{pmatrix}f_1 \\ f_2\end{pmatrix}$.
The inverse of the Jacobian will be $JF^{1}(X) = \frac{1}{4}\begin{pmatrix}\frac{1}{x} & \frac{1}{y} \\ \frac{1}{x} & -\frac{1}{y}\end{pmatrix}$. Then will take an initial guess, say $X_0 = \begin{pmatrix}x_0 \\ y_0\end{pmatrix} = \begin{pmatrix}0.5 \\ 0.5\end{pmatrix}$. Now we perform the iteration
$X_1 = X_0 - JF^{-1}(X_0)\cdot F(X_0)$, so we have
$X_1 = \begin{pmatrix}x_1 \\ y_1\end{pmatrix} = \begin{pmatrix}0.5 \\ 0.5\end{pmatrix} - \frac{1}{4}\begin{pmatrix}2 & 2\\2 & -2\end{pmatrix} \cdot \begin{pmatrix} -1.5 \\ 0\end{pmatrix}$.
Thus, we have
$X_1 = \begin{pmatrix}0.5 \\ 0.5\end{pmatrix} - \begin{pmatrix}-0.75 \\ -0.75\end{pmatrix} = \begin{pmatrix}1.25 \\ 1.25\end{pmatrix}$.
Now repeat this for $X_2 = X_1 - JF^{-1}(X_1)\cdot F(X_1)$.
$X_2 = \begin{pmatrix}1.25 \\ 1.25\end{pmatrix} - \frac{1}{4}\begin{pmatrix}0.8 & 0.8\\0.8 & -0.8\end{pmatrix} \cdot \begin{pmatrix} 1.125 \\ 0\end{pmatrix}$.
$X_2 = \begin{pmatrix}1.25 \\ 1.25\end{pmatrix} - \begin{pmatrix}0.225 \\ 0.225\end{pmatrix} = \begin{pmatrix}1.025 \\ 1.025\end{pmatrix}$.
Continue like this until $\frac{\|X_n - X_{n-1}\|_{\infty}}{\|X_{n-1}\|_{\infty}} \le tol$
• December 6th 2009, 09:00 AM
maniacraghu
matlab help..
how do you define a variable..

my program is as shown:

clc
clear all
F=[y^2+z^2-2;y^2-z^2];
v=[y,z]
R=jacobian(F,v)
y=0.1;z=0.1;
xo=[y;z]
for j=1:30
D=(inv(R))*(-F)
xo=xo-D
end

i am getting an error saying that y and z are undefined variables
however if i use syms y,z the guess value of y and z does not get passed on into the for loop...dono why...PLS HELP
• December 6th 2009, 09:03 AM
lvleph
Matlab doesn't like anything but numbers. So, x and y would have had to be given to it. You can pass functions to matlab using @F. But F will need some numbers. Look at the Newton.m that I attached earlier and it should help.