3
$\begingroup$

My problem is to find all solutions to an equation with 2 variables between two values that define the range of my search. e.g., $(x+y-y²)/(1-y-x²)=0$ with solutions ${x,y} \in \mathbb{Z}$.

$\endgroup$

2 Answers 2

7
$\begingroup$

The following might be of use:

Reduce[x + y == y^2 && x^2 + y != 1, {x, y}, Integers]

To ease things, we consider the numerator and denominator separately. Here, we are asking Mathematica for conditions on integer x and y such that the numerator is zero, and the denominator isn't.

Solve[x + y == y^2 && x^2 + y != 1, {x, y}, Integers]

is useful as well.


If you need examples, you can use

FindInstance[x + y == y^2 && x^2 + y != 1, {x, y}, Integers, 10]

Change 10 to the number of examples you wish to generate.

$\endgroup$
2
  • $\begingroup$ thanks the tip of separating numerator and denominator is great ;) $\endgroup$
    – sol
    Commented May 14, 2012 at 10:36
  • $\begingroup$ and for the FindInstance 10 that's what I needed! $\endgroup$
    – sol
    Commented May 14, 2012 at 10:47
7
$\begingroup$

You can obtain all integer solutions with Reduce:

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

which gives

Mathematica graphics

If you also want to restrict to solutions satisfying $x<15$ and $y<42$ then this works

Reduce[(x + y - y^2)/(1 - y - x^2) == 0 && x < 15 && x < 42, {x,y}, Integers]

Mathematica graphics

$\endgroup$
3
  • $\begingroup$ ok thanks and if I want to condition it so that x and y are between [O,1] (how to condition the solving process?) $\endgroup$
    – sol
    Commented May 14, 2012 at 10:29
  • $\begingroup$ you can do that in a way analogous to the second example I gave $\endgroup$
    – acl
    Commented May 14, 2012 at 10:34
  • $\begingroup$ yep thanks Acl ^^ $\endgroup$
    – sol
    Commented May 14, 2012 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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