11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

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.

12 • Chapter 2: Procedures, Variables, and Extending MapleSummaryThis section introduced:• Rules Maple uses to distinguish global and local variables• Principal implications of these rules• Tools available for writing nested procedures2.2 Procedures That Return ProceduresSome of the standard Maple commands return procedures. For example,rand returns a procedure which in turn produces randomly chosen integersfrom a specified range. The dsolve function with the type=numericoption returns a procedure which supplies a numeric estimate of the solutionto a differential equation.You can write procedures that return procedures. This section discusseshow values are passed from the outer procedure to the inner procedure.Conveying ValuesThe following example demonstrates how locating the roots of a functionby using Newton’s method can be implemented in a procedure.Creating a Newton IterationUse Newton’s method to find the roots of a function.1. Choose a point on the x-axis that you think might be close to a root.2. Find the slope of the curve at the point you chose.3. Draw the tangent to the curve at that point and observe where thetangent intersects the x-axis. For most functions, this second point iscloser to the real root than your initial guess. To find the root, usethe new point as a new guess and keep drawing tangents and findingnew points.

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

Saved successfully!

Ooh no, something went wrong!