Documentos de Académico
Documentos de Profesional
Documentos de Cultura
LAB 2. GR 11
LAB 2. GR 11
Carlos Gutierrez, Daniela Parra, Sofía Puello, Valentina Rodriguez, Mauro Villadiego
Ejercicio 1.
Código
clear
clc
format short
syms x
syms y
syms z
fx=(b1-f1c2*y-f1c3*z)/f1c1;
Soluciones Computacionales a Problemas de Ingeniería
fy=(b2-f2c1*x-f2c3*z)/f2c2;
fz=(b3-f3c1*x-f3c2*y)/f3c3;
z_ant=double(subs(fz, [x,y], [x_ant, y_ant]));
z_nuevo=z_ant;
x_nuevo=x_ant;
y_nuevo=y_ant;
eax=100;
eay=100;
eaz=100;
Di=max([eax,eay,eaz]);
i=0;
fprintf('i,x_ant,y_ant,z_ant,eax,eay,eaz,Di \n');
while(Di>tol)
fprintf('%i %d %d %d %d %d %d %d
\n',i,x_ant,y_ant,z_ant,eax,eay,eaz,Di);
x_nuevo = double(subs(fx, [y,z], [y_nuevo,z_nuevo]));
y_nuevo = double(subs(fy, [x,z], [x_nuevo,z_nuevo]));
z_nuevo = double(subs(fz, [x,y], [x_nuevo, y_nuevo]));
eax=abs(x_nuevo-x_ant);
eay=abs(y_nuevo-y_ant);
eaz=abs(z_nuevo-z_ant);
erx=abs((x_nuevo-x_ant)/x_nuevo)*100
ery=abs((y_nuevo-y_ant)/y_nuevo)*100
erz=abs((z_nuevo-z_ant)/z_nuevo)*100
Di=max([eax,eay,eaz]);
x_ant=x_nuevo;
y_ant=y_nuevo;
z_ant=z_nuevo;
i=i+1;
end
x_nuevo
y_nuevo
z_nuevo
disp('El error absoluto de x es:')
disp(eax)
disp('El error absoluto de y es:')
disp(eay)
disp('EL error absoluto de z es:')
disp(eaz)
disp('El error relativo de x es:')
disp(erx)
disp('El error relativo de y es:')
disp(ery)
disp('El error relativo de z es:')
disp(erz)
Soluciones Computacionales a Problemas de Ingeniería
Prueba
1 1 -1
1
-1
1
3
Digite el valor al que esta igualada la
segunda ecuación:
Soluciones Computacionales a Problemas de Ingeniería
ery =
A2 =
100
3 2
5 3
erz =
A3 = 280
1 1 -1
erx =
No es definida positiva.
i,x_ant,y_ant,z_ant,eax,eay,eaz,Di
250.0000
erx =
ery =
100
33.3333
Soluciones Computacionales a Problemas de Ingeniería
171.4286
erx =
2 -4.444444e-01 6.666667e-01
-7.777778e-01 1.111111e+00 2.222222e-
01 1.333333e+00 1.333333e+00 117.6471
erx =
ery =
400
15.6863
ery =
erz =
54.2373
204.2553
228.5714
erx =
Soluciones Computacionales a Problemas de Ingeniería
168.4211 9.8310
ery = erz =
35.8042 260.3390
6 -1.190672e+00 1.786008e+00
-4.046639e-01 8.779150e-01 1.755830e-
erz =
01 1.053498e+00 1.053498e+00
189.4292
erx =
5 -3.127572e-01 1.961591e+00
64.8101
6.488340e-01 5.267490e-01 7.023320e-
01 1.229081e+00 1.229081e+00
erx = ery =
73.7327 25.9011
ery = erz =
Soluciones Computacionales a Problemas de Ingeniería
158.8300 erx =
ery =
erx =
19.7543
51.9270
erz =
ery =
134.4053
6.9236
9 -1.086623e+00 2.809158e+00
7.225355e-01 4.161967e-01 5.549290e-
erz = 01 9.711257e-01 9.711257e-01
376.7014 erx =
ery = erz =
5.1951 114.5823
11 -1.410332e+00 3.163696e+00
7.533649e-01 3.699526e-01 4.932702e-
erz =
01 8.632228e-01 8.632228e-01
757.7000
erx =
10 -1.780284e+00 2.670426e+00
30.4199
-1.098579e-01 6.936612e-01 1.387322e-
01 8.323934e-01 8.323934e-01
erx = ery =
26.2316 4.0560
ery = erz =
15.5916 5.4972e+03
Soluciones Computacionales a Problemas de Ingeniería
ery =
erx =
3.2534
19.3659
erz =
ery =
534.3834
12.6037
14 -2.246150e+00 3.369226e+00
1.230752e-01 5.480780e-01 1.096156e-
erz = 01 6.576936e-01 6.576936e-01
98.2761 erx =
ery =
erx =
Soluciones Computacionales a Problemas de Ingeniería
10.3684 265.1186
16 -2.441023e+00 3.661534e+00
2.205113e-01 4.871804e-01 9.743609e-
erz =
02 5.846165e-01 5.846165e-01
84.7136
erx =
15 -1.953842e+00 3.758970e+00
11.9123
8.051278e-01 2.923083e-01 3.897443e-
01 6.820526e-01 6.820526e-01
erx = ery =
19.9580 8.6438
ery = erz =
2.6611 73.3289
17 -2.181193e+00 4.007973e+00
8.267803e-01 2.598296e-01 3.464394e-
erz =
01 6.062690e-01 6.062690e-01
Soluciones Computacionales a Problemas de Ingeniería
erx = ery =
16.5650 7.2812
ery = erz =
2.2087 63.6984
19 -2.383283e+00 4.229310e+00
8.460269e-01 2.309596e-01 3.079461e-
erz =
01 5.389058e-01 5.389058e-01
169.2033
erx =
18 -2.614242e+00 3.921364e+00
13.9054
3.071212e-01 4.330493e-01 8.660985e-
02 5.196591e-01 5.196591e-01
erx = ery =
9.6908 1.8541
Soluciones Computacionales a Problemas de Ingeniería
120.2577
erx =
20 -2.768215e+00 4.152323e+00
3.841077e-01 3.849327e-01 7.698654e-
02 4.619192e-01 4.619192e-01 11.7781
erx =
ery =
8.0103
1.5704
ery =
erz =
6.1845
90.7311
55.4985
erx =
Soluciones Computacionales a Problemas de Ingeniería
6.7027 1.3398
ery = erz =
5.2884 71.0937
24 -3.026738e+00 4.540107e+00
5.133691e-01 3.041443e-01 6.082887e-
erz =
02 3.649732e-01 3.649732e-01
48.4779
erx =
23 -2.722594e+00 4.600936e+00
5.6627
8.783423e-01 1.824866e-01 2.433155e-
01 4.258021e-01 4.258021e-01
erx = ery =
10.0486 4.5472
ery = erz =
Soluciones Computacionales a Problemas de Ingeniería
42.4384 erx =
ery =
erx =
3.9278
8.6240
erz =
ery =
37.2215
1.1499
27 -2.990691e+00 4.894567e+00
9.038754e-01 1.441869e-01 1.922493e-
erz = 01 3.364362e-01 3.364362e-01
57.1728 erx =
ery = erz =
0.9917 32.6994
29 -3.102837e+00 5.017393e+00
9.145559e-01 1.281662e-01 1.708882e-
erz =
01 2.990544e-01 2.990544e-01
46.8519
erx =
28 -3.231003e+00 4.846504e+00
6.4409
6.155015e-01 2.403116e-01 4.806232e-
02 2.883739e-01 2.883739e-01
erx = ery =
4.1306 0.8588
ery = erz =
3.4059 38.9431
Soluciones Computacionales a Problemas de Ingeniería
ery =
erx =
0.7463
3.5574
erz =
ery =
32.7279
2.9630
32 -3.392397e+00 5.088596e+00
6.961987e-01 1.898758e-01 3.797516e-
erz = 02 2.278510e-01 2.278510e-01
28.7675 erx =
ery =
erx =
Soluciones Computacionales a Problemas de Ingeniería
2.5849 27.7461
34 -3.459909e+00 5.189863e+00
7.299544e-01 1.687785e-01 3.375570e-
erz =
02 2.025342e-01 2.025342e-01
25.3397
erx =
33 -3.291130e+00 5.223619e+00
2.6712
9.324886e-01 1.012671e-01 1.350228e-
01 2.362899e-01 2.362899e-01
erx = ery =
4.8781 2.2603
ery = erz =
0.6504 22.3444
35 -3.369894e+00 5.309883e+00
9.399899e-01 9.001520e-02 1.200203e-
erz =
01 2.100355e-01 2.100355e-01
Soluciones Computacionales a Problemas de Ingeniería
erx = ery =
4.2622 1.9806
ery = erz =
0.5683 19.7218
37 -3.439905e+00 5.386563e+00
9.466577e-01 8.001351e-02 1.066847e-
erz =
01 1.866982e-01 1.866982e-01
23.6895
erx =
36 -3.519919e+00 5.279878e+00
3.7320
7.599595e-01 1.500253e-01 3.000507e-
02 1.800304e-01 1.800304e-01
erx = ery =
2.3260 0.4976
Soluciones Computacionales a Problemas de Ingeniería
20.3434
erx =
38 -3.573261e+00 5.359892e+00
7.866306e-01 1.333559e-01 2.667117e-
02 1.600270e-01 1.600270e-01 3.2739
erx =
ery =
2.0308
0.4365
ery =
erz =
1.7385
17.5539
17.4214
erx =
Soluciones Computacionales a Problemas de Ingeniería
1.7771 0.3836
ery = erz =
1.5284 15.2080
42 -3.662824e+00 5.494236e+00
8.314119e-01 1.053676e-01 2.107352e-
erz =
02 1.264411e-01 1.264411e-01
15.4005
erx =
41 -3.557456e+00 5.515309e+00
1.5581
9.578530e-01 6.322055e-02 8.429407e-
02 1.475146e-01 1.475146e-01
erx = ery =
2.8767 1.3454
ery = erz =
Soluciones Computacionales a Problemas de Ingeniería
13.6228 erx =
ery =
erx =
1.1857
2.5312
erz =
ery =
12.0570
0.3375
45 -3.650336e+00 5.617034e+00
9.666986e-01 4.995204e-02 6.660272e-
erz = 02 1.165548e-01 1.165548e-01
13.2204 erx =
ery = 0.8668
0.0833
0.0167
11.5257
0.0999
x_nuevo =
2.2298
y_nuevo =
5.6004 0.2973
11.5257
Soluciones Computacionales a Problemas de Ingeniería
___________________________________
Punto 2.
Script:
clear
clc
format short
syms x
si=randi(70,300);
uss=randi(40,300);
n=length(si);
X=si(1,1:n);
Y=uss(1,1:n);
n=length(X);
sumaX=0;
sumaY=0;
sumaXY=0;
sumaX2=0;
for i=1:n
sumaX=sumaX+X(i);
sumaY=sumaY+Y(i);
sumaXY=sumaXY+X(i)*Y(i);
sumaX2=sumaX2+X(i)^2;
end
a=double((n*sumaXY-sumaX*sumaY)/(n*sumaX2-sumaX^2));
b=double((sumaY-a*sumaX)/n);
mode=a*x+b;
modef=simplify(mode);
disp('El modelo es:');
disp(modef);
inicio=double(subs(mode,X(1)))
fin=double(subs(mode,X(n)))
minY=min(Y);
maxY=max(Y);
hold off
Soluciones Computacionales a Problemas de Ingeniería
fplot(mode,'b');
hold on
plot(X,Y,'gv');
grid on
title(char(modef))
legend('Modelo');
Prueba de escritorio
El modelo es:
6088566771603465/281474976710656 - (147134860316321*x)/4503599627370496
inicio =
20.3568
fin =
19.8667
_______________________________
Ejercicio 3.
Soluciones Computacionales a Problemas de Ingeniería
Algoritmo
clear
clc
syms x
syms y
format long
syms y(x)
Ea = 0;
Er = 0;
r= 0;
yf = subs(u,xi);
y_sig= yi;
x1 = xi;
syms y
hold off
for i=1:n
k1=double(subs(dydx, [x,y], [xi, yi]));
k2=double(subs(dydx, [x,y], [xi+h/2, yi+((k1*h)/2)]));
k3=double(subs(dydx, [x,y], [xi+h/2, yi+((k2*h)/2)]));
k4=double(subs(dydx, [x,y], [xi+h, yi+k3*h]));
plot(xi,yi,'r*');
hold on
fprintf(' %.1f %.1f %.3f %.3f
%.1f %.1f \n',i,xi,yf,y_sig,Ea,Er);
y_sig=yi+(1/6)*(k1+2*k2+2*k3+k4)*h;
xi=xi+h;
yf = subs(u,xi);
Soluciones Computacionales a Problemas de Ingeniería
yi=y_sig;
Ea = yf-y_sig;
Er = ((yf-y_sig)/yf)*100;
end
fprintf(' %.1f %.1f %.3f %.3f
%.1f %.1f \n',i+1,xi,yf,y_sig,Ea,Er);
plot(xi,yi,'r*');
fplot(u,[x1 xi+h],'b');
grid on
title('Grafica')
Prueba de escritorio
i x yreal ycalc Ea
Er
1.0 2.0 1.000 1.000 0.0
0.0
2.0 2.1 1.221 1.221 0.0
0.0
3.0 2.2 1.486 1.486 0.0
0.0
Soluciones Computacionales a Problemas de Ingeniería
Gráfica
_____________________________________
Ejercicio 4.
Código:
clear
clc
syms x
format long
f=input('digite la funcion')
a=input('digite el limite inferior')
Soluciones Computacionales a Problemas de Ingeniería
sumat=0;
for i=1:n
sumat=sumat+wi(i)*subs(f,(((b-a)/2)*xi(i))+(a+b)/2);
end
vAprox=double(sumat*(b-a)/2);
vReal=double(int(f,a,b));
disp('el valor aproximado es: ' )
disp( vAprox)
disp('el valor real es: ' )
disp(vReal )
errab=double(abs(vReal-vAprox));
errrel=double(abs((vReal-vAprox)*100/vReal));
disp('el error absoluto es: ' );
disp(errab)
disp('el error relativo es: ' );
disp(errrel)
toc
Soluciones Computacionales a Problemas de Ingeniería
X=a:0.01:b;
Y=subs(f,X);
area(X,Y)
Prueba de escritorio
digite la funcion
log(x)+3
f = log(x) + 3
a = 1
b = 3
n = 5