MATH226-maple代写
时间:2023-08-04
MATH226 Solutions 2
2.1 This problem has been moved to the week 2 group activity. The number has
been left in place to maintain parity with the video content.
2.2 The add command can be used to add up the terms in a simple series. For
example:
add( j^2 , j = 1 .. 10 )
Explain the difference between
add( evalf( 1 / j^2 ) , j = 1 .. 100 )
and
evalf( add( 1 / j^2 , j = 1 .. 100 ) )
Which is more accurate? Why does this happen?
Solution
The first form converts each term to a decimal and adds these together, so
the term with j = 3 is 0.1111111111, etc. The second form works with exact
arithmetic and converts to a decimal at the end (try the command without
evalf to see this). This is slightly more accurate because only one rounding
error occurs in the whole calculation. However, it should be noted that exact
arithmetic requires the computer to do much more work and so will be very
slow in more complex problems.
2.3 Suppose that Maple allowed only one assignment per statement, so you can’t
do
a , b := b , a
How could the values of two variables be swapped with this limitation?
Note: assign (different) numerical values to a and b before attempting this;
otherwise you may end up with a confusing error message.
Solution
It would be necessary to use a temporary (scratch) variable. For example
a := 1 :
b := 2 :
tmp := a :
a := b :
b := tmp :
a , b ;
2, 1
2.4 (a) Sum the series
S =
100∑
j=1
1
j3
using a do loop. Check the result using the add command.
(b) Evaluate the product
P =
500∏
j=2
1− 1
j5

Check the result using the mul command (look this up in the help
system if you can’t guess how it works).
Solution
See Maple worksheet.
2.5 (a) Estimate the sum of the series
S =
∞∑
j=1
1
j4
using a do loop. Do not use an upper limit for the index. Instead, break
the loop when
1
j4
< 0.5× 10−10 × Sj−1,
where Sj−1 is the partial sum to j − 1 terms.
(b) Estimate the value of the product
P =
∞∏
j=1
(
1− e−j)
Do not use an upper limit for the index. Instead, break the loop when
e−j < 0.5× 10−10.
Solution
See Maple worksheet.
2.6 In the late 18th century, French mathematicians under the direction of
Gaspard de Prony began construction of huge tables of logarithms and other
important functions. The task took several years, and occupied up to 80
assistants.
(a) Declare an array A with entries indexed from 1 to 200000. Then use
a do loop to fill in the entries so that Aj = ln j, calculated using 32
significant digit arithmetic. When this is completed, the array is better
than de Prony’s table of logarithms (more accurate and contains no
errors). Roughly how long does the calculation take?
(b) Gaspard de Prony’s team of assistants could calculate around 600
results per day. Roughly how many calculations of this type could Maple
perform if you left it running on your computer for one day?
Solution
See Maple worksheet.
essay、essay代写