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

Infinite Series Trigonometric functions are usually calculated on computers usin

ID: 3109084 • Letter: I

Question

Infinite Series Trigonometric functions are usually calculated on computers using truncated infinite series. An infinite series is an infinite set of terms whose sum is a particular function or expression. For example, the infinite series used to evaluate the sine of a number is sin(x) = x - (x^3/3!) + (x^5/5!) - (x^7/7!) + (x^9/9!)... sin(x) = sigma^N_n=1 (-1)^(n-1) x^(2n-1)/(2n-1)! where x is in units of radians. Since a computer does not have enough memory (or time, obviously!) to add an infinite number of terms for every sine that is calculated, the infinite series truncates after a finite number of terms, determined by a pre-defined precision. N represents the number of terms For program 4, write a MATLAB program that prompts for degrees, and then prompts for a precision. Determine the number of terms required to evaluate the sine for the given precision as compared to MATLAB's sin(x) function (x is also in units of radians). For each iteration, output the current value of the series as shown in the Sample Output. The MATLAB command for pi is pi. The MATLAB command for sine in radians is sin(x). 2. The MATLAB command for factorial is factorial(x). 7. The power and the subsequent factorial both increase by factors of 2. Keep track of the current power for each iteration of the while-loop by adding 2 each time.

Explanation / Answer

Matlab code in radians

clear all
clc
n=input('enter the value of n ,n=')
x=input('enter the value of x in radians ,x=')

for i=1:1:n
sum=0
sum=sum+((-1)^(i-1))*(x^(2*i-1)/factorial(2*i-1))
end

Matlab code in degrees

clear all
clc
n=input('enter the value of n ,n=')
x=input('enter the value of x in degrees ,x=')

for i=1:1:n
sum=0
sum=sum+((-1)^(i-1))*(x^(2*i-1)/factorial(2*i-1))
end