piTilingError - % minus the pi estimation. % error2 =...

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

View Full Document Right Arrow Icon
% Script piTilingError % Eric Young / CS 100M % % Creates an array of 1,000 f values, where f is the fraction a cut tile is of a % whole tile, with each value equally spaced in the interval. % f = linspace(0,1,1000); f % Approximate Pi with radius n = 100: % % piEstimate is an array with each element getting the value of the output % of the piTiling function for n = 100 and the specific f value. % piEstimate1 = piTiling(100,f); p % error1 is an array with each element equal to the absolute value of pi % minus the pi estimation. % error1 = abs(pi-piEstimate1); e %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Approximate Pi with radius n = 1,000: % % piEstimate is an array with each element getting the value of the output % of the piTiling function for n = 1,000 and the specific f value. % piEstimate2 = piTiling(1000,f); p % error2 is an array with each element equal to the absolute value of pi.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % minus the pi estimation. % error2 = abs(pi-piEstimate2); e %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Approximate Pi with radius n = 10,000: % % piEstimate is an array with each element getting the value of the output % of the piTiling function for n = 10,000 and the specific f value. % piEstimate3 = piTiling(10000,f); p % error3 is an array with each element equal to the absolute value of pi. % minus the pi estimation. % error3 = abs(pi-piEstimate3); e %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % plot(f,error1,'k',f,error2,'b',f,error3,'r') p title('Pi Approximation Error vs. Cut-tile Fraction f for Radius n = 100,1,000, and 10,000') 1 xlabel('f') ylabel('Error') y legend('n = 100','n = 1,000','n = 10,000','Location','North')...
View Full Document

This note was uploaded on 09/12/2009 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

Ask a homework question - tutors are online