Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

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

share|improve this answer
add comment

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]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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