Professional Documents
Culture Documents
GRUPO: 4AM1
TAREA 6
INTEGRACIN NUMRICA
PROFESOR:
RAMREZ BARRIOS MIGUEL LUIS
INTRODUCCIN
INTEGRACIN NUMRICA
EJERCICIO 1
Resolver la siguiente Integral, comparando el resultado con los tres mtodos (Mtodo del
Trapecio y las Reglas de Simpson 1/3 y 3/8).
3
e sin x dx
2
CODIFICACIN EN MATLAB
clc
clear all
close all
%INTEGRAL EJERCICIO 1 [exp(sin(x))](TRAPECIO)
a=2;
b=3;
n=3;
h=(b-a)/n;
x=[a:h:b]
N=length(x);
f=exp(sin(x));
f1=f(2:N-1);
suma=sum(f1);
I=(h/2)*(f(1)+2*suma+f(N))
CODIFICACIN EN MATLAB
clc
clear all
close all
%INTEGRAL EJERCICIO 1 [exp(sin(x))](REGLA DE SIMPSON 1/3)
a=2;
b=3;
n=3;
h=(b-a)/n;
x=[a:h:b]
f=exp(sin(x));
N=length(x);
Spar=0;
Simpar=0;
for i=2:2:N-1
Simpar=Simpar+f(i);
end
Simpar
for j=3:2:N-2
Spar=Spar+f(j);
end
Spar
I=(h/3)*(f(1)+4*Simpar+2*Spar+f(N))
CODIFICACIN EN MATLAB
Tabla 1. Comparacin de resultados del Ejercicio 1 con diferente n en los tres mtodos de
aproximacin de la integracin numrica.
n
3
4
6
9
12
18
30
60
1.8192
1.8196
1.8199
1.8200
1.82010
1.82011
1.82012
1.82013
Regla de Simpson
(1/3)
1.3197
1.8200
1.82012
1.6800
1.82013
1.8201382
1.8201383
1.8201383
Regla de Simpson
(3/8)
1.8195
1.4647
1.82010
1.82013
1.8201364
1.8201379
1.820138329
1.820138375
EJERCICIO 2
Resolver la siguiente Integral, comparando el resultado con los tres mtodos (Mtodo del
Trapecio y las Reglas de Simpson 1/3 y 3/8).
0.5
e x dx
2
CODIFICACIN EN MATLAB
clc
clear all
close all
%INTEGRAL EJERCICIO 2 [exp(x.^2)](TRAPECIO)
a=-2;
b=0.5;
n=3;
h=(b-a)/n;
x=[a:h:b]
N=length(x);
f=exp(x.^2);
f1=f(2:N-1);
suma=sum(f1);
I=(h/2)*(f(1)+2*suma+f(N))
CODIFICACIN EN MATLAB
clc
clear all
close all
%INTEGRAL EJERCICIO 2 [exp(x.^2)](REGLA DE SIMPSON 1/3)
a=2;
b=3;
n=3;
h=(b-a)/n;
x=[a:h:b]
f=exp(x.^2);
N=length(x);
Spar=0;
Simpar=0;
for i=2:2:N-1
Simpar=Simpar+f(i);
end
Simpar
for j=3:2:N-2
Spar=Spar+f(j);
end
Spar
I=(h/3)*(f(1)+4*Simpar+2*Spar+f(N))
CODIFICACIN EN MATLAB
Tabla 2. Comparacin de resultados del Ejercicio 2 con diferente n en los tres mtodos de
aproximacin de la integracin numrica.
n
3
4
6
9
12
18
30
60
27.4659
23.3346
19.9952
18.3723
17.7799
17.3483
17.1244
17.0294
Regla de Simpson
(1/3)
19.8567
18.7394
17.5050
16.8261
17.0415
17.0069
16.9989
16.9977
Regla de Simpson
(3/8)
22.1676
18.9886
17.8546
17.2356
17.0856
17.0174
17.0004
16.9978
*En el Mtodo del Trapecio, usando una n=1000, el resultado es: 16.9977
Si la n=2000, el resultado es: 16.9976
EJERCICIO 3
Resolver la siguiente Integral, comparando el resultado con los tres mtodos (Mtodo del
Trapecio y las Reglas de Simpson 1/3 y 3/8).
0.5
3.16
dx
( x+ 3.18)
2
+7
0
CODIFICACIN EN MATLAB
clc
clear all
close all
%INTEGRAL EJEMPLO 3 [(3.16)*((x+3.18).^2+7).^-1](NEWTON-COTES)
a=0;
b=0.5;
n=3;
h=(b-a)/n;
x=[a:h:b]
N=length(x);
f=((3.16)*((x+3.18).^2+7).^-1);
f1=f(2:N-1);
suma=sum(f1);
I=(h/2)*(f(1)+2*suma+f(N))
CODIFICACIN EN MATLAB
clc
clear all
close all
%INTEGRAL EJERCICIO 3 [(3.16)*((x+3.18).^2+7).^-1](REGLA DE SIMPSON 1/3)
a=0;
b=0.5;
n=3;
h=(b-a)/n;
x=[a:h:b]
f=((3.16)*((x+3.18).^2+7).^-1);
N=length(x);
Spar=0;
Simpar=0;
for i=2:2:N-1
Simpar=Simpar+f(i);
end
Simpar
for j=3:2:N-2
Spar=Spar+f(j);
end
Spar
I=(h/3)*(f(1)+4*Simpar+2*Spar+f(N))
CODIFICACIN EN MATLAB
%SIMPSON 3/8 (FOR) EJERCICIO 3 [(3.16)*((x+3.18).^2+7).^-1]
clc
clear all
close all
n=6;
a=0;
b=0.5;
h=(b-a)/n;
f=inline('((3.16)*((x+3.18).^2+7).^-1);');
sum1=0
for x=a+h:3*h:b-2*h
sum1=sum1+f(x);
end
sum2=0;
for x=a+2*h:3*h:b-h
sum2=sum2+f(x);
end
sum3=0;
for x=a+3*h:3*h:b-3*h
sum3=sum3+f(x);
end
I=(3*h/8)*(f(a)+3*sum1+3*sum2+2*sum3+f(b))
Tabla 3. Comparacin de resultados del Ejercicio 3 con diferente n en los tres mtodos de
aproximacin de la integracin numrica.
n
3
4
6
9
12
18
30
60
0.08437195
0.08435826
0.08434848
0.08434414
0.08434262
0.08434153
0.08434097
0.08434074
Regla de Simpson
(1/3)
0.057388239195237
0.084340664998651
0.084340666596875
0.075651491868361
0.084340666970408
0.084340666990520
0.084340666994835
0.084340666995437
Regla de Simpson
(3/8)
0.084340653481830
0.064341407876865
0.084340666106123
0.084340666818156
0.084340666939189
0.084340666984333
0.084340666994031
0.084340666995387
CONCLUSIONES:
Estos Mtodos de Integracin Numrica son aptos cuando tenemos integrales que no se pueden
resolver analticamente, siendo el Mtodo ms eficiente el de Simpson 1/3.