$24.99
CST8233: Lab #5
Maclurin Series Expansion
Objective
The objective of this lab is to familiarize the student with the theory topics
covered in week 4. Mainly, this lab focuses on Maclaurin Series expansion
and Reminder theorem.
Earning
To earn your mark for this lab, each student should finish the lab’s requirements
within the lab session and demonstrate the working code to the instructor.
Discussion
Before starting the lab, the student has to show the instructor the steps of
developing Maclaurin series in general. Then, each student should derive
Maclaurin series for the function 𝑓(𝑥) = cos 𝑥
Laboratory Problem Description
The Maclaurin series expansion of 𝑓(𝑥) = cos 𝑥 is given as:
cos 𝑥 = 1 −
𝑥
2
2!
+
𝑥
4
4!
−
𝑥
6
6!
+
𝑥
8
8!
− ⋯
Or,
cos 𝑥 = ∑(−1)
𝑛
𝑥
2𝑛
2𝑛!
∞
𝑛=0
Part A: Write a C program to compute the function 𝑓(𝑥) = cos 𝑥 using the
series shown above. Inputs to your program will be: 1) the value of 𝑥 (in
radians), and 2) a pre-specified approximate relative error (%). Your program
should print the final value of 𝑓(𝑥) = cos 𝑥 obtained along with the true and
approximate errors. Your program needs to get the true value of 𝑓(𝑥) = cos 𝑥
using the built-in cos 𝑥 function in C.
Part B: Run your program to estimate the value of 𝑓(
𝜋
3
⁄ ) with relative error of
less than 0.5%. In other words, choose your inputs as 𝑥 = 𝜋
3
⁄ and the
relative error equals 0.5%. Print your result along with the final error values
(true and approximate percent relative errors). You need to add the terms in
the Maclaurin series until the approximate percent relative error falls below
0.5%.