Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 2: Taylor Series Expansion of Cosine (-1) x2n cos(x) x4 x2 + =1 n=o (2n)! 2! 4! Write a script that uses a while
Part 2: Taylor Series Expansion of Cosine (-1)" x2n cos(x) x4 x2 + =1 n=o (2n)! 2! 4! Write a script that uses a while loop to estimate the cosine of using the Taylor series expansion until the output is within +/- 0.0001 of the actual value returned when using the cosine function in MATLAB. Assign the number of iterations through the while loop as variable n. Script Save C Reset MATLAB Documentation 1 %Title: LAB 2 Part 2 2 %Author: 3 %Date: 4 %Description: This script solves the cosine of pi using the Taylor series 5 % expansion until the result is within a threshold of cos(pi) 6 7 threshold = 0.0001; %set a threshold to determine when to stop the numerical approximation 8 expansion 1; %set the initial value of the Taylor series expansion when n=0 9 n = 0; %store the number of times through the while loop and the summation index = 10 11 %add your code here 12 13 fprintf('%g iterations to estimate cos(pi) to +/-%g ',n, threshold); %print the number of times through the while loop and the estimated cos(pi)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started