Está en la página 1de 2

DESARROLLO DE EJERCICIOS EN MATLAB

1) Hallar la raíz real de 𝑓(𝑥) = 𝑥 3 − 15𝑥 − 12


2) Hallar la raíz más grade de 0.95𝑥 3 − 5.9𝑥 2 + 10.9𝑥 − 6
a) Método grafica
b) Método de I.P.F(cinco iteraciones 𝑥0 = 3)
c)Método Newton Y Raphson (cinco interaciones 𝑥0 = 3)
Programa
%metodo de newton y raphson.
clear,clc
cf=input('Ingrese funcion a evaluar:');
syms 'x'
f=inline(cf);
derivada=diff(cf,x);
df=inline(derivada);
tol=input('Ingrse tolerancia:');
error=50;
x0=input('Ingrese un valor inicial:');
n=0;
disp('n xi eroor')
while(error>tol)
fprintf('\t%i\t%3.5f \t%f\n',n,x0,error);
n=n+1;
x1=x0-f(x0)/df(x0);
error = abs(f(x0));
x0=x1;

end

Desarrollo
Ingrese función a evaluar:'0.95*x^3-5.9*x^2+10.9*x-6'
Ingrese tolerancia:0.0000001
Ingrese un valor inicial:3
n xi eroor
0 3.00000 50.000000
1 3.65217 0.750000
2 3.41318 1.390647
3 3.34926 0.244563
4 3.34467 0.015388
5 3.34465 0.000077
>>
d) Método de la secante (cinco interaciones 𝑥0 = 3 𝑥1 = 3.3)
Programa
% método de la secante
clear, clc
cf=input('Ingrese funcion:');
f=inline(cf);
x0=input('ingrese primer valor:');
x1=input('ingrese segundo valor:');
tol=input('ingrese la tolerancia:');
error=100;
n=0;
fprintf('n x0 x1 x2 error\n');
fprintf('%i %4.5f %4.5f ---- ----\n', n, x0, x1);
while (error>tol)
n=n+1;
x2=x1-((x1-x0)*f(x1)/f(x1)-f(x0));
error=abs(f(x2));
fprintf('%i %4.5f %4.5f %4.5 %4.5\n', n, x0, x1, error);
x0=x1;
x1=x2;
end
desarrollo
Ingrese funcion:'0.95*x^3-5.9*x^2+10.9*x-6'
ingrese primer valor:3
ingrese segundo valor:3.3
ingrese la tolerancia:0.0000001
n x0 x1 x2 error
0 3.00000 3.30000 ---- ----
1 3.00000 3.30000 2 3.30000 2.25000 3 2.25000 3.15915 4 3.15915 1.72734 5 1.72734
2.66312

e) Método de newton de segundo orden (𝑥0 = 3

También podría gustarte