Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. 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

For the equation

$f(x,y) = x^2/y$

given that $x$ and $y$ are integers

What is the easiest/fastest way to find at least one tuple $(x_0,y_0)$ solution to $f(x,y)=4$ or any other number really. I know that $(2,1)$ would work, but is there a process for finding the solution to any integer that is equal to $f(x,y)$?

Is there any easy way to just enter this in and calculate it in Mathematica, MATLAB, Sage, etc.? Is there any way to work this out by hand besides just guessing which values would work?

share|cite|improve this question

This could help: $x^2/y=a$, where $x,y,a$ are integers. If $a$ is a perfect square, $y=1$ and $x=\sqrt{a}$. If it isn't a perfect square, suppose $a=p_1^{\alpha_1}...p_k^{\alpha_k}$. Then any $y$ of the form $p_1^{\beta_1}...p_k^{\beta_k}$ such that $\alpha_i +\beta_i$ is even will do, because then $ay$ will be a perfect square. Moreover, $ay$ times any other perfect square is good too.

share|cite|improve this answer

One obvious solution to f(x,y)=a is x=y=a, since a^2/a = a.

share|cite|improve this answer
  • Mathematica is great. Mathematica is a crutch. If you depend on a calculator, you won't get the meaning of your answer and you won't know what to do with it.

  • If you know nothing about the RHS, to get a 'minimal' answer by generate and test, go in rings around the origin:




    ... (is that how Mathematics's FindInstance works?)

  • If the RHS is $x^2/y$, to understand the problem, what is the thing that causes immediate problems with integers (getting integer solutions)? It's the division. If $x$ divides $y^2$ (in order to make f an integer) $x$ has to divide $y$. That is, beyond yrudoy's answer, you can make $x$ be any divisor of $y$.

share|cite|improve this answer

Your Answer


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