Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to write a script file to compute the Maclaurin series expansion for the sine function (sin(x)). and I cannot figure out what I

I need to write a script file to compute the Maclaurin series expansion for the sine function (sin(x)). and I cannot figure out what I am doing wrong -- I cannot seem to get anything reminiscent of what the actual solution should be for x=pi/3. Thanks so much in advance!

%es -- stopping criterion

%ea -- approximate relative error

iter = 1; es=0.01; x = pi/3; maxit=100; ea=1;

while (1) xold=x; x = x + (-1^(iter))*(x^(2*iter+1)/factorial(2*iter+1)); if x~=0 ea = abs((x-xold)/x); end if ea<=es || iter >= maxit break end

display (sum(x)); end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions