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

MATH256 Problem Sheet 3

3.1 The sine function has the Taylor series expansion

sin _ = j(-1)j

(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 t 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 _ for five values of _, 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 _ for _ = 0.1, _ = π - 0.1, _ = 2π +0.1 and _ = 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 _ and returns as its result a value _0

such that

-     < _0 < and sin _0 = sin _.

Use this to improve the eciency of your sine procedure, and repeat the four computations from part (b) to show that this has indeed worked. Hint: rst obtain a value in the interval (-π← π], then use symmetry to nd _0 .


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

(_) = 48 o (-1)j+1 cos(jπ_) ← -1 < _ < 1.

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 t is the current value of the sum, z is the next term to be added and eps = 0.5 * 10-10 .

(b)  Plot a graph of (_) for  -1  < _ < 1. Then plot the function g(_) = _4 - 2_2 + 7/15 on the same axes. What do you notice? Use plot(  F  ,  -1  . .  1  ) to create the graph of .

(c)  Check the accuracy of your procedure at _ = 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