Question

4.2 The Maclaurin series expansion for cos x is 6 .8 Starting with the simplest version, cos -I, add terms one at a time to e

0 1
Add a comment Improve this question Transcribed image text
Answer #1

Solution Code: alize the epsilon value %initialize the x value that is pi/3 x = pi/3; %assign the approximation value is zero%check if appro. error is <-epsilon value %then it break If ap err <= epsilon, break, end end Sample Output: $octave -qf no-w

copyable Code:

%initialize the epsilon value

epsilon=0.5*0.1;

%initialize the x value that is pi/3

x = pi/3;

%assign the approximation value is zero

app= 0;

%set the term, n = 1

n = 1;

%assign the true is cos (x)

t = cos(x);

%print the statement

fprintf('   N True Approximation Abs_Error Approx_Error ')

%check condition in while

while(1)

    %assign old approximation is in app

    appOld= app;

    %find the approximation value

    app = app+(-1)^(n-1)*x^(2*n-2)/factorial(2*n-2);

    %increment the term

    n = n+1;

    %formula for find the abs error

    ae = abs((t - app)/t)*100;

    %formula for find the approx. error

    ap_err = abs((app - appOld)/app)*100;

    %print the given result in table format

    fprintf('%4d %8.4f %8.4f %8.4f %8.4f ',n-1,t,app,ae,ap_err);

    %check if appro.error is <= epsilon value

    %then it break

    if ap_err <= epsilon,

        break,

    end

end

Add a comment
Know the answer?
Add Answer to:
4.2 The Maclaurin series expansion for cos x is 6 .8 Starting with the simplest version,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT