Question: Strange behavior of the procedure

March 23 2014 Kitonum 3720

0

It is well known that  operating in  geometry  package when setting objects symbolically some inconveniences arise. The error occurs if you do not set limits on the parameters. I wrote the procedure for finding center and radius of the circumscribed circle, devoid of drawbacks:

restart;

Circumcircle:=proc(a,b,c)

local x1, y1, x2, y2, x3, y3, n;

uses geometry;

x1,y1:=op(a); x2,y2:=op(b); x3,y3:=op(c);

n:=x2*y3-x3*y2+x3*y1-x1*y3+x1*y2-x2*y1;

point(A,a), point(B,b), point(C,c);

if type(n,realcons) then triangle(T,[A,B,C]); circumcircle(cc,T,'centername'=OO);

return [coordinates(OO),radius(cc)]  else assume(n<>0);

triangle(T,[A,B,C]); circumcircle(cc,T,'centername'=OO);

simplify([coordinates(OO),radius(cc)]); fi;

end proc:

 

At initial startup procedure works correctly:

Circumcircle([x1,y1], [x2,y2], [x3,y3]);

 

 

But if you change the arguments of the procedure, an error occurs:

Circumcircle([x1,1], [x2,y2], [x3,y3]);

 

But if you run the procedure again with the same arguments, the error disappears:

Circumcircle([x1,1], [x2,y2], [x3,y3]);

 

What is the reason?

Circumcircle.mws

Please Wait...