

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Calculations with floating-point numbers must be done with care. Computations done with- out some forethought and planning can easily lead to incorrect or nonsensical conclusions. For example, based solely on numerical evidence, one might conclude the harmonic series converges. The purposes of this lab, and project, are to alert you to some of the potential problems and ways they can be addressed.
The Activities and Project 3 involve various topics from earlier in the course:
Review these topics for this lab (and as early preparation for the final exam).
ApproximateInt( f , a..b, partition=N , method=left, output=plot ); (see also Lab 13 for Calculus I, Fall 2004) Digits maximum number of significant (decimal) digits in a floating-point number Digits := 5; (the default value is 10) print print one or more Maple quantities print( 9, 9^9, 9! ); printf formatted printing of one or more Maple quantities printf( "%5a %10a %10a\n", 9, 9^9, 9! ); (see ?printf for full formatting details) [for ...] [from ...] command for controlling iterative loops [to ... ] [by ...] the for, from, to, and by clauses are all optional [while ...] only the do and end do are required; do ... end do explicit examples are provided in the Activities
f := arctan(x); # define function a := 1; # define base point for Taylor expansion for k from 1 to 15 do df := diff( f, x$k ); # compute kth derivative dfa := eval( df, x=a ); # evaluated at x = 0 printf( " %3a %20a\n", k, dfa/k! ); # display coefficient of (x − a)k^ in Taylor polynomial end do: # note use of colon here
∫ (^) x
0
e−t
2 dt.
Digits := 6; # maximum number of decimal digits for k from 0 to 12 do q := 1+10^(-k); # compute 1 + (†) printf( " %3a %15a %30 %15a \n", k, 10^k, q, evalf(q) ); end do; An estimate of machine epsilon can be obtained from this table of values. How does machine epsilon change with the value of Digits? Note: Maple has no trouble working with arbitrarily large integers; this effect is a concern only for floating-point arithmetic.
∑∞ k=1 ak.^ If the terms of the series converge to zero (as we know they must for any convergent series), then — eventually — the ak < and adding additional terms contributes nothing to the computed sum. That is, the series appears to converge!
a := k -> 1/k; # define terms in harmonic series Digits := 6; # maximum number of decimal digits SUM := 0.0; # initialize sum to zero for k from 1 to 100000 do # add next term to sum (‡) SUM := SUM + a(k); end do: # with a ;, output is 100,000 lines! SUM; # final sum Change the value of Digits (and possibly the upper bound on the sum) and observe how the “sum” of the harmonic series changes.