Escolar Documentos
Profissional Documentos
Cultura Documentos
Ejercicio1
Código:
Inciso a)
>> x=-5:0.1:5;
>> y=x.^2-7*x+2;
>> plot(x,y),grid
>> Ejercicio1
Ingrese la funcion f= x.^2-
7*x+2
Ingrese el valor del limite
inferior a= -3
Ingrese el valor del limite
superior b= 3
Ingrese el numero de
iteraciones a realizar n= 3
f =
Inline function:
f(x) = x.^2-7*x+2
r =0
ans =
logical
1
a =0
r =1.5000
b = 1.5000
r = 0.7500
b = 0.7500
Inciso b)
>> x=-5:0.1:5;
>> y=exp(-x)+2*x-6;
>> plot(x,y),grid
Ingrese la funcion f= exp(-
x)+2*x-6
Ingrese el valor del limite
inferior a= -3
Ingrese el valor del limite
superior b= 3
Ingrese el numero de iteraciones
a realizar n= 5
f =
Inline function:
f(x) = exp(-x)+2*x-6
Inciso c)
>> x=-5:0.1:5;
>> y=log(x)+x.^2-5;
>> plot(x,y),grid
Ingrese la funcion f=
log(x)+x.^2-5
Ingrese el valor del limite
inferior a= -4
Ingrese el valor del limite
superior b= 4
Ingrese el numero de iteraciones
a realizar n= 4
f =
Inline function:
f(x) = log(x)+x.^2-5
El valor aproximado a la raiz es:
-2.5000
Inciso d)
>> x=-5:0.1:5;
>> y=cos(2*x)+7*x-1;
>> plot(x,y),grid
>> Ejercicio1
Ingrese la funcion f=
cos(2*x)+7*x-1
Ingrese el valor del limite
inferior a= -3
Ingrese el valor del limite
superior b= 3
Ingrese el numero de
iteraciones a realizar n= 4
f =
Inline function:
f(x) = cos(2*x)+7*x-1
El valor aproximado a la raiz es:
2.6250
Ejercicio 2
a) >> x=-5:0.1:5;
>> y=-0.5*x.^2+2.5*x+4.5;
>> plot(x,y),grid
b) Ingrese la funcion f= -
0.5*x.^2+2.5*x+4.5
Ingrese el valor del limite
inferior a= 5
Ingrese el valor del limite
superior b= 10
Ingrese el numero de iteraciones
a realizar n= 3
f =
Inline function:
f(x) = -0.5*x.^2+2.5*x+4.5
b) Ingrese la funcion f= -
25+82*x-90*x.^2+44*x.^3-
8*x.^4+0.7*x.^5;
Ingrese el valor del limite
inferior a= 0.5
Ingrese el valor del limite
superior b= 1
Ingrese el numero de iteraciones a realizar n= 1
f =
Inline function:
f(x) = -25+82*x-90*x.^2+44*x.^3-8*x.^4+0.7*x.^5;
El valor aproximado a la raiz es:
0.7500
Ejercicio 4
a) >> syms x
>> f=log(x.^2)-0.7;
>> ezplot(f),grid
b) Ingrese la funcion f=
log(x.^2)-0.7
Ingrese el valor del limite
inferior a= 0.5
Ingrese el valor del limite
superior b= 2
Ingrese el numero de iteraciones
a realizar n= 3
f =
Inline function:
f(x) = log(x.^2)-0.7
El valor aproximado a la raiz es: 1.4375
Metodo Newton-Raphson
Ejercicio 2
syms x
>> f=-1+5.5*x-4*x.^2+0.5*x.^3;
>> ezplot(f),grid
CODIGO
function raphson
cf=input('Ingrese la
funcion: ','s');
syms x
f=inline(cf);
derivada=diff(cf,x);
df=inline(derivada);
tol=input('Ingrese tolerancia: ');
error=50;
x=input('Ingrese el valor inicial: ');
n=0;
while (error>tol)
fprintf('\t%i\t%3.5f\t%f\n',n,x,error);
n=n+1;
x=x-f(x)/df(x);
error=abs(f(x));
end