OPTICS BY THE NUMBERS
L’Ottica Attraverso i Numeri
Michael Scalora
U.S. Army Research, Development, and Engineering CenterRedstone Arsenal, Alabama, 35898-5000
&Universita' di Roma "La Sapienza"
Dipartimento di Energetica
Rome, April-May 2004
Integrazioni Numeriche di Equazioni differenziali di Primo Grado
Soluzione Numeriche di Equazioni Nonlineari: Predictor-Corrector Algorithm
0
0.2
0.4
0.6
0.8
1.0
0
Ritorniamo alla tipica equazione differenziale di primo grado che abbiamo gia visto, e risolviamo.
( )( )
dp tp t
dt
La soluzione puo anche essere espressa cosi:
' '
0
( ) (0) ( )t
p t p p t dt
p(t)L’integrale rappresental’area sotto la curva p(t).Il problema numerico: come meglio stimarla
0 t
1( )
( )dp t dt
p t ( ) (0) tp t p e
' '
0
( ) (0) ( )t
p t p p t dt
' '
0
( ) (0) ( )t
p t p p t dt
Se ci limitiamo ad intervalli infinitesimali...
1If t
0 0 0 0( ) ( ) ( ) ( ) 1p t t p t p t t p t t
Dato un punto di partenza diverso da zero0t
'
0
( ) (0) (0) (0) 1t
p t p p dt p t
La funzione p(t’) puo essere approssimata come una costante data dal valore all’inizio dell’intervallo...
221 .... ...
2 !nnt tte tn
0 0 0 0( ) ( ) ( ) ( ) 1p t t p t p t t p t t }
}Taylor expansiondell’esponenziale
0 0;( ) (0) ( ) ( )t tp t p e p t t p t e
La soluzione approssimata e’…
…mentre la soluzione esatta e’…
2 20 0 0( ) ( ) ( )(1 / 2 ...)tp t t p t e p t t t
Il confronto rivela un errore dato dalla differenza delle
due soluzioni…
22 ...
2
tError
Stimato con un errore dell’ordine t2, l’integrale e’ l’area del rettangolo.
invece rappresenta la sottostima dell’integrale, che per funzioni che variano rapidamente puo essere notevole.
0
0.2
0.4
0.6
0.8
1.0
0 t
p(t0)
0 0 0 0( ) ( ) ( ) ( ) 1p t t p t p t t p t t }
} 2 20 0 0( ) ( ) ( )(1 / 2 ...)tp t t p t e p t t t
22 ...
2
tError
0
0.2
0.4
0.6
0.8
1.0
0 t
p(t0)
p(t0+t)
} 0 0( ) ( )p t t p t
0 00 0 0
( ) ( )( ) ( ) ( )
2
p t t p t tp t t p t p t t
How can we increase the accuracy of the solution?
' '0 0
0
( ) ( ) ( )t
p t t p t p t dt
+
0 01 / 2 ( 2) ) 1 /( t pp t tt t
Solve for p(t0+t)…
0 0
1 / 2( )(
1 / 2)p t t
tp t
t
00 00( ) (( ( )2
))t
p t pp t t p tt t
0 00 0 0
( ) ( )( ) ( ) ( )
2
p t t p t tp t t p t p t t
♠ ♠
Nella gran parte dei casi, una soluzione con un errore
del terzo ordine e’ piu che sufficiente.
30 0 0
2 32 4( ) ( ) ( ) 1 ( )
2 6
t ttp t t p t e p t t t
0 0
1 / 2( )(
1 / 2)p t t
tp t
t
Taylor expansion
1 2 2 3 3(1 / 2) 1 / 2 / 4 / 4 ...t t t t
2 3
1 2 3 41 / 2 1 / 2 1 ( )2 8
t tt t t t
confrontando con la soluzione esatta...
( )( )
dx tx t
dtSimple example:
( ) (0) tx t x e
0 0
1 / 2( ) ( )
1 / 2
tx t t x t
t
0 0( ) ( ) 1x t t x t t First order accuratesolution
Second order accuratesolution
Exact solution
0
0.2
0.4
0.6
0.8
1.0
0 1 2 3 4 5
second order solutionexact solutionfirst order solution
time
x(t)
t=1x(0)=1
( )( )
dx tx t
dt ( ) (0) tx t x e
0 0
1 / 2( ) ( )
1 / 2
tx t t x t
t
0 0( ) ( ) 1x t t x t t
First order solution Second order solution
0
0.2
0.4
0.6
0.8
1.0
0 2 4 6
second order solutionexact solutionfirst order solution
time
x(t)
t=0.5x(0)=1
( )( )
dx tx t
dt ( ) (0) tx t x e
0 0
1 / 2( ) ( )
1 / 2
tx t t x t
t
0 0( ) ( ) 1x t t x t t
0
0.2
0.4
0.6
0.8
1.0
0 2 4 6
t=0.25x(0)=1
( )( )
dx tx t
dt ( ) (0) tx t x e
0 0
1 / 2( ) ( )
1 / 2
tx t t x t
t
0 0( ) ( ) 1x t t x t t
First order solution Second order solution
0
0.2
0.4
0.6
0.8
1.0
0 2 4 6
t=0.125
( )( )
dx tx t
dt ( ) (0) tx t x e
0 0
1 / 2( ) ( )
1 / 2
tx t t x t
t
0 0( ) ( ) 1x t t x t t
0
0.2
0.4
0.6
0.8
1.0
0 t
f [x(t0)]
f [x(t0+t)]
' '0 0
0
( ) ( ) [ ( )]t
x t t x t f x t dt
( )
[ ( )]dx t
f x tdt
0 00 0
[ ( )] [ ( )]( ) ( )
2
f x t f x t tx t t x t t
0 0[ ( )] [ ( )]
2
f x t f x t t
Let’s look at the more generic equation…
0
0.2
0.4
0.6
0.8
1.0
0 t
f [x(t0)]
f [x(t0+t)]
0 0[ ( )] [ ( )]
2
f x t f x t t
0 0[ ( )] [ ( )]
2
f x t f x t t …quindi rappresenta un punto al centro dell’intervallo, che stimal’area con accuratezza al secondo ordine
.
2( )[( ( )] ( )
dx tf x t x t
dt
(0)( )
1 (0)
xx t
x t
Soluzione esatta…
Risolviamo numericamente…
Example
20 0[ ( )] ( )f x t x t 2
0 0[ ( )] ( )f x t t x t t
2[ ( )] ( )f x t x t
0 00 0
[ ( )] [ ( )]( ) ( )
2
f x t f x t tx t t x t t
2 20 0
0 0
( ) ( )( ) ( )
2
x t x t tx t t x t t
0
20
0
20( ) (
( )2
)( )
x t tx t
tt tt
xx
Per semplicita, riscriviamo cosi….20
20 { ) / 2x txx x …e sostituiamo x sul lato destro…
22 20 0
20 0 { ) / 2 / 2x x x xx x tt
22
2 2 2 2 2 200 0 00 0[ ]
4/ 2[ ]x x
tx x x t x x tx x
♠♠
2 2 2 2 30 0 0 0 0 0[ ] / 2 ( )x x x x x t x x t t
2 3 2 30 0 0 1( )x x x t x t t
23
0 0 0 0
2 3
2 3 2 30 0 0 0 2
( ) ( ) ( ) ( ) ( )...2
( ) ( ); ( ) 2 ( ) ( ) 2 ( )
( ) ( ) ( ) ( ) ( )...
tx t t x t x t t x t t
x t x t x t x t x t x t
x t t x t x t t x t t t
Confrontiamo con un’espanzione di Taylor…
La soluzione e’ accurata al secondo ordine, ma la procedura non e’ ne conveniente,
(come nel caso di equazioni nonlineari:)
o efficiente, se si devono calcolare derivate per l’espanzione di Taylor:
2 20 0{ ) / 2x x x x t
23
0 0 0 0
2 3
( ) ( ) ( ) ( ) ( )...2
( ) ( ); ( ) 2 ( ) ( ) 2 ( )
tx t t x t x t t x t t
x t x t x t x t x t x t
Invece, adottiamo ilPredictor-Corrector algorithm
(1) Prediction Step: obtain a First-Order solution at t0+t…
( )( ) [ ( )]dx t
i f x tdt
' '0 0
0
( ) ( ) ( ) [ ( )]t
ii x t t x t f x t dt
0 0 0( ) ( ) ( ) [ ( )]predictediii x t t x t f x t t
(2)…and use it to correct (or find) the solution by averaging the values of the functions at the beginning and at the end of the interval…
0 00 0
[ ( )] [ ( )]( ) ( )
2predictedf x t f x t t
x t t x t t
0
0.2
0.4
0.6
0.8
1.0
0 t
0[ ( )]predictedf x t t
0[ ( )]f x t
0 00 0
[ ( )] [ ( )]( ) ( )
2predictedf x t f x t t
x t t x t t
( )[ ( )] ( )
dx tf x t x t
dt
0 0 0 0 0( ) ( ) [ ( )] ( ) ( )predictedx t t x t f x t t x t x t t
0 0 0
0 0
0 0
( ) ( ) ( )
[ ( )] [ ( ) ]
( ) ( )
predictedf x t t f x t x t t
f x t f x t t
x t x t t
[ ]d
fdt
0 0 00 0
( ) ( ) ( )( ) ( )
2
x t x t x t tx t t x t t
0 0 00 0
( ) ( ) ( )( ) ( )
2
x t x t x t tx t t x t t
2
0 0 0 0( ) ( ) ( ) ( )2
tx t t x t x t t x t
…which is just a Taylor expansion for ANY function 0( )x t t
0 00 0
[ ( )] [ ( )]( ) ( )
2predictedf x t f x t t
x t t x t t
Therefore, the correction step…
…always finds a second order accurate (error is of order t3) solution to the generic differential equation
( )[ ( )]
dx tf x t
dt
20 0 0( ) ( ) ( )predictedx t t x t x t t
2 20 0
0 0
( ) ( )( ) ( )
2predictedx t x t t
x t t x t t
2 3 2 30 0 0 0( ) ( ) ( ) ( ) ( )x t t x t x t t x t t t
Back to our example…
2( )[( ( )] ( )
dx tf x t x t
dt
22 20 0 0
0 0
( ) ( ) ( )( ) ( )
2
x t x t x t tx t t x t t
Predictor-Corrector da una soluzioneaccurata al secondo ordine
(0)( )
1 (0)
xx t
x t
2 20 0
0 0
( ) ( )( ) ( )
2predictedx t x t t
x t t x t t
2( )( )
dx tx t
dt
0
0.2
0.4
0.6
0.8
1.0
0 10 20 30 40
numericalexact
t
x(t)
t=1.5
0
0.2
0.4
0.6
0.8
1.0
0 10 20 30 40 50
t
x(t)
t=0.5
0
0.2
0.4
0.6
0.8
1.0
0 10 20 30 40 50
t
x(t)
t=0.125
Sommario
Integrazioni Numeriche di Equazioni differenziali di Primo Grado
Soluzione Numeriche di Equazioni Nonlineari: Predictor-Corrector Algorithm
PC method da soluzioni accurate al secondo ordinecioe l’errore e’ del terzo ordine: basta nella maggior parte dei casi.