Chapter 6 - Davidson Physics

Chapter 6 - Davidson Physics Chapter 6 - Davidson Physics

phy.davidson.edu
from phy.davidson.edu More from this publisher
12.07.2015 Views

CHAPTER 6. THE CHAOTIC MOTION OF DYNAMICAL SYSTEMS 183Appendix 6B: Finding the Roots of a FunctionThe roots of a function f(x) are the values of the variable x for which the function f(x) is zero.Even an apparently simple equation such aswhere c is a constant cannot be solved analytically for x.f(x) = tan x − x − c = 0. (6.54)Regardless of the function and the approach to root finding, the first step should be to learn asmuch as possible about the function. For example, plotting the function will help us to determinethe approximate locations of the roots.Newton’s (or the Newton-Raphson) method is based on replacing the function by the firsttwo terms of the Taylor expansion of f(x) about the root x. If our initial guess for the root isx 0 , we can write f(x) ≈ f(x 0 ) + (x − x 0 )f ′ (x 0 ). If we set f(x) equal to zero and solve for x, wefind x = x 0 − f(x 0 )/f ′ (x 0 ). If we have made a good choice for x 0 , the resultant value of x shouldbe closer than x 0 to the root. The general procedure is to calculate successive approximations asfollows:x n+1 = x n − f(x n)f ′ (x n ) . (6.55)If this series converges, it converges very quickly. However, if the initial guess is poor or if thefunction has closely spaced multiple roots, the series may not converge. The successive iterationsof Newton’s method is an another example of a map. Newton’s method also works with complexfunctions as we will see in the following problem.Problem 6.24. Cube rootsConsider the function f(z) = z 3 − 1, where z = x + iy, and f ′ (z) = z 2 . Map the range ofconvergence of (6.55) in the region [−2 < x < 2, −2 < y < 2] in the complex plane. Color thestarting z value red, green, or blue depending on the root to which the initial guess converges. Ifthe trajectory does not converge, color the starting point black. For more insight add a mousehandler to your program so that if you click on your plot, the sequence of iterations starting fromthe point where you clicked will be shown.The following problem discusses a situation that typically arises in courses on quantum mechanics.Problem 6.25. Energy levels in a finite square wellThe quantum mechanical energy levels in the one-dimensional finite square well can be found bysolving the relation:ɛ tan ɛ = √ ρ 2 − ɛ 2 , (6.56)where ɛ = √ mEa 2 /2 and ρ = √ mV 0 a 2 /2 are defined in terms of the particle mass m, theparticle energy E, the width of the well a, and the depth of the well V 0 . The function ɛ tan ɛ haszeros at ɛ = 0, π, 2π, . . . and asymptotes at ɛ = 0, π/2, 3π/2, 5π/2 . . .. The function √ ρ − ɛ 2 is aquarter circle of radius ρ. Write a program to plot these two functions with ρ = 3 and then useNewton’s method to determine the roots of (6.56). Find the value of ρ and thus V 0 , such thatbelow this value there is only one energy level and above this value there is more than one. Atwhat value of ρ do three energy levels first appear?

CHAPTER 6. THE CHAOTIC MOTION OF DYNAMICAL SYSTEMS 184In Section 6.6 we introduced the bisection root finding algorithm. This algorithm is implementedin the Root class in the numerics package. It can be used with any function.Listing 6.2: The bisection method defined in the Root class in the numerics package.public s t a t i c double b i s e c t i o n ( f i n a l Function f , double x1 , double x2 , f i n a l double t o l ) {int count = 0 ;int maxCount = ( int ) (Math . l o g (Math . abs ( x2 − x1 ) / t o l ) / Math . l o g ( 2 ) ) ;maxCount = Math . max(MAX ITERATIONS, maxCount ) + 2 ;double y1 = f . e v a l u a t e ( x1 ) , y2 = f . e v a l u a t e ( x2 ) ;i f ( y1 * y2 > 0) { // y1 and y2 must have o p p o s i t e s i g nreturn Double .NaN; // i n t e r v a l does not contain a r o o t}while ( count < maxCount ) {double x = ( x1 + x2 ) / 2 ;double y = f . e v a l u a t e ( x ) ;i f (Math . abs ( y ) < t o l ) return x ;i f ( y * y1 > 0) { // r e p l a c e t h e end−p o i n t t h a t has t h e same s i g nx1 = x ;y1 = y ;}else {x2 = x ;y2 = y ;}count++;}return Double .NaN; // did not converge in max i t e r a t i o n s}The bisection algorithm is guaranteed to converge if you can find an interval where the functionchanges sign. However, it is slow. Newton’s algorithm is very fast, but may not converge. Wedevelop an algorithm in the following problem that combines these two approaches.Problem 6.26. Finding rootsModify Newton’s algorithm to keep track of the interval between the minimum and the maximumof x while iterating (6.55). If the iterate x n+1 jumps outside this interval, interrupt Newton’smethod and use the bisection algorithm for one iteration. Test the root at the end of the iterativeprocess to check that the algorithm actually found a root. Test your algorithm on the function in(6.54).References and Suggestions for Further ReadingBooksRalph H. Abraham and Christopher D. Shaw, Dynamics – The Geometry of Behavior, secondedition, Addison-Wesley (1992). The authors use an abundance of visual representations.

CHAPTER 6. THE CHAOTIC MOTION OF DYNAMICAL SYSTEMS 184In Section 6.6 we introduced the bisection root finding algorithm. This algorithm is implementedin the Root class in the numerics package. It can be used with any function.Listing 6.2: The bisection method defined in the Root class in the numerics package.public s t a t i c double b i s e c t i o n ( f i n a l Function f , double x1 , double x2 , f i n a l double t o l ) {int count = 0 ;int maxCount = ( int ) (Math . l o g (Math . abs ( x2 − x1 ) / t o l ) / Math . l o g ( 2 ) ) ;maxCount = Math . max(MAX ITERATIONS, maxCount ) + 2 ;double y1 = f . e v a l u a t e ( x1 ) , y2 = f . e v a l u a t e ( x2 ) ;i f ( y1 * y2 > 0) { // y1 and y2 must have o p p o s i t e s i g nreturn Double .NaN; // i n t e r v a l does not contain a r o o t}while ( count < maxCount ) {double x = ( x1 + x2 ) / 2 ;double y = f . e v a l u a t e ( x ) ;i f (Math . abs ( y ) < t o l ) return x ;i f ( y * y1 > 0) { // r e p l a c e t h e end−p o i n t t h a t has t h e same s i g nx1 = x ;y1 = y ;}else {x2 = x ;y2 = y ;}count++;}return Double .NaN; // did not converge in max i t e r a t i o n s}The bisection algorithm is guaranteed to converge if you can find an interval where the functionchanges sign. However, it is slow. Newton’s algorithm is very fast, but may not converge. Wedevelop an algorithm in the following problem that combines these two approaches.Problem 6.26. Finding rootsModify Newton’s algorithm to keep track of the interval between the minimum and the maximumof x while iterating (6.55). If the iterate x n+1 jumps outside this interval, interrupt Newton’smethod and use the bisection algorithm for one iteration. Test the root at the end of the iterativeprocess to check that the algorithm actually found a root. Test your algorithm on the function in(6.54).References and Suggestions for Further ReadingBooksRalph H. Abraham and Christopher D. Shaw, Dynamics – The Geometry of Behavior, secondedition, Addison-Wesley (1992). The authors use an abundance of visual representations.

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

Saved successfully!

Ooh no, something went wrong!