# C++/matlab programming

• Jan 21st 2008, 02:40 PM
anncar
C++/matlab programming
So I am given three non linear equations:
Code:

    x1(x2-2)=0,     x2(x3-3)=0,     x3(x1-1)=0
and i need to solve using newtons method using 100 randomly selected initial guesses for x1^(0), x2^(0) and x3^(0).
• Jan 21st 2008, 11:09 PM
CaptainBlack
Quote:

Originally Posted by anncar
So I am given three non linear equations:
Code:

    x1(x2-2)=0,     x2(x3-3)=0,     x3(x1-1)=0
and i need to solve using newtons method using 100 randomly selected initial guesses for x1^(0), x2^(0) and x3^(0).

First find the Jacobian:

$
J(x_1,x_2,x_3)=\left[ \begin{array}{ccc}x_2-2&x_1&0\\
0&x_3-3&x_2\\
x_3&0&x_1-1 \end{array}\right]
$

Now Newton's method proceeds from a initial approximation of guess: $P_{(0)}$ to the next approximation using by solving:

$J(P_{(0)}) \delta P = F(P_{(0)})$

for $\delta P$, then the next estimate is:

$P_{(1)}=P_{(0)}+ \delta P$.

Then the general itteration step is:

solve:

$J(P_{(n)}) \delta P = F(P_{(n)})$

for $\delta P$, then the next estimate is:

$P_{(n+1)}=P_{(n)}+ \delta P$.

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

dP=J\P

if I recall correctly

RonL