Está en la página 1de 7

Estudiante: Ronald Canaza Guzman while ea>es

cont=cont+1
PRACTICA 5 x2=x1-dfe(x1)/df2e(x1);
x1=x2
Programas a usar : ea=abs((x2-x1)/x2)*100
end
1)function maxminnewton disp('La aproximacion de la raiz
es')
f1=input('ingrese la funsion disp(x1)
f(x)= ','s') disp('El error aproximado es')
x1=input('ingrese el valor disp(ea)
inicial x1= ') disp('El numero de iteraciones es
n=input('ingrese l numero de ')
iteraciones n= ') disp(cont)
syms x
f=inline(f1)
df=diff(f1,x)  Ejercicio 1
dfe=inline(df)
df2=diff(f1,x,2) ingrese la funsion f(x)= -x^2+8*x-12
df2e=inline(df2)
for i=1:1:n f1 =
x2=x1-dfe(x1)/df2e(x1);
x1=x2; -x^2+8*x-12
end ingrese el valor inicial x1= 2
disp('El punto critico aproximado
es ') x1 =
disp(x1)
if df2e(x1)<0 2
disp('El punto ')
disp(vpa([x1,f(x1)],5)) ingrese l numero de iteraciones n= 3
disp ('El maximo local es ')
elseif df2e(x1)>0 n=
disp('El punto ')
3
disp(vpa([x1,f(x1)],5))
disp('El minimo local es ') f=
elseif df2e(x1)==0
disp('El criterio no es Inline function:
concluyente')
end f(x) = -x^2+8*x-12

df =
2)function newtonlerancia 8 - 2*x
f1=input('ingrese la funsion dfe =
f(x)= ','s')
x1=input('ingrese el valor Inline function:
inicial x1= ')
es=input('ingrese l numero de dfe(x) = x.*-2.0+8.0
tolerancia= ')
syms x df2 =
f=inline(f1)
df=diff(f1,x) -2
dfe=inline(df) df2e =
df2=diff(f1,x,2)
df2e=inline(df2) Inline function:
ea=100
cont=0; df2e(x) = -2.0
El punto critico aproximado es 1

4 ea =

El punto 18.6813

[ 4.0, 4.0] x1 =

El maximo local 2.5278

 Ejercicio 2 cont =

ingrese la funsion f(x)= 4*x-1.8*x^2+1.2*x^3- 2


0.3*x^4 ea =
f1 = 7.4854
4*x-1.8*x^2+1.2*x^3-0.3*x^4 x1 =
ingrese el valor inicial x1= 3 2.3517
x1 = cont =
3 3
ingrese l numero de tolerancia= 1 ea =
es = 1.0708
1 x1 =
f= 2.3268
Inline function: cont =
f(x) = 4*x-1.8*x^2+1.2*x^3-0.3*x^4 4
df = ea =
- 1.2*x^3 + 3.6*x^2 - 3.6*x + 4 0.0204
dfe = x1 =
Inline function: 2.3264
dfe(x) = x.*-3.6+x.^2.*3.6-x.^3.*1.2+4.0 La aproximacion de la raiz es
df2 = 2.3264
- 3.6*x^2 + 7.2*x - 3.6 El error aproximado es
df2e = 0.0204
Inline function: El numero de iteraciones es
df2e(x) = x.*7.2-x.^2.*3.6-3.6 4
ea =
 Ejercicio 3
100
ingrese la funsion f(x)= -x^4-2*x^3-8*x^2-5*x
cont =
f1 =
-x^4-2*x^3-8*x^2-5*x x1 =

ingrese el valor inicial x1= -1 -0.3466

x1 = cont =

-1 3

ingrese l numero de tolerancia= 1 ea =

es = 0.1997

1 x1 =

f= -0.3473

Inline function: La aproximacion de la raiz es

f(x) = -x^4-2*x^3-8*x^2-5*x -0.3473

df = El error aproximado es

- 4*x^3 - 6*x^2 - 16*x - 5 0.1997

dfe = El numero de iteraciones es

Inline function: 3

dfe(x) = x.*-1.6e1-x.^2.*6.0-x.^3.*4.0-5.0  Ejercicio 4


df2 = ingrese la funsion f(x)=
- 12*x^2 - 12*x - 16 3+6*x+5*x^2+3*x^3+4*x^4

df2e = f1 =

Inline function: 3+6*x+5*x^2+3*x^3+4*x^4

df2e(x) = x.*-1.2e1-x.^2.*1.2e1-1.6e1 ingrese el valor inicial x1= -1

ea = x1 =

100 -1

cont = ingrese l numero de tolerancia= 1

1 es =

ea = 1

128.5714 f=

x1 = Inline function:

-0.4375 f(x) = 3+6*x+5*x^2+3*x^3+4*x^4

cont = df =

2 16*x^3 + 9*x^2 + 10*x + 6

ea = dfe =

26.2419 Inline function:


dfe(x) = -0.5867
x.*1.0e1+x.^2.*9.0+x.^3.*1.6e1+6.0
La aproximacion de la raiz es
df2 =
-0.5867
48*x^2 + 18*x + 10
El error aproximado es
df2e =
0.0833
Inline function:
El numero de iteraciones es
df2e(x) = x.*1.8e1+x.^2.*4.8e1+1.0e1
4
ea =
 Ejercicio 5
100
ingrese la funsion f(x)=
cont = ((2.5)/120*50000*30000*600)*(-
1 x^5+2*(600)^2*x^3-(600)^4*x)

ea = f1 =

37.9310 ((2.5)/120*50000*30000*600)*(-
x^5+2*(600)^2*x^3-(600)^4*x)
x1 =
ingrese el valor inicial x1= 300
-0.7250
x1 =
cont =
300
2
ingrese l numero de iteraciones n= 3
ea =
n=
19.4344
3
x1 =
f=
-0.6070
Inline function:
cont =
f(x) = ((2.5)/120*50000*30000*600)*(-
3 x^5+2*(600)^2*x^3-(600)^4*x)

ea = df =

3.3816 - 93750000000.0*x^4 +
40500000000000000.0*x^2 -
x1 = 2430000000000000000000.0
-0.5872 dfe =
cont = Inline function:
4 dfe(x) = x.^2.*4.05e16-x.^4.*9.375e10-
ea = 2.43e21

0.0833 df2 =

x1 = - 375000000000.0*x^3 +
81000000000000000.0*x
df2e = 2.25*y - 3.0*x
Inline function: dfy =
df2e(x) = x.*8.1e16-x.^3.*3.75e11
2.25*x - 4*y + 1.75
El punto critico aproximado es
dfxe =
268.3282
-0.75
El punto
dfye =
[ 268.33, -4.173e23]
0.0
El minimo local
g1 =
PRACTICA 6
2.0 - 1.5*(0.75*h - 1)^2 - 1.6875*h
Ejercicio 2
g=
Dada :
- 0.84375*h^2 + 0.5625*h + 0.5
f(x,y)= 2.25xy+1.75y-1.5x^2-2y^2
ea =
Valores iniciales x1=1,y=1 realice dos
aplicaciones del método de ascenso máxima 100
inclinación para f(x,y)
dg =
>> maxinclinacion1
0.5625 - 1.6875*h
ingrese la funcion f(x)= 2.25*x*y+1.75*y-
d2g =
1.5*x^2-2*y^2
-1.6875
f=
h2 =
2.25*x*y+1.75*y-1.5*x^2-2*y^2
0.33333333333333333333333333333333
ingrese el valor inicial x1= 1
h1 =
x1 =
0.33333333333333333333333333333333
1
h2 =
ingrese el valor inicial y1= 1
0.33333333333333333333333333333333
y1 =
h1 =
1
0.33333333333333333333333333333333
ingrese el numero de iteraciones n= 2
el valor extremo es
n=
0.33333333333333333333333333333333
2
x1 =
dfx =
0.75
y1 = y1 =

1.0 0.859375

dfxe = la aproximacion del valor extremo es:

0.0 [ 0.75, 0.85938]

dfye = Ejercicio 4

-0.5625 Dada

g1 = F(x,y)= 8x+x^2+12y+4y^2-2xy

2.59375 - 2*(0.5625*h - 1.0)^2 - Comience con x=1 y y=1 realice dos


1.93359375*h aplicaciones del método de ascenso de
máxima inclinación
g=
>> maxinclinacion1
- 0.6328125*h^2 + 0.31640625*h + 0.59375
ingrese la funcion f(x)= -
ea =
8*x+x^2+12*y+4*y^2-2*x*y
100
f=
dg =
-8*x+x^2+12*y+4*y^2-2*x*y
0.31640625 - 1.265625*h
ingrese el valor inicial x1= 0
d2g =
x1 =
-1.265625
0
h2 =
ingrese el valor inicial y1= 0
0.25
y1 =
h1 =
0
0.25
ingrese el numero de iteraciones n= 2
h2 =
n=
0.25
2
h1 =
dfx =
0.25
2*x - 2*y - 8
el valor extremo es
dfy =
0.25
8*y - 2*x + 12
x1 =
dfxe =
0.75
-8
dfye = -2

12 g1 =

g1 = (3*h - 1)^2 + 4*(2*h + 3/2)^2 - 2*(3*h -


1)*(2*h + 3/2) - 26
832*h^2 + 208*h
g=
g=
13*h^2 + 13*h - 13
832*h^2 + 208*h
ea =
ea =
100
100
dg =
dg =
26*h + 13
1664*h + 208
d2g =
d2g =
26
1664
h2 =
h2 =
-1/2
-1/8
h1 =
h1 =
-1/2
-1/8
h2 =
h2 =
-1/2
-1/8
h1 =
h1 =
-1/2
-1/8
el valor extremo es
el valor extremo es
-1/2
-1/8
x1 =
x1 =
5/2
1
y1 =
y1 =
-1/2
-3/2
la aproximacion del valor extremo es:
dfxe =
[ 2.5, -0.5]
-3

dfye =

También podría gustarte