# This worksheet contains the Maple commands from Chapter 3 of # Introduction to Scientific Programming by Joseph L. Zachary. # # (3.4) This calculates the circumference of the earth in kilometers, # beginning from Eratosthenes's measurements. # > 360 / 7.2 * 5000. * 0.1575; # # (3.5) We can save the value of the expression from (3.4) into the # variable circumference by using an assignment statement. # > circumference := 360 / 7.2 * 5000. * 0.1575; # # (3.6) Now that we have given circumference a floating-point value, we # can use it as if it were a floating-point number. We can, for # example, determine its value. # > circumference; # # (3.7) We can also use its value in more complicated expressions. # > diameter := circumference / 3.14159; # # (3.8) Here we recompute circumference using parentheses to explicitly # group the operands and operators from (3.5). # > circumference := (360 / 7.2) * (5000. * 0.1575); # # (3.9) The Digits variable is consulted by Maple to determine how many # digits to use in the mantissas of floating-point numbers. Its value # can be modified via assignment. # > Digits := 4; # # (3.10) Now when we repeat the calculation from (3.5), we obtain a # four-digit result. (Maple adds the trailing zero so that the # magnitude of the result will be correct.) # > four_digit_circum := 360 / 7.2 * 5000. * 0.1575; # # (3.11) We can also obtain a four-digit approximation to the earth's # diameter. # > four_digit_diameter := four_digit_circum / 3.1; # # Let's set the mantissa size back to ten. # > Digits := 10; # # (3.12) This is part of an interval arithmetic computation. We use # the smallest possible value (7.15) for the angle measured by # Eratosthenes, the largest possible value (5050) for the distance from # Alexandria to Cyrene, and the largest possible value for the # conversion factor from stadia to kilometers. This gives us the # largest possible value for the circumference of the earth. # > (360 / 7.15) * 5050. * 0.15755; # # (3.13) We compute the smallest possible value for the circumference # of the earth by perturbing the measurements in the other direction. # > (360 / 7.25) * 4950. * 0.15745; >