Skip to main content

equation solving - Why don't I get numeric values from this Solve?


Solve[ a^2 + b^2 == c^2 && a < 100 && b < 100 && c < 100, {a, b, c}, Integers]

gives me this result



{{c -> ConditionalExpression[-Sqrt[ a^2 + b^2],

((a | b | c) ∈ Integers && Sqrt[10000 - a^2] - b > 0 && -99 <= a <= -1) ||
((a | b | c) ∈ Integers && Sqrt[10000 - a^2] - b > 0 && 1 <= a <= 99) ||
((a | b | c) ∈ Integers && Sqrt[10000 - a^2] + b <= 0 && -99 <= a <= -1) ||
((a | b | c) ∈ Integers && Sqrt[10000 - a^2] + b <= 0 && 1 <= a <= 99) ||
... ] }, ... }

where I would expect something like



{{x -> 3, y -> 4, z -> 5}, {x -> 4, y -> 3, z -> 5}, {x -> 5, y -> 12, z -> 13},...}


What am I doing wrong?



Answer



This works (it's obvious the same will hold for negative integers):


Reduce[a^2 + b^2 == c^2 && 0 < a < 100 && 0 < b < 100 && 0 < c < 100, {a, b, c}, Integers]

enter image description here


And if you're up for an interesting visualization, here is my take:


ListPlot3D[{a, b, c} /. Solve[a^2 + b^2 == c^2 && 0 < a < 100 && 0 < b < 100 && 
0 < c < 100, {a, b, c}, Integers], InterpolationOrder -> 0,
Mesh -> None, ColorFunction -> "Rainbow", Filling -> Bottom, BoxRatios -> 1]


enter image description here


Comments