Question & Answer: A series expansion for sin(x) is given by sin(x) = x – x^3/3! + x^5/5! – x^7/7! + … a) Write a Matlab scr…..

I need this in matlab please
Thanks
A series expansion for sin(x) is given by sin(x)-x--+ +… ! 5! 7 Write a Matlab script to calculate sin (n/3) using this series expansion. Ensure that the script will add terms one at a time until the numerical result is accurate to 4 significant figures. 13 points Plot the exact analytical form of sin(x) for 0 < x < showing the calculated values for sin(n/3) with successive terms added. Create multiple plots with different axis limits if necessary to show detail. 3 points Plot the true relative error and approximate relative error versus number of terms in your solution using a log scale for the y-axis. (Hint: Use the semilogy function) [3 points a) b) with individual points from your series expansion superimposed c) d) What is the minimum number of terms required in order to obtain the required level of accuracy? [1 point

A series expansion for sin(x) is given by sin(x) = x – x^3/3! + x^5/5! – x^7/7! + … a) Write a Matlab script to calculate sin (pi/3) using this series expansion. Ensure that the script will add terms one at a time until the numerical result is accurate to 4 significant figures. b) Plot the exact analytical form of sin(x) for 0

Expert Answer

 

format short
function approx = Sine(val)
x = val;
k = 1;
i = 3;
count = 3;
while(abs( ((sin(val)))- x) > 0.00001)
x = x + ( (-1)^k *(val)^i )/factorial(i);
k = k+1;
i = 2*count – 1;
count = count + 1;
end
approx = x;
end
approx =Sine(0.33*pi);
fprintf(“Approximate value of Sine for 0.3PI is: %.4fn”,approx);
approx =Sine(pi/6);
fprintf(“Approximate value of Sine for (PI/6) is: %.4fn”,approx);
============================================================
See Output , You can verify Sine values

Still stressed from student homework?
Get quality assistance from academic writers!