Vous êtes sur la page 1sur 8

UNIVERSIDAD DEL NORTE

DEPARTAMENTO DE INGENIERÍA INDUSTRIAL

SOLUCIONES COMPUTACIONALES A PROBLEMAS DE INGENIERÍA

DOCENTE: MARLON PIÑERES

INTEGRANTES:
FREDDY ALVARADO
JUAN FELIPE YUSUNGUAIRA
GERSON HERNANDEZ

BARRANQUILLA, ATLANTICO
NOVIEMBRE 2019
1. Resolver un sistema de ecuaciones lineales usando el método de Jacobi. Mostrar los
valores de cada incógnita.
 Clc
clear all
disp('Método de Jacobi');
disp('Ecuaciones:'); disp('2x+y-3z=7');
disp('5x-4y+z=-19'); disp('x-y-4z=4');
disp('RECOMENDACIÓN: DIGITE UN NÚMERO DE ITERACIONES
ALTO');
k=input('Digite el número de iteraciones: ');
xo=(7)/(2); yo=(-19)/(-4);
zo=(4)/(-4);
for i=1:k y1=(7-yo+3*(zo))/(2);
y2=(-19-5*(xo)-zo)/(-4); y3=(4-xo+yo)/(-4);
xo=y1;
yo=y2;
zo=y3;
end disp('los valores de X, Y, Z:');
disp('X: ');
disp(xo);
disp('Y: ');
disp(yo);
disp('Z: ');
disp(zo);
 PRUEBA:
Método de Jacobi
Ecuaciones:
2x+y-3z=7 5x-4y+z=-19 x-y-4z=4
RECOMENDACIÓN: DIGITE UN NÚMERO DE ITERACIONES ALTO
Digite el número de iteraciones: 900
los valores de X, Y, Z: X: -1 Y: 3 Z: -2

2. Hacer un script que dado la cantidad de n términos a calcular de f(x), muestre la


solución de la ecuación diferencial ordinaria y el valor de xi, usando el método de
Runge Kutta de 4to orden. Debe mostrar la respectiva gráfica
 clc
clear
fprintf('\n \tRESOLUCION DE ECUACIONES DIFERENCIALES POR MEDIO
RUNGE-KUTTA DE ORDEN 4\n')
syms x;
syms y;
x0=input('Ingrese el valor inicial de x0: ');
y0=input('Ingrese el valor inicial de yo: ');
n=input('Ingrese la cantidad de terminos n a resolver: ');
h=input('Ingrese el tamaño de paso h: ');
ing=input('Ingrese una función empleando las variables x,y: ','s');
fun=str2func(['@(x,y)' ing]);
i=1;
x(i)=x0;
y(i)=y0;
while i<=n
k1=fun(x0,y0);
k2=fun(x0+h/2,y0+k1*h/2);
k3=fun(x0+h/2,y0+k2*h/2);
k4=fun(x0+h,y0+h*k3);
km=(k1+2*k2+2*k3+k4)/6;
y1=y0+h*km;
x1=x0+h;
i=i+1;
x(i)=x1;
y(i)=y1;
x0=x1;
y0=y1;
num=i-1;
fprintf('Y %i',num);
disp(y1)
fprintf('X %i',num);
disp(x1)
end
plot(x,y)
grid on
title('SOLUCION DE EDO USANDO RUNGE KUTTA DE ORDEN 4',
'FontSize',12)
xlabel('X')
ylabel('Y')

 PRUEBA:
RESOLUCION DE ECUACIONES DIFERENCIALES POR MEDIO RUNGE-
KUTTA DE ORDEN 4
Ingrese el valor inicial de x0: 0
Ingrese el valor inicial de yo: 1
Ingrese la cantidad de terminos n a resolver: 2
Ingrese el tamaño de paso h: 0.1
Ingrese una función empleando las variables x,y: x*y
Y 1 1.005012520833333
X 1 0.100000000000000

Y 2 1.020201339758368

X 2 0.200000000000000

3. Hacer un script que, dado un conjunto de puntos, grafique la regresión lineal y


muestre la ecuación de la recta.
clc
clear
syms x;
format long
n=input('Ingrese la cantidad de puntos: ');
%[ 1 2 3 4 5 6 7 ]
ex=input('Ingrese los puntos de la variable x = \n');
%[ 0.5 2.5 2 4 3.5 6 5.5 ]
y=input('Ingrese los puntos de la variable y = \n');
sumatoriaX=0;
sumatoriaY=0;
producto=0;
cuadrado=0;
for i=1:n
sumatoriaX=sumatoriaX+ex(i);
sumatoriaY=sumatoriaY+y(i);
producto=producto+ex(i)*y(i);
cuadrado=cuadrado+ex(i)^2;
end
pendiente=(n*producto-sumatoriaX*sumatoriaY)/(n*cuadrado-sumatoriaX^2);
xbarra=sumatoriaX/n;
ybarra=sumatoriaY/n;
interceptoy=ybarra-pendiente*xbarra;
func=(pendiente)*x+interceptoy
%func=input('Digite la función ax+b usando la pendiente y interceptoy: ');
for i=1:n
axis auto
plot(ex(i),y(i),'x')
hold on;
end
title('Grafica Regresion Lineal y Ec. de la Recta','FontSize',12)
xlabel('X')
ylabel('Y')
grid on
fig=fplot(func);
set (fig, 'color', 'blue');

 PRUEBA
Ingrese la cantidad de puntos: 7
Ingrese los puntos de la variable x =
[1 2 3 4 5 6 7]
Ingrese los puntos de la variable y =
[0.5 2.5 2 4 3.5 6 5.5]
func = (47*x)/56 + 1/14
4. Hacer una función que retorne: la aproximación de una integral definida, el valor de
n y el error absoluto, usando Simpson 3/8 compuesto, tomando como entrada la
integral definida y la tolerancia, mostrar la gráfica del área bajo la curva, el error
absoluto.
clc
clear
syms x;
limiteinf_a=input('Ingrese el valor del limite inferior a: ');
limitesup_b=input('Ingrese el valor del limite superior b: ');
tolerancia=input('Ingrese la tolerancia: ');
funcion=input('Ingrese una función:');
%exp(x^2)
real=double(int(funcion,limiteinf_a,limitesup_b))
i=0;
n=i+1;
error_absoluto=5;
while error_absoluto>=tolerancia
for i=1:n+1
h=(limitesup_b-limiteinf_a)/n;
x=zeros([1 n+1]);
xm=zeros([1 n+1]);
fin=n;
if i==1
x(i)=limiteinf_a;
xm(i)=subs(funcion,limiteinf_a);
else
if i==n+1
x(i)=limitesup_b;
xm(i)=subs(funcion,limitesup_b);
else
x(i)=(i-1)/fin;
if mod(i-1,3)==0
xm(i)=2*subs(funcion,(i-1)/fin);
else
xm(i)=3*subs(funcion,(i-1)/fin);
end
end
end
end
sumatoria=0;
for i=1:n+1
sumatoria=sumatoria+xm(i);
end
I=(3/8)*h*sumatoria;
%ea=19/(15*n^4);
error_absoluto=double((n*h^5*subs(diff(funcion,4),tolerancia))/80);
n=n+1;
end
int=123;
dx=(limitesup_b-limiteinf_a)/int;
resultado=zeros(1,int);
fs=subs(funcion,limiteinf_a);
fr=fs*dx;
resultado(1)=fr;
for i=1:int
fs=subs(funcion,(limiteinf_a+i*dx));
fr=fs*dx;
resultado(i+1)=resultado(i)+fr;
end
x=limiteinf_a:dx:limitesup_b;
bar(x,resultado);
fprintf('\n El error absoluto es: \n')
disp(error_absoluto)
fprintf('\n La aproximación de la integral es: \n')
disp(I)
fprintf('\n El valor de n es: \n')
disp(n-1)
xlabel('X')
ylabel('Y')
title('AREA BAJO LA CURVA METODO SIMPSON 3/8 COMPUESTO',
'FontSize', 12)

 PRUEBA:
Ingrese el valor del limite inferior a: -3
Ingrese el valor del limite superior b: 3
Ingrese la tolerancia: 10^-2
Ingrese una función:log(4*x^2+4)
real = 15.1295
El error absoluto es: -1.1652e+03
La aproximación de la integral es: 8.3000
El valor de n es: 1

Vous aimerez peut-être aussi