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

Trigonometric functions are usually calculated on computers using truncated infi

ID: 3109193 • Letter: T

Question

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! ... or sin(x) = sigma^_n = 1 (-1)^(x - 3) x^(2x - 1)/(2x - 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.

Explanation / Answer

%%%%% Matalab Code %%%%%

clc;
clear all;
close all;
format long

n=input('Enter the degree for which to find the value of sin ');
x=n*pi/180;
err=input('Enter the precision for the infinite sin series ' );

act_s=sin(x);
fprintf('Actual sin[%d : degree ]=%f',n,act_s);
fprintf(' ');
sum=0;
k=1;
while(abs(sum-act_s)>err)
sum=sum+(-1)^(k+1)*x^(2*k-1)/factorial(2*k-1);
k=k+1;
fprintf('Current value of sine series is :%f', sum);
fprintf(' ');

end
fprintf('Actual sin[%d : degree ]=%f',n,act_s);
fprintf(' ');
fprintf('Series sin[%d : degree ]=%f using %d terms',n,sum,k-1);
fprintf(' ');

Output:

Enter the degree for which to find the value of sin 60
Enter the precision for the infinite sin series 0.0001
Actual sin[60 : degree ]=0.866025
Current value of sine series is :1.047198
Current value of sine series is :0.855801
Current value of sine series is :0.866295
Current value of sine series is :0.866021
Actual sin[60 : degree ]=0.866025
Series sin[60 : degree ]=0.866021 using 4 terms

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote