12.05.2013 Views

Problemas resueltos de Cálculo Numérico

Problemas resueltos de Cálculo Numérico

Problemas resueltos de Cálculo Numérico

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TEMA 1<br />

<strong>Problemas</strong> <strong>resueltos</strong> <strong>de</strong> <strong>Cálculo</strong> <strong>Numérico</strong><br />

1. Interpolación y aproximación<br />

1. Escribir los polinomios <strong>de</strong> interpolación <strong>de</strong> Lagrange y <strong>de</strong> Newton para los siguientes<br />

datos:<br />

xi -2 0 1<br />

f(xi) 0 1 -1<br />

Escribir ambos polinomios en la forma a+bx+cx 2 con el fin <strong>de</strong> verificar que son idénticos.<br />

SOLUCIÓN:<br />

Método <strong>de</strong> Lagrange:<br />

Construimos los polinomios <strong>de</strong> Lagrange, ℓi(x), i = 0, 1, 2.<br />

ℓ0(x) =<br />

ℓ1(x) =<br />

ℓ2(x) =<br />

(x − x1)(x − x2) (x − 0)(x − 1)<br />

=<br />

(x0 − x1)(x0 − x2) (−2 − 0)(−2 − 1)<br />

1<br />

= x (x − 1)<br />

6<br />

(x − x0)(x − x2) (x + 2)(x − 1)<br />

= = −1 (x + 2) (x − 1)<br />

(x1 − x0)(x1 − x2) (0 + 2)(0 − 1) 2<br />

(x − x0)(x − x1) (x + 2)(x − 0) 1<br />

= = (x + 2) x<br />

(x2 − x0)(x2 − x1) (1 + 2)(1 − 0) 3<br />

El polinomio <strong>de</strong> interpolación viene dado por<br />

p2(x) =<br />

= 0<br />

2<br />

f(xi)ℓi(x) = f(x0)ℓ0(x) + f(x1)ℓ1(x) + f(x2)ℓ2(x)<br />

i=0<br />

= − 1<br />

2<br />

Método <strong>de</strong> Newton:<br />

<br />

1<br />

x (x − 1)<br />

6<br />

<br />

(x + 2)(x − 1) − 1<br />

3<br />

<br />

+ 1 − 1<br />

(x + 2)(x − 1)<br />

2<br />

Escribimos el polinomio <strong>de</strong> interpolación en la forma<br />

<br />

7 5<br />

(x + 2)x = 1 − x −<br />

6 6 x2<br />

<br />

1<br />

− 1 (x + 2) x<br />

3<br />

p2(x) = f(x0) + f[x0, x1](x − x0) + f[x0, x1, x2](x − x0)(x − x1)


2 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

Calculamos la tabla <strong>de</strong> diferencias divididas<br />

Luego,<br />

p2(x) = 0 + 1<br />

2<br />

xi f(xi<br />

-2 0<br />

1/2<br />

0 1 -5/6<br />

-2<br />

1 -1<br />

(x + 2) − 5<br />

6<br />

7 5<br />

(x + 2)(x − 0) = 1 − x −<br />

6 6 x2<br />

2. Determinar un polinomio p(x) = ax 6 + bx 4 + cx 2 + d que satisfaga los siguientes datos<br />

SOLUCIÓN:<br />

p(0) = 2 , p(−1) = 8 , p ′′ (0) = −2 , p ′′ (−1) = 8 .<br />

p(x) = a x 6 + b x 4 + c x 2 + d<br />

p ′ (x) = 6a x 5 + 4b x 3 + 2c x<br />

p ′′ (x) = 30a x 4 + 12b x 2 + 2c<br />

Al imponer las condiciones <strong>de</strong> interpolación se tiene<br />

p(0) = 2 ⇒ d = 2<br />

p(−1) = 8 ⇒ a + b + c + d = 8<br />

p ′′ (0) = 2 ⇒ 2c = 2<br />

Resolviendo el sistema anterior obtenemos<br />

El polinomio pedido será<br />

p ′′ (−1) = 8 ⇒ 30a + 12b + 2c = 8<br />

a = − 37<br />

9<br />

100<br />

, b = , c = −1, d = 2.<br />

9<br />

p(x) = − 37<br />

6 x6 + 100<br />

9 x4 − x 2 + 2.<br />

3. En estudios <strong>de</strong> polimerización inducida por radiación, se emplea una fuente <strong>de</strong> rayos<br />

gamma para obtener dosis medidas en radiación. Sin embargo, la dosis varía con la<br />

posición <strong>de</strong>l aparato, según los datos que se dan a continuación.<br />

Posición Dosis<br />

(en pulgadas) (10 5 rads/h)<br />

1.0 2.71<br />

1.5 2.98<br />

2.0 3.20<br />

3.0 3.20<br />

(a) ¿Cuál es la estimación para el nivel <strong>de</strong> dosis en 2.5 pulgadas?


1. INTERPOLACIÓN Y APROXIMACIÓN 3<br />

(b) Si se efectúa una nueva medición que indica que a 3.5 pulgadas el nivel <strong>de</strong> dosis<br />

correspondiente es <strong>de</strong> 2 ′ 98, ¿cuál será ahora la estimación para el nivel <strong>de</strong> dosis en<br />

2.5 pulgadas?<br />

SOLUCIÓN:<br />

(a) Calculamos el polinomio <strong>de</strong> interpolación para los datos <strong>de</strong> la tabla anterior. Utilizamos el<br />

método <strong>de</strong> Newton.<br />

xi f(xi)<br />

1.0 2.71<br />

0.54<br />

1.5 2.98 -0.1<br />

0.44 -0.29/3<br />

2.0 3.20 -0.44/1.5<br />

0<br />

3.0 3.20<br />

El polinomio <strong>de</strong> interpolación vendrá dado por<br />

p3(x) = 2.71 + 0.54(x − 1) − 0.1(x − 1)(x − 1.5) − 0.29<br />

(x − 1)(x − 1.5)(x − 2).<br />

3<br />

Ahora po<strong>de</strong>mos estimar la dosis <strong>de</strong> radiación para x = 2.5 evaluando el polinomio <strong>de</strong><br />

interpolación en ese punto.<br />

p3(2.5) = 2.71 + 0.54(1.5) − 0.1(1.5)(1) − 0.29<br />

(1.5)(0.5) = 3.2975.<br />

3<br />

(b) Observemos que ahora disponemos <strong>de</strong> un dato más <strong>de</strong> interpolación. Una forma <strong>de</strong> obtener<br />

el nuevo polinomio <strong>de</strong> interpolación es añadir este dato a nuestra tabla <strong>de</strong> diferencias divididas<br />

y completarla.<br />

xi f(xi)<br />

1.0 2.71<br />

0.54<br />

1.5 2.98 -0.1<br />

0.44 -0.29/3<br />

2.0 3.20 -0.44/1.5 0.29/7.5<br />

0 0<br />

3.0 3.20 -0.44/1.5<br />

-0.44<br />

3.5 2.98<br />

El nuevo polinomio <strong>de</strong> interpolación será<br />

p4(x) = 2.71 + 0.54(x − 1) − 0.1(x − 1)(x − 1.5) −<br />

0.29<br />

(x − 1)(x − 1.5)(x − 2) +<br />

3<br />

0.29<br />

(x − 1)(x − 1.5)(x − 2)(x − 3).<br />

7.5<br />

La estimación <strong>de</strong>l nivel <strong>de</strong> radiación para x = 2.5 será ahora<br />

p4(2.5) = 3.2975 + 0.29<br />

(1.5)(0.5)(−0.5) = 3.283<br />

7.5


4 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

4. Para los valores siguientes<br />

E 40 60 80 100 120<br />

P 0.63 1.36 2.18 3.00 3.93<br />

don<strong>de</strong> E son los voltios y P los kilovatios en una curva <strong>de</strong> pérdida en el núcleo para un<br />

motor eléctrico.<br />

(a) Elaborar una tabla <strong>de</strong> diferencias divididas<br />

(b) Calcular el polinomio <strong>de</strong> interpolación <strong>de</strong> Newton <strong>de</strong> segundo grado para E =<br />

80, 100, 120. Utilizarlo para estimar el valor <strong>de</strong> P correspondiente a E = 90 voltios.<br />

SOLUCIÓN:<br />

(a) Calculamos la tabla <strong>de</strong> diferencias divididas<br />

xi f(xi)<br />

40 0.63<br />

0.0365<br />

60 1.36 0.0001125<br />

0.041 -0.000001875<br />

80 2.18 0 0.0000000521<br />

0.041 0.00002292<br />

100 3.00 0.0001375<br />

0.0465<br />

120 3.93<br />

(b) En la tabla anterior hemos marcado los coeficientes <strong>de</strong>l polinomio <strong>de</strong> interpolación para<br />

E = 80, 100, 120. El polinomio será<br />

p2(x) = 2.18 + 0.041(x − 80) + 0.0001375(x − 80)(x − 100).<br />

La estimación <strong>de</strong> P para E = 90 se obtendrá evaluando el polinomio <strong>de</strong> interpolación en<br />

x = 90. En nuestro caso<br />

p(90) = 2.18 + 0.041(10) + 0.0001375(10)(−10) = 2.57625<br />

5. Una función f(x) <strong>de</strong> la que solamente se conocen los datos <strong>de</strong> la tabla que figura a continuación,<br />

alcanza un máximo en el intervalo [1, 1.3]. Hallar la abscisa <strong>de</strong> dicho máximo.<br />

Interpreta los resultados.<br />

SOLUCIÓN:<br />

xi 1.0 1.1 1.2 1.3<br />

f(xi) 0.841 0.891 0.993 1.000<br />

La solución <strong>de</strong> este problema pasa necesariamente por <strong>de</strong>terminar una función que interpole o<br />

aproxime los datos anteriores. A continuación calculamos el punto don<strong>de</strong> esta función alcance<br />

su máximo o su mínimo. Por tanto, una primera estrategia pue<strong>de</strong> ser calcular el polinomio <strong>de</strong><br />

interpolación.


El polinomio <strong>de</strong> interpolación será<br />

1. INTERPOLACIÓN Y APROXIMACIÓN 5<br />

xi f(xi)<br />

1.0 0.841<br />

0.5<br />

1.1 0.891 2.6<br />

1.02 -24.5<br />

1.2 0.993 -4.75<br />

0.07<br />

1.3 1.00<br />

p(x) = 0.841 + 0.5(x − 1) + 2.6(x − 1)(x − 1.1) − 24.5(x − 1)(x − 1.1)(x − 1.2)<br />

= 35.541 − 93.65x + 83.45x 2 − 24.5x 3<br />

Calculamos los puntos críticos<br />

p ′ (x) = 0 ⇒ −73.5x 2 + 166.9x − 93.65 = 0 ⇒<br />

x = 1.25754<br />

x = 1.01321<br />

Para precisar si hay máximo o mínimo recurrimos a la segunda <strong>de</strong>rivada.<br />

p ′′ (x) = −147x + 166.9 ⇒<br />

Puesto que<br />

p ′′ (1.25754) = −17.95838 < 0 ⇒ máx. relativo<br />

p ′′ (1.01321) = 17.95813 > 0 ⇒ mín. relativo<br />

p(1.25754) = 1.018062648073915<br />

<strong>de</strong>ducimos que la función p(x) alcanza su máximo absoluto en el intervalo [1, 1.3] en el punto <strong>de</strong><br />

abscisa x = 1.25754.<br />

Otra forma <strong>de</strong> abordar este problema sería utilizando interpolación lineal a trozos. De acuerdo<br />

con este nuevo mo<strong>de</strong>lo y observando los datos <strong>de</strong> la tabla anterior concluiríamos que la función<br />

f(x) alcanzaría su máximo absoluto en x = 1.30.<br />

6. En la siguiente tabla, R es la resistencia <strong>de</strong> una bobina en ohms y T la temperatura <strong>de</strong><br />

la bobina en grados centígrados. Por mínimos cuadrados <strong>de</strong>terminar el mejor polinomio<br />

lineal que represente la función dada.<br />

SOLUCIÓN:<br />

T 10.50 29.49 42.70 60.01 75.51 91.05<br />

R 10.421 10.939 11.321 11.794 12.242 12.668<br />

Se trata <strong>de</strong> ajustar una función <strong>de</strong>l tipo<br />

R = a + b T<br />

al conjunto <strong>de</strong> datos (Ti, Ri). Matricialmente el sistema que tenemos que resolver vendrá dado<br />

por<br />

⎛ 6 6<br />

⎞ ⎛ 6<br />

⎞<br />

⎜ 1 Ti ⎟ ⎜ Ri ⎟<br />

⎜<br />

⎟<br />

⎜ i=1 i=1 a ⎜ ⎟<br />

⎟<br />

⎜ 6 6<br />

⎟ = ⎜ i=1 ⎟<br />

⎝<br />

⎠ b ⎜ 6<br />

⎟<br />

⎝ ⎠<br />

i=1<br />

Ti<br />

i=1<br />

T 2 i<br />

i=1<br />

TiRi


6 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

Construimos la siguiente tabla<br />

Ti Ri T 2 i TiRi<br />

10.50 10.421 110.25 109.4205<br />

29.49 10.939 869.6501 322.59111<br />

42.70 11.321 1823.29 483.4067<br />

60.01 11.794 3601.2001 707.75794<br />

75.51 12.242 5701.7601 924.39242<br />

91.05 12.668 8290.1025 1153.4214<br />

309.26 69.385 20396.2628 3700.99107<br />

Por tanto, el sistema que tenemos que resolver será,<br />

<br />

6a + 309.26b = 69.385<br />

309.26a + 20396.2628b = 3700.99107 ⇒<br />

Luego, la solución vendrá dada por<br />

R = 10.1222293891 + 0.0279752430495 T<br />

a = 10.1222293891<br />

b = 0.0279752430495<br />

7. Aproximar mediante los mínimos cuadrados un polinomio <strong>de</strong> grado dos a los siguientes<br />

datos<br />

xi 1 2 4 10 16<br />

yi 6 1 2 4 5<br />

SOLUCIÓN:<br />

Se trata <strong>de</strong> ajustar una función <strong>de</strong>l tipo<br />

i=1<br />

x 2 i<br />

i=1<br />

x 3 i<br />

y = a + b x + c x 2<br />

al conjunto <strong>de</strong> datos (xi, yi).<br />

Matricialmente el sistema que tenemos que resolver vendrá dado por<br />

⎛<br />

5 5 5<br />

⎜ 1 xi x<br />

⎜ i=1 i=1 i=1<br />

⎜<br />

⎝<br />

2 i<br />

5 5<br />

xi x<br />

i=1 i=1<br />

2 5<br />

i x<br />

i=1<br />

3 ⎞ ⎛ 5<br />

⎞<br />

⎟ ⎜ yi ⎟<br />

⎟ ⎛ ⎞ ⎜ ⎟<br />

⎜ i=1 ⎟<br />

⎟ a ⎜<br />

⎟ ⎜ ⎟ ⎜ 5<br />

⎟<br />

i ⎟ ⎝ b ⎠ = ⎜ xiyi<br />

⎟<br />

⎟ ⎜<br />

5 5 5<br />

⎟ c<br />

i=1 ⎟<br />

⎜ ⎟<br />

⎟ ⎜ 5 ⎟<br />

⎠ ⎝ ⎠<br />

Construimos la siguiente tabla<br />

i=1<br />

x 4 i<br />

i=1<br />

xi yi x 2 i x 3 i x 4 i xiyi x 2 i yi<br />

1 6 1 1 1 6 6<br />

2 1 4 8 16 2 4<br />

4 2 16 64 256 8 32<br />

10 4 100 1000 10000 40 400<br />

16 5 256 4096 65536 80 1280<br />

33 18 377 5169 75809 136 1722<br />

x 2 i yi


1. INTERPOLACIÓN Y APROXIMACIÓN 7<br />

Por tanto, el sistema que tenemos que resolver será,<br />

⎧<br />

⎨<br />

⎩<br />

5a + 33b + 377c = 18<br />

33a + 377b + 5169c = 136<br />

377a + 5169b + 75809c = 1722<br />

Luego, la solución vendrá dada por<br />

8. Hallar la función <strong>de</strong>l tipo<br />

⇒<br />

⎧<br />

⎨<br />

⎩<br />

y = 4.08582 − 0.45685x + 0.03355x 2<br />

a = 4.08582<br />

b = −0.45685<br />

c = 0.03355<br />

g(x) = a √ x + b<br />

x<br />

que mejor se ajuste, mediante el criterio <strong>de</strong> los mínimos cuadrados, a los datos<br />

SOLUCIÓN:<br />

(1, 2) , (2, 4) , (3, 0).<br />

Matricialmente el sistema que tenemos que resolver vendrá dado por<br />

⎛<br />

⎜<br />

⎝<br />

3<br />

xi<br />

i=1<br />

3<br />

3 1<br />

√<br />

xi<br />

i=1<br />

3 1<br />

⎞ ⎛<br />

⎟ ⎜<br />

⎟ a ⎜<br />

⎟ = ⎜<br />

⎠ b ⎜<br />

⎝<br />

3 √<br />

xi yi<br />

i=1<br />

3 1<br />

⎞<br />

⎟<br />

⎠<br />

i=1<br />

√ xi<br />

x<br />

i=1<br />

2 i<br />

yi<br />

xi<br />

i=1<br />

Construimos la siguiente tabla<br />

xi 1/ √ xi 1/x2 1 1<br />

i<br />

1<br />

√<br />

xi yi<br />

2<br />

yi/xi<br />

2<br />

2 0.7071 0.25 5.65685 2<br />

4 0.5 0.0625 0 0<br />

7 2.20711 1.3125 7.65685 4<br />

Por tanto, el sistema que tenemos que resolver será,<br />

<br />

7a + 2.20711b = 7.65685<br />

2.20711a + 1.3125b = 4<br />

Luego, la solución vendrá dada por<br />

⇒<br />

y = 0.43556 √ x + 2.20774<br />

x<br />

.<br />

a = 0.43556<br />

b = 2.20774<br />

9. En la siguiente tabla aparecen recogidos los datos <strong>de</strong> población <strong>de</strong> un pequeño barrio <strong>de</strong><br />

una ciudad en un periodo <strong>de</strong> 20 años. Como ingeniero que trabaja en una compañía <strong>de</strong><br />

servicio <strong>de</strong>bes pronosticar la población que habrá <strong>de</strong>ntro <strong>de</strong> 5 años, para po<strong>de</strong>r anticipar<br />

la <strong>de</strong>manda <strong>de</strong> energía. Emplea un mo<strong>de</strong>lo exponencial y regresión lineal para hacer esta<br />

predicción.<br />

t 0 5 10 15 20<br />

p 100 212 448 949 2009


8 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

SOLUCIÓN:<br />

Preten<strong>de</strong>mos ajustar una función <strong>de</strong>l tipo<br />

p = a e bt .<br />

Se trata <strong>de</strong> un mo<strong>de</strong>lo <strong>de</strong> aproximación no lineal. Tomando logaritmos y <strong>de</strong>notando P = ln p y<br />

A = ln a se llega al mo<strong>de</strong>lo lineal<br />

ln p = ln a e bt = ln a + b t ⇒ P = A + b t.<br />

Ahora nuestro objetivo será ajustar una función <strong>de</strong>l tipo P = A + b t al conjunto <strong>de</strong> datos (ti, Pi).<br />

Matricialmente el sistema que tenemos que resolver será<br />

⎛ 5 5<br />

⎞ ⎛ 5<br />

⎞<br />

⎜ 1 ti ⎟ ⎜ Pi ⎟<br />

⎜<br />

⎟<br />

⎜ i=1 i=1 A ⎜ ⎟<br />

⎟<br />

⎜ 5 5<br />

⎟ = ⎜ i=1 ⎟<br />

⎝<br />

⎠ b ⎜ 6<br />

⎟<br />

⎝ ⎠<br />

i=1<br />

Construimos la siguiente tabla<br />

ti<br />

i=1<br />

t 2 i<br />

i=1<br />

tiPi<br />

ti pi Pi = ln pi t 2 i tiPi<br />

0 100 4.6052 0 0<br />

5 212 5.3566 25 26.783<br />

10 448 6.1048 100 61.048<br />

15 949 6.8554 225 102.831<br />

20 2009 7.6054 400 152.108<br />

50 30.5274 750 342.77<br />

Por tanto, el sistema que tenemos que resolver será,<br />

<br />

5A + 50b = 30.5274<br />

50A + 750b = 342.77 ⇒<br />

<br />

A 4.60564 A = 4.60564 ⇒ a = e = e = 100.0470<br />

b = 0.149984<br />

Luego, la solución vendrá dada por<br />

p(t) = 100.0470 e 0.149984 t .<br />

La población estimada en los próximos 5 años se obtendrá calculando p(25). En nuestro caso,<br />

p(25) = 100.0470e 3.7496 4252.<br />

2. Resolución numérica <strong>de</strong> ecuaciones<br />

10. Probar que la ecuación<br />

e x − 2e −x = 0<br />

tiene una única solución real. Obtenerla mediante el método <strong>de</strong> Newton-Raphson (3 iteraciones).<br />

Utiliza 5 cifras <strong>de</strong>cimales en los cálculos.<br />

SOLUCIÓN:<br />

Consi<strong>de</strong>ramos la función<br />

f(x) = e x − 2e −x .<br />

Buscamos un intervalo don<strong>de</strong> haya alternancia <strong>de</strong> signo<br />

f(0) = −1 , f(1) = 1.9825


2. RESOLUCIÓN NUMÉRICA DE ECUACIONES 9<br />

Puesto que f es una función continua, el teorema <strong>de</strong> Bolzano nos garantiza la existencia <strong>de</strong> al<br />

menos una solución en el intervalo (0, 1). A<strong>de</strong>más se tiene que<br />

por lo que la solución es única.<br />

f ′ (x) = e x + 2e −x = 0 , ∀x ∈ IR,<br />

Apliquemos el método <strong>de</strong> Newton para obtener <strong>de</strong> forma aproximada la solución.<br />

xn+1 = xn − f(xn)<br />

f ′ , n ≥ 0.<br />

(xn)<br />

Elegimos como punto <strong>de</strong> arranque un x0 ∈ [0, 1] tal que f(x0)f ′′ (x0) > 0. En este caso, puesto<br />

que<br />

f ′′ (x) = e x − 2e −x ,<br />

po<strong>de</strong>mos tomar como punto <strong>de</strong> arranque cualquier x0 ∈ [0, 1].<br />

Partiendo <strong>de</strong> x0 = 0 generamos las siguientes aproximaciones<br />

x0 = 0<br />

x1 = x0 − f(x0)<br />

f ′ f(0)<br />

= 0 −<br />

(x0) f ′ = −−1 = 0.33333<br />

(0) 3<br />

x2 = x1 − f(x1)<br />

f ′ f(0.33333)<br />

= 0.33333 −<br />

(x1) f ′ = 0.34654<br />

(0.33333)<br />

x3 = x2 − f(x2)<br />

f ′ f(0.34654)<br />

= 0.34654 −<br />

(x2) f ′ = 0.34657<br />

(0.34654)<br />

En este caso, po<strong>de</strong>mos resolver algebraicamente la ecuación para obtener la solución exacta.<br />

e x − 2e −x = 0 ⇒ e 2x − 2 = 0 ⇒ x = 1<br />

ln 2 = 0.346573590279972<br />

2<br />

11. Aproximar mediante el método <strong>de</strong> la regula falsi la raíz <strong>de</strong> la ecuación<br />

x 3 − 2x 2 − 5 = 0<br />

en el intervalo [1, 4], realizando 5 iteraciones y utilizando cinco cifras <strong>de</strong>cimales.<br />

SOLUCIÓN:<br />

Definimos la función f(x) = x 3 − 2x 2 − 5. Puesto que f(1) = −6 y f(4) = 27, el teorema <strong>de</strong><br />

Bolzano nos garantiza la existencia <strong>de</strong> al menos una solución en el intervalo (1, 4). A<strong>de</strong>más, puesto<br />

que<br />

f ′′ (x) = 6x − 4 > 0 , ∀x ∈ [1, 4],<br />

la función f es convexa en [1, 4]. Esto nos asegura que hay solución única en [1, 4] y que el método<br />

<strong>de</strong> regula falsi es convergente. Generamos las aproximaciones<br />

xn = an − f(an)(bn − an)<br />

f(bn) − f(an)<br />

, n = 0, 1, · · ·


10 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

partiendo <strong>de</strong> a0 = 1, b0 = 4. Los valores an y bn se eligen en cada paso <strong>de</strong> forma que f(an)f(bn) <<br />

0. Los cálculos realizados se recogen en la siguiente tabla.<br />

La solución vendrá dada por<br />

n an bn xn f(an) f(bn) f(xn)<br />

0 1.0000 4.0 1.5454 -6.0000 27.0 -6.0856<br />

1 1.5454 4.0 1.9969 -6.0856 27.0 -5.0122<br />

2 1.9969 4.0 2.3105 -5.0122 27.0 -3.3420<br />

3 2.3105 4.0 2.4966 -3.3420 27.0 -1.9043<br />

4 2.4966 4.0 2.5957 -1.9043 27.0 -0.98648<br />

5 2.5957 4.0 2.6452 -0.98648 27.0 -0.48559<br />

x 2.6452<br />

Observación: Si nos fijamos en la tabla anterior se observa que en cualquier iteración, bn = b0<br />

y an+1 = xn. Esta situación se podía haber previsto inicialmente por la convexidad <strong>de</strong> la función<br />

f. De esta forma las aproximaciones se podrían calcular directamente a partir <strong>de</strong> la fórmula<br />

xn = xn−1 − f(xn−1)(b − xn−1)<br />

f(b) − f(xn−1)<br />

, n = 0, 1, · · ·<br />

tomando x−1 = a0 = 1.<br />

12. Encontrar un valor aproximado <strong>de</strong> 3√ 2 mediante el método <strong>de</strong> bisección y el método <strong>de</strong> la<br />

secante.<br />

SOLUCIÓN:<br />

Consi<strong>de</strong>ramos la función f(x) = x 3 − 2 y buscamos un intervalo don<strong>de</strong> haya alternancia <strong>de</strong> signo<br />

f(1) = −1 , f(1.5) = 1.375<br />

El teorema <strong>de</strong> Bolzano nos garantiza la existencia <strong>de</strong> al menos una solución en el intervalo [1, 1.5].<br />

A<strong>de</strong>más, puesto que<br />

f ′ (x) = 3x 2 = 0 , ∀x ∈ [1, 1.5]<br />

la solución será única.<br />

Método <strong>de</strong> bisección: Partiendo <strong>de</strong> a0 = 1, b0 = 1.5 generamos las aproximaciones<br />

xn = an + bn<br />

2<br />

don<strong>de</strong> an y bn se eligen <strong>de</strong> forma que en cualquier iteración se cumpla que f(an)f(bn) < 0. Los<br />

cálculos efectuados se recogen en la siguiente tabla<br />

n an bn xn f(an) f(bn) f(xn)<br />

0 1.0 1.5 1.25 -1.000 1.375 -0.046<br />

1 1.25 1.5 1.375 -0.046 1.375 0.599<br />

2 1.25 1.375 1.3125 -0.046 0.599 0.260<br />

3 1.25 1.3125 1.28125 -0.046 0.260 0.103<br />

4 1.25 1.28125 1.265625 -0.046 0.103 0.0272<br />

5 1.25 1.265625 1.2578125 -0.046 0.027 -0.01<br />

6 1.2578125 1.265625 1.26171875 -0.010 0.027 0.008<br />

7 1.2578125 1.26171875 1.259765625 -0.010 0.008 -0.0007<br />

8 1.259765625 1.26171875 1.2607421875 -0.0007 0.008 0.003<br />

9 1.259765625 1.2607421875 1.26025390625 -0.0007 0.003 0.001<br />

10 1.259765625 1.26025390625 1.260009765625 -0.0007 0.001 0.0004


2. RESOLUCIÓN NUMÉRICA DE ECUACIONES 11<br />

El valor aproximado obtenido <strong>de</strong>spués <strong>de</strong> 10 iteraciones <strong>de</strong>l método <strong>de</strong> bisección es<br />

x 1.260009765625<br />

Método <strong>de</strong> la secante: Partiendo <strong>de</strong> x0 = 1 y x1 = 1.5 generamos las aproximaciones<br />

xn+1 = xn − f(xn)(xn − xn−1)<br />

f(xn) − f(xn−1)<br />

x0 = 1<br />

x1 = 1.5<br />

x2 = x1 − f(x1)(x1 − x0)<br />

f(x1) − f(x0)<br />

x3 = x2 − f(x2)(x2 − x1)<br />

f(x2) − f(x1)<br />

x4 = x3 − f(x3)(x3 − x2)<br />

f(x3) − f(x2)<br />

x5 = x4 − f(x4)(x4 − x3)<br />

f(x4) − f(x3)<br />

x6 = x5 − f(x5)(x5 − x4)<br />

f(x5) − f(x4)<br />

, n = 1, 2, · · ·<br />

= 1.2105263157894736842<br />

= 1.2514085388756729685<br />

= 1.2602652758390120360<br />

= 1.2599187140887994992<br />

= 1.2599210492568176179<br />

La solución aproximada obtenida al realizar 5 iteraciones con el método <strong>de</strong> la secante viene dada<br />

por<br />

x 1.2599210492568176179<br />

13. Determinar una solución aproximada <strong>de</strong> la ecuación<br />

ln x − x + 2 = 0<br />

en el intervalo [3, 4], utilizando 3 iteraciones con el método <strong>de</strong> Newton-Raphson.<br />

SOLUCIÓN:<br />

Puesto que f es continua en el intervalo [3, 4] y f(3)f(4) < 0, el teorema <strong>de</strong> Bolzano nos garantiza<br />

la existencia <strong>de</strong> al menos una solución en dicho intervalo. A<strong>de</strong>más,<br />

f ′ (x) = 1<br />

− 1 = 0 , ∀x ∈ [3, 4],<br />

x<br />

lo que nos asegura que hay solución única en el intervalo [3, 4].<br />

Generamos las aproximaciones <strong>de</strong> la solución mediante el algoritmo<br />

xn+1 = xn − f(xn)<br />

f ′ , n = 0, 1, · · ·<br />

(xn)


12 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

partiendo <strong>de</strong> un punto inicial x0 ∈ [3, 4] tal que f(x0)f ′′ (x0) > 0. Puesto que f ′′ (x) = −1/x 2<br />

po<strong>de</strong>mos tomar como punto <strong>de</strong> arranque x0 = 4.<br />

x0 = 4<br />

x1 = x0 − f(x0)<br />

f ′ f(4)<br />

= 4 −<br />

(x0) f ′ = 3.181725815<br />

(4)<br />

x2 = x1 − f(x1)<br />

f ′ f(3.181725815)<br />

= 3.181725815 −<br />

(x1) f ′ = 3.146284844<br />

(3.181725815)<br />

x3 = x2 − f(x2)<br />

f ′ f(3.146284844)<br />

= 3.146284844 −<br />

(x2) f ′ = 3.146193221<br />

(3.146284844)<br />

14. Resolver la ecuación diferencial<br />

SOLUCIÓN:<br />

y ′′′ + y ′′ − 3y ′ − y = 0.<br />

El conjunto fundamental <strong>de</strong> soluciones <strong>de</strong> la ecuación diferencial anterior se obtiene resolviendo<br />

la ecuación característica<br />

r 3 + r 2 − 3r − 1 = 0.<br />

Dado que la ecuación es polinómica <strong>de</strong> grado impar sabemos que tiene al menos una solución<br />

real. Las posibles soluciones racionales <strong>de</strong> esta ecuación son ±1. La comprobación mediante la<br />

regla <strong>de</strong> Ruffini nos revela que ninguna <strong>de</strong> ellas es solución. Hemos <strong>de</strong> buscar, por tanto, raíces<br />

irracionales. En este caso, la regla <strong>de</strong> Ruffini no es operativa. Afortunadamente po<strong>de</strong>mos obtener<br />

una solución aproximada utilizando el método <strong>de</strong> Newton-Raphson.<br />

Comenzamos <strong>de</strong>finiendo la función f(r) = r 3 + r 2 − 3r − 1 y buscamos un intervalo don<strong>de</strong> haya<br />

alternancia <strong>de</strong> signo.<br />

f(1) = −2 , f(2) = 5<br />

Tenemos, por tanto, asegurada la existencia <strong>de</strong> solución en el intervalo [1, 2]. A<strong>de</strong>más,<br />

f ′ (r) = 3r 2 + 2r − 3<br />

cuyas raíces son −1.38742588672 y 0.72075922005, por lo que f ′ (x) = 0, ∀x ∈ [1, 2]. Esto nos<br />

garantiza que la solución en [1, 2] es única. Generamos las aproximaciones<br />

rn+1 = rn − f(rn)<br />

f ′ , n = 0, 1, · · ·<br />

(rn)<br />

partiendo <strong>de</strong> un punto r0 ∈ [1, 2] tal que f(r0)f ′′ (r0) > 0.


2. RESOLUCIÓN NUMÉRICA DE ECUACIONES 13<br />

Puesto que f ′′ (r) = 6r − 2, entonces f(2)f ′′ (2) > 0. Po<strong>de</strong>mos tomar r0 = 2.<br />

r0 = 2<br />

r1 = r0 − f(r0)<br />

f ′ f(2)<br />

= 2 −<br />

(r0) f ′ = 1.6153846154<br />

(2)<br />

r2 = r1 − f(r1)<br />

f ′ f(1.6153846154)<br />

= 1.6153846154 −<br />

(r1) f ′ = 1.4939568508<br />

(1.6153846154)<br />

r3 = r2 − f(r2)<br />

f ′ f(1.4939568508)<br />

= 1.4939568508 −<br />

(r2) f ′ = 1.4813275882<br />

(1.4939568508)<br />

r4 = r3 − f(r3)<br />

f ′ f(1.4813275882)<br />

= 1.4813275882 −<br />

(r3) f ′ = 1.4811943189<br />

(1.4813275882)<br />

r5 = r4 − f(r4)<br />

f ′ f(1.4811943189)<br />

= 1.4811943189 −<br />

(r4) f ′ = 1.4811943041<br />

(1.4811943189)<br />

r6 = r5 − f(r5)<br />

f ′ f(1.4811943041)<br />

= 1.4811943041 −<br />

(r5) f ′ = 1.48119430409<br />

(1.4811943041)<br />

Po<strong>de</strong>mos tomar como solución r 1.48119430409. Ahora para <strong>de</strong>terminar las otras soluciones<br />

aplicamos la regla <strong>de</strong> Ruffini<br />

1 1 -3 -1<br />

1.48119430409 1.48119430409 3.67513087056 0.999999999989<br />

1 2.48119430409 0.67513087056 -0.000000000011<br />

y resolvemos la ecuación<br />

r 2 + 2.48119430409r + 0.67513087056 = 0 ⇒<br />

La solución general <strong>de</strong> la ecuación diferencial será<br />

r = −0.31110781746<br />

r = −2.17008648663<br />

y = c1e 1.48119430409x + c2e −0.31110781746x + c3e −2.17008648663x , c1, c2, c3 ∈ IR .<br />

15. La velocidad hacia arriba <strong>de</strong> un cohete se pue<strong>de</strong> calcular usando la siguiente fórmula<br />

v = u ln m0<br />

− g t,<br />

m0 − q t<br />

don<strong>de</strong> v = velocidad hacia arriba, u = la velocidad con la que el combustible sale relativa<br />

al cohete, m0 = masa inicial <strong>de</strong>l cohete en el tiempo t = 0, q = razón <strong>de</strong> consumo <strong>de</strong><br />

combustible y g = aceleración hacia abajo <strong>de</strong>bido a la gravedad (considérese la gravedad<br />

constante = 9.8 m/s 2 ). Si u = 2200 m/s, m0 = 160000 Kg y q = 2680 Kg/s, calcule el<br />

tiempo para el cual v = 1000 m/s.<br />

SOLUCIÓN:<br />

Se trata <strong>de</strong> resolver la ecuación<br />

<br />

<br />

160000<br />

1000 = 2200 ln<br />

− 9.8 t<br />

160000 − 2680 t<br />

Simplificando se llega a la ecuación equivalente<br />

Definimos la función<br />

0.00445454545454 t + ln(4000 − 67 t) − 7.83950418556 = 0 .<br />

f(t) = 0.00445454545454 t + ln(4000 − 67 t) − 7.83950418556


14 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

y buscamos un intervalo don<strong>de</strong> haya alternancia <strong>de</strong> signo<br />

f(25) = 0.0233348 , f(26) = −0.00145126.<br />

Luego existe una solución en el intervalo [25, 26]. A<strong>de</strong>más,<br />

f ′ [t] = 0.00445454545454 −<br />

lo que nos asegura que la solución buscada es única.<br />

Generamos las aproximaciones mediante el algoritmo<br />

67<br />

= 0 , ∀t > 0,<br />

4000 − 67t<br />

tn+1 = tn − f(tn)<br />

f ′ , n = 0, 1, · · ·<br />

(tn)<br />

partiendo <strong>de</strong> un punto inicial t0 ∈ [25, 26] tal que f(t0)f ′′ (t0) > 0. En nuestro caso f ′′ (t) =<br />

−4489/(4000 − 67t) 2 , por lo que f(26)f ′′ (26) > 0 y po<strong>de</strong>mos tomar, t0 = 26.<br />

t0 = 26<br />

t1 = t0 − f(t0)<br />

f ′ f(26)<br />

= 26 −<br />

(t0) f ′ = 25.9424508478<br />

(26)<br />

t2 = t1 − f(t1)<br />

f ′ f(25.9424508478)<br />

= 25.9424508478 −<br />

(t1) f ′ = 25.9423929821<br />

(25.9424508478)<br />

t3 = t2 − f(t2)<br />

f ′ f(25.9423929821)<br />

= 25.9423929821 −<br />

(t2) f ′ = 25.9423929820<br />

(25.9423929821)<br />

La solución aproximada será t 25.9423929820.<br />

3. Derivación e Integración Numérica<br />

16. Obtener la <strong>de</strong>rivada segunda en x = 3.7 para la función f(x) <strong>de</strong> la que se conocen los<br />

siguientes datos<br />

xi 1 1.8 3 4.2 5<br />

f(xi) 3.00 4.34 6.57 8.88 10.44<br />

SOLUCIÓN:<br />

Calculamos el polinomio <strong>de</strong> interpolación <strong>de</strong> la función f para el conjunto <strong>de</strong> datos.<br />

xi f(xi)<br />

1.0<br />

1.8<br />

3.0<br />

4.2<br />

5.0<br />

3.00<br />

4.34<br />

6.57<br />

8.88<br />

10.44<br />

1.675<br />

1.85833<br />

1.925<br />

1.95<br />

0.0916667<br />

0.027778<br />

0.0125<br />

-0.0199653<br />

-0.00477431<br />

0.00379774<br />

El polinomio <strong>de</strong> interpolación vendrá dado por<br />

p(x) = 3 + 1.675(x − 1) + 0.0916667(x − 1)(x − 1.8) −<br />

0.0199653(x − 1)(x − 1.8)(x − 3) +<br />

0.00379774(x − 1)(x − 1.8)(x − 3)(x − 4.2)<br />

= 1.68395 + 1.03148 x + 0.338715 x 2 − 0.0579427 x 3 + 0.00379774 x 4


3. DERIVACIÓN E INTEGRACIÓN NUMÉRICA 15<br />

Ahora po<strong>de</strong>mos estimar el valor <strong>de</strong> f ′′ (3.7) evaluando p ′′ (3.7). En nuestro caso,<br />

Luego,<br />

p ′ (x) = 1.03148 + 0.677431 x − 0.173838 x 2 + 0.05191 x 3<br />

p ′′ (x) = 0.677431 − 0.347656 x + 0.0455729 x 2<br />

f ′′ (3.7) 0.677431 − 0.347656 (3.7) + 0.0455729 (3.7) 2 = 0.0149917<br />

17. Dado un circuito con un voltaje V (t), una inductancia L y una resistencia R, la primera<br />

ley <strong>de</strong> Kirchoff que lo mo<strong>de</strong>la es<br />

V = L dI<br />

+ RI.<br />

dt<br />

La siguiente tabla recoge los valores experimentales <strong>de</strong> I correspondientes a varios tiempos<br />

t dados en segundos.<br />

Si la inductancia L es constante e igual a 0.97 henrios y la resistencia R es <strong>de</strong> 0.14<br />

ohmios, aproximar el voltaje V cuando t = 0.97.<br />

SOLUCIÓN:<br />

t 0.95 0.96 0.97 0.98 0.99 1.0<br />

I 0.90 1.92 2.54 2.88 3.04 3.10<br />

Dado que conocemos I(0.97) = 2.54, el problema se reduce a calcular I ′ (0.97). Para ello calculamos<br />

el polinomio <strong>de</strong> interpolación p(t) para el conjunto <strong>de</strong> datos <strong>de</strong> la tabla anterior. La <strong>de</strong>rivada <strong>de</strong><br />

este polinomio para t = 0.97 nos dará una estimación <strong>de</strong> I ′ (0.97).<br />

ti<br />

Ii<br />

0.95 0.90<br />

102<br />

0.96 1.92 -2000<br />

62 2000<br />

0.97 2.54 -1400 -250000/3<br />

34 50000/3 0<br />

0.98 2.88 -900 -250000/3<br />

16 40000/3<br />

0.99 30.4 -500<br />

6<br />

1.00 3.10<br />

El polinomio <strong>de</strong> interpolación vendrá dado por<br />

Luego,<br />

p(t) = 0.90 + 102(t − 0.95) − 2000(t − 0.95)(t − 0.96) +<br />

20000(t − 0.95)(t − 0.96)(t − 0.97) −<br />

250000<br />

(t − 0.95)(t − 0.96)(t − 0.97)(t − 0.98)<br />

3<br />

= −91858.4 + 358719.83 t − 525191.67 t 2 + 341666.67 t 3 − 250000<br />

t<br />

3<br />

4 .<br />

p ′ (t) = 358719.83 − 1050383.33 t + 1025000 t 2 − 333333.33 t 3<br />

Evaluando en t = 0.97 se tiene<br />

I ′ (0.97) p ′ (0.97) = 358719.83 − 1050383.33 (0.97) + 1025000 (0.97) 2 −<br />

333333.33 (0.97) 3 = 46.1667


16 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

Por tanto,<br />

V (0.97) = 0.97 I ′ (0.97) + 0.14 I(0.97) = 0.97(46.1667) + 0.14(2.54) = 45.1373<br />

18. Utilizar la fórmulas usuales <strong>de</strong> <strong>de</strong>rivación numérica para calcular un valor aproximado <strong>de</strong><br />

la <strong>de</strong>rivada <strong>de</strong> la función f(x) = (1 + x)e x en el punto x = 0.6 para h = 0.1, 0.01, 0.001.<br />

Comparar los resultados obtenidos con el valor exacto.<br />

SOLUCIÓN:<br />

En nuestro caso se tiene que<br />

Por tanto,<br />

f ′ (x) = e x + (1 + x)e x = (2 + x)e x .<br />

f ′ (0.6) = (2 + 0.6)e 0.6 = 4.737508881015323<br />

Al aplicar la fórmulas <strong>de</strong> <strong>de</strong>rivación numérica se obtiene<br />

f ′ (0.6) <br />

f(0.6 + h) − f(0.6)<br />

h<br />

h Valor aproximado Error<br />

0.1 5.0798952207499504 −0.3423863397346274<br />

0.01 4.7704471413621885 −0.032938260346865533<br />

0.001 4.7407900922387114 −0.003281211223388425<br />

f ′ (0.6) <br />

f(0.6 + h) − f(0.6 − h)<br />

2h<br />

h Valor aproximado Error<br />

0.1 4.7514884832480853 −0.013979602232762289<br />

0.01 4.7376485777921973 −0.00013969677687430959<br />

0.001 4.7375102779729783 −0.13969576553307661 × 10 −5<br />

f ′ (0.6) <br />

4f(0.6 + h) − 3f(0.6) − f(0.6 + 2h)<br />

2h<br />

h Valor aproximado Error<br />

0.1 4.7068724881917579 0.030636392823565117<br />

0.01 4.7372269244113419 0.00028195660398111499<br />

0.001 4.7375060845467054 0.27964686175607767 × 10 −5


3. DERIVACIÓN E INTEGRACIÓN NUMÉRICA 17<br />

19. De una función f conocemos los siguientes datos<br />

Calcular un valor aproximado <strong>de</strong><br />

x 0 1 2 3<br />

f(x) 2 -2 -1 0<br />

3<br />

0<br />

f(x)dx a partir <strong>de</strong>:<br />

(a) Un polinomio <strong>de</strong> interpolación, a lo sumo <strong>de</strong> grado tres, p(x) obtenido <strong>de</strong> dichos<br />

datos.<br />

(b) La recta y(x) que mejor se ajusta a estos datos en el sentido <strong>de</strong> los mínimos cuadrados.<br />

(c) La regla <strong>de</strong>l trapecio compuesta.<br />

SOLUCIÓN:<br />

(a) Construimos la tabla <strong>de</strong> diferencias divididas<br />

El polinomio <strong>de</strong> interpolación será<br />

xi f(xi)<br />

0<br />

1<br />

2<br />

−2<br />

−4<br />

1<br />

5<br />

2 − 5<br />

2<br />

3<br />

−1<br />

0<br />

1<br />

0 6<br />

p(x) = 2 − 4x + 5<br />

5<br />

49<br />

x(x − 1) − x(x − 1)(x − 2) = 2 −<br />

2 6 6 x + 5 x2 − 5<br />

6 x3<br />

Luego,<br />

3<br />

0<br />

f(x)dx <br />

3<br />

0<br />

p(x)dx =<br />

3<br />

0<br />

<br />

2 − 49<br />

6 x + 5 x2 − 5<br />

6 x3<br />

<br />

dx = − 21<br />

8<br />

(b) Se trata <strong>de</strong> ajustar una función <strong>de</strong>l tipo y(x) = a + b x al conjunto <strong>de</strong> datos (xi, yi) don<strong>de</strong><br />

yi = f(xi). Los coeficientes a y b se obtienen resolviendo el sistema<br />

⎛ 4 4<br />

⎞ ⎛ 4<br />

⎞<br />

⎜ 1 xi ⎟ ⎜ yi ⎟<br />

⎜<br />

⎟<br />

⎜ i=1 i=1 a ⎜ ⎟<br />

⎟<br />

⎜ 4 4<br />

⎟ = ⎜ i=1 ⎟<br />

⎝<br />

⎠ b ⎜ 4<br />

⎟<br />

⎝ ⎠<br />

i=1<br />

xi<br />

i=1<br />

Para ello construimos la siguiente tabla<br />

Luego,<br />

x 2 i<br />

4a + 6b = −1<br />

6a + 14b = −4<br />

xi yi x 2 i xiyi<br />

0 2 0 0<br />

1 -2 1 -2<br />

2 -1 4 -2<br />

3 0 9 0<br />

6 -1 14 -4<br />

i=1<br />

xiyi<br />

1<br />

⇒ a = , b = −1<br />

2 2


18 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

La recta buscada vendrá dada por y(x) = 1 1<br />

− x. Por lo tanto,<br />

2 2<br />

3 3 3 <br />

1 1<br />

f(x)dx y(x)dx = −<br />

2 2 x<br />

<br />

dx = − 3<br />

4<br />

0<br />

0<br />

0<br />

(c) Po<strong>de</strong>mos dividir el intervalo [0, 3] en 3 subintervalos utilizando los puntos 0, 1, 2, 3. Aplicamos<br />

sobre cada uno <strong>de</strong> ellos la regla <strong>de</strong>l trapecio.<br />

3<br />

0<br />

f(x)dx =<br />

1<br />

0<br />

1<br />

2<br />

f(x)dx +<br />

2<br />

1<br />

(f(0) + f(1)) + 1<br />

2<br />

f(x)dx +<br />

3<br />

2<br />

f(x)dx<br />

1<br />

(f(1) + f(2)) + (f(2) + f(3))<br />

2<br />

= 1<br />

1<br />

(f(0) + 2f(1) + 2f(2) + f(3)) = (2 − 4 − 2 + 0)= −2<br />

2 2<br />

Aplicar la fórmula <strong>de</strong>l trapecio compuesta equivale a calcular la integral <strong>de</strong> la poligonal que<br />

pasa por los puntos (xi, f(xi)).<br />

Observemos que los resultados obtenidos son bastante dispares <strong>de</strong>pendiendo <strong>de</strong>l método que hemos<br />

elegido. ¿Cuál es el valor más exacto?. Para dar respuesta a esta pregunta necesitaríamos conocer<br />

información adicional sobre la función f o sobre la naturaleza <strong>de</strong> los datos que estamos manejando.<br />

20. Encontrar las constantes A, B y C para que la fórmula <strong>de</strong> integración numérica<br />

2<br />

1<br />

f(x)dx Af(0) + Bf(1) + Cf(2)<br />

sea exacta para toda función polinómica <strong>de</strong> grado menor o igual que 2.<br />

SOLUCIÓN:<br />

En particular, la fórmula pedida <strong>de</strong>berá ser exacta para las funciones {1, x, x 2 }. Por lo tanto,<br />

f(x) = 1 ⇒<br />

f(x) = x ⇒<br />

f(x) = x 2 ⇒<br />

2<br />

1<br />

2<br />

1<br />

2<br />

Resolviendo el sistema se obtiene<br />

A = −1 2<br />

, B =<br />

12 3<br />

La fórmula <strong>de</strong> integración vendrá dada por<br />

2<br />

1<br />

1<br />

dx = A · 1 + B · 1 + C · 1 ⇒ A + B + C = 1<br />

<br />

1<br />

x dx = A · 0 + B · 1 + C · 2 ⇒ B + 2C =<br />

2 x2<br />

x 2 dx = A · 0 + B · 1 + C · 4 ⇒ B + 4C =<br />

, C = 5<br />

12 .<br />

f(x) dx = − 1 2 5<br />

f(0) + f(1) + f(2) .<br />

12 3 12<br />

2<br />

1<br />

3 x3<br />

= 3<br />

2<br />

1<br />

2 1<br />

= 7<br />

3


21. Obtener un valor aproximado <strong>de</strong><br />

3. DERIVACIÓN E INTEGRACIÓN NUMÉRICA 19<br />

π<br />

0<br />

sen x dx utilizando:<br />

(a) El método <strong>de</strong> Simpson.<br />

(b) El polinomio <strong>de</strong> interpolación en los puntos 0, π/2, π.<br />

Explicar razonadamente lo que suce<strong>de</strong> en los apartados anteriores.<br />

SOLUCIÓN:<br />

(a)<br />

π<br />

0<br />

sen x dx <br />

π − 0<br />

6<br />

<br />

f(0) + 4f<br />

<br />

π<br />

<br />

+ f(π) =<br />

2<br />

π<br />

2π<br />

[0 + 4 · 1 + 0] =<br />

6 3<br />

(b) Calculamos el polinomio <strong>de</strong> interpolación <strong>de</strong> la función f(x) = sen x en los puntos x =<br />

0, π/2, π. Para ello construimos la tabla <strong>de</strong> diferencias divididas<br />

xi f(xi)<br />

0<br />

π/2<br />

0<br />

1<br />

2/π<br />

−4/π2 π 0<br />

−2/π<br />

El polinomio <strong>de</strong> interpolación vendrá dado por<br />

Luego,<br />

π<br />

0<br />

p(x) = 2<br />

π<br />

sen x dx <br />

π<br />

0<br />

4<br />

<br />

x − x<br />

π2 x − π<br />

2<br />

<br />

= − 4<br />

x(x − π).<br />

π2 − 4<br />

4<br />

x(x − π) dx = −<br />

π2 π2 π<br />

3 x x2<br />

− π =<br />

3 2 0<br />

2π<br />

3<br />

No es casualidad la coinci<strong>de</strong>ncia <strong>de</strong> resultados en los apartados (a) y (b), puesto que la fórmula<br />

<strong>de</strong> Simpson,<br />

b<br />

a<br />

f(x)dx =<br />

b − a<br />

6<br />

<br />

f(a) + 4f<br />

a + b<br />

2<br />

<br />

+ f(b) ,<br />

se obtiene precisamente integrando el polinomio <strong>de</strong> interpolación <strong>de</strong> la función f en los puntos<br />

a, (a + b)/2 , b. En nuestro caso, estos puntos se correspon<strong>de</strong>n con 0, π/2, π.<br />

22. Estimar mediante la regla <strong>de</strong> Simpson el valor <strong>de</strong> la integral<br />

1<br />

0<br />

cos √ xdx<br />

dividiendo el intervalo <strong>de</strong> integración en dos subintervalos iguales y utilizando en los<br />

cálculos seis cifras <strong>de</strong>cimales redon<strong>de</strong>adas.<br />

SOLUCIÓN:<br />

Dividimos el intervalo [0, 1] en los subintervalos 0, 1<br />

<br />

1<br />

2 y 2 , 1 . Ahora aplicamos la fórmula <strong>de</strong>


20 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

Simpson para estimar el valor <strong>de</strong> la integral en cada uno <strong>de</strong> los subintervalos.<br />

1<br />

0<br />

cos √ x dx =<br />

1<br />

2 − 0<br />

6<br />

1<br />

12<br />

1<br />

2<br />

0<br />

<br />

f(0) + 4f<br />

<br />

f(0) + 4f<br />

cos √ x dx +<br />

1<br />

4<br />

<br />

1<br />

4<br />

<br />

+ f<br />

<br />

+ 2f<br />

1<br />

1<br />

2<br />

<br />

1<br />

2<br />

1<br />

2<br />

cos √ x dx <br />

<br />

+ 1 − 1<br />

2<br />

<br />

+ 4f<br />

6<br />

3<br />

4<br />

<br />

1 3<br />

f + 4f + f(1) =<br />

2 4<br />

<br />

+ f(1) =<br />

1<br />

[1 + 4(0.877583) + 2(0.760244) + 4(0.647860) + 0.54302] = 0.763547<br />

12<br />

En este caso po<strong>de</strong>mos calcular el valor exacto <strong>de</strong> la integral. En efecto, efectuando el cambio <strong>de</strong><br />

variable x = t2 se obtiene:<br />

1<br />

0<br />

cos √ x dx =<br />

x = t 2<br />

dx = 2t dt =<br />

1<br />

0<br />

2t cos t dt=<br />

u = 2t ⇒ du = 2 dt<br />

dv = cos t dt ⇒ v = sen t<br />

= [2t sen t + 2 cos t] 1<br />

0 = 2 sen 1 + 2 cos 1 − 2 = 0.763547.<br />

4. Resolución numérica <strong>de</strong> ecuaciones diferenciales<br />

23. Consi<strong>de</strong>remos el problema <strong>de</strong> valores iniciales<br />

y ′ = x 2 y − 1.2y , y(0) = 1 .<br />

(a) Resolverlo <strong>de</strong> manera analítica.<br />

(b) Calcular una solución aproximada en el intervalo [0, 2] aplicando el método <strong>de</strong> Euler<br />

con h = 0.5, h = 0.25 y h = 0.1. Comparar los resultados obtenidos con los valores<br />

exactos.<br />

SOLUCIÓN:<br />

(a) La ecuación diferencial pue<strong>de</strong> resolverse mediante separación <strong>de</strong> variables<br />

Por integración se llega a<br />

dy<br />

dx = (x2 − 1.2)y ⇒ dy<br />

y = (x2 − 1.2)dx.<br />

ln y = 1<br />

3 x2 − 1.2 x + c ⇒ y = k e 1<br />

3 x2 −1.2x .<br />

Al imponer las condiciones iniciales, y(0) = 1, se obtiene k = 1, luego la solución vendrá<br />

dada por<br />

y(x) = e 1<br />

3 x2 −1.2x .<br />

(b) Tomando la función f(x, y) = x 2 y − 1.2y, el método <strong>de</strong> Euler con paso h nos proporciona<br />

las aproximaciones<br />

yk+1 = yk + h f(xk, yk) = yk + h(x 2 kyk − 1.2yk) , k = 0, 1, · · · ,<br />

partiendo <strong>de</strong> y0 = y(0) = 1, don<strong>de</strong> xk = k h.


4. RESOLUCIÓN NUMÉRICA DE ECUACIONES DIFERENCIALES 21<br />

Para h = 0.5 se generan las siguientes aproximaciones<br />

k xk yk y(xk) ek = |yk − y(xk)|<br />

0 0 1. 1. 0<br />

1 0.5 0.4 0.5721618727 0.1721618727<br />

2 1.0 0.21 0.4203503845 0.2103503845<br />

3 1.5 0.189 0.5091564206 0.3201564206<br />

4 2.0 0.288225 1.305605172 1.017380172<br />

Para h = 0.25 se generan las siguientes aproximaciones<br />

k xk yk y(xk) ek = |yk − y(xk)|<br />

0 0.00 1. 1. 0<br />

1 0.25 0.7 0.7446867144 0.04468671437<br />

2 0.50 0.5009375 0.5721618727 0.07122437274<br />

3 0.75 0.3819648437 0.4679588099 0.08599396614<br />

4 1.00 0.3210891968 0.4203503845 0.09926118773<br />

5 1.25 0.3050347369 0.4278603878 0.1228256509<br />

6 1.50 0.33267851 0.5091564206 0.1764779106<br />

7 1.75 0.4200066188 0.7308539261 0.3108473073<br />

8 2.00 0.6155722007 1.305605172 0.6900329713<br />

Para h = 0.1 se generan las siguientes aproximaciones<br />

k xk yk y(xk) ek = |yk − y(xk)|<br />

0 0.0 1. 1. 0<br />

1 0.1 0.88 0.8872161261 0.007216126142<br />

2 0.2 0.77528 0.7887283347 0.01344833475<br />

3 0.3 0.68534752 0.7039837539 0.01863623386<br />

4 0.4 0.6092739453 0.6321259184 0.02285197314<br />

5 0.5 0.545909455 0.5721618727 0.02625241777<br />

6 0.6 0.4940480567 0.5230909131 0.02904285635<br />

7 0.7 0.45254802 0.4840017935 0.03145377353<br />

8 0.8 0.4204171106 0.4541474594 0.03373034879<br />

9 0.9 0.3968737524 0.4330075996 0.03613384727<br />

10 1. 0.381395676 0.4203503845 0.03895470848<br />

11 1.1 0.3737677625 0.416306574 0.04253881152<br />

12 1.2 0.3741415303 0.4214728148 0.0473312845<br />

13 1.3 0.383120927 0.4370679226 0.05394699561<br />

14 1.4 0.4018938524 0.4651788455 0.06328499309<br />

15 1.5 0.4324377852 0.5091564206 0.0767186354<br />

16 1.6 0.4778437527 0.5742636505 0.09641989786<br />

17 1.7 0.542830503 0.6687577893 0.1259272863<br />

18 1.8 0.634568858 0.8057353019 0.1711664439<br />

19 1.9 0.7640209051 1.006353431 0.2423325262<br />

20 2.0 0.9481499432 1.305605172 0.3574552289<br />

24. Usar el método <strong>de</strong> Euler con h = 0.2 para estimar la solución <strong>de</strong>l siguiente problema <strong>de</strong><br />

valor inicial en x = 2<br />

y ′ = e y , y(1) = 0<br />

SOLUCIÓN: Tomamos la función f(x, y) = e y y generamos las aproximaciones<br />

yk+1 = yk + h f(xk, yk) = yk + h e yk , k = 0, 1, · · ·


22 1. PROBLEMAS RESUELTOS DE CÁLCULO NUMÉRICO<br />

partiendo <strong>de</strong> y0 = y(1) = 2. En este caso, xk = 1 + k h. Las aproximaciones obtenidas se recogen<br />

en la siguiente tabla<br />

k xk yk<br />

0 1 0<br />

1 1.2 0.2<br />

2 1.4 0.4442805516<br />

3 1.6 0.7561541331<br />

4 1.8 1.182167831<br />

5 2. 1.834455188<br />

El valor aproximado <strong>de</strong> y(2) obtenido viene dado por<br />

y(2) 1.834455188<br />

25. Utilizar el método <strong>de</strong> Euler mejorado con h = 0.2 para obtener un valor aproximado <strong>de</strong><br />

y(1) en el problema <strong>de</strong> valores iniciales<br />

Comparar con el resultado exacto.<br />

SOLUCIÓN:<br />

y ′ = 3x 2 , y(0) = 0.<br />

La solución <strong>de</strong> la ecuación diferencial y ′ = 3x 2 viene dada por y = x 3 + c. Al imponer la condición<br />

inicial, y(0) = 0, se obtiene y = x 3 .<br />

Consi<strong>de</strong>ramos ahora la función f(x, y) = 3x 2 . Las aproximaciones generadas por el método <strong>de</strong><br />

Euler mejorado o método <strong>de</strong>l trapecio vienen dadas por<br />

yk+1 = yk + h<br />

2 [f(xk, yk) + f(xk + h, yk + h f(xk, yk))] , k = 0, 1, · · ·<br />

partiendo <strong>de</strong> y0 = y(0) = 0, don<strong>de</strong> xk = k h. En la práctica se calcula yk+1 en la forma<br />

don<strong>de</strong><br />

yk+1 = yk + h<br />

2 (K1 + k2)<br />

K1 = f(xk, yk) K2 = f(xk + h, yk + h K1).<br />

Las aproximaciones obtenidas se recogen en la siguiente tabla<br />

k xk K1 K2 yk y(xk) |yk − y(xk)|<br />

0 0 0 0 0<br />

1 0.2 0 0.12 0.012 0.008 0.004<br />

2 0.4 0.12 0.48 0.072 0.064 0.008<br />

3 0.6 0.48 1.08 0.228 0.216 0.012<br />

4 0.8 1.08 1.92 0.528 0.512 0.016<br />

5 1. 1.92 3. 1.02 1. 0.02<br />

26. Utilizar el método <strong>de</strong> Runge-Kutta para obtener un valor aproximado <strong>de</strong> y(0.5) para el<br />

siguiente problema <strong>de</strong> valor inicial y comparar con la solución exacta.<br />

SOLUCIÓN:<br />

y ′ = y 2 , y(0) = 1 , h = 0.1<br />

Resolviendo la ecuación diferencial por separación <strong>de</strong> variables se obtiene<br />

dy<br />

y<br />

1<br />

−1<br />

= dx ⇒ − = x + c ⇒ y =<br />

y x − c


4. RESOLUCIÓN NUMÉRICA DE ECUACIONES DIFERENCIALES 23<br />

Al imponer la condición inicial, y(0) = 1, se obtiene c = −1. La solución será, por tanto,<br />

y(x) = 1<br />

1 − x .<br />

Tomando la función f(x, y) = y 2 , el método <strong>de</strong> Runge-Kutta genera las siguientes aproximaciones<br />

don<strong>de</strong><br />

yk+1 = yk + h<br />

6 (K1 + 2K2 + 2K3 + K4) , k = 0, 1, · · ·<br />

K1<br />

K2<br />

=<br />

=<br />

f(xk, yk)<br />

<br />

f xk + 1<br />

2 h, yk + 1<br />

K3 =<br />

2<br />

<br />

f xk + 1<br />

2 h, yk + 1<br />

2<br />

K4 = f(xk + h, yk + h K3)<br />

h K1<br />

h K2<br />

partiendo <strong>de</strong> y0 = y(0) = 1 y tomando xk = k h.<br />

Los resultados se recogen en la siguiente tabla<br />

k xk K1 K2 K3 K4 yk y(xk) |yk − y(xk)|<br />

0 0 1. 1. 0<br />

1 0.1 1.0 1.1025 1.1133 1.2350 1.11111049 1.11111111 0.621×10 −6<br />

2 0.2 1.2345 1.3755 1.3921 1.5633 1.24999799 1.25 0.201×10 −5<br />

3 0.3 1.5625 1.7639 1.7907 2.0422 1.42856618 1.42857142 0.523×10 −5<br />

4 0.4 2.0408 2.3428 2.3892 2.7805 1.66665326 1.66666667 0.00001341<br />

5 0.5 2.7777 3.26 3.3476 4.0057 1.99996326 2. 0.00003674

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!