My previous comment about floating point equality verification in the procedure 'check' was incorrect. The arguments are always integers, so the equality checking is fine. I have edited my previous post to point out my stupidity

There ***seems* **to be a typo in the procedure 'check'

check := proc(a, b, c, d, index)
local flag, i, j;
flag := 1;
for i to index do
if a = c[i]
then flag := 0;
break;
else for j to index do
if b = d[i]
then flag := 0;
break;
end if;
end do;
end if;
end do;
return flag;
end proc

Nothing in the highlighted loop depends on the associated loop index 'j': so the loop performs **an absolutely identical calculation** 'j' times which is completely pointless. I'm going to guess that what you meant was the following

check := proc(a, b, c, d, index)
local flag, i, j;
flag := 1;
for i to index do
if a = c[i]
then flag := 0;
break;
else for j to index do
if b = d[j]
then flag := 0;
break;
end ifOK;
end do;
end if;
end do;
return flag;
end proc

Note the change of index variable on d[..]

Even with this change there is still a fundamental issue about when/whether the following loop within the procedure 'f1' **will ever exit**

while(d>0.1 or flag=1) do
rx:=rand(1..n):
x[i]:=rx():
ry:=rand(x[i]..n):
y[i]:=ry():
flag:=check(x[i],y[i],xdumb,ydumb,dumbindex):
if flag=1
then dumbindex:=dumbindex+1:
xdumb[dumbindex]:=x[i]:
ydumb[dumbindex]:=y[i]:
fi:
p,d:=f(x[i],y[i])
end

Monitoring the values of the parameters 'd' and 'flag' using the debugger, all I can say is that the value of 'd' is rarely (if ever) <=0.1, and the value of 'flag' chenges pretty randomly. Thus the probability that

d<=0.1 **and** flag=0

for the loop to exit seems pretty remote - **how many iterations do you expect????**

I tried restricting the number of iterations in the above 'while' loop to 100, so with the enclosing 'for' loop running 50 times, a total of 50,000 calculations, but Igot bored and terminated this after about 30minutes execution time.

I only have three suggestions at this point

- Change the 'logic' of the code so that this 'while' loop does not run for an indeterminate (possibility infinite) time
- Rewrite the same "logic" in an efficient way - the current implementation is very poor, and I'd guess(!?) that could generate a speed-up of around 10X. Although you should be aware that reducing an infinite execution time by a factor of 10 still results in an infinite execution time!
- Leave it running - you never know - it might(?) finish eventually!