Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Maclaurin series expansion for the cosine function is: where x is in radians. This function can be used to approximate the cosine of x

The Maclaurin series expansion for the cosine function is:
where x is in radians. This function can be used to approximate the cosine of x with increasing accuracy as terms are added to the summation. Write a function that accepts two scalar inputs (in order):
A value for x (in radians) for the series approximation of cos(x).
The number of terms, N , to be uses in the approximation.
Your function should generate the following three outputs (in order):
A column vector of the first N term(s) summations. Consider the first summation to be 1, the second summation to be
A column vector of relative approximate error . The relative approximate error is calculated using (present approximation - previous approximation)/ present approximation (not in percentage). Note: use the relative approximate error to be 1 for the first iteration, since there is no "previous approximation".
A column vector of the relative true error . The relative true error is calculated using (true value - present approximation)/ true value. Use MATLAB's built-in cosine function for the true value.
Supplemental Deliverables (2 points):
For supplemental deliverables, you do not need to run your code in Matlab Grader. You have to turn in a hard copy of what is asked.
Utilizing this function you wrote and run your code on Matlab for the following condition. Set up a while loop to evaluate by continue adding terms until the relative approximate error to be less than . Print out the number of terms, N.
Also print your output with 3 columns of numbers. First column is your approximation, second column is the relative approximate error. Third column is the relative true error. The number of rows will be determined by the stopping criteria of relative approximate error to be less than .

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions