You are on page 1of 7

DIAZ CRUZ INGRID PAMELA - CASTILLO ALCÁNTARA DIEGO

DESCENSO MAS RÁPIDO


In[ ]:= f1[x_, y_] := x2 + y2 - 1;
f2[x_, y_] := x2 - y2 + 1 / 2;

Paso 1
In[ ]:= g[x_, y_] := f1[x, y]2 + f2[x, y]2 ;
g[x, y]
1 2
2
Out[]= + x2 - y2 + - 1 + x2 + y2 
2

Paso 2
∂x x2 + y2 - 1 ∂y x2 + y2 - 1
In[ ]:= J[x_, y_] := ;
∂x x2 - y2 + 1 / 2 ∂y x2 - y2 + 1 / 2
J[x, y] // MatrixForm
forma de matriz
A = J[x, y];
t = Transpose[A];
transposición
t // MatrixForm
forma de matriz
F[x_, y_] := x2 + y2 - 1, x2 - y2 + 1 / 2
B = F[x, y];
B // MatrixForm
forma de matriz
Out[]//MatrixForm=
2x 2y
2 x -2 y
Out[]//MatrixForm=
2x 2x
2 y -2 y
Out[]//MatrixForm=

- 1 + x 2 + y2
1
+ x2 - y2
2

Printed by Wolfram Mathematica Student Edition


2 descenso mas rapido.nb

In[ ]:= ∇ G = 2 J (x)t F (x);


∇ G[x_, y_] := 2 4 x3 - x, 2 4 y3 - 3 y;
∇ G[x, y] // MatrixForm
forma de matriz
Out[]//MatrixForm=

2 - x + 4 x3 
2 - 3 y + 4 y3 

Paso 3
In[ ]:= x0 = {{0.01}, {0.01}};
g[0.01, 0.01]
∇ G[0.01, 0.01] // MatrixForm
forma de matriz

Out[]= 1.2496
Out[]//MatrixForm=
- 0.019992
- 0.059992

In[ ]:= z0 = (- 0.019992`)2 + (- 0.059992`)2


Out[]= 0.0632354

1
In[ ]:= Z= ∇ G[0.01, 0.01];
z0
Z // MatrixForm
forma de matriz
Out[]//MatrixForm=
- 0.316152
- 0.948709

Paso 4
In[ ]:= α1 = 0;
aux1 = 0.01 - (α1 ) ( - 0.31615185819589475`);
aux2 = 0.01 - (α1 ) ( - 0.9487085972833191`);
g1 = g[aux1, aux2]
Out[]= 1.2496

In[ ]:= α3 = 1;
aux1 = 0.01 - (α3 ) ( - 0.31615185819589475`);
aux2 = 0.01 - (α3 ) ( - 0.9487085972833191`);
g3 = g[aux1, aux2]
Out[]= 0.0984609

Printed by Wolfram Mathematica Student Edition


descenso mas rapido.nb 3

α3
In[ ]:= α2 = ;
2
aux1 = 0.01 - (α2 ) ( - 0.31615185819589475`);
aux2 = 0.01 - (α2 ) ( - 0.9487085972833191`);
g2 = g[aux1, aux2]
Out[]= 0.629623

Paso 5
P (α) = g1 + h1 α + h3 α(α - α2)
In[ ]:=
g 2 - g1
h1 =
α2 - α1
g 3 - g2
h2 =
α3 - α2
h 2 - h1
h3 =
α3 - α1
Out[]= - 1.23995

Out[]= - 1.06232

Out[]= 0.177631

1
In[ ]:= P[α_] := g1 + h1 α + h3 α2 - α ;
2
p = P '[α]
1
Out[]= - 1.23995 + 0.177631 - +2α
2

In[ ]:= α = α0 = 3.74024;

Paso 6
In[ ]:= α0 = 3.74024;
aux1 = 0.01 - (α0 ) ( - 0.31615185819589475`);
aux2 = 0.01 - (α0 ) ( - 0.9487085972833191`);
g0 = g[aux1, aux2]
Out[]= 286.548

Printed by Wolfram Mathematica Student Edition


4 descenso mas rapido.nb

In[ ]:= α3 = 1;
x1 = x0 - (1) Z;
x1 // MatrixForm
forma de matriz
Out[]//MatrixForm=
0.326152
0.958709

MÉTODO CUASI - NEWTON


ITERACIÓN 1
PASO 1
∂x x2 + y2 - 1 ∂y x2 + y2 - 1
In[ ]:= J[x_, y_] :=
∂x x2 - y2 + 1 / 2 ∂y x2 - y2 + 1 / 2

F[x_, y_] := x2 + y2 - 1, x2 - y2 + 1 / 2


J[x, y] // MatrixForm
forma de matriz
x0 = {{0.32615185819589476`}, {0.9587085972833191`}};
x0 // MatrixForm
forma de matriz
Out[]//MatrixForm=
2x 2y
2 x -2 y
Out[]//MatrixForm=
0.326152
0.958709

Printed by Wolfram Mathematica Student Edition


descenso mas rapido.nb 5

PASO 2
In[ ]:= J[x_, y_] := {{2 x, 2 y}, {2 x, - 2 y}}
A = J[0.32615185819589476`, 0.9587085972833191`];
A // MatrixForm
forma de matriz
B = F[0.32615185819589476`, 0.9587085972833191`];
B // MatrixForm
forma de matriz
Out[]//MatrixForm=
0.652304 1.91742
0.652304 - 1.91742
Out[]//MatrixForm=
0.0254972
- 0.312747

PASO 3
In[ ]:= c = Inverse[A];
matriz inversa
c // MatrixForm
forma de matriz
Out[]//MatrixForm=
0.766514 0.766514
0.260767 - 0.260767

PASO 4
In[ ]:= y0 = {{- 0.22018}, {0.08820}};

PASO 5
In[ ]:= X 1 = x 0 - y0 ;
X1 // MatrixForm
forma de matriz
Out[]//MatrixForm=
0.546332
0.870509

Printed by Wolfram Mathematica Student Edition


6 descenso mas rapido.nb

PASO 6
In[ ]:= error =

(0.5463318581958947 - 0.32615185819589476)2 + (0.8705085972833191 - 0.9587085972833191)2 
Out[]= 0.237189

ITERACION 2

PASO 2
In[ ]:= J[x_, y_] := {{2 x, 2 y}, {2 x, - 2 y}}
A = J[0.5463318581958947`, 0.8705085972833191`];
A // MatrixForm
forma de matriz
B = F[0.5463318581958947`, 0.8705085972833191`];
B // MatrixForm
forma de matriz
Out[]//MatrixForm=
1.09266 1.74102
1.09266 - 1.74102
Out[]//MatrixForm=
0.0562637
0.0406933

PASO 3
In[ ]:= c = Inverse[A];
matriz inversa
c // MatrixForm
forma de matriz
Out[]//MatrixForm=
0.457597 0.457597
0.287188 - 0.287188

PASO 4
In[ ]:= y1 = (c) (B);
y1 = {{0.04436}, {0.00447}};

Printed by Wolfram Mathematica Student Edition


descenso mas rapido.nb 7

PASO 5
In[ ]:= X 2 = X 1 - y1 ;
X2 // MatrixForm
forma de matriz
Out[]//MatrixForm=
0.501972
0.866039

PASO 6
In[ ]:= error =

(0.5019718581958947 - 0.5463318581958947)2 + (0.8660385972833191 - 0.8705085972833191)2 
Out[]= 0.0445846

Observamos que en la iteración 2(usando el descenso mas rápido)


logramos lo que en la iteración 5 (sin el descenso).

Printed by Wolfram Mathematica Student Edition

You might also like