首页 > > 详细

讲解 MATH226 Problem Sheet 2讲解 Prolog

MATH226 Problem Sheet 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?

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.

2.4 (a) Sum the series

using a do loop. Check the result using the add command.

(b) Evaluate the product

Check the result using the mul command (look this up in the help system if you can’t guess how it works).

2.5 (a) Estimate the sum of the series

using a do loop. Do not use an upper limit for the index. Instead, break the loop when

where Sj−1 is the partial sum to j − 1 terms.

(b) Estimate the value of the product

Do not use an upper limit for the index. Instead, break the loop when

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?




联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp