Matlab The Maclaurin series expansion for the sine function

Matlab

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):

1) A value for x (in radians).

2) 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):

1) A column vector of the first N series summations. Consider the first summation to be x-x^3/3!.

2) A column vector of the magnitude (i.e. absolute value) of the approximate relative error values associated with the first Nseries summations. Note the \"previous approximation\" for the first value in this vector will be x.

3) 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.

copy and paste your MATLAB code

this is what i have so far please help

function [series_sums, approx_rel_error, true_rel_error] = student_solution(x, number_of_sums)

X\'X\'X\'X 3\' 5\' 7! 9! _5 _3 .1

Solution

Solution :- Matlab code for the Maclaurins series expansion for the sine function.

clear, clc

% Let\'s see more decimals
format long

% We go from n = 0 to n = 3
n = 0 : 3;

% This is the point for evaluation
x = 0.1;

% These are the derivatives for each term
d = [0 1 0 -1];

% We form the sequence, following the formula
seq = d .* x.^n ./(factorial(n))

% We add-up to get the Maclaurin approximation
approx = sum(seq)

% Let\'s compare with the official number
real_value = sin(x)

Matlab 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 ac

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site