Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The values of sin(x) and cos(x) sin(x)=x-x^3/3!+x^5/5!-x^7/7!+... cos(x)=1-x^2/2

ID: 644161 • Letter: T

Question

The values of sin(x) and cos(x)

sin(x)=x-x^3/3!+x^5/5!-x^7/7!+... cos(x)=1-x^2/2!+x^4/4!-x^6/6!....

Rcall the symbol ! stands for factorial. The more terms you have in the series, the more accurate the approximation for the values of sin(x) or cos(x). However, it is not necessary or possible to include an infinite number of terms to calculate their values. Start with the first two in their summation series. Then, in a loop, add additional terms in the series one by one. When the ABSOLUTE difference the new summation and previous summation(without the new term) is less than 0.001, you can stop and obtain an approximate value for sin(x) or cos(x). (Hint: Consider MATLAB functions factorial(),

2)Then, in each subplot, draw another blue dashed curve for x versus the exact values of sin(x) or cos(x), which are calculated by the built in MATLAB function of cos(x) or sin(x). The same x vales should be considered here as above.

The values of sin(x) and cos(x) sin(x)=x-x^3/3!+x^5/5!-x^7/7!+... cos(x)=1-x^2/2!+x^4/4!-x^6/6!.... Rcall the symbol ! stands for factorial. The more terms you have in the series, the more accurate the approximation for the values of sin(x) or cos(x). However, it is not necessary or possible to include an infinite number of terms to calculate their values. Start with the first two in their summation series. Then, in a loop, add additional terms in the series one by one. When the ABSOLUTE difference the new summation and previous summation(without the new term) is less than 0.001, you can stop and obtain an approximate value for sin(x) or cos(x). (Hint: Consider MATLAB functions factorial(), 1) Write a MATLAB script that follows the above algorithm to estimate the value for sin(x) or cos(x) for x in the range on [0,4 pi ]. Your script should also generate a graph with two subplots side by side. Showing x versus the approximate results of cos(x) or sin(x) you obtained from the above algorithm with red circle markers. At least 20 values of x should be considered in the approximation. 2)Then, in each subplot, draw another blue dashed curve for x versus the exact values of sin(x) or cos(x), which are calculated by the built in MATLAB function of cos(x) or sin(x). The same x vales should be considered here as above.

Explanation / Answer

function s = mysin(t)
s = 0;
for s = 1:max(s)
nsteps(s) = ones(s);
k = 0:.1:pi/2;
x = 0:.1:2;
t = (1:2:2*k-1);
end
while t = (-1)^(0:k-1) .* x^t ./ factorial(t)
end