MATH226-maple代写
时间:2023-08-04
MATH226 Problem Sheet 3
• This problem sheet is for practice only; solutions will not be assessed, and do
not need to be submitted to Canvas.
• However, similar questions may appear in the assessments.
3.1 The sine function has the Taylor series expansion
sin x =
∞∑
j=0
(−1)j x
2j+1
(2j + 1)! .
(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 = pi−0.1, x = 2pi+ 0.1
and x = 3pi − 0.1. Don’t forget to use evalf to obtain a numerical
approximation to pi. 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
− pi2 ≤ x0 ≤
pi
2 and sin x0 = sin x.
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 (−pi, pi], then use symmetry to
find x0.
3.2 (a) Write a Maple procedure that takes as its argument a real number x
and computes the sum
F (x) = 48
pi4
∞∑
j=1
(−1)j+1
j4
cos(jpix), −1 ≤ x ≤ 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 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 of F .
(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
essay、essay代写