problem_3_1 - cosx=cosx+fact;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function y=problem_3_1(x,nterms) %Problem 3.1 % cosx=0; i=1; cosxtrue=cos(x); disp('order true value approximation error'); while i<=nterms n=2*i-2; fact=(-1)^(i-1)*x^n/factorial(n);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cosx=cosx+fact; perror=((cosxtrue-cosx)/cosxtrue)*100; fprintf('%2d %11.10f %11.10f %12.8f\n',i,cosxtrue,cosx,perror); i=i+1; end...
View Full Document

Ask a homework question - tutors are online