关键词 > MATH226

MATH226 Problem Sheet 3

发布时间:2024-06-10

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MATH226 Problem Sheet 3

3.1  The sine function has the Taylor series expansion

 

(a)  Write a Maple procedure which computes this sum up to a finite number of terms using a do loop.  Do not use an upper limit for the index; use the condition

if  (  abs(  t  )  <=  eps  *  abs(  s  )  ) then

break  : end  if  :

where s is the current value of the sum, t is the next term to be added and eps = 0.5 * 10 10 .  Use your  procedure to compute sin x for five values of x, and compare these to values obtained using Maple’s built in sine function.

(b)  In your sine procedure, insert a print statement to show how many terms have been summed when the break statement is activated.  Now  use your procedure to compute sin x for x = 0.1, x = π − 0.1, x = 2π + 0.1 and x = 3π − 0.1.  Don’t forget to  use evalf to obtain a numerical approximation to π . What do you notice? Why does this happen?

(c)  In view of your answer to part (b), write a Maple procedure which takes as its argument a real number x and returns as its result a value x0 such that

Use this to improve the efficiency of your sine procedure, and repeat the four computations from part (b) to show that this has indeed worked.

Hint:  first obtain a  value in the interval (−π, π], then use symmetry to nd x0 .

3.2    (a)  Write a Maple procedure that takes as its argument a real number x and computes the sum

using a do  loop.   Do  not  use  an  upper  limit  for  the  index;  use  the condition

if  (  abs(  t  )  <=  eps  *  abs(  s  )  ) then

break  :

end  if  :

where s is the current value of the sum, t is the next term to be added and eps = 0.5 * 10 10 .

(b)  Plot  a  graph  of  F (x)  for  −1  ≤  x  ≤  1.    Then  plot  the  function

g(x) = x4  − 2x2 + 7/15 on the same axes. What do you notice?

Use plot(  F  ,  -1  . .   1  ) to create the graph ofF.

(c)  Check the accuracy of your procedure at x = 0.4, 0.5 and 0.6.  What do you notice?  Why do you think this happens, and how should the procedure be changed to prevent it?

3.3  Write a procedure which takes a student number (a nine digit positive integer with no leading zeros) as its argument and returns an array containing the individual digits in their original order. That is, the result of

dismantle_student_number(  123456789  )

should be  [  1 2 3 4 5 6 7 8 9 ] .  Test the  procedure using your own student number, and two other nine digit natural numbers.

Hint: you can use the mod command to obtain the last digit of an integer; for example

1023  mod  10