Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 15 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

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

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

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.