Está en la página 1de 3

ESCUELA DE INGENIERA EN CIENCIAS DE LOS MATERIALES

CM3207- METODOS NUMERICOS PARA INGENIERIA

TAREA No.1

PROGRAMACION EN MATLAB

REALIZADO POR:

IGNACIO RAMREZ QUESADA


200560563
JOSE DANIEL RODRIGUEZ CHACON
201231719

PROFESOR:
ING.MANUEL CALDERON SOLANO

03 DE ENERO DE 2017

VERANO 2016/2017
Teorema de biseccin
% Se define el error mximo aceptable
er = 0.00001;

% Se define en otro script llamado "g" la funcin g(f) = 0 para poder


% usarla fcilmente.

% Se prueban valores para definir donde es positiva y donde negativa

x_sup = 1; % Estos salen por prueba y error


x_inf = 0.01;

% Se inicializan variables que se usarn luego


x_anterior = 1; % note que este es el x_(i-1) realmente
x_i = 0;

while abs((x_i-x_anterior)/x_i) > er % Ec. (2.3)

x_i = (x_sup + x_inf)/2; % Nuevo valor

if g(x_inf)*g(x_i) < 0
x_sup = x_i;
x_anterior = x_inf; % esto es para definir la convergencia sin
% almacenar los valores de x
elseif g(x_inf)*g(x_i) > 0
x_inf = x_i;
x_anterior = x_sup; % Idem al anterior
end
end

% No se van almacenando los valores de x, esto es bueno por espacio y


malo
% porque no se conoce el comportamiento.

disp(['Solucin de la ecuacin =' num2str(x_i)])

Teorema Newton Ralston


function y=newtonr(fun,x0,tol)
dfun=diff(sym(fun));
f=subs(fun,x0);
df=subs(dfun,x0);
c=1;
while abs(f)>tol
a=x0-f/df;
f=subs(fun,a);
df=subs(dfun,a);
x0=a;
c=c+1;
end
Gauss Legendre
function y=gaussl(f,a,b)
syms x
x1=sqrt(1/3);
x2= -sqrt(1/3);
t1=(a+b)/2+(b-a)/2*x1;
t2=(a+b)/2+(b-a)/2*x2;
y=double((subs(f,x,t1)+subs(f,x,t2))*(b-a)/2);

end

Regla Trapecio
function [I]=ReglaTrapecio(a,b,f,n)
syms x;
fa=subs(f,x,a);
fb=subs(f,x,b);
h=(b-a)/(n-1)
I=(h*(fa+fb))/2;
suma=0;
for i=1:n-1
xi=a+h*i;
suma=suma+subs(f,xi);
end
I=I+h*suma
end

Regla de Simpson
function [I]=ReglaSimpson(a,b,c,f)
syms x;
fa=subs(f,x,a)
fb=subs(f,x,b)
fc=subs(f,x,c)
I=((b-a)/6)*(fa+4*fc*fb)
end

También podría gustarte