12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

differentiation & searching 1517.6 Second Derivatives (Problem)Let’s say that you have measured the position y(t) versus time for a particle(Figure 7.1). Your problem now is to determine the force on the particle. Newton’ssecond law tells us that force and acceleration are linearly related:F = ma = m d2 ydt 2 , (7.16)where F is the force, m is the particle’s mass, and a is the acceleration. So if we candetermine the acceleration a(t)=d 2 y/dt 2 from the y(t) values, we can determinethe force.The concerns we expressed about errors in first derivatives are even morevalid for second derivatives where additional subtractions may lead to additionalcancellations. Let’s look again at the central-difference method:dy(t)dt≃y(t + h/2) − y(t − h/2). (7.17)hThis algorithm gives the derivative at t by moving forward and backward from tby h/2. We take the second derivative d 2 y/dt 2 to be the central difference of thefirst derivative:d 2 y(t)dt 2 ≃ y′ (t + h/2) − y ′ (t − h/2)h[y(t + h) − y(t)] − [y(t) − y(t − h)]≃h 2 (7.18)y(t + h)+y(t − h) − 2y(t)=h 2 . (7.19)As we did for first derivatives, we determine the second derivative at t by evaluatingthe function in the region surrounding t. Although the form (7.19) is more compactand requires fewer steps than (7.18), it may increase subtractive cancellation by firststoring the “large” number y(t + h)+y(t − h) and then subtracting another largenumber 2y(t) from it. We ask you to explore this difference as an exercise.7.6.1 Second-Derivative AssessmentWrite a program to calculate the second derivative of cos t using the centraldifferencealgorithms (7.18) and (7.19). Test it over four cycles. Start with h ≃ π/10and keep reducing h until you reach machine precision.7.7 Unit II. Trial-and-Error SearchingMany computer techniques are well-defined sets of procedures leading to definiteoutcomes. In contrast, some computational techniques are trial-and-error−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 151

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

Saved successfully!

Ooh no, something went wrong!