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.

5.2 Hardware Floating-Point Numbers • 197> evalf(q);0.3546007367 10 −7The two previous examples use the Int command rather than int forthe integration. If you use int, Maple first tries to integrate your expressionsymbolically. Thus, when evaluating the following commands, Mapledetermines a symbolic answer and then converts it to a floating-pointapproximation, rather than performing direct numerical integration.> evalf( int(x^99 * (1-x)^199 / Beta(100, 200), x=0..1/5) );0.3546007367 10 −7When performing numerical calculations, do not use commands likeint, limit, and sum that evaluate their arguments symbolically.In general, results from evalf(Int(...)) , evalf(Sum(...)) , andevalf(Limit(...)), are more accurate than results obtained from thecorresponding evalf(int(...)), evalf(sum(...)), and evalf(limit(...))operations. Generally, symbolic evaluation can be suppressed by usingunevaluation quotes. For example, evalf(sin(Pi/3)) = evalf(1/2 *3^(1/2)) while evalf(’sin’(Pi/3)) computes a floating-point approximationto sin(evalf(Pi/3)).5.2 Hardware Floating-Point NumbersMaple offers an alternative to software floating-point numbers: your computer’shardware floating-point arithmetic. Hardware floating-point calculationsare typically much faster than software floating-point calculations.However, hardware floating-point arithmetic accuracy depends on yourcomputer, and you cannot increase the precision.The evalhf command evaluates an expression using hardware floatingpointarithmetic.> evalhf( 1/3 );0.333333333333333314> evalhf( Pi );

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

Saved successfully!

Ooh no, something went wrong!