14.08.2013 Views

Tutorial slides (PDF) - Clemson University

Tutorial slides (PDF) - Clemson University

Tutorial slides (PDF) - Clemson University

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Implementation Example: Calculating Pi<br />

Generate random points inside a square<br />

Identify fraction (f) that fall inside a circle with radius equal<br />

to box width<br />

x 2 + y 2 < r<br />

Area of quarter of circle (A) = pi*r 2 / 4<br />

Area of square (B) = r 2<br />

A/B = f = pi/4<br />

pi = 4f

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!