18.01.2015 Views

Appunti di Calcolo Numerico - Esercizi e Dispense - Università degli ...

Appunti di Calcolo Numerico - Esercizi e Dispense - Università degli ...

Appunti di Calcolo Numerico - Esercizi e Dispense - Università degli ...

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.

3.7. Instabilità e malcon<strong>di</strong>zionamento<br />

Esempio<br />

Esempio 3.7.1 Consideriamo l’integrale<br />

∫ 1<br />

x n<br />

y n =<br />

0 x + 10 dx<br />

per valori <strong>di</strong> n = 1,2,...,30. Osserviamo che, poichè x ∈ [0,1], la funzione integranda varia pure essa<br />

nell’intervallo [0,1] per cui 0 < y n < 1.<br />

Analiticamente, si ha:<br />

∫ 1<br />

x n + 10x n−1 ∫ 1<br />

x n−1 (x + 10)<br />

y n + 10y n−1 =<br />

dx =<br />

dx =<br />

0 x + 10<br />

0 x + 10<br />

Vale anche la relazione<br />

y 0 =<br />

∫ 1<br />

0<br />

1<br />

dx = ln(11) − ln(10).<br />

x + 10<br />

∫ 1<br />

0<br />

x n−1 dx = 1 n<br />

Possiamo pensare, quin<strong>di</strong>, <strong>di</strong> calcolare numericamente il valore <strong>di</strong> y n attraverso il seguente algoritmo:<br />

1. valutare y 0 = ln(11) − ln(10)<br />

2. per n = 1,2,...,30 valutare y n = 1 n − 10y n−1<br />

Questa formula ricorsiva darebbe l’esatto valore se non fossero presenti errori <strong>di</strong> arrotondamento che ci<br />

allontanano completamente dalla soluzione vera. L’errore si moltiplica esponenzialmente. Infatti<br />

y 1 = 1 − 10y 0<br />

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

y 3 = 1 3 − 10( 1 2 − 10 + 102 y 0 ) = −10 3 y 0 + cost ante<br />

. . . .<br />

y n = (−10) n y 0 + cost ante n<br />

L’algoritmo quin<strong>di</strong>, considerati gli errori <strong>di</strong> arrotondamento, presenta un errore E n con crescita <strong>di</strong> tipo<br />

esponenziale. Difatti otteniamo valori che via via si allontanano dall’intervallo <strong>di</strong> ammissibilità [0,1].<br />

I risultati che ricaviamo sono i seguenti (osserviamo che sono leggermente <strong>di</strong>versi a seconda dal<br />

linguaggio usato, proprio per effetto dell’instabilità).<br />

Da un programma in Fortran:<br />

Da un programma Matlab:<br />

n y n<br />

0 9.5310e-2<br />

1 4.6898e-2<br />

2 3.1021e-2<br />

3 2.3122e-2<br />

4 1.8778e-2<br />

... ....<br />

7 -3.0229e-1<br />

8 3.1479e+0<br />

9 -3.1368e+1<br />

10 3.1378e+2<br />

18 3.1377e+10<br />

27 -3.1377e+19<br />

30 3.1377e+22<br />

n y n<br />

0 9.5310e-2<br />

1 4.6898e-2<br />

2 3.1018e-2<br />

3 2.3154e-2<br />

4 1.8465e-2<br />

... ....<br />

7 1.1481-2<br />

8 1.0194e-2<br />

9 9.1673e-3<br />

10 8.3270e-3<br />

18 -9.1694e+1<br />

27 -9.1699e+9<br />

30 -9.1699e+13<br />

33

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

Saved successfully!

Ooh no, something went wrong!