Answer to Question #172067 in C for Phillip Le

Question #172067

Write a C program to compute the Maclaurin Series expansion of 𝑓(𝑥) = cos 𝑥.

You need to add the terms in the Maclaurin series until the percent relative error falls below a certain pre-specified relative error (%).

Inputs to your program will be x (in radians)) and the pre-specified relative error (%).

Your program should print the number of terms, cos x value obtained along with the true, absolute, and relative approximate errors (%).

Your program needs to get the true value of 𝑓(𝑥) = cos 𝑥 using the built-in cos 𝑥 function in C\C++.


Sample output:

Enter your approx. relative error bound:

0.001

Enter your angle in radians:

1.04719

N.terms Exact   aproximate value     absolute error  relative error

1     0.500007     0.451697     0.048310   9.661871

2     0.500007    0.501803     0.001796    0.359220

......................



1
Expert's answer
2021-03-16T13:16:54-0400
#include <iostream>
using namespace std;


int main()
{
    int relative_error,angle;
    cout<<"Enter your approx. relative error bound:"<<endl;
    cin>>relative_error;
    
    cout<<"Enter your angle in radians"<<endl;
    cin>>angle;


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS