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

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
% Script piTilingError % Eric Young / CS 100M % % Approximate Pi with radius n = 100: % % Creates an array of 100 f values, where f is the fraction a cut tile is of a % whole tile, with each value equally spaced in the interval. % f1 = linspace(0,1,1000); f % piEstimate is an array with each element getting the value of the output % of the piTiling function for n = 100 and the specific f1 value. % piEstimate1 = piTiling(100,f1); 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: % % 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. % f2 = linspace(0,1,1000); f % piEstimate is an array with each element getting the value of the output % of the piTiling function for n = 1,000 and the specific f2 value. % piEstimate2 = piTiling(1000,f2); p % error2 is an array with each element equal to the absolute value of pi.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
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: % % Creates an array of 10,000 f values, where f is the fraction a cut tile is of a % whole tile, with each value equally spaced in the interval. % f3 = linspace(0,1,1000); f % piEstimate is an array with each element getting the value of the output % of the piTiling function for n = 10,000 and the specific f3 value. % piEstimate3 = piTiling(10000,f3); p % error2 is an array with each element equal to the absolute value of pi. % minus the pi estimation. % error3 = abs(pi-piEstimate3); e %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % plot(f1,error1,'k',f2,error2,'b',f3,error3,'r') title('Pi Approximation Error vs. Cut-tile Fraction f for Radius n = 100,1,000, and 10,000') legend('n = 100','n = 1,000','n = 10,000','Location',)...
View Full Document

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online