This preview shows page 1. Sign up to view the full content.
Unformatted text preview: .
> sqrt(3)^2; 3 Maple recognizes the standard mathematical constants, such as π and the base of the natural logarithms, e. It works with them as exact quantities.
> Pi; π
> sin(Pi); 0 12 • Chapter 2: Mathematics with Maple: The Basics The exponential function is represented by the Maple function exp.
> exp(1); e
> ln(exp(5)); 5 The example with π may look confusing. When Maple is producing typeset real-math notation, it attempts to represent mathematical expressions as you might write them yourself. Thus, you enter π as Pi and Maple displays it as π . Maple is case sensitive. Ensure that you use proper capitalization when stating these constants. The names Pi, pi, and PI are distinct. The names pi and PI are used to display the lowercase and uppercase Greek letters π and Π, respectively. For more information on Maple constants, enter ?constants at the Maple prompt. Floating-Point Approximations
Maple works with exact values, but it can return a ﬂoating-point approximation up to about 228 digits, depending upon your computer’s resources. Ten or twenty accurate digits in ﬂoating-point numbers is adequate for many purposes, but two problems severely limit the usefulness of such a system. • When subtracting two ﬂoating-point numbers of almost equal magnitude, the relative error of the diﬀerence may be very large. This is known as catastrophic cancellation. For example, if two numbers are identical in their ﬁrst seventeen (of twenty) digits, their diﬀerence is a three-digit number accurate to only three digits. In this case, you would need to use almost forty digits to produce twenty accurate digits in the answer. • The mathematical form of the result is more concise, compact, and convenient than its numerical value. For instance, an exponential function provides more information about the nature of a phenomenon than a large set of numbers with twenty accurate digits. An exact analytical description can also determine the behavior of a function when extrapolating to regions for which no data exists. 2.2 Numerical Computations • 13 The evalf command converts an exact numerical expression to a ﬂoating-point number.
> evalf(Pi); 3.141592654 By default, Maple calculates the result using ten digits of accuracy, but you can specify any number of digits. Indicate the number after the numerical expression, using the following notation.
> evalf(Pi, 200); 3.1415926535897932384626433832795028841\ 97169399375105820974944592307816406286\ 20899862803482534211706798214808651328\ 23066470938446095505822317253594081284\ 81117450284102701938521105559644622948\ 9549303820 You can also force Maple to do all its computations with ﬂoating-point approximations by including at least one ﬂoating-point number in each expression. Floats are contagious : if an expression contains one ﬂoatingpoint number, Maple evaluates the entire expression using ﬂoating-point arithmetic.
> 1/3 + 1/4 + 1/5.3; 0.7720125786
> sin(0.2); 0.1986693308 The optional second...
View Full Document