Sie sind auf Seite 1von 17

Departamento de Ciencias Exactas

Andres Suarez
Area: Analisis Funcional

Trabajo de Metodos Numericos

NRC: 4438
7 de agosto de 2016

1
METODOS NUMERICOS

1. Sea f (x) = xsen(x), con x en radianes. Calcule aproximaciones f 0 ( 4 ) usando


las formulas de diferencias centradas de orden O(h2 ) y O(h4 ) tomando h=0.1,
h=0.01 y h=0.001 con diez cifras significativas, calcule el error en cada caso,
resuma la informacion en una tabla y determine el menor error que representa
la mayor aproximacion.
Solucion:
f (x) = xsen(x)
f 0 (x) = sen(x) + xcos(x) evaluando en x = 4 es 1,262467148
Para orden O(h2 ):
f1 f1
f 0 (x) = 2h

Entonces se procede a calcular los respectivos valores de f1 = f (x + h) y f1 = f (x h):

f ( 4 + 0,1) = 0,6854461094

f ( 4 + 0,01) = 0,5680275344

f ( 4 + 0,001) = 0,5566232634

f ( 4 0,1) = 0,4338442251

f ( 4 0,01) = 0,5427790836

f ( 4 0,001) = 0,55409833
0,68544610940,4338442251
f 0 (x) = 20,1
= 1,258009422
0,56802753440,5427790836
f 0 (x) = 20,01
= 1,26242254
0,55662326340,55409833
f 0 (x) = 20,001
= 1,2624667

Para orden O(h4 ):


f2 +8f1 8f1 +f2
f 0 (x) = 12h

Entonces se procede a calcular los respectivos valores de f1 = f (x+h),f1 = f (xh),f2 =


f (x + 2h) y f2 = f (x 2h):

Los valores f1 y f1 ya fueron calculados previamente.

f ( 4 + 2 0, 1) = 0,821321638

f ( 4 + 2 0, 01) = 0,5807778969

Andres Suarez 2
METODOS NUMERICOS

f ( 4 + 2 0, 001) = 0,5578870157

f ( 4 2 0, 1) = 0,3234508037

f ( 4 2 0, 01) = 0,53028633486

f ( 4 2 0, 001) = 0,5528371542
0,821321638+80,685446109480,4338442251+0,3234508037
f 0 (x) = 120,1
= 1,262453533
0,5807778969+80,568027534480,5427790836+0,53028633486
f 0 (x) = 120,01
= 1,262467036
0,5578870157+80,556623263480,55409833+0,5528371542
f 0 (x) = 120,001
= 1,262467142

Presentando todos los valores resumidos en una tabla tenemos:


h f 0 (x)Oh2 f 0 (x)Oh4 Error Oh2 Error Oh4
0,1 1.258009422 1.262453533 0.0035309639 0.0000107844
0,01 1.26242254 1.262467036 0.0000353339 0.0000000887
0,001 1.2624667 1.262467142 0.0000003548 0.0000000047
Por lo tanto el valor con menor error y por ende mejor aproximacion es h = 0, 001 con
orden de aproximacion Oh4 .

2. Sea f (x) = xex , realice lo solicitado en el ejercicio anterior para aproximar


f 0 (1,2).
Solucion:
f (x) = xex
f 0 (x) = ex xex evaluado en x = 1,2 es 0,06023884238.

Para orden O(h2 ):


f1 f1
f 0 (x) = 2h

Entonces se procede a calcular los respectivos valores de f1 = f (x + h) y f1 = f (x h):

f (1,2 + 0, 1) = 0,3542913309

f (1,2 + 0, 01) = 0,3608187081

f (1,2 + 0, 001) = 0,3613726951

f (1,2 0, 1) = 0,3661581921

f (1,2 0, 01) = 0,3620233042

f (1,2 0, 001) = 0,3614931726

Andres Suarez 3
METODOS NUMERICOS

0,35429133090,3661581921
f 0 (x) = 20,1
= 0,059334306
0,36081870810,3620233042
f 0 (x) = 20,01
= 0,060229805
0,36137269510,3614931726
f 0 (x) = 20,001
= 0,06023875

Para orden O(h4 ):


f2 +8f1 8f1 +f2
f 0 (x) = 12h

Entonces se procede a calcular los respectivos valores de f1 = f (x+h),f1 = f (xh),f2 =


f (x + 2h) y f2 = f (x 2h):

Los valores f1 y f1 ya fueron calculados previamente.

f (1,2 + 2 0, 1) = 0,3452357495

f (1,2 + 2 0, 01) = 0,3601808036

f (1,2 + 2 0, 001) = 0,3613120954

f (1,2 2 0, 1) = 0,3678794412

f (1,2 2 0, 01) = 0,3625889115

f (1,2 2 0, 001) = 0,3615530493


0,3452357495+80,354291330980,3661581921+0,3678794412
f 0 (x) = 120,1
= 0,06024266492
0,3601808036+80,360818708180,3620233042+0,3625889115
f 0 (x) = 120,01
= 0,06023884083
0,3613120954+80,361372695180,3614931726+0,3615530493
f 0 (x) = 120,001
= 0,06023884167

Presentando todos los valores resumidos en una tabla tenemos:


h f 0 (x)Oh2 f 0 (x)Oh4 Error Oh2 Error Oh4
0,1 -0.059334306 -0.06024266492 0,01501583271 0.0000634564
0,01 -0.060229805 -0.06023884083 0.0001500258 0.0000000257
0,001 -0.06023875 -0.06023884167 0.0000015335 0.0000000117
Por lo tanto el valor con menor error y por ende mejor aproximacion es h = 0, 001 con
orden de aproximacion Oh4 .

3. Deduzca la formula de cuadratura cerrada de Simpson 3/8 y de Boole


Solucion:

Andres Suarez 4
METODOS NUMERICOS

Para Simpson 3/8:


Una funcion f (x) puede ser aproximada por un polinomio interpolador de Lagrange
as:
f (x) = Pn (x) = m
P
k=0 Lm,k (x)fk

Si integramos se obtiene:
R xm Rx P
x0
f (x)dx = x0m [ Lm,k (x)fk ]dx
R xm
= m
P
( L (x)fk dx)
Pk=0
m Rxx0m m,k
= k=0 ( x0 Lm,k (x)dx)fk
En nuestro caso, m = 3 tenemos:
R x3 P3 R x3
x0
f (x)dx = k=0 ( x0 L3,k (x)dx)fk
R x3 (xx 1 )(xx2 )(xx3 )dx
R x (xx0 )(xx2 )(xx3 )dx
= f0 x0 (x0 x1 )(x0 x2 )(x0 x3 ) + f1 x03 (x 1 x0 )(x1 x2 )(x1 x3 )
+
R x3 (xx0 )(xx1 )(xx3 )dx R x3 (xx )(xx )(xx )dx
f2 x0 (x2 x0 )(x2 x1 )(x2 x3 ) + f3 x0 (x3 x00 )(x3 x1 2
1 )(x3 x2 )

Realizando el siguiente reemplazo tenemos:


x = x0 + ht
Cuya derivada es dx = hdt en donde los nuevos l?mites de integracion ser?n t = 0 y
t = 3.Como los nodos son equiespaciados, podemos reemplazar as?:
xi xj = (i j)h y x xi = (t i)h
R3 R3 R3
= f0 0 (t1)h(t2)h(t3)h(hdt)
(h)(2h)(3h)
+ f1 0 (t)h(t2)h(t3)h(hdt)
(h)(h)(2h)
+ f2 0 (t)h(t1)h(t3)h(hdt)
(2h)(h)(h)
+
R3
f3 0 (t)h(t1)h(t2)h(hdt)
(3h)(2h)(h)
R3 R3 R3
= h6 f0 0
(t 1)(t 2)(t 3)dt + h2 f1 0 (t)(t 2)(t 3)dt h2 f2 0 (t)(t 1)(t
R3
3)dt + h6 f3 0 (t)(t 1)(t 2)dt

= h6 f0 ( 94 ) + h2 f1 ( 94 ) h2 f2 ( 49 ) + h6 f3 ( 94 )
3h 9h 9h 3h
= f
8 0
+ f
8 1
+ f
8 2
+ f
8 3
3h
= 8
(f0 + 3f1 + 3f2 + f3 ) lqqd

Para Boole:
Una funcion f (x) puede ser aproximada por un polinomio interpolador de Lagrange
as?:
f (x) = Pn (x) = m
P
k=0 Lm,k (x)fk

Si integramos se obtiene:
R xm Rx P
x0
f (x)dx = x0m [ Lm,k (x)fk ]dx
Rx
= m ( x0m Lm,k (x)fk dx)
P
k=0 R xm
= m
P
k=0 ( x0 Lm,k (x)dx)fk

Andres Suarez 5
METODOS NUMERICOS

En nuestro caso, m = 4 tenemos:


R x4 Rx
f (x)dx = 4k=0 ( x04 L4,k (x)dx)fk
P
x0
Rx R x4 (xx0 )(xx2 )(xx3 )(xx4 )dx
= f0 x04 (x(xx 1 )(xx2 )(xx3 )(xx4 )dx
0 x1 )(x0 x2 )(x0 x3 )(x0 x4 )
+ f 1 (x1 x0 )(x1 x2 )(x1 x3 )(x1 x4 )
+
R x4 (xx 0 )(xx1 )(xx3 )(xx4 )dx
R xx40 (xx 0 )(xx1 )(xx2 )(xx4 )dx
f2 x0 (x2 x0 )(x2 x1 )(x2 x3 )(x2 x4 ) + f3 x0 (x3 x0 )(x3 x1 )(x3 x2 )(x3 x4 ) +
Rx
f4 x04 (x(xx 0 )(xx1 )(xx2 )(xx3 )dx
4 x0 )(x4 x1 )(x4 x2 )(x4 x3 )

Realizando el siguiente reemplazo tenemos:


x = x0 + ht
Cuya derivada es dx = hdt en donde los nuevos l?mites de integracion ser?n t = 0 y
t = 4.Como los nodos son equiespaciados, podemos reemplazar as?:
xi xj = (i j)h y x xi = (t i)h
R4 R4
= f0 0 (t1)h(t2)h(t3)h(t4)h(hdt)
(h)(2h)(3h)(4h)
+ f1 0 (t)h(t2)h(t3)h(t4)h(hdt)
(h)(h)(2h)(3h)
+
R 4 (t)h(t1)h(t3)h(t4)h(hdt) R 4 (t)h(t1)h(t2)h(t4)h(hdt)
f2 0 (2h)(h)(h)(2h)
+ f3 0 (3h)(2h)(h)(h)
+
R 4 (t)h(t1)h(t2)h(t3)h(hdt)
f4 0 (4h)(3h)(2h)(h)

h
R4 R4 R4
= 24 f0 0 (t 1)(t 2)(t 3)(t 4)dt h6 f1 0 (t)(t 2)(t 3)(t 4)dt + h4 f2 0 (t)(t
R4 R4
1)(t 3)(t 4)dt h6 f3 0 (t)(t 1)(t 2)(t 4)dt + 24h
f4 0 (t)(t 1)(t 2)(t 3)dt
h
= f ( 112 )
24 0 15
h6 f1 ( 128
15
) + h4 f2 ( 32
15
) h6 f3 ( 128
15
)+ h
f ( 112 )
24 4 15

14h 64h 8h 64h 14h


= f
45 0
+ f
45 1
+ f
15 2
+ f
45 3
+ f
45 4

2h
= 45
(7f0 + 32f1 + 12f2 + 32f3 + 7f4 ) lqqd

4. Determinar las aproximaciones centradas, regresivas y progresivas de orden


O(h2 ) a f 0 (xk) en cada uno de los cuatro puntos de la siguiente tabla, presente
la informacion calculada y resumida en una tabla.

x f(x)
0.00 0.98992
0.10 0.999135
0.20 0.998295
0.30 0.987480

Solucion:

x f(x) Centrada Progresiva Regresiva


0.00 0.98992 no si no
0.10 0.999135 si si no
0.20 0.998295 si no si
0.30 0.987480 no no si

Andres Suarez 6
METODOS NUMERICOS

Punto 0,0 Progresiva:


3f0 + 4f1 f2
f 0 (x) =
2h
3f (0,0) + 4f (0,1) f (0,2)
f 0 (x) =
2 0,1
3 0,98992 + 4 0,99135 0,998295
f 0 (x) = = 0,142425
0,2
Punto 0,1 Central:
f1 f1
f 0 (x) =
2h
f (0,2) f (0,0)
f0 =
2 0,1
0,998295 0,98992
f0 = = 0,041875
0,2
Punto 0,1 Progresiva:
3f0 + 4f1 f2
f 0 (x) =
2h
3f (0,1) + 4f (0,2) f (0,3)
f0 =
2 0,1
3 0,999135 + 4 0,998295 0,987480
f0 = = 0,041475
0,2
Punto 0,2 Central:
f1 f 1
f 0 (x) =
2h
f (0,3) f (0,1)
f0 =
2 0,1
0,987480 0,999135
f0 = = 0,058275
0,2
Punto 0,2 Regresiva:
3f0 4f1 + f2
f 0 (x) =
2h
3f (0,0) 4f (0,1) + f (0,0)
f0 =
2 0,1
3 0,998295 4 0,999135 + 0,98992
f0 = = 0,058675
0,2
Punto 0,3 Regresiva:

Andres Suarez 7
METODOS NUMERICOS

3f0 4f1 + f2
f 0 (x) =
2h
3f (0,3) 4f (0,2) + f (0,1)
f0 =
2 0,1
3 0,987480 4 0,998295 + 0,999135
f0 = = 0,158025
0,2

Punto Centrada Progresiva Regresiva


0.00 no 0.142425 no
0.10 0.041875 0.041475 no
0.20 -0.058275 no -0.058675
0.30 no no -0.158025

5. Calcule cada una de las siguientes integrales, utilizando los codigos compues-
tos estudiados (trapecio, punto medio y Simpson). Adem?s, analice el error
absoluto.
a)
R1
0
((1 + X 3 )1 ) dx

Codigo de programa de trapecio, punto medio y simpson:

%Taller
%Adriana Lupero-Andre Cobo
function[T S M]=ICLC(a,b,fx,n)
%[T S M]=ICLC(0,1,(1+x^3)^-1,10)
f=inline(fx);
%trapecio
h=(b-a)/n;
k=0;
for i=1:n-1
x=a+h*i;
k=k+f(x);
endfor
T=h*(f(b)+f(a))/2+h*k;

%Simpson
h1=(b-a)/(2*n);
r=0;
I=0;
for i=1:n-1
x1=a+h1*2*i;

Andres Suarez 8
METODOS NUMERICOS

r=r+f(x1);
endfor
for i=1:n
x1=a+h1*(2*i-1);
I=I+f(x1);
endfor
S=h1/3*(f(a)+f(b)) + h1/3*(2*r) + h1/3*(4*I);

%Puntomedio
h2= (b-a)/n;
for i=1:n
x(i) = a+(2*i-1)*(h2/2);
endfor
d = 0;
for i=1:n
d = d + f(x(i));
endfor
M = h2*d;
endfunction

Comprobacion

Valor Real 0,8356488483 Valores Error


Trapecio 0.83502 0,00063
Simpson 0.83565 0,00001
Punto medio 0.83596 0,00032

Analisis:
Se puede observar en la tabla que el error absoluto menor es de Simpson con un valor de
0,00001 mientras que los otros valores son bajos

b)

Andres Suarez 9
METODOS NUMERICOS

R1
0
(x)2 cos(x) dx

Codigo de programa de trapecio, punto medio y simpson:

%Taller
%Adriana Lupero-Andre Cobo
function[T S M]=ICLC(a,b,fx,n)
%[T S M]=ICLC(0,1,x^2*cos(x),10)
f=inline(fx);
%trapecio
h=(b-a)/n;
k=0;
for i=1:n-1
x=a+h*i;
k=k+f(x);
endfor
T=h*(f(b)+f(a))/2+h*k;

%Simpson
h1=(b-a)/(2*n);
r=0;
I=0;
for i=1:n-1
x1=a+h1*2*i;
r=r+f(x1);
endfor
for i=1:n
x1=a+h1*(2*i-1);
I=I+f(x1);
endfor
S=h1/3*(f(a)+f(b)) + h1/3*(2*r) + h1/3*(4*I);

%Puntomedio
h2= (b-a)/n;
for i=1:n
x(i) = a+(2*i-1)*(h2/2);
endfor
d = 0;
for i=1:n
d = d + f(x(i));
endfor
M = h2*d;
endfunction

Andres Suarez 10
METODOS NUMERICOS

Comprobacion

Valor Real 0,2391336269 Valores Error


Trapecio 0,23933 0,000196
Simpson 0,23913 0,000003
Punto medio 0,23903 0,000103

Analisis:
Se puede observar en la tabla que el error absoluto menor es de Simpson con un valor de
0,000003 mientras que los otros valores son bajos

c)
R pi
0
sen(x) e2x dx

Codigo de programa de trapecio, punto medio y simpson:

%Taller
%Adriana Lupero-Andre Cobo
function[T S M]=ICLC(a,b,fx,n)
%[T S M]=ICLC(0,pi,exp(2*x)*sin(x),10)
f=inline(fx);
%trapecio
h=(b-a)/n;
k=0;
for i=1:n-1
x=a+h*i;
k=k+f(x);
endfor
T=h*(f(b)+f(a))/2+h*k;

%Simpson

Andres Suarez 11
METODOS NUMERICOS

h1=(b-a)/(2*n);
r=0;
I=0;
for i=1:n-1
x1=a+h1*2*i;
r=r+f(x1);
endfor
for i=1:n
x1=a+h1*(2*i-1);
I=I+f(x1);
endfor
S=h1/3*(f(a)+f(b)) + h1/3*(2*r) + h1/3*(4*I);

%Puntomedio
h2= (b-a)/n;
for i=1:n
x(i) = a+(2*i-1)*(h2/2);
endfor
d = 0;
for i=1:n
d = d + f(x(i));
endfor
M = h2*d;
endfunction

Comprobacion

Valor Real 107.2983311 Valores Error


Trapecio 102,97 4,32833
Simpson 107,28 0,01833
Punto medio 109,44 2,14166

Andres Suarez 12
METODOS NUMERICOS

Analisis:
Se puede observar en la tabla que el error absoluto menor es de Simpson con un valor de
0,01833 mientras que los otros valores son altos es aconsejable usar el metodo de simpson.

6. La longitud de una curva y = f (x) definida sobre un intervalo [a, b] viene dado
por:
Rbq
L = a 1 + f 0 (x)2 dx

El area de la superficie del solido de revolucion que se obtiene al girar alrededor


del eje OX la region limitada por la curva y = f (x) y el intervalo [a, b] viene
dada por:
Rb q
S = 2 a f (x) 1 + f 0 (x)2 dx

Calcular la longitud y la superficie de revolucion de las curvas dadas, utilizan-


do el codigo compuesto de Simpson 1/3. Calcule el error y realice las graficas
respectivas de la funcion y de la superficie del solido de revolucion.

a)

f (x) = ex parax [0, 1]

Solucion:
Su derivada es: f 0 (x) = ex El valor real de la longitud es: 1,19270140197
El valor real de la superficie de revolucion es: 4,84921849147
Utilizando el codigo desarrollado:

Su error absoluto en longitud es: 0,000000028299


Su error absoluto en longitud es: 0,000001526185

La grafica de la funcion es:

Andres Suarez 13
METODOS NUMERICOS

Su superficie de revolucion es:

b)

f (x) = cos(x)parax [0, 2 ]

Solucion:
Su derivada es: f 0 (x) = sen(x) El valor real de la longitud es: 1,57099304696
El valor real de la superficie de revolucion es: 9,86960384375
Utilizando el codigo desarrollado:

Andres Suarez 14
METODOS NUMERICOS

Su error absoluto en longitud es: 0,339105847553856


Su error absoluto en revolucion es: 2,657799406671792
La grafica de la funcion es:

Su superficie de revolucion es:

c)

Andres Suarez 15
METODOS NUMERICOS

f (x) = x2 parax [0, 1]

Solucion:
Su derivada es: f 0 (x) = 2x El valor real de la longitud es: 1,47894285759
El valor real de la superficie de revolucion es: 3,80972970486
Utilizando el codigo desarrollado:

Su error absoluto en longitud es: 0,0000000297


Su error absoluto en revolucion es: 0,0000026226
La grafica de la funcion es:

Su superficie de revolucion es:

Andres Suarez 16
METODOS NUMERICOS

Andres Suarez 17

Das könnte Ihnen auch gefallen