#Hint for the generation of random Points #and for finding area #This does for calculating the area of a circle centered at (2,2) with # radius 1. randnum := rand(1..100000); # r generates random numbers between 1 and 3 r := proc() x := randnum(); evalf(x/50000 + 1); end; generate:= proc(n) x:= array(1..2*n); icount:=0; inside := 0; for i from 1 by 1 to n do icount:=icount+1; y := r(); x[icount] := y; temp:=(x[icount]-2)^2; icount:=icount+1; y := r(); x[icount] := y; temp:= temp +(x[icount]-2)^2; # # temp calculates the sum of x^2+y^2 for the generated random point # if (temp <=1) then inside:=inside+1; fi; od; # what is printed is the ratio of area of circle to the area of square #(in which random points are generated - between 1 to 3. # If you multiply the answer by 4, you get area of circle which is Pi. print(evalf(inside/n)); end;