8
$\begingroup$

I want to solve the equation $$(x-1)^2 + (y-1)^2 + (z-1)^2 = 49$$ where $x$, $y$, $z$ are integer and $x \neq 1$, $y \neq 1$, $x \neq 1$. How do I tell Mathematica to do that?

$\endgroup$
18
$\begingroup$

A geometrical view of the solutions:

s = Solve[(x - 1)^2 + (y - 1)^2 + (z - 1)^2 == 49, {x, y, z},  Integers];
pts = {x, y, z} /. s;
subs = Subsets[pts, {2}];
minds = Union[dists = N[EuclideanDistance @@@ subs]][[1 ;; 3]];
Show[Graphics3D[Sphere[{1, 1, 1}, 13/2]], 
     Graphics3D[Line /@ Extract[subs, Position[dists, Alternatives @@ minds]]],
     ListPointPlot3D[pts, PlotStyle -> Directive[PointSize[Medium], Red]],
     Boxed -> False]

Mathematica graphics

Edit

Another useful visualization:

s = Solve[(x - 1)^2 + (y - 1)^2 + (z - 1)^2 == 49 && 
             x != 1 && y != 1 && z != 1, {x, y, z}, Integers];
pts = {x, y, z} /. s;

w = Sqrt@13;
f[i_, k_] := RotateLeft[{w Cos@u, w Sin@u, k} + {1, 1, 0}, i];

Show[Graphics3D[Sphere[{1, 1, 1}, 13/2]],
     ParametricPlot3D[Flatten[{f[1, #], f[2, #], f[3, #]} & /@ {-5, 7}, 1], {u, 0, 2 Pi}],
     ListPointPlot3D[pts, PlotStyle -> Directive[PointSize[Large], Red]],
     Boxed -> False]

Mathematica graphics

Edit

Note that the problem turns religious if you use 81 instead of 49:

Mathematica graphics

$\endgroup$
12
$\begingroup$

Try :

Solve[(x - 1)^2 + (y - 1)^2 + (z - 1)^2 == 49, {x, y, z}, Integers]

or

Reduce[(x - 1)^2 + (y - 1)^2 + (z - 1)^2 == 49, {x, y, z}, Integers]

You can add inequalities as well as :

Solve[{(x - 1)^2 + (y - 1)^2 + (z - 1)^2 == 49, x != 1, y != 1, z != 1}, {x, y, z}, Integers]
$\endgroup$
1
$\begingroup$

Or use my favorite command:

FindInstance[
{(x - 1)^2 + (y - 1)^2 + (z - 1)^2 == 49, x != 1, y != 1,z != 1}, {x, y, z},Integers, 100]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.