Está en la página 1de 15

Evaluación

UNIVERSIDAD PRIVADA DEL VALLE


FACULTAD DE INFORMATICA Y ELECTRONICA
INGENIERIA BIOMEDICA
CAMPUS TIQUIPAYA

METODOS NUMERICOS

Practica Nº1

Raíces de ecuaciones
Grupo “A”

Estudiante: ROJAS LIMA CINTHIA


V.

Docente: Ing. Andrade Irahola


Mario
Cochabamba 25 de agosto del 2022

Gestión II – 2022
a)
>> x=-3:0.1:3;
>> f=x.^2+10*x-3;
>> plot(x,f),grid

b)
>> x=-3:0.1:3;
>> f=x.^8+8*x.^4+18;
>> plot(x,f),grid
c)
>> x=-3:0.1:3;
>> f=exp(-2*x)-2*x+sin(1.5);
>> plot(x,f),grid

d)
>> x=-3:0.1:3;
>> f=log(-x)-x.^3-8;
>> plot(x,f),grid
Warning: Imaginary parts of complex X and/or Y arguments ignored
function biseccion_2022
f1=input('ingrese la función f(x)= ', 's'); %
ingreso de datos
a=input('ingrese el limite inferior del intervalo
a= ');
b=input('ingrese el limite superior del intervalo
b= ');
n=input('ingrese el numero maximo de iteraciones
n= '); %ingreso de datos
f=inline(f1);
for i=1:1:n
xr=(a+b)/2; %Calculo del punto medio
if f(a)*f(xr)<0
b=xr;
elseif f(xr)*f(b)<0
a=xr;
elseif f(xr)==0
disp('la raiz es: ')
disp(xr);
end
end
disp('la raiz es: ')
disp(xr);
a)
>> biseccion_2022
ingrese la función f(x)= x.^2+10*x-3
ingrese el limite inferior del intervalo a= 0
ingrese el limite superior del intervalo b= 1
ingrese el numero maximo de iteraciones n= 4
la raiz es:
0.3125

b)
>> biseccion_2022
ingrese la función f(x)= exp(-2*x)-2*x+sin(1.5)
ingrese el limite inferior del intervalo a= 0
ingrese el limite superior del intervalo b= 1
ingrese el numero maximo de iteraciones n= 6
la raiz es:
0.6406

c)
>> biseccion_2022
ingrese la función f(x)= log(-x)-x.^3-8
ingrese el limite inferior del intervalo a= -3
ingrese el limite superior del intervalo b= -2
ingrese el numero maximo de iteraciones n= 4
la raiz es:
-2.5000
a)
>> x=10:0.1:15;
>> f=-0.5*x.^2+4*x+20.5;
>> plot(x,f),grid

b)
−b ± √ b −4 ac
2
x=
2a
−4 ± √ 4 −4 (−0.5 ) (2 0. 5)
2
x=
2(−0.5)

−4 ± √ 5 7
x=
−1
−4 ±7.55
x=
−1
−4 +7.55
x 1=
−1
3 .55
x 1=
−1
x 1=−3. 55

−4−7 . 55
x 2=
−1
−11 . 55
x 2=
−1
x 2=1 1. 55

a)
>> x=-15:0.1:16;
>> f=-19+82*x-90*x.^2+44*x.^3+7*x.^4-0.6*x.^5;
>> plot(x,f),grid
b)
function bisecciontol_2022
f1=input('ingrese la función f(x)= ', 's');
a=input('ingrese el limite inferior del
intervalo a= ');
b=input('ingrese el limite superior del
intervalo b= ');
es=input('ingrese la tol es= ');
f=inline(f1);
ea=100;
cont=0;
while ea>es
cont=cont+1;
xr=(a+b)/2;
if f(a)*f(xr)<0
b=xr;
if cont>1
ea=abs((xr-xant)/xr)*100;
end
else f(xr)*f(b)<0
a=xr;
if cont>1
ea=abs((xr-xant)/xr)*100;
end
end
xant=xr;
end
disp('El numero de iteraciones es: ')
disp(cont)
disp('la raiz es: ')
disp (vpa(xr,8))
>> bisecciontol_2022
ingrese la función f(x)= -19+82*x-90*x.^2+44*x.^3+7*x.^4-
0.6*x.^5
ingrese el limite inferior del intervalo a= 15
ingrese el limite superior del intervalo b= 16
ingrese la tol es= 0.15
ans =

logical

ans =

logical

El numero de iteraciones es:


6

la raiz es:
15.765625
function neewton_raphson
syms x;
f=input('ingrrese una funcion:');
funcion =inline(f);
x1=input('ingrese el valor de x1:');
n=input('ingrese el numero de
repeticiones:');
%derivada=diff(f);
derivada=diff(f,x);
dff=inline(derivada);
c=x1-funcion(x1)/dff(x1);
for i=1:n
c=x1-(funcion(x1)/dff(x1));
x1=c;
end
disp(c)
disp('La aproximacion es: ')
disp(vpa(x1,6))
end

a)
>> x=-3:0.1:3;
>> f=x.^2+10*x-3;
>> plot(x,f),grid
>> neewton_raphson
ingrrese una funcion:x.^2+10*x-3
ingrese el valor de x1:0
ingrese el numero de repeticiones:4
0.2915

La aproximacion es:
0.291503

b)
>> x=-3:0.1:3;
>> f=exp(-2*x)-2*x+sin(1.5);
>> plot(x,f),grid
ingrrese una funcion:exp(-2*x)-2*x+sin(1.5)
ingrese el valor de x1:0
ingrese el numero de repeticiones:6
0.6383

La aproximacion es:
0.638253

c)
>> x=-3:0.1:3;
>> f=log(-x)-x.^3-8;
>> plot(x,f),grid
Warning: Imaginary parts of complex X and/or Y arguments
Ignored
ingrrese una funcion:log(-x)-x.^3-8
ingrese el valor de x1:-2
ingrese el numero de repeticiones:4
-1.9430

La aproximacion es:
-1.94304

a)
>> x=-5:0.1:5;
>> f=-1+5*x-4.5*x.^2+0.5*x.^3;
>> plot(x,f),grid
a)
>> x=-5:0.1:5;
>> f=x.^(2.8)-60*x;
>> plot(x,f),grid
Warning: Imaginary parts of complex X and/or Y arguments
Ignored
function raphsontol_7
f1=input('Ingrese la función f(x)= ','s');
x1=input('Ingrese el valor inicial x1= ');
es=input('Ingrese la tolerancia es= ');
syms x
f=inline(f1);
df=diff(f1,x);
ddf=inline(df);
ea=100;
cont=0;
while ea>es
x2=x1-f(x1)/ddf(x1);
ea=(abs(x2-x1)/x2)*100;
x1=x2;
cont=cont+1;
end
disp('La aproximación es: ')
disp(x2)
fprintf('El resultado es%4.7f\n',x2)
disp('El error aproximado es: ')
disp(ea)
disp('El numero de iteraciones es:')
disp(cont)

También podría gustarte