Newton Neliniare

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

(*metoda newton*)

In[1]:=

f25[x_, y_] := Sin[y + 1] - x - 1.2


f26[x_, y_] := 2 y + Cos[x] - 2
ContourPlot[{f25[x, y], f26[x, y]}, {x, - 10, 10}, {y, - 10, 10}, Axes True]
x0 = 0.74;
y0 = 0.67;
dx = {0, 0};
f25[x, y] y f25[x, y]

J := x
x f26[x, y] y f26[x, y]
F := - {f25[x, y], f26[x, y]}
eps = 10 ^ - 20;
old = {0, 0};
new = {x0, y0};
A = J;
x := new[[1]];
y := new [[2]];
i = 0;
old = new;
dx = LinearSolve[A, F];
new = old + dx;
i ++;
While[Or[Abs[old[[1]] - new[[1]]] > eps, Abs[old[[2]] - new[[2]]] > eps],
old = new;
dx = LinearSolve[A, F];
new = old + dx;
i ++;]
Print["x= ", x // N]
Print["y=", y // N]
Clear["x", "y"];

newton neliniare.nb

10

Out[3]=

-5

-10
-10

x= - 0.201838
y=0.51015

-5

10

newton neliniare.nb

In[47]:=

f9[x_, y_] := 2 * x ^ 2 + 3 * y;
f10[x_, y_] := x * y - 2;
ContourPlot[{f9[x, y], f10[x, y]}, {x, - 10, 10}, {y, - 10, 10}, Axes True]
x0 = - 1;
y0 = 1;
dx = {0, 0};
f9[x, y] y f9[x, y]

J := x
x f10[x, y] y f10[x, y]
F := - {f9[x, y], f10[x, y]}
eps = 10 ^ - 20;
old = {0, 0};
new = {x0, y0};
A = J;
x := new[[1]];
y := new [[2]];
i = 0;
old = new;
dx = LinearSolve[A, F];
new = old + dx;
i ++;
While[Or[Abs[old[[1]] - new[[1]]] > eps, Abs[old[[2]] - new[[2]]] > eps],
old = new;
dx = LinearSolve[A, F];
new = old + dx;
i ++;]
Print["x= ", x // N]
Print["y=", y // N]
Clear["x", "y"];
10

Out[49]=

-5

-10
-10

-5

10

newton neliniare.nb

x= - 1.44225
y=- 1.38672

You might also like