11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

202 • Chapter 5: Numerical <strong>Programming</strong> in Maple1.51.416666666666666741.414215686274509881.414213562374689871.414213562373095141.414213562Newton must use software floating-point arithmetic to find a root ofthe following Bessel function.> F := z -> BesselJ(1, z);F := z → BesselJ(1, z)> Newton(F, 4, 15);4Software arithmetic is used because evalhf does not recognize BesselJand the symbolic code for BesselJ uses the type command and remembertables, which evalhf does not allow.> evalhf( BesselJ(1, 4) );Error, remember tables are not supported in evalhfUsing a try-catch block as in the previous Newton procedure, allowsyour procedure to work when evalhf fails.The previous Newton procedure prints many digits when it is tryingto find a ten-digit approximation. The reason is that the print commandis located inside the iterate procedure which is inside a call to evalhf,where all numbers are hardware floating-point numbers, and print as such.Computing with Arrays of NumbersUse the evalhf command for calculations with numbers. The only structuredMaple objects allowed in a call to evalhf are arrays of numbers,either table-based arrays or rtable-based Arrays. If an array has unassignedentries, evalhf initializes them to zero.

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

Saved successfully!

Ooh no, something went wrong!