Ejercicios de Metodos Numericos
Ejercicios de Metodos Numericos
Ejercicios de Metodos Numericos
, en torno al eje x.
Si el valor exacto es
I=11.7286.
Calcular el error en cada
caso.
Solucin:
a) REGLA DEL TRAPECIO SIMPLE.
1)
El volumen:
Solucin:
A) LA REGLA DEL TRAPECIO EXTENDIDO:
n=4:
n=3:
n=2:
n=1:
Reporte:
n
integral
error
15.7080
0.2533
12.7627
0.0810
0.667
12.2007
0.0387
0.5
11.9886
0.0218
n=6:
n=4:
3)
Solucin:
Solucin a:
Solucin b:
n=1;a=-1;b=1;i=1;s=0;
a=-1;b=1;
f=inline('exp(-(x^2)/2)/
(power(2*pi,0.5))');
for i=1:11
h=(b-a)/n;
n=2*(i-1);h=(b-a)/n;x=a;s=0;
if(n>1)
while(i<=n-1)
for j=1:n-1
x=a+h;
x=x+h;
s=s+f(x);
i=i+1;
f=1/sqrt(2*pi)*exp(x^2/2);
end
s=f+s;
y=h/2*(f(a)+2*s+f(b))
end
end
fa=1/sqrt(2*pi)*exp(a^2/2);
fb=1/sqrt(2*pi)*exp(b^2/2);
s=h/2*(fa+2*s+fb);
end
Solucin c:
f=inline('exp(-(x^2)/2)/(power(2*pi,0.5))');
h=(b-a)/n;
while(i<=n-1)
x=a+h;
s=s+f(x);
i=i+1;
end
y=5*h/288*(19*f(a)+75*f(a+h)+50*f(a+2*h)+50*f(a+3*h)
+75*f(a+4*h)+19*f(b))
Solucin d:
datos: el numero de puntos (2,3,4,5 o 6) por utilizar N, el limite inferor A y
limite superior B
Hacer (NP(I);I=1,2,,5)=(2,3,4,5,6)
Hacer (IAUX(I);I=1,2,,6)=(1,2,4,6,9,12)
Hacer (Z(I);I=1,2,
,11)=(0.577350269,0.0,0.774596669,0.339981044,0.861136312,0
.0,0.538469310,0.906179846, 0.238619186,
0.661209387,0.932469414).
Hacer
(W(I);I=1,2..,11)=(1,0.0,0.888888888,0.555555555,0.652145155,0.347854
845,0.56888888,
0.478628671, 0.23692885, 0.467913955, 0.360761573, 0.171324493).
Hacer I=1
Mientras I<=5,repetir pasos 7 y 8.
Si N=NP(I),ir al paso 10, de otro modo continuar
Hacer I=I+1
Imprimir N no es 2,3,4,5 o 6y terminar
Hacer S=0
Hacer I=IAUX(I)
Mientras I<= IAUX(I+1)-1,repetir del 13 al 17.
Hacer ZAUX=(Z(J)*(B-A)+B+A)/2.
Hacer S=S+F(ZAUX*W(J))
Hacer ZAUX=(-Z(J)*(B-A)+B+A)/2.
Hacer S=S+F(ZAUX*W(J))
Hacer
J=J+1 y segunda derivada en x=1 para la siguiente tabla:
5) Obtenga
la primera
Hacer AREA(B-A)/2*S
puntos
0
1
IMPRIMIR AREA Y TERMINAR
X
-1
0
F(x)
11
10
23
143
583
6) Resuelva el siguiente:
PVI
Usar:
a) Mtodo de Euler
b) Mtodo de Euler modificado
c) Mtodo de Runge Kutta cuarto orden
Solucin:
a) Mtodo de Euler (n=5):
(n=1):
(n=2):
(n=3):
(n=4):
(n=5):
-Para 5 iteraciones:
(n=1):
(n=2):
(n=3):
(n=4):
(n=5):
7) resuelve el siguiente problema de valor inicial por el mtodo de RungeKutta de cuarto orden:
PVI
PVI
Solucin:
Escribiendo del EDO como un sistema:
Buscando el (P.V.I):
y =z(f1)
z=
..(f2)
y(1) =1
z(1) =2
y(3)= ?
h=0.2
5
Primera iteracin:
k1=f1(x0, y0, z0)=f1 (1, 1,2)
c1= f2(x0, y0, z0)=f2 (1, 1, 2)
k1=2
c1=-2
k2=f1(x0+h/2, y0+hk1/2, z0+hc1/2)
c2=f2(x0+h/2, y0+hk1/2, z0+hc1/2)
k2=f1 (1.125,1.25, 1.75)
c2=f2 (1.125,1.25, 1.75)
k2=1.75
c2=-1.8179
k3=f1(x0+h/2, y0+hk2/2, z0+hc2/2)
c3=f2(x0+h/2, y0+hk2/2, z0+hc2/2)
k3=f1 (1.125,1.2188, 1.7728)
c3=f2 (1.125,1.2188,1.7728)
k3=1.7728
c3=-1.8316
k4=f1(x0+h, y0+hk3, z0+hc3)
c4=f2(x0+h, y0+hk3, z0+hc3)
k4=f1 (1.25, 1.4432, 1.5421)
c4=f2 (1.25, 1.4432, 1.5421)
k4=1.5421
c4=-1.7532
x1 = x0+h = 1.25
Tercera iteracin:
k1=f1(x2, y2, z2)=f1 (1.5, 1.7719, 1.1073)
c1= f2(x2, y2, z2)=f2 (1.5, 1.7719, 1.1073)
k1=1.1073
c1=-1.7226
k2=f1 (x2+h/2, y2+hk1/2, z2+hc1/2)
c2=f2 (x2+h/2, y2+hk1/2, z2+hc1/2)
k2=f1 (1.625,1.9103, 0.8920)
c2=f2 (1.625,1.9103, 0.8920)
k2=0.8920
c2=-1.7358
k3=f1 (x2+h/2, y2+hk2/2, z2+hc2/2)
c3=f2(x2+h/2, y2+hk2/2, z2+hc2/2)
k3=f1 (1.625, 1.8834, 0.8903)
c3=f2 (1.625,1.8834, 0.8903)
k3=0.8903
c3=-1.7180
k4=f1 (x2+h, y2+hk3, z2+hc3)
c4=f2 (x2+h, y2+hk3, z2+hc3)
k4=f1 (1.75, 1.9945, 0.6778)
c4=f2 (1.75, 1.9945, 0.6778)
k4=0.6778
c4=-1.7305
x3 = x2+h = 1.75
y3= y2+h/6 (k1+2*k2+2*k3+k4) = 1.9948
z3= z2 +h/6 (c1+2*c2+2*c3+c4) = 0.6756
Cuarta iteracin:
k1=f1(x3, y3, z3)=f1 (1.75, 1.9948, 0.6756)
c1=-1.7050
k2=f1 (x4+h/2, y4+hk1/2, z4+hc1/2)
c2=f2 (x4+h/2, y4+hk1/2, z4+hc1/2)
k2=f1 (2.125, 2.1405, 0.0322)
c2=f2 (2.125, 2.1405, 0.0322)
k2=0.0322
c2=-1.6816
k3=f1 (x4+h/2, y4+hk2/2, z4+hc2/2)
c3=f2 (x4+h/2, y4+hk2/2, z4+hc2/2)
k3=f1 (2.125, 2.1138, 0.0351)
c3=f2 (2.125, 2.1138, 0.0351)
k3=0.0351
c3=-1.6622
k4=f1 (x4+h, y4+hk3, z4+hc3)
c4=f2 (x4+h, y4+hk3, z4+hc3)
k4=f1 (2.25, 2.1186, -0.1703)
c4=f2 (2.25, 2.1186, -0.1703)
k4=-0.1703
c4=-1.6244
x5 = x4+h = 2.25
y5= y4+h/6 (k1+2*k2+2*k3+k4) = 2.1185
z5= z4 +h/6 (c1+2*c2+2*c3+c4) = -0.1721
Sexta iteracin:
k1=f1(x5, y5, z5)=f1 (2.25, 2.1185, -0.1721)
c1= f2(x5, y5, z5)=f2 (2.25, 2.1185, -0.1721)
k1=-0.1721
c1=-1.6235
k2=f1 (x5+h/2, y5+hk1/2, z5+hc1/2)
..(f2)
y(1) =1
z(1) =2
y(3)=?
x0=1;y0=1;z0=2;xf=3;N=8,I=1;
f1=inline('0*x+0*y+z')
f2=inline('-(z/x)+((1/(x^2))-1)*y')
h=(xf-x0)/N;
while(I<=N)
k1=f1(x0,y0,z0);
c1=f2(x0,y0,z0);
k2=f1(x0+h/2,y0+(h*k1)/2,z0+(h*c1)/2);
c2=f2(x0+h/2,y0+(h*k1)/2,z0+(h*c1)/2);
k3=f1(x0+h/2,y0+(h*k2)/2,z0+(h*c2)/2);
c3=f2(x0+h/2,y0+(h*k2)/2,z0+(h*c2)/2);
k4=f1(x0+h,y0+(h*k3),z0+(h*c3));
c4=f2(x0+h,y0+(h*k3),z0+(h*c3));
x0=x0+h;
y0=y0+(h/6)*(k1+2*k2+2*k3+k4);
z0=z0+(h/6)*(c1+2*c2+2*c3+c4);
I=I+1;
end
y0
8) Resolver:
Solucin:
Datos dados en el enunciado:
n=10
Primera iteracin:
k1=f1(x0, y0, z0)=f1 (0, 0, 1.5)
c1= f2(x0, y0, z0)=f2 (0, 0, 1.5)
k1=1.5
c1=0
k2=f1(x0+h/2, y0+hk1/2, z0+hc1/2)
c2=f2(x0+h/2, y0+hk1/2, z0+hc1/2)
k2=f1 (0.05, 0.075, 1.5)
c2=f2 (0.05, 0.075, 1.5)
k2=1.5
c2=0.075
k3=f1 (x0+h/2, y0+hk2/2, z0+hc2/2)
c3=f2 (x0+h/2, y0+hk2/2, z0+hc2/2)
k3=f1 (0.05, 0.075, 1.5038)
c3=f2 (0.05, 0.075, 1.5038)
k3=1.5038
c3=0.075
k4=f1 (x0+h, y0+hk3, z0+hc3)
c4=f2 (x0+h, y0+hk3, z0+hc3)
k4=f1 (0.1, 0.1504, 1.5075)
c4=f2 (0.1, 0.1504, 1.5075)
k4=1.5075
c4=0.1504
x1 = x0+h = 0.1
y1= y0 +h/6 (k1+2*k2+2*k3+k4) = 0.1503
z1= z0 +h/6 (c1+2*c2+2*c3+c4) = 1.5075
Segunda iteracin:
k1=f1 (x1, y1, z1)=f1 (0.1, 0.1503, 1.5075)
c1= f2 (x1, y1, z1)=f2 (0.1, 0.1503, 1.5075)
k1=1.5075
c1=0.1503
k2=f1 (x1+h/2, y1+hk1/2, z1+hc1/2)
c2=f2 (x1+h/2, y1+hk1/2, z1+hc1/2)
k2=f1 (0.15, 0.2257, 1.5150)
c2=f2 (0.15, 0.2257, 1.5150)
k2=1.5150
c2=0.2257
k3=f1 (x1+h/2, y1+hk2/2, z1+hc2/2)
c3=f2 (x1+h/2, y1+hk2/2, z1+hc2/2)
x2 = x1+h = 0.2
y2= y1+ h/6 (k1+2*k2+2*k3+k4) = 0.3021
z2= z1 + h/6 (c1+2*c2+2*c3+c4) = 1.5301
Tercera iteracin:
k1=f1 (x2, y2, z2)=f1 (0.2, 0.3021, 1.5301)
c1= f2 (x2, y2, z2)=f2 (0.2, 0.3021, 1.5301)
k1=1.5301
c1=0.3021
k2=f1 (x2+h/2, y2+hk1/2, z2+hc1/2)
c2=f2 (x2+h/2, y2+hk1/2, z2+hc1/2)
k2=f1 (0.25, 0.3786, 1.5452)
c2=f2 (0.25, 0.3786, 1.5452)
k2=1.5452
c2=0.3786
k3=f1 (x2+h/2, y2+hk2/2, z2+hc2/2)
c3=f2 (x2+h/2, y2+hk2/2, z2+hc2/2)
k3=f1 (0.25, 0.3794, 1.5490)
c3=f2 (0.25, 0.3794, 1.5490)
k3=1.5490
c3=0.3794
k4=f1 (x2+h, y2+hk3, z2+hc3)
c4=f2 (x2+h, y2+hk3, z2+hc3)
k4=f1 (0.3, 0.4570, 1.5680)
c4=f2 (0.3, 0.4570, 1.5680)
k4=1.5680
c4=0.4570
x3 = x2+h = 0.3
y3= y2+h/6 (k1+2*k2+2*k3+k4) = 0.4569
Cuarta iteracin:
k1=f1(x3, y3, z3)=f1 (0.3, 0.4569, 1.5680)
c1= f2(x3, y3, z3)=f2 (0.3, 0.4569, 1.5680)
k1=1.5680
c1=0.4569
k2=f1 (x3+h/2, y3+hk1/2, z3+hc1/2)
c2=f2 (x3+h/2, y3+hk1/2, z3+hc1/2)
k2=f1 (0.35, 0.5353, 1.5908)
c2=f2 (0.35, 0.5353, 1.5908)
k2=1.5908
c2=0.5353
Sexta iteracin:
k1=f1 (x5, y5, z5)=f1 (0.5, 0.7817, 1.6914)
c1= f2 (x5, y5, z5)=f2 (0.5, 0.7817, 1.6914)
k1=1.6914
c1=0.7817
k2=f1 (x5+h/2, y5+hk1/2, z5+hc1/2)
c2=f2 (x5+h/2, y5+hk1/2, z5+hc1/2)
k2=f1 (0.55, 0.8663, 1.7305)
c2=f2 (0.55, 0.8663, 1.7305)
k2=1.7305
c2=0.8863
k2=1.8266
c2=1.0439
Octava iteracin:
k1=f1(x7, y7, z7)=f1 (0.70, 1.1380, 1.8834)
c1= f2(x7, y7, z7)=f2 (0.70, 1.1380, 1.8834)
k1=1.8834
c1=1.1380
k2=f1 (x7+h/2, y7+hk1/2, z7+hc1/2)
c2=f2 (x7+h/2, y7+hk1/2, z7+hc1/2)
k2=f1 (0.75, 1.2322, 1.9403)
c2=f2 (0.75, 1.2322, 1.9403)
k2=1.9403
c2=1.2322
Novena iteracin:
k1=f1(x8, y8, z8)=f1 (0.80, 1.3323, 2.0068)
c1= f2(x8, y8, z8)=f2(0.80, 1.3323, 2.0068)
k1=2.0068
c1=1.3323
k2=f1 (x8+h/2, y8+hk1/2, z8+hc1/2)
c2=f2 (x8+h/2, y8+hk1/2, z8+hc1/2)
k2=f1 (0.85, 1.4326, 2.0734)
c2=f2 (0.85, 1.4326, 2.0734)
k2=2.0734
c2=1.4326
x9 = x8+h = 0.9
BIBLIOGRAFIA: