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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CAPITOLO 3<br />

Rappresentazione dei numeri nel<br />

calcolatore<br />

Tutti noi ogni giorno usiamo la<br />

matematica: per prevedere il tempo,<br />

per <strong>di</strong>re l’ora, per contare il denaro.<br />

Usiamo la matematica anche per<br />

analizzare i crimini, comprendere<br />

gli schemi, prevedere i<br />

comportamenti. Usando i numeri,<br />

possiamo svelare i più gran<strong>di</strong><br />

misteri della vita!<br />

NUMB3RS<br />

3.1 Introduzione . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19<br />

3.2 Aritmetica <strong>di</strong> macchina . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21<br />

3.3 Conversione <strong>di</strong> base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22<br />

3.4 Rappresentazione IEEE dei numeri <strong>di</strong> macchina . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23<br />

3.5 Precisione numerica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26<br />

3.6 Propagazione <strong>degli</strong> errori . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27<br />

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

3.7.1 Instabilità . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31<br />

3.7.2 Malcon<strong>di</strong>zionamento . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35<br />

3.1 Introduzione<br />

Molte volte, si pensa che i risultati numerici ottenuti da un calcolatore elettronico, specie se sono ottenuti<br />

come output <strong>di</strong> un sofisticato software, non contengano errori e, se ne abbiano, siano da ritenersi trascurabili.<br />

In realtà, quando si esegue un programma al calcolatore, bisogna prima <strong>di</strong> tutto aver verificato che sia stato<br />

scritto correttamente (il programma deve, cioè, tradurre correttamente il problema matematico che si vuole<br />

risolvere). Inoltre, bisogna tener conto che i risultati numerici sono sempre affetti da un certo tipo <strong>di</strong> errore,<br />

che può essere, per esempio, <strong>di</strong> arrotondamento o <strong>di</strong> troncamento: π è un numero con infinite cifre decimali<br />

ma il calcolatore lo può vedere solo come un numero con finite cifre decimali..., molte formule non possono<br />

essere usate così come sono ma devono essere in qualche modo semplificate (basti pensare ad una somma <strong>di</strong><br />

infiniti termini). Non tenere conto <strong>di</strong> questi fattori può portare a risultati davvero <strong>di</strong>sastrosi, come può essere<br />

verificato andando a controllare la pagina web de<strong>di</strong>cata ai <strong>di</strong>sastri dovuti a uno scorretto calcolo numerico:<br />

http://www.ima.umn.edu/~arnold/<strong>di</strong>sasters/<strong>di</strong>sasters.html<br />

19

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

Saved successfully!

Ooh no, something went wrong!