Question: Equation of a sphere (1)

Let A(1,-1,-1), B(2,1,2), C(1, 3, 1) be three points and Delta: x = -t, y = -t, z = t be a line. Write the equation of the sphere (S), knowing that center of (S) lies on the line Delta, (S) passing the point A and cuts the plane passing through the  three points A, B, C cut (S) a circle has least radius.  

This is my code.

> restart;

with(geom3d):

a:=[-t,-t,t]:

point(T,a):

point(A,1,-1,-1):

point(B,2,1,2):

point(C,1,3,1):

plane(ABC,[A,B,C],[x,y,z]):

d:=distance(T,ABC):

R:=distance(T,A):

r:=R^2-d^2;

sol:=minimize(r,'location');

coordinates(point(T1,op(eval(a,op(1,sol[2][1]))))):

rad:=subs(op(1,sol[2][1]),R):

Equation(sphere(S,[T1,rad],[x,y,z])):

Student[Precalculus][CompleteSquare](Equation(S));

Please help me some following questions:

1) I can't use the commant expand(r) or simplify(r).

2) How i can use the  commant in the line Student[Precalculus][CompleteSquare](Equation(S));? 

3) Please comment to me at the line coordinates(point(T1,op(eval(a,op(1,sol[2][1]))))):

Thank you very much.

Please Wait...