Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% encontró este documento útil (0 votos)
33 vistas3 páginas

Códigos Parcial

Descargar como docx, pdf o txt
Descargar como docx, pdf o txt
Descargar como docx, pdf o txt
Está en la página 1/ 3

Cóigo Bisección

function [r] = bis(a,b,n,tol)


for i= 1:n
c=(a+b)/2;
if funcion(a)*funcion(c)<0
b=c;
else
a=c;
end
if abs(funcion(c))<tol
r = c;
break
end
end
end
function y=funcion(x)
y=sin(x);
end

(b − a )/(2 ^n) < 10−2

Có digo Regula

function [r,rep]=reg(a,b,n,tol)
for i= 1:n
m=(funcion(b)-funcion(a))/(b-a);
corte=funcion(a)-(m*a);
c=(-corte)/m;
if funcion(a)*funcion(c)<0
b=c;
else
a=c;
end
if abs(funcion(c))<tol
r = c;
rep=i;
break
end
end
end
function y=funcion(x)
y=sin(x);
end
Có digo Secante
function [r,rep]=secante(a,b,n,tol)
format long
for i = 1:n
m=(funcion(b)-funcion(a))/(b-a);
corte=funcion(a)-(m*a);
c=(-corte)/m;
if abs(funcion(c))<tol
r=c;
rep=i;
break
end
a=b;
b=c;
end
end
function y=funcion(x)
y=cos(x);
end

Có digo Newton

function [r,rep]=new(a,n,tol)
for i = 1:n
m=derivada(a);
corte=funcion(a)-(m*a);
c = (-corte)/m;
if abs(funcion(c))<tol
r=c;
rep=i;
break
end
a=c;
end
end

function y=funcion(x)
y=cos(x);
end
function z=derivada(x1)
z=-sin(x1);
end
Código Punto Fijo

function [r,rep]=fijo(a,n,tol)
for i = 1:n
a=funcion(a);
if abs((a-funcion(a)))<tol
r=a;
rep=i;
break
end
end
end
function y=funcion(x)
y=x^(2)-4;
end

(k^n)max[x-a,b-x] X=punto de partida de la iteración

También podría gustarte