Sie sind auf Seite 1von 33

Computation and Programming in Physics

Root Finding Algorithms

Syeilendra Pramuditya

Physics Program
Institut Teknologi Bandung
1
2

Root Finding?
f ( x)  cos x  x
3

Root Finding Algorithms


 Bisection
 Newton-Rhapson (NR)
 Regula-Falsi
 Secant
 And many many more..
4

Bisection Method

ab
Root 
2
5

Bisection Method: Algorithm


1. Tentukan batas kiri dan kanan
interval
2. Periksa apakah akar ada di dalam
interval, jika tidak, maka kembali ke
step 1, loop step 1 dan 2 sampai akar
dipastikan ada di dalam interval
3. Bagi interval menjadi dua, dan
evaluasi nilai f(x) di titik tengah ini,
jika |f(x)|>>0, maka lanjut ke step 4,
jika |f(x)|sangat dekat 0, maka
selesai
4. Periksa apakah akar ada di sisi kiri
atau kanan
5. Perbarui batas kiri/kanan
ab
6. Kembali ke step 3 Root 
7. Loop sampai nilai mutlak f(x) sudah 2
sangat mendekati nol
8. Silahkan coba buat program untuk
mencari akar persamaan f(x) = x2 - 7
6

Newton Method
Taylor Series
f (a)( x  a) f (a)( x  a) 2 f (a)( x  a )3
f ( x)  f (a)    
1! 2! 3!

Linear approximation: the first two terms


f ( x )  f (a )  f ( a )( x  a )  0

f (a)
xa
f (a)
f ( xold )
xnew  xold 
f ( xold )
7

Regula-Falsi Method
y

f(c)

a
x
c

f(a) y  f ( x)   x  
f (c )  f ( a ) cf ( a)  af (c)
f ( x)  x
ca ca

af (c)  cf (a )
f ( x)  0  x 
f (c )  f ( a )
8

Regula-Falsi Method (Bisection-like)

y  f ( x)   x  
f (c )  f ( a ) cf ( a)  af (c)
f ( x)  x
ca ca

af (c)  cf (a )
f ( x)  0  x 
f (c )  f ( a )
9

Secant Method (NR-like)

f ( xi )
xi 1  xi 
 f ( xi )  f ( xi 1 ) 
 
 xi  xi 1 
10
10
Sample Function
1
f ( x)  tanh(50 x  250) f ( x)  25sech 2 (50 x  250)
2
1
sech 
cosh
0.6

0.4

0.2

0
-20 -15 -10 -5 0 5 10 15 20
-0.2

-0.4

-0.6
11

Bi-NR Hybrid Method


 Slow-but-sure Bisection combined with
efficiency of Newton-Raphson method
12

Bisection-NR Hybrid Method


 Tentukan batas kiri dan kanan untuk
Bisection
 Pastikan akar ada diantara batas tsb
 Tentukan tebakan awal untuk NR
 Tebakan awal harus ada diantara batas Bisection
 Gunakan NR untuk estimasi akar
 Jika estimasi akar NR ada di dalam batas
Bisection, maka gunakan NR
 Jika estimasi akar NR ada di luar batas
Bisection, maka gunakan Bisection
 Iterasi sampai f(x) sangat dekat nol
13

Physics Problem


xf

Wg   Fg  dx  mg x cos   mg x
xi

xf
 
xf
k 1
Ws   Fs  dx    kxdx    x 2f  xi2    k x 2
xi xi
2 2

K  W  K f  K i  Wg  Ws  vi  ...

Ki  U i  K f  U f
1 2 1 1
mvi  mgxi  mv 2f  mgx f  kx 2f
2 2 2
ax 2  bx  c  0  Root Finding!
14
14

Quantum Mechanics Problem


A Particle in a Potential Field
15
15
Infinite Potential Well
 2 d 2 ( x)
  V ( x) ( x)  E ( x) ( x)
2m dx 2

d 2 ( x) 2m 2
   E  V ( x )  ( x )   k  ( x)
dx 2
 2

2m
2 
k E  V ( x) 

 ( x)  A sin kx  B cos kx
 2 dx  Probability to find a particle in dx

Inside the well  V (a  x  a )  0


d 2 ( x ) 2mE
   ( x)   k 2 ( x)
dx 2
 2

2mE
k
2
Boundary Condition   ( x  a )   ( x  a )  0
16
16
Infinite Potential Well
General Solution   ( x)  A sin kx  B cos kx
Boundary Condition   ( x   a)   ( x  a)  0
 ( x  a )  A sin(ka)  B cos( ka)  0
 ( x  a )   A sin ka  B cos ka  0
 ( x  a )  A sin ka  B cos ka  0

Add and subtract the above 2 eqs:


A sin ka  0 and B cos ka  0

Solutions??
A  B  0  Boring!
A  0 and B  0  Impossible
A  0 and B  0  Possible
A  0 and B  0  Possible
17
17
Infinite Potential Well

Case 1
A  0 and B  0  Possible
cos ka  0
2mE 1 3
ka  a   ,  ,...  (n  1/ 2) n  0,1, 2,...
 2
2 2
(n  1/ 2) 2  2  2
En  2
n  0,1, 2,...
2ma
Discrete Energy Levels of Particle
18
18
Infinite Potential Well

Case 2
A  0 and B  0  Possible
sin ka  0
2mE
ka  a  0,  , 2 ,...  n n  0,1, 2,...
 2

n 2 2  2
En  n  0,1, 2,...
2ma 2
Discrete Energy Levels of Particle
19
19
Finite Potential Well?

 2 d 2 ( x)
 2
 V ( x) ( x)  E ( x) ( x)
2m dx

Region II
d 2 ( x) 2m
2 
  E  V ( x)  ( x)   2 ( x)
dx 2

d 2 ( x) 2mE 2
   ( x )    ( x)
dx 2
 2

2mE

2
 II ( x)  A sin  x  B cos  x
20
20
Finite Potential Well

 2 d 2 ( x)
 2
 V ( x) ( x)  E ( x) ( x)
2m dx

Region I
d 2 ( x) 2m 2
 V ( x )  E  ( x )    ( x)
dx 2
 2

2m
2 
 V ( x)  E 

 ( x)  Ce  x  De   x
The farther into the "clasically forbidden" region,
the less likely it is to find the particle.
D  0   I ( x)  Ce  x
21
21
Finite Potential Well

 2 d 2 ( x)
 2
 V ( x) ( x)  E ( x) ( x)
2m dx

Region III
d 2 ( x) 2m 2
 V ( x )  E  ( x )  k  ( x)
dx 2
 2

2m
2 
k V ( x)  E 

 ( x)  Ee  x  Fe   x
The farther into the "clasically forbidden" region,
the less likely it is to find the particle.
E  0   III ( x)  Fe   x
22
22
Finite Potential Well

Three separate regions, with boundary conditions:


 ( x) continuous at boundaries
 ( x) continuous at boundaries

At x  a At x  a
 I (a)   II ( a)  II (a)   III (a)
Ce  a   A sin  a  B cos  a A sin  a  B cos  a  Fe   a
 I ( a)   II (a)  II (a)   III
 (a)
 Ce   a   A cos  a   B sin  a  A cos  a   B sin  a    Fe   a
23
23
Finite Potential Well

 A sin  a  B cos  a  Ce   a
 A cos  a   B sin  a   Ce   a
A sin  a  B cos  a  Fe   a
 A cos  a   B sin  a    Fe   a

2mE 2m
2 
  V ( x)  E 
2 

A  0& B  0  C  F
 B sin  a   Ce   a
  sin  a   cos  a
B cos  a  Ce   a
 B sin  a    Fe   a
a
  sin  a   cos  a
B cos  a  Fe
24
24
Finite Potential Well

 A sin  a  B cos  a  Ce   a
 A cos  a   B sin  a   Ce   a
A sin  a  B cos  a  Fe   a
 A cos  a   B sin  a    Fe   a

2mE 2m
2 
  V ( x)  E 
2 

A  0 & B  0  C  F
 A cos  a   Ce   a
a
  cos  a    sin  a
 A sin  a  Ce
 A cos  a    Fe   a
  cos  a    sin  a
A sin  a  Fe  a
25
25
Finite Potential Well

 A sin  a  B cos  a  Ce   a
 A cos  a   B sin  a   Ce   a
A sin  a  B cos  a  Fe   a
 A cos  a   B sin  a    Fe   a

A  0& B  0
2mE 2m
2 
  V ( x)  E 
2 
f ( E )   sin  a   cos  a  0  Root finding problem!
26
26
Finite Potential Well

 A sin  a  B cos  a  Ce   a
 A cos  a   B sin  a   Ce   a
A sin  a  B cos  a  Fe   a
 A cos  a   B sin  a    Fe   a

A  0&B  0
2mE 2m
  V ( x)  E 
2 2
f ( E )   cos  a   sin  a  0  Root finding problem!
27
27
Finite Potential Well

 Input:
 Particle mass m
 Well width a
 Potential V0
A  0& B  0
2mE 2m
2  0
  V  E
2 
f ( E )   sin  a   cos  a  0  Root finding problem!

A  0&B  0
2mE 2m

2

2
V0  E 
f ( E )   cos  a   sin  a  0  Root finding problem!
28
28

Easy..??
29
29
Finite Potential Well
 Particle mass
 m ~ 1E-31 kg
 Potential well
 V0 ~ 1E-19 J
 Width of quantum well
 a ~ 1E-10 m
 Planck constant
 h2 = 1.112E-68 J.s

Super tiny world..!!


30
30
Finite Potential Well (Unit Conversion)
 Particle mass
 m ~ 1 me
 Potential well
 V0 ~ 1 eV
 Width of quantum well
 a ~ 1 Angstrom (A)
 Planck constant
 h2 = 7.619 me.eV.A2

Now they look “normal” 


31
31
Finite Potential Well
 Sample Input
 a = 3 Angstrom
 m = 1 me
 V0 = 10 eV
32
32
Finite Potential Well
 Estimate root locations
 Plot f(E) versus E

A  0& B  0
2mE 2m
2  0
  V  E
2 
f ( E )   sin  a   cos  a  0  Root finding problem!

A  0&B  0
2mE 2m
2  0
  V  E
2 
f ( E )   cos  a   sin  a  0  Root finding problem!
33
33
Finite Potential Well
4

1
Function f(E)

-1

-2

-3

-4
0 5 10 15 20 25 30 35 40 45 50
Particle Energy (eV)

All we have to do now is simply find the roots!


Roots of f(E)  Discrete energy levels of the particle

Das könnte Ihnen auch gefallen