In Matlab: Filename: sineseries.m. The sine function can be represented by the f
ID: 3827135 • Letter: I
Question
In Matlab:
Filename: sineseries.m. The sine function can be represented by the following series: sin(theta) = sigma^infinity_i = 0 (-1)^i/(2i + 1)! theta^2i + 1 = theta - theta^3/3! + theta^5/5! - theta^7/7! + theta^9/9! - ... This is an equality as long as the sum includes all terms for i = 0 ... infinity, but the series can also provide a useful approximation for sin (theta) by truncating the sum after N terms (i.e., for i = 0 ... N - 1). For example, truncating the series after three terms gives the following approximation sin (theta) almostequalto theta - theta^3/3! + theta^5/5! Write a MATLAB function that uses the series given above to calculate an approximation for sin (theta). Function syntax y = sine series (theta, N) The angle input, the ta, should have units of radians. The second input argument, N, specifies the number of terms to use in the approximation, and should be an optional input with a default value of N = 10.Explanation / Answer
Max=10;
term=zeros(1,Max);
s=1;
for n=1:2:i
term(n)=s*x^n;
s=-s/((n+1)*(n+2));
end;
y=sin(s);
disp(y);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.