MAPLE output for calculating Pi using the area under the curve y=2*sqrt(1-x^2).
First, we know that the area under the curve y=sqrt(1-x^2) from x=-1..1 is Pi/2, because it is simply half of the unit circle.
> int(2*sqrt(1-x^2), x=-1..1); evalf(%);
> with(student):
If we want to estimate Pi, we can use the rectangle method with increasing numbers of rectangles in order to get better approximations.
> leftbox(2*sqrt(1-x^2), x=-1..1, 10);
> evalf(leftsum(2*sqrt(1-x^2), x=-1..1, 10));
> rightbox(2*sqrt(1-x^2), x=-1..1, 30);
> evalf(rightsum(2*sqrt(1-x^2), x=-1..1, 30));
> middlebox(2*sqrt(1-x^2), x=-1..1, 50);
We can also take a look at roughly how much error there is in each of our calculations.
> evalf(middlesum(2*sqrt(1-x^2), x=-1..1, 50)); evalf(Pi-%);
> evalf(middlesum(2*sqrt(1-x^2), x=-1..1, 100)); evalf(Pi-%);
> evalf(middlesum(2*sqrt(1-x^2), x=-1..1, 1000)); evalf(Pi-%);
> evalf(middlesum(2*sqrt(1-x^2), x=-1..1, 10000)); evalf(Pi-%);
Using 100,000 rectangles, we get an approximation of Pi that is correct to the seventh place.
> evalf(middlesum(2*sqrt(1-x^2), x=-1..1, 100000)); evalf(Pi-%);