% write a program to approximate cosx for a vaule of x using maclaurin % series
ID: 3549898 • Letter: #
Question
% write a program to approximate cosx for a vaule of x using maclaurin
% series approxmation, determine the number of terms necessary to calculate
% the appproximation to a error no less than 0.0001
prompt= input('enter a value of x: ');
x= prompt;
n= 0;
c_x= (-1^n/(factorial (2*n)))* x^2*n;
while c_x > 0.0001
n=n+1;
c_x= (-1^n+1/(factorial(2*n+1))* x^2*n+1;
end
dip (c_x)
% the program should stop once the error threshold is reached
% then output the number of terms it required
% display terms in array
Please check and fix
Explanation / Answer
prompt= input('enter a value of x: ');x= prompt;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.