Question: I need the script code of the Matlab. HW6P2 (15 points) The following are infinite series representations of the functions sine and cosine along with
I need the script code of the Matlab. HW6P2 (15 points) The following are infinite series representations of the functions sine and cosine along with the exponential. x2n+1 (2n 1)! sinx)1 (2n + 1) cos(x) = 2(-1)"(2 2n (2n)! 72 n! n-o Performing the summation only to N terms is called a partial sum and is denoted S. 7t Use nested for loops to compute the first 5 partial sums with N 1, 2,3, 4 and 5 in order to estimate the following: a) sin(/3) b) cos(/4) c) e-2 Assuming that MATLAB sin), cos ) and exp ) functions return exact values of the functions, calculate the absolute difference between the value of the function determined by your code and that determined by the built-in functions of MATLAB and assign this difference to a variable name Error. The error term vanishes as N increases. For every function, (sin, cos and e). Your display in the command window for part (a) must be shown as: PART a) sin(pi/3) s(1) 0.8558007816, Error- 1.0224622219321308-02. S (2) = 0.8662952838, Error- 2.698800023961390E-04. S(-) = , Error s(Error Use fprintf inside the loop with format i for N (1,2,.., 5) and format 10f for the value of Sw and format. 1SE for the Error. Hint: You can use the MATLAB function factorial) to determine the factorial However, DO NOT use the sum) function in MATLAB
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
