I'm solving a Diophantine equation inside of a function using Reduce
but I'm having trouble extracting the necessary parts of the answer.
For example, if my input equation is linear, I get an output from Reduce
like:
C[1] ∈ Integers && x == 8 + 49 C[1] && k == 1 + 5 C[1]
if the equation is a quadratic, though, I get:
(C[1] ∈ Integers && x == 20 - 49 C[1] &&
k == 41 - 200 C[1] + 245 C[1]^2) || (C[1] ∈ Integers &&
x == 29 - 49 C[1] && k == 86 - 290 C[1] + 245 C[1]^2)
if the equation is cubic, I get:
C[1] ∈
Integers && (x == 2 + 49 C[1] || x == 11 + 49 C[1] ||
x == 36 + 49 C[1]) && k == 1/49 (9 + 5 x^3)
How do I identify and/or extract, say, the resulting condition on x? I originally used Part
when I just had the linear case. So for example I would do something like:
Ans=Reduce[SomeEquality[x,k],{x,k},Integers];
X=x/.ToRules[Ans[[2]]/.{C[1]->0}]
But the outputs in the quadratic and cubic cases are in wildly different places...
x
, but on the existence of another constantsC[i]
, which must be integers in your examples. You can't get rid of them if you want the full result set. There isn't "a condition onx
" to extract. Sorry. $\endgroup$ – Dr. belisarius Mar 29 '13 at 6:00Last@Reap[(output of Reduce)/. {Equal[x, y_] :> Sow[y]}]
? This gives a list of all the "somethings" where the formx==(something)
appears in the solution. $\endgroup$ – whuber Mar 29 '13 at 22:49