# How can I write the equations of the tangent plane to the sphere at all points in a list?

I have a list

list = {x, y, z} /.
Solve[{(x - 1)^2 + (y - 2)^2 + (z + 3)^2 == 7^2}, {x, y, z},
Integers]


{{-6, 2, -3}, {-5, -1, -5}, {-5, -1, -1}, {-5, 0, -6}, {-5, 0, 0}, {-5, 4, -6}, {-5, 4, 0}, {-5, 5, -5}, {-5, 5, -1}, {-2, -4, -5}, {-2, -4, -1}, {-2, 0, -9}, {-2, 0, 3}, {-2, 4, -9}, {-2, 4, 3}, {-2, 8, -5}, {-2, 8, -1}, {-1, -4, -6}, {-1, -4, 0}, {-1, -1, -9}, {-1, -1, 3}, {-1, 5, -9}, {-1, 5, 3}, {-1, 8, -6}, {-1, 8, 0}, {1, -5, -3}, {1, 2, -10}, {1, 2, 4}, {1, 9, -3}, {3, -4, -6}, {3, -4, 0}, {3, -1, -9}, {3, -1, 3}, {3, 5, -9}, {3, 5, 3}, {3, 8, -6}, {3, 8, 0}, {4, -4, -5}, {4, -4, -1}, {4, 0, -9}, {4, 0, 3}, {4, 4, -9}, {4, 4, 3}, {4, 8, -5}, {4, 8, -1}, {7, -1, -5}, {7, -1, -1}, {7, 0, -6}, {7, 0, 0}, {7, 4, -6}, {7, 4, 0}, {7, 5, -5}, {7, 5, -1}, {8, 2, -3}}

At the point of contact, e.g {-6, 2, -3},

I see here, I tried

pC = {1, 2, -3};
pA = {-6, 2, -3};
pM = {x, y, z};
FactorList[(pA - pC) . (pM - pA)][[-1, 1]] == 0


6 + x == 0

How can I write the equation of all points in the list?

For pedagogical reasons I am showing one way that requires minor modification of your code.

pC = {1, 2, -3};
pM = {x, y, z};
pA = pM /.
Solve[{(x - 1)^2 + (y - 2)^2 + (z + 3)^2 == 7^2}, {x, y, z},
Integers]


Then

Table[FactorList[(pA[[index]] - pC) . (pM - pA[[index]])][[-1, 1]] ==
0, {index, 1, pA // Length}]


• When we set f[x_, y_, z_] := (x - 1)^2 + (y - 2)^2 + (z + 3)^2 - 7^2, then the normal of the tangent plane is Grad[f[x, y, z], {x, y, z}].
Clear[f, list];
f[x_, y_, z_] := (x - 1)^2 + (y - 2)^2 + (z + 3)^2 - 7^2;
list = Solve[f[x, y, z] == 0, {x, y, z}, Integers];
({X, Y, Z} - {x, y, z}) . Grad[f[x, y, z], {x, y, z}] == 0 /.
list // Simplify


The list of contact points and the center of the sphere are:

list = {x, y, z} /.
Solve[{(x - 1)^2 + (y - 2)^2 + (z + 3)^2 == 7^2}, {x, y, z},
Integers];
cen = {1, 2, -3};


Now, note that the vector from any point of the tangent plane to the point of contact is perpendicular to the radius of the sphere at the contact point. We therefore define a function, that gives the equation of the tangent plane at the contact point {x0,y0,z0} and apply it to the list:

tan[{x0_, y0_,
z0_}] = {x - x0, y - y0, z - z0} . ({x0, y0, z0} - cen) == 0;
tan /@ list // Simplify


If you want to use the output Solve in the way it was intended, the basic computational structure is this, with the use of Hold or Inactivate depending on the details of the problem:

<[held|inactive] code> /. Solve[eqns, vars] [// <[release|activate]>]


For instance:

pC = {1, 2, -3};
pA = {x0, y0, z0};
pM = {x, y, z};
gensol = Solve[{(x0 - 1)^2 + (y0 - 2)^2 + (z0 + 3)^2 == 7^2}, {x0, y0, z0},
Integers];

Inactivate[FactorList[(pA - pC) . (pM - pA)][[-1, 1]] == 0] /.
gensol //
Activate
(*
{6+x==0,            43+6 x+3 y+2 z==0, 31+6 x+3 y-2 z==0,
48+6 x+2 y+3 z==0, 30+6 x+2 y-3 z==0, 56+6 x-2 y+3 z==0,
38+6 x-2 y-3 z==0, 55+6 x-3 y+2 z==0, 43+6 x-3 y-2 z==0,
40+3 x+6 y+2 z==0, 28+3 x+6 y-2 z==0, 60+3 x+2 y+6 z==0,
24+3 x+2 y-6 z==0, 68+3 x-2 y+6 z==0, 32+3 x-2 y-6 z==0,
64+3 x-6 y+2 z==0, 52+3 x-6 y-2 z==0, 44+2 x+6 y+3 z==0,
26+2 x+6 y-3 z==0, 59+2 x+3 y+6 z==0, 23+2 x+3 y-6 z==0,
71+2 x-3 y+6 z==0, 35+2 x-3 y-6 z==0, 68+2 x-6 y+3 z==0,
50+2 x-6 y-3 z==0, 5+y==0,  10+z==0,  -4+z==0,  -9+y==0,
-48+2 x-6 y-3 z==0,-30+2 x-6 y+3 z==0,-63+2 x-3 y-6 z==0,
-27+2 x-3 y+6 z==0,-75+2 x+3 y-6 z==0,-39+2 x+3 y+6 z==0,
-72+2 x+6 y-3 z==0,-54+2 x+6 y+3 z==0,-46+3 x-6 y-2 z==0,
-34+3 x-6 y+2 z==0,-66+3 x-2 y-6 z==0,-30+3 x-2 y+6 z==0,
-74+3 x+2 y-6 z==0,-38+3 x+2 y+6 z==0,-70+3 x+6 y-2 z==0,
-58+3 x+6 y+2 z==0,-55+6 x-3 y-2 z==0,-43+6 x-3 y+2 z==0,
-60+6 x-2 y-3 z==0,-42+6 x-2 y+3 z==0,-68+6 x+2 y-3 z==0,
-50+6 x+2 y+3 z==0,-67+6 x+3 y-2 z==0,-55+6 x+3 y+2 z==0,
-8+x==0}
*)


Applying the output of Solve creates multiple copies of the held/inactive code, one copy for each set of parameter values in the solution. (The parameter values are the coordinates of the point {x0, y0, z0} in the example.) When the hold is released or the code activated, each code is evaluated with the parameter values already substituted. Usually, some parts of <code> need to be evaluated (e.g. pA) before the solution from Solve is applied, and some parts need to remain unevaluated (held or inactive). That can be tricky at times, but you learn how to do it with practice.

Alternatives to Inactivate[FactorList[(pA - pC) . (pM - pA)][[-1, 1]] == 0]:

Inactivate[FactorList[(pA - pC) . (pM - pA)][[-1, 1]] == 0, Part | FactorList]
With[{pA = pA}, Hold[FactorList[(pA - pC) . (pM - pA)][[-1, 1]] == 0]]
Hold[FactorList[({x0, y0, z0} - pC) . (pM - {x0, y0, z0})][[-1, 1]] == 0]
Hold[FactorList[(# - pC) . (pM - #)][[-1, 1]] == 0] &[pA]
Hold[FactorList[#][[-1, 1]] == 0 &][(pA - pC) . (pM - pA)]


For the ones using Hold, replace Activate by ReleaseHold:

<hold code> /. gensol // ReleaseHold


Or you can use Table or Map to iterate though the list of solutions, as the other answers show. However, ReplaceAll does have this iteration capability built into it. So for pedagogical reasons, I wanted show it as well.