Question
Matlab coding question. The Maclaurin series expansion for the sine function is: where x is in radians. This function can be used to approximate the
Matlab coding question.
The Maclaurin series expansion for the sine function is:
where x is in radians. This function can be used to approximate the sine of x with increasing accuracy as terms are added to the summation. Write a function that accepts two scalar inputs (in order):
- A value for x (in radians).
- The number of series sums, N , to use in the series approximation of sin(x).
Your function should generate the following three outputs (in order):
- A column vector of the first N series summations. Consider the first summation to be x-x^3/3!.
- A column vector of the magnitude (i.e. absolute value) of the approximate relative error values associated with the first N series summations. Note the "previous approximation" for the first value in this vector will be x.
- A column vector of the true relative error values associated with the first N series summations. Use MATLAB's built-in sine function to compute the true value for this error calculation ============================================================
The coding starts with
function [series_sums, approx_rel_error, true_rel_error] = student_solution(x, number_of_sums)
end
=========================================================
The answer should look something like this.
>> student_solution(pi/3,4)
series_sums = 0.8558 0.8663 0.8660 0.8660 approx_rel_error = 0.2236 0.0121 0.0003 0.0000 true_rel_error = 0.0118 -0.0003 0.0000 -0.0000
==========================================
please copy and paste the code here please. Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started