Está en la página 1de 30

UNIVERSIDAD DE LAS FUERZAS

ARMADAS-ESPE
Edisson-Villegas Bryan
Canar
NRC 1823
Departamento de Ciencias Exactas

Docente Mgs. Fabian Ordo nez


16 de febrero de 2015

Metodos Numericos

Tercer Parcial
Deber N:1

1. Sea f ( x ) = csc( x ), con x radianes. Calcule aproximaciones a f 0 (0,6) usando las formu2
4
las de diferencias centradas de orden O(h ) y O(h ) toamando h = 0,1; h = 0,01;
h = 0,001 con diez cifras significativas, calcule el error en cada caso, resuma la infor en una tabla determine el menor error que presenta la mejor aproximacion..

macion
f ( x ) = csc( x )
f 0 ( x ) = csc( x ) cot( x )
f 0 (0,6) = csc(0,6) cot(0,6) = 2,5887105840
Diferencia Centrada O(h2 )
f 0 (x) =

f 1 f 1
2h

Solucion
Manual:
Para h = 0,1
f 0 (0,6) =

csc 2,3 + 0,1 2,3 0,1


= 2,6677965798
2(0,1)

Eab = | 2,5887105840 + 2,6677965798| = 0,0790859958

Para h = 0,01
f 0 (0,6) =

csc(0,6 + 0,01) csc(0,6 0,01)


= 2,5894796165
2(0,01)

Eab = | 2,5887105840 + 2,5894796165| = 0,000769032

Para h = 0,001
f 0 (0,6) =

csc(0,6 + 0,001) csc(0,6 0,001)


= 2,5887182722
2(0,001)

Eab = | 2,5887105840 + 2,5887182722| = 0,0000076882

Metodos Numericos
Tabla de Resultados:
h
0,1
0,01
0,001

f 0 (x)
2,6677965799
2,5894796165
2,5887182722

Error
0,0790859958
0,0007690325
0,0000076882

Analisis:
Se observa que en la diferencias centradas de orden O(h2 ) con h = 0,001 se obtiene

la mejor aproximacion.
Editor:
function [L,n]=DerivadaCent1(f,x,h)
format long
max1=3;
H(1)=h;
D(1)=(subs(f,x,x+h)-subs(f,x,(x-h)))/(2*h);
E(1)=abs(subs(diff(f),x,x)-D(1));
for n=1:2
h=h/10;
H(n+1)=h;
D(n+1)=(subs(f,x,x+h)-subs(f,x,x-h))/(2*h);
E(n+1)=abs(subs(diff(f),x)-D(n+1));
end
while n<max1
h=h/10;
H(n+2)=h;
D(n+2)=(subs(f,x,x+h)-subs(f,x,x-h))/(2*h);
E(n+2)=abs(subs(diff(f),x)-D(n+1));
n=n+1;
end
n=length(D)-1;
fprintf(\tPrimera Derivada Centrada (O(h^2))\n);
fprintf(f(x)=);disp(f);
fprintf(\tPunto:%.2f\n,x)
fprintf(\t\thk\t\t|\t\t Dk \t\t|\t\t Error \t\t \n);
fprintf(\t-------------------------------------------------\n);
for i=1:n
fprintf(\t %.4f \t|\t %.10f \t|\t %.10f \t \n,H(i),D(i),E(i));
end

Metodos Numericos
Command Window:
>> DerivadaCent1(sym(csc(x)),0.6,0.1)
Primera Derivada Centrada (O(h^2))
f(x)=1/sin(x)
Punto:0.60
hk
|
Dk
|
Error
-----------------------------------------0.1000 | -2.6677965799 | 0.0790859958
0.0100 | -2.5894796165 | 0.0007690325
0.0010 | -2.5887182722 | 0.0000076882
Diferencia Centrada O(h4 )
f 0 (x) =

f 2 + 8 f 1 8 f 1 + f 2
12h

Solucion
Manual:
Para h = 0,1

csc(0,6 + 2(0,1)) + 8 csc(0,6 + 0,1) 8 csc(0,6 0,1) + csc(0,6 2(0,1))


12(0,1)
= 2,5787915763
f 0 (0,6) =

Eab = | 2,5887105840 + 2,5787915763| = 0,009919007

Para h = 0,01

csc(0,6 + 2(0,01)) + 8 csc(0,6 + 0,01) 8 csc(0,6 0,01) + csc(0,6 2(0,01))


12(0,01)
= 2,5887097256
f 0 (0,6) =

Eab = | 2,5887105840 + 2,5887097256| = 0,0000000858

Para h = 0,001

csc(0,6 + 2(h)) + 8 csc(0,6 + h) 8 csc(0,6 h) + csc(0,6 2(h))


12(h)
= 2,5887105839
f 0 (0,6) =

Eab = | 2,5887105840 + 2,5887105839| = 0

Metodos Numericos
Tabla de Resultados:
h
0,1
0,01
0,001

f 0 (x)
2,5787915763
2,5887097256
2,5887105839

Error
0,009919007
0,0000000858
0

Analisis:
Se observa que en la diferencias centradas de orden O(h4 ) el error es menor para
los diferentes de valores; es evidente que estas aproxiamciones son mejores que
para las generadas de orden O(h2 ), en especial con h = 0,001.
Editor:
function [L,n]=DerivadaCentO4(f,x,h)
format long
max1=3;
H(1)=h;
D(1)=(-subs(f,x,x+2*h)+8*subs(f,x,x+h)-8*subs(f,x,x-h)
+subs(f,x,x-2*h))/(12*h);
E(1)=abs(subs(diff(f),x,x)-D(1));
for n=1:2
h=h/10;
H(n+1)=h;
D(n+1)=(-subs(f,x,x+2*h)+8*subs(f,x,x+h)-8*subs(f,x,x-h)
+subs(f,x,x-2*h))/(12*h);
E(n+1)=abs(subs(diff(f),x)-D(n+1));
end
while n<max1
h=h/10;
H(n+2)=h;
D(n+2)=(-subs(f,x,x+2*h)+8*subs(f,x,x+h)-8*subs(f,x,x-h)
+subs(f,x,x-2*h))/(12*h);
E(n+2)=abs(subs(diff(f),x)-D(n+1));
n=n+1;
end
n=length(D)-1;
fprintf(\tPrimera Derivada Centrada (Oh4)\n);
disp(f);
fprintf(\tPunto:%.2f\n,x)
fprintf(\t\thk\t\t|\t\t Dk \t\t|\t\t Error \t\t \n);
fprintf(\t-------------------------------------------------\n);
for i=1:n
fprintf(\t %.4f \t|\t %.10f \t|\t %.10f \t \n,H(i),D(i),E(i));
end
5

Metodos Numericos
Command Window:
>> DerivadaCentO4(sym(csc(x)),0.6,0.1)
Primera Derivada Centrada (Oh4)
1/sin(x)
Punto:0.60
hk
|
Dk
|
Error
------------------------------------------0.1000 | -2.5787915764 | 0.0099190077
0.0100 | -2.5887097257 | 0.0000008584
0.0010 | -2.5887105840 | 0.0000000001
2. Sea f ( x ) = esin( x) , realice lo solicitado en el ejercicio anterior para aproximar f 0 (2,3).
f (x) = ex
f 0 (x) = ex
f 0 (2,3) = e2,3 = 9,9741824548
Diferencia Centrada O(h2 )
f 0 (x) =

f 1 f 1
2h

Solucion
Manual:
Para h = 0,1
f 0 (2,3) =

e2,3+0,1 e2,30,1
= 9,9908144060
2(0,1)

Eab = |9,9741824548 9,9908144060| = 0,0166319512


Para h = 0,01
f 0 (2,3) =

e2,3+0,01 e2,30,01
= 9,9743486920
2(0,01)

Eab = |9,9741824548 9,9743486920| = 0,000166237

Para h = 0,001
f 0 (2,3) =

e2,3+0,001 e2,30,001
= 9,9741841171
2(0,001)

Eab = |9,9741824548 9,9741841171| = 0,000001662

Metodos Numericos
Tabla de Resultados:
h
f 0 (x)
0,1 9,9908144060
0,01 9,9743486920
0,001 9,9741841171

Error
0,0166319512
0,0001662372
0,0000016624

Analisis:
Se observa que en la diferencias centradas de orden O(h2 ) con h = 0,001 se

obtiene la mejor aproximacion.


Editor:
function [L,n]=DerivadaCent1(f,x,h)
format long
max1=3;
H(1)=h;
D(1)=(feval(f,x+h)-feval(f,(x-h)))/(2*h);
E(1)=(feval(f,x)-D(1));
for n=1:2
h=h/10;
H(n+1)=h;
D(n+1)=(feval(f,x+h)-feval(f,x-h))/(2*h);
E(n+1)=abs(feval(f,x)-D(n+1));
end
while n<max1
h=h/10;
H(n+2)=h;
D(n+2)=(feval(f,x+h)-feval(f,x-h))/(2*h);
E(n+2)=abs(feval(f,x)-D(n+1));
n=n+1;
end
n=length(D)-1;
fprintf(\tPrimera Derivada Centrada\n);
disp(f);
fprintf(\tPunto:%f\n,x)
fprintf(\t\thk\t\t|\t\t Dk \t\t|\t\t Error \t\t \n);
fprintf(\t-------------------------------------------------\n);
for i=1:n
fprintf(\t %.4f \t|\t %.10f \t|\t %.10f \t \n,H(i),D(i),E(i));
end

Metodos Numericos
Command Window:
>> DerivadaCent1(inline(exp(x)),2.3,0.1)
Primera Derivada Centrada
Inline function:
f(x) = exp(x)
Punto:2.300000
hk |
Dk
| Error
-------------------------------------------0.1000 | 9.9908144060 | 0.0166319512
0.0100 | 9.9743486920 | 0.0001662372
0.0010 | 9.9741841172 | 0.0000016624
Diferencia Centrada O(h4 )
f 0 (x) =

f 2 + 8 f 1 8 f 1 + f 2
12h

Solucion
Manual:
Para h = 0,1
f 0 (2,3) =

e2,3+2(0,1) + 8 e2,3+0,1 8 e2,30,1 + e2,32(0,1)


= 9,9741491679
12(0,1)

Eab = |9,9741824548 9,9741491679| = 0,0000332869

Para h = 0,01
f 0 (2,3) =

e2,3+2(0,01) + 8 e2,3+0,01 8 e2,30,01 + e2,32(0,01)


= 9,9741824515
12(0,01)

Eab = |9,9741824548 9,9741824515| = 0,0000000033

Para h = 0,001
f 0 (2,3) =

e2,3+2(0,001) + 8 e2,3+0,001 8 e2,30,001 + e2,32(0,001)


= 9,9741824548
12(0,001)

Eab = |9,9741824548 9,9741824548| = 0

Metodos Numericos
Tabla de Resultados:
h
f 0 (x)
0,1 9,9741491679
0,01 9,9741824515
0,001 9,9741824548

Error
0,0000332869
0,0000000033
0

Analisis:
Se observa que en la diferencias centradas de orden O(h4 ) el error es menor
para los diferentes de valores; es evidente que estas aproxiamciones son mejores que para las generadas de orden O(h2 ), en especial con h = 0,001.
Editor
function [L,n]=DerivadaCentO4(f,x,h)
format long
max1=3;
H(1)=h;
D(1)=(-feval(f,x+2*h)+8*feval(f,x+h)-8*feval(f,x-h)+feval(f,x-2*h))
/
(12*h);
E(1)=(feval(f,x)-D(1));
for n=1:2
h=h/10;
H(n+1)=h;
D(n+1)=(-feval(f,x+2*h)+8*feval(f,x+h)-8*feval(f,xh)+feval(f,x-2*h))
/(12*h);
E(n+1)=abs(feval(f,x)-D(n+1));
end
while n<max1
h=h/10;
H(n+2)=h;
D(n+2)=(-feval(f,x+2*h)+8*feval(f,x+h)-8*feval(f,xh)+feval(f,x-2*h))
/(12*h);
E(n+2)=abs(feval(f,x)-D(n+1));
n=n+1;
end
n=length(D)-1;
fprintf(\tPrimera Derivada Centrada (Oh4)\n);
disp(f);
fprintf(\tPunto:%f\n,x)
fprintf(\t\thk\t\t|\t\t Dk \t\t|\t\t Error \t\t \n);
fprintf(\t-------------------------------------------------\n);
for i=1:n
fprintf(\t %.4f \t|\t %.10f \t|\t %.10f \t \n,H(i),D(i),E(i));
end
9

Metodos Numericos
Command Window
>> DerivadaCentO4(inline(exp(x)),2.3,0.1)
Primera Derivada Centrada (Oh4)
Inline function:
f(x) = exp(x)
Punto:2.300000
hk |
Dk
| Error
-----------------------------------------0.1000 | 9.9741491679 | 0.0000332869
0.0100 | 9.9741824515 | 0.0000000033
0.0010 | 9.9741824548 | 0.0000000000

3. Usando el desarrollo de Taylor para f ( x + h), f ( x h), f ( x + 2h) y f ( x 2h), deduzca

la formula
de diferencias centradas f (3) ( x ) y f (4) ( x ).
a)

f ( x + 2h) 2 f ( x + h) + 2 f ( x h) f ( x 2h)
2h3

f (3) ( x ) =
Demostracion:

f ( x + h) = f ( x ) + f 0 ( x )h +

f (2) ( x ) h 2
f (3) ( x ) h 3
f (4) ( x ) h 4
f (5) ( x ) h 5
+
+
+
2!
3!
4!
5!

f ( x h) = f ( x ) f 0 ( x )h +

f (3) ( x ) h 3
f (4) ( x ) h 4
f (5) ( x ) h 5
f (2) ( x ) h 2

2!
3!
4!
5!

f (2) ( x ) h 2
f (3) ( x ) h 3
f (4) ( x ) h 4
f (5) ( x ) h 5
f ( x + 2h) = f ( x ) + 2 f ( x )h + 4
+8
+ 16
+ 32
2!
3!
4!
5!
0

f ( x 2h) = f ( x ) 2 f 0 ( x )h + 4

f (3) ( x ) h 3
f (4) ( x ) h 4
f (5) ( x ) h 5
f (2) ( x ) h 2
8
+ 16
32
2!
3!
4!
5!

f ( x + h) f ( x h) = 2 f 0 ( x )h + 2

f (3) ( x ) h 3
f (5) ( c ) h 5
+2
3!
5!

f ( x + 2h) f ( x 2h) = 4 f 0 ( x )h + 16

10

f (3) ( x ) h 3
f (5) ( c ) h 5
+ 64
3!
5!

Metodos Numericos

2 f ( x + h ) + 2 f ( x h ) = 4 f 0 ( x ) h 4
f ( x + 2h) f ( x 2h) = 4 f 0 ( x )h + 16

f (3) ( x ) h 3
f (5) ( c ) h 5
4
3!
5!

f (5) ( c ) h 5
f (3) ( x ) h 3
+ 64
3!
5!

f ( x + 2h) 2 f ( x + h) + 2 f ( x h) f ( x 2h) = 12

f (3) ( x ) =

f (5) ( c ) h 5
f (3) ( x ) h 3
+ 60
6
120

f (5) ( c ) h 2
f ( x + 2h) 2 f ( x + h) + 2 f ( x h) f ( x 2h)

4
2h3
f (3) ( x ) =

f (5) ( c ) h 2
f i +2 2 f i +1 + 2 f i 1 f i 2

4
2h3

b)
f (4) ( x ) =

f ( x + 2h) 4 f ( x + h) + 6 f ( x ) 4 f ( x h) + f ( x 2h)
h4

Demostracion:

f ( x + h) = f ( x ) + f 0 ( x )h +

f (2) ( x ) h 2
f (3) ( x ) h 3
f (4) ( x ) h 4
f (5) ( x ) h 5
f (6) ( x ) h 6
+
+
+
+
2!
3!
4!
5!
6!

f ( x h) = f ( x ) f 0 ( x )h +

f (3) ( x ) h 3
f (4) ( x ) h 4
f (5) ( x ) h 5
f (6) ( x ) h 6
f (2) ( x ) h 2

+
2!
3!
4!
5!
6!

f ( x + 2h) = f ( x ) + 2 f 0 ( x )h + 4

f (2) ( x ) h 2
f (3) ( x ) h 3
f (4) ( x ) h 4
f (5) ( x ) h 5
f (6) ( x ) h 6
+8
+ 16
+ 32
+ 64
2!
3!
4!
5!
6!

f ( x 2h) = f ( x ) 2 f 0 ( x )h + 4

f (2) ( x ) h 2
f (3) ( x ) h 3
f (4) ( x ) h 4
f (5) ( x ) h 5
f (6) ( x ) h 6
8
+ 16
32
+ 64
2!
3!
4!
5!
6!

f ( x + h) + f ( x h) = 2 f ( x ) + 2

f ( x + 2h) + f ( x 2h) = 2 f ( x ) + 8

f (2) ( x ) h 2
f (4) ( x ) h 4
f (6) ( c ) h 6
+2
+2
2!
4!
6!

f (2) ( x ) h 2
f (4) ( x ) h 4
f (6) ( c ) h 6
+ 32
+ 128
2!
4!
6!

11

Metodos Numericos

4 f ( x + h ) 4 f ( x h ) = 8 f ( x ) 8

f ( x + 2h) + f ( x 2h) = 2 f ( x ) + 8

f (2) ( x ) h 2
f (4) ( x ) h 4
f (6) ( c ) h 6
8
8
2!
4!
6!

f (2) ( x ) h 2
f (4) ( x ) h 4
f (6) ( c ) h 6
+ 32
+ 128
2!
4!
6!

f (6) ( c ) h 6
f (4) ( x ) h 4
+ 120
f ( x + 2h) 4 f ( x + h) 4 f ( x h) + f ( x 2h) = 6 f ( x ) + 24
24
720

f (4) ( x ) =

f ( x + 2h) 4 f ( x + h) + 6 f ( x ) 4 f ( x h) + f ( x 2h)
f (6) ( c ) h 2

6
h4
f (4) ( x ) =

f i +2 4 f i +1 + 6 f i 4 f i 1 + f i 2
f (6) ( c ) h 2

6
h4

4. Determinar las aproximaciones centradas, regresivas y progresivas de orden O(h2 ) a

f 0 ( xk ) en cada uno de los cuantro puntos de la siguiente tabla, presente la informacion


calculada y resumida en una tabla.
x
0,00
0,10
0,20
0,30

f (x)
0,98992
0,999135
0,998295
0,987480

Aproximaciones Centradas:
Se pueden utilizar aproximaciones centradas con los puntos 0.10 y 0.20; debido a
que solo estos possen un punto anterior y posterior, de la siguiente manera:
f 0 (x) =

f 1 f 1
2h

f (0,20) f (0,00)
0,998295 0,98992
=
= 0,041875
2(0,10)
2(0,1)
f (0,30) f (0,10)
0,987480 0,999135
f 0 (0,20) =
=
= 0,058275
2(0,10)
2(0,1)
f 0 (0,10) =

12

Metodos Numericos
Aproximaciones Progresivas:

3 f 0 + 4 f 1 f 2
2h

f 0 (x) =
f 0 (0,00) =

3(0,98992) + 4(0,99135) 0,998295


= 0,142425
2(0,1)

f 0 (0,10) =

3(0,999135) + 4(0,998295) 0,987480


= 0,041475
2(0,1)

Aproximaciones Regresivas:
f 0 (x) =

3 f 0 4 f 1 + f 2
2h

f 0 (0,20) =

3(0,998295) 4(0,999135) + 0,98992


= 0,058675
2(0,1)

f 0 (0,30) =

3(0,987480) 4(0,998295) + 0,999135


= 0,158025
2(0,1)

Tabla de Resultados:
x
0,00
0,10
0,20
0,30

Aprox.Centradas Aprox.Progresivas

0,142425
0,041875
0,041475
0,058275

Aprox.Regresivas

0,058675
0,158025

Editor:
function DifAp(x,fx)
n=length(x);
m=length(fx);
D(n,3)=0;
Dc(n)=0;
Dp(n)=0;
Dr(n)=0;
if n~=m
fprintf(Longitud de los valores no corresponde.\n);
return
end
h=x(2)-x(1);
D(n,3)=0;
%Aproximacion Centrada
for i=2:n-1
Dc(i)=(fx(i+1)-fx(i-1))/(2*h);
end
%Aproximacion Progresiva
13

Metodos Numericos

for i=1:n-2
Dp(i)=(-3*fx(i)+4*fx(i+1)-fx(i+2))/(2*h);
end
%Aproximacion Regresiva
for i=3:n
Dr(i)=(3*fx(i)-4*fx(i-1)+fx(i-2))/(2*h);
end
fprintf(|x| f(x)|Dif. Centradas|Dif. Progresivas|Dif. Regresivas|\n);
fprintf(-----------------------------------------------------\n);
for i=1:n
fprintf(%.2f\t %f \t,x(i),fx(i));
if Dc(i)==0
fprintf(\t\t---------\t);
else fprintf(\t\t%.6f\t,Dc(i));
end
if Dp(i)==0
fprintf(\t\t---------\t);
else fprintf(\t\t%.6f,Dp(i));
end
if Dr(i)==0
fprintf(\t\t--------\n);
else fprintf(\t%.6f\n,Dr(i));
end
end
end
Command Window:
>> DifAp([0.00 0.10 0.20 0.30],[0.98992 0.999135 0.998295 0.987480])
|
x
|
f(x)
| Dif. Centradas | Dif. Progresivas | Dif. Regresivas|
---------------------------------------------------------------------------0.00
0.989920
--------0.142425
-------0.10
0.999135
0.041875
0.041475
-------0.20
0.998295
-0.058275
---------0.058675
0.30
0.987480
-----------------0.158025

14

Metodos Numericos

5. Calcule cada una de las siguientes integrales, utilizando los codigos


compuestos estudiados(Trapecio,Simpson y Punto Medio). Ademas, analice el error absoluto.
a)

Z 1
1
Z 1
1

(1 + x2 )1 dx
(1 + x2 )1 dx = arctan(1) arctan(1) = 1,5707963267

Trapecio:
Command Window:
>> It=intt(-1,1,200,inline((1+x.^2).^(-1)))
El valor por el Metodo de Trapecio es:
It =
1.570787993461564
Err ab = |1,5707963267 1,5707879934| = 0,000008333

Punto Medio:
Command Window:
>> Ir=intr(-1,1,200,inline((1+x.^2).^(-1)))
El valor por el Metodo del Punto Medio es:
Ir =
1.570787993461564
Err ab = |1,5707963267 1,5707879934| = 0,000008333

Simpson: Command Window:


>> Isc=Intsimpson(-1,1,200,inline((1+x.^2).^(-1)))
El valor por el Metodo de Simpson es:
Isc =
1.570796326794896
Err ab = |1,5707963267 1,5707963267| = 0

15

Metodos Numericos

b)

Z 1
0

Z 1
0

x (sin( x ))dx
1 Z
x (sin( x ))dx = x (cos( x )) 0 +

1
0

1
cos( x )dx = ( x (cos( x )) + sin( x )) 0

( cos(1) + sin(1)) sin(0) = 0,3011686789

Trapecio: Command Window:


>> It=intt(0,1,200,inline(x*sin(x)))
El valor por el Metodo de Trapecio es:
It =
0.301171557636773
Err ab = |0,3011686789 0,3011715576| = 0,0000002878

Punto Medio: Command Window:


>> Ir=intr(0,1,200,inline(x*sin(x)))
El valor por el Metodo del Punto Medio es:
Ir =
0.303275235098793
Err ab = |0,3011686789 0,3032752350| = 0,002106556

Simpson: Command Window:


>> Isc=Intsimpson(0,1,200,inline(x*sin(x)))
El valor por el Metodo de Simpson es:
Isc =
0.301168678939092
Err ab = |0,3011686789 0,3011686789| = 0

16

Metodos Numericos

c)

Z
0

cos( x )e x dx

u = cos( x ); dv = e x
du = sin( x ); v = e x
Z
0

cos( x )e x dx = cos( x )e x

u = sin( x ); dv = e x
du = cos( x ); v = e x
Z
0

Z
0

Z
0

Z
0

e x sin( x )

cos( x )e x dx = x cos( x )e x + e x sin( x )


cos( x )e x dx =
cos( x )e x dx =

cos( x )ex

Z
0

e x cos( x )

+ ex sin( x )

cos( )e + e sin( ) + cos(0)e0 e0 sin(0)


= 0,5216069591
2

Trapecio: Command Window:


>> It=intt(0,pi,200,inline(cos(x)*exp(-x)))
El valor por el Metodo de Trapecio es:
It =
0.521628409534720
Err ab = |0,5216069591 0,5216284095| = 0,00002145

Punto Medio:
>> Ir=intr(0,pi,200,inline(cos(x)*exp(-x)))
El valor por el Metodo del Punto Medio es:
Ir =
0.513435026580370
Err ab = |0,5216069591 0,5134350265| = 0,008171932

Simpson:
El valor por el Metodo de Simpson es:
Isc =
0.521606959087782
Err ab = |0,5216069591 0,5216069590| = 0

17

Metodos Numericos
Tabla de Resultados:
f(x)
(1 + x 2 ) 1
x sin( x )
cos( x )e x

[a,b]
[1, 1]
[0, 1]
[0, ]

Trapecio
Punto Medio Simpson
0,000008333
0,000008333
0
0,0000002878 0,002106556
0
0,00002145
0,008171932
0

6. La longitud de una curva y = f ( x ) definida sobre un intervalo [ a, b] viene dado por:

L=

Z bq
a

1 + ( f 0 ( x ))2 dx

que se obtiene al girar alrededor del


El a rea de la superficie del solido
de revolucion
limitada por la curva y = f ( x ) y el intervalo [ a, b] viene dada por:
eje OX la region
S = 2

Z b
a

f (x)

1 + ( f 0 ( x ))2 dx

de las curvas dadas, utilizando el


Calcular la longitud y la superficie de revolucion

codigo
compuesto del punto medio. Analice el error y realice las graficas respectivas
y de la superficie del solido

de la funcion
de revolucion.
x
a) f ( x ) = e x sin( ) para x [0, 1]
2
x
e x cos( )
x
2
f 0 ( x ) = e x sin( ) +
2
2
Longitud:

L=

v
u
Z 1u
t
0

x
e x cos( )
x
2 )2 dx = 1,0255312361
1 + (e x sin( ) +
2
2

Editor:
function intr2(a,b,n,f)
dx=diff(f);
L=sqrt(1+(dx).^2);
h=(b-a)/n;
Long=0;
for i=1:n
x=a+h*i;
Long=Long+subs(L,x,x);
end
18

Metodos Numericos

Long=h*Long;
fprintf(El valor aproximado de la longitud es:%.10f\n,Long);
x=a:0.01:b;
y=subs(f,x,x);
hold on
plot(x,y);
grid on
xlabel(X),ylabel(Y);
title(Grafica de la funcion)
Command Window:
>> intr2(0,1,200,sym(exp(-x)*sin(x/2)))
El valor aproximado de la longitud es:1.0252373681
Grafica:

Error:
Err ab = |1,0255312361 1,0252373681| = 0,000293868
Ere =

|1,0255312361 1,0252373681|
= 0,000286551
|1,0255312361|
19

Metodos Numericos
Superficie:
v
u
x
u
Z 1
e x cos( )
t
x
x
2 )2 dx = 0,8261269128
S = 2
e x sin( ) 1 + (e x sin( ) +
2
2
2
0
Editor:
function intr3(a,b,n,f)
dx=diff(f);
S=f*sqrt(1+(dx).^2);
h=(b-a)/n;
Sup=0;
for i=1:n
x=a+h*i;
Sup=Sup+subs(S,x,x);
end
Sup=2*pi*h*Sup;
fprintf(El valor aproximado de la superficie es:%.10f\n,Sup);
x=a:0.01:b;
y=subs(f,x,x);
cylinder(y),xlabel(Z),ylabel(Y),zlabel(X),axis square;
hold on
grid on
title(Grafica de la Superficie de Revolucion)
Command Window:
>> intr3(0,1,200,sym(exp(-x)*sin(x/2)))
El valor aproximado de la superficie es:0.8288901418
Error:
Err ab = |0,8261269128 0,8288901418| = 0,002763229
Ere =

|0,8261269128 0,8288901418|
= 0,003344799
|0,8261269128|

20

Metodos Numericos
Grafica:

b) g( x ) = sin( x ) cos(2x ) para x [0,

]
4

g0 ( x ) = cos( x ) cos(2x ) 2 sin(2x )sin( x )


Longitud:

L=

Z q

1 + (cos( x ) cos(2x ) 2 sin(2x )sin( x ))2 dx = 0,985814099793

Editor:
function intr2(a,b,n,f)
dx=diff(f);
L=sqrt(1+(dx).^2);
h=(b-a)/n;
21

Metodos Numericos

Long=0;
for i=1:n
x=a+h*i;
Long=Long+subs(L,x,x);
end
Long=h*Long;
fprintf(El valor aproximado de la longitud es:%.10f\n,Long);
x=a:0.01:b;
y=subs(f,x,x);
hold on
plot(x,y);
grid on
xlabel(X),ylabel(Y);
title(Grafica de la funcion)
Command Window:
>> intr2(0,pi/4,200,sym(sin(x)*cos(2*x)))
El valor aproximado de la longitud es:0.9864411396
Grafica:

22

Metodos Numericos
Error:
Err ab = |0,985814099793 0,9864411396| = 0,000627039
Errre =

|0,985814099793 0,9864411396|
= 0,000636062
|0,985814099793|

Superficie:
S = 2

Z
0

4 sin( x ) cos(2x )

1 + (cos( x ) cos(2x ) 2 sin(2x )sin( x ))2 dx = 1,0151907524

Editor:
function intr3(a,b,n,f)
dx=diff(f);
S=f*sqrt(1+(dx).^2);
h=(b-a)/n;
Sup=0;
for i=1:n
x=a+h*i;
Sup=Sup+subs(S,x,x);
end
Sup=2*pi*h*Sup;
fprintf(El valor aproximado de la superficie es:%.10f\n,Sup);
x=a:0.01:b;
y=subs(f,x,x);
cylinder(y),xlabel(Z),ylabel(Y),zlabel(X),axis square;
hold on
grid on
title(Grafica de la Superficie de Revolucion)
Command Window:
> intr3(0,pi/4,200,sym(sin(x)*cos(2*x)))
El valor aproximado de la superficie es:1.0151595546
Error:
Err ab = |1,0151907524 1,0151595546| = 0,000031197
Ere =

|1,0151907524 1,0151595546|
= 0,00003073
|1,0151907524|

23

Metodos Numericos
Grafica:

c) h( x ) = x3 cosh( x ) para x [0, 1]


h0 ( x ) = 3x2 cosh( x ) + x3 sinh( x )
Longitud:
L=

Z 1q
0

1 + (3x2 cosh( x ) + x3 sinh( x ))2 dx = 2,0436298070

Editor:
function intr2(a,b,n,f)
dx=diff(f);
L=sqrt(1+(dx).^2);
h=(b-a)/n;
Long=0;
for i=1:n
x=a+h*i;
Long=Long+subs(L,x,x);
24

Metodos Numericos

end
Long=h*Long;
fprintf(El valor aproximado de la longitud es:%.10f\n,Long);
x=a:0.01:b;
y=subs(f,x,x);
hold on
plot(x,y);
grid on
xlabel(X),ylabel(Y);
title(Grafica de la funcion)
Command Window:
>> intr2(0,1,200,sym(x^3*cosh(x)))
El valor aproximado de la longitud es:2.0558913456
Error:
Err ab = |2,0436298070 2,0558913456| = 0,0122615386
Ere =

|2,0436298070 2,0558913456|
= 0,005999882
|2,0436298070|

Grafica:

25

Metodos Numericos
Superficie:
S = 2

Z 1
0

x cosh( x )

1 + (3x2 cosh( x ) + x3 sinh( x ))2 dx

Editor:
function intr3(a,b,n,f)
dx=diff(f);
S=f*sqrt(1+(dx).^2);
h=(b-a)/n;
Sup=0;
for i=1:n
x=a+h*i;
Sup=Sup+subs(S,x,x);
end
Sup=2*pi*h*Sup;
fprintf(El valor aproximado de la superficie es:%.10f\n,Sup);
x=a:0.01:b;
y=subs(f,x,x);
cylinder(y),xlabel(Z),ylabel(Y),zlabel(X),axis square;
hold on
grid on
title(Grafica de la Superficie de Revolucion)
Command Window:
>> intr3(0,1,200,sym(x^3*cosh(x)))
El valor aproximado de la superficie es:8.0062060679
Error:
Err ab = |7,8626386306 8,0062060679| = 0,1435674373
Ere =

|7,8626386306 8,0062060679|
= 0,0182594475
|2,0436298070|

26

Metodos Numericos
Grafica:

7. Determine un valor aproximado del Ln(2) aplicando las formulas


compuestas anali del error relativo. Presente los datos en
zadas y obtenga en cada caso una estimacion
una tabla de resumen.

Z 1
0

dx
x+1

Valor Real:
ln(2) = 0,6931471805
Para 5 nodos:
x
f (x)
0
1
0,25
0,8
0,5 0,666666667
0,75 0,571428571
1
0,5
27

Metodos Numericos
Trapecio Compuesto:
n=4
h=

1
4

41
h
dx
= ( f ( a) + f (b)) + h f ( xi )
2
0 x+1
i =1
h
= ( f ( x0 ) + f ( x4 )) + h( f ( x1 ) + f ( x2 ) + f ( x3 ))
2

Z 1

h
= ( f (0) + 2 f (0,25) + 2 f (0,5) + 2 f (0,75) + f (1))
2
0,25
=
(1 + 2(0,8) + 2(0,666667) + 2(0,571428571) + 0,5) = 0,6970238095
2
Error:
Ere =

|0,6931471805 0,6970238095|
= 0,005592793
|0,6931471805|

Editor:
function intt(a,b,n,f)
re=log(2);
format long
h=(b-a)/n;
It=0;
for i=1:n-1
x=a+h*i;
It=It+f(x);
end
It=h*(f(a)+f(b))/2+h*It;
err=abs(re-It)/abs(re);
fprintf(El valor por el Metodo de Trapecio es:%.10f\n,It);
fprintf(El error relativo es:%.10f\n,err)
Command Window:
>> intt(0,1,5,inline(1/(x+1)))
El valor por el Metodo de Trapecio es:0.6956349206
El error relativo es:0.0035890503

28

Metodos Numericos
Simpson Compuesto:
Para conseguir 5 nodos, se toma n = 2.
h
2h 21
dx
4h 2
= ( f ( a) + f (b)) +
f
(
x
i
)
+
2
f (x2i1 )
3
3 i
3
0 x+1
=1
i =1
2h
4h
h
= ( f ( x0 ) + f ( x1 )) + ( f ( x2 ) + f ( x4 )) + ( f ( x1 ) + f ( x3 )))
3
3
3
h
= ( f0 + 4 f1 + 2 f2 + 4 f3 + f4 )
3
0,25
=
(1 + 4(0,8) + 2(0,6666666667) + 4(0,5714285714) + 0,5) = 0,6932539682
3
Z 1

Error:

|0,6931471805 0,6932539682|
= 0,0001540620
|0,6931471805|
Editor:
Ere =

function Intsimpson(a,b,n,f)
re=log(2);
format long
h=(b-a)/(2*n);
Sp=0;
Si=0;
for i=1:n
x=a+h*(2*i-1);
Si=Si+f(x);
end
for i=1:n-1
x=a+h*2*i;
Sp=Sp+f(x);
end
Isc=h/3*(f(a)+f(b)+4*Si+2*Sp);
err=abs(re-Isc)/abs(re);
fprintf(El valor por el Metodo de Simpson es:%.10f\n,Isc);
fprintf(El error relativo es:%.10f\n,err)
Command Window:
>> Intsimpson(0,1,5,inline(1/(x+1)))
El valor por el Metodo de Simpson es:0.6931502307
El error relativo es:0.0000044004

29

Metodos Numericos
Tabla de Resultados(Manual):
Metodo Compuesto
Valor
Trapecio
0,6970238095
simpson
0,6932539682

Error
0,005592793
0,0001540620

Tabla de Resultados(Matlab):
Metodo Compuesto
Valor
Trapecio
0,6956349206
simpson
0,6931502307

Error
0,0035890503
0,0000044004

Es notable por los resultados del error que el metodo mas factible sera el compuesto de Simpson.

30

También podría gustarte