25

Is there a formula, method or anyway to find all positive $x$ integer values (if exists) such that $f(x)$ is Perfect square where $f(x)$ is a quadratic equation?

For example if I have the following function:
\begin{align*} f(x)= 4x^2+84x-15 \end{align*} Then I need all integer x values which makes $f(x)$ Perfect Squares.

I know for this equation $x \in \{2,10,19,47\}$ but I knew this by guessing, I mean I wrote a program in java and I traversed all of x values from 1 to 1000 and I got this set of x values that gives me a perfect square, I am not sure if I have to go further and what is the bound to do this guessing. But I am not interested in such method.

I am interested in a generalization for this problem (if possible) where I need to know all x values which makes $f(x)$ square where:

\begin{align*} f(x) = ax^2+bx+c \tag{1} \end{align*}

where \begin{align} a,b,c \in \mathbb Z \end{align}

Update 1

I have found a way from my derived equations of my research where I can find \begin{align*} x_i \, | \ \sqrt{f(x_i)}\in \mathbb Z \end{align*} \begin{align*} where\ i=1,2\ and\ x_1 > x_2 \end{align*} The question now, is there a way to use $x_1,x_2$ to find any other $x_i$ (if exist) \begin{align*} where \quad i>2 \ \ and\ \ 0 < x_i < x_2 \end{align*}

For the mentioned example, I know that the equation has $x_1 = 47$ and $x_2 = 19$, is there a way to find $ 0 < x_3 < 19 $ if $x_3$ exists from the known $x_1$ and $x_2$?

Update 2

After reading @ColmBhandal note I am trying in this update to transform the original equation to another equation. Resolving the new equation will resolve the previous equation.

Since $a$ in my case is always square then to get $x$ where $f(x)$ a perfect square we need to resolve the following: \begin{align*} bx+c=2nsx+n^2\ where\ s=\sqrt{a},\ n >= 1, n\in\mathbb Z \end{align*} Therefore \begin{align*} x=g(n)=\frac{n^2-c}{b-2sn}\tag{2} \end{align*} Now this is a Diophantine equation in the following form (assign $x=Y$ and $n=X$): \begin{align*} X^2-bY+2sXY-c=0\tag{3} \end{align*} Now we need to find $n$|$n>1\ and\ n\in\mathbb Z$ which makes $g(n)\in\mathbb Z$.

Let's note the following:

  1. $n$ has min value when $numerator = denominator$ (this happens to get $n=1$)which is \begin{align*} n^2-c = b-2sn \end{align*} \begin{align*} n^2+2sn-b-c = 0\implies\ n>= \Bigg\lceil {\frac{-(2s)+\sqrt{(2s)^2-(4(-b-c))}}{2}}\ \Bigg\rceil \end{align*}
  2. $n$ has a max value when the $denominator=0$ which is \begin{align*} b-2sn=0\implies n < \frac{b}{2s} \end{align*}
  3. We can get the first biggest two $n$ values because we know $x_1$ and $x_2$.

So for the mentioned example since $a=4$ then $s=2$ which lets $x=g(n)$ is \begin{align*} g(n)=\frac{n^2+15}{84-4n}\quad where\ n\in\mathbb Z, 7<=n<21 \end{align*} We also know that $n_1=19\ and\ n_2=17$ because $x_1=47\ and\ x_2=19$ so actually we are looking for $n$ (if exists) \begin{align*} 7<= n < 17\ |\ n\in\mathbb Z \end{align*}

So we need now the integer solutions for this equation. I hope this equation now could be resolved, I think it is a Diophantine Equation and we need integer solutions for it because the equation looks like: \begin{align*} x^2-84y+4xy+15=0 \end{align*}

Update 3

After reading this paper, I found (on page 6) that equation (3) could be transformed to \begin{align*} (bx + e)(by + d) = ed − bf \end{align*} Then writing $ed − bf = N$ and if $N$ is not zero (which is in our case) then we can factorize N to get all integer solutions.
Unfortunately, This means that my new Diophantine Equation number (3) should be resolved by factoring.
My question now is this the only way to solve such equations? Is there a way to solve equation (1) or (3) without completing the square or factoring a number to get solutions?

Notes:

  • Completing the square method and solving Pell's equation needs at the end of the day to do factoring and because in my case the coefficients could be 40-50 digits numbers, factorization couldn't be a solution. I am looking for a generalization for the problem and write a computer program to solve such equations with a very large coefficients.
  • Therefore any method that needs factorization or to iterate linearly to find the solutions are not helpful.
  • I don't really know what tags I have to give for this question so please correct my tags if I missed or messed something. Thanks.
Zrieq
  • 369
  • For example such a decision. http://mathoverflow.net/questions/31118/integer-polynomials-taking-square-values/195614#195614 Although you can write and other formulas. It all comes down to the Pell equation. – individ Sep 14 '15 at 13:28
  • @individ Thanks for the reply, but I need a detailed answer to understand how to solve such equations. I didn't know from where to get p,s values and how to solve it, I appreciate if you can give detailed answer. Thanks in advance. – Zrieq Sep 14 '15 at 13:35
  • You can also write a more General formula. http://www.artofproblemsolving.com/community/c3046h1049910___4 – individ Sep 14 '15 at 13:37
  • 2
    $p, s - $ it solutions of Pell equations. Their finding is standard procedure. – individ Sep 14 '15 at 13:39
  • 5
    For such cases when the coefficients of the squares. It all comes down to a difference of squares. $$y^2=4x^2+84x-15=4x^2+84x+441-456=(2x+21)^2-456$$ $$456=(2x+21-y)(2x+21+y)$$ Need the number $456$ be decomposed into all possible combinations of multipliers and solve linear equations. – individ Sep 14 '15 at 15:27
  • @individ Thanks again for your contribution. The issue with your solution is that I need to know the factors of 456, so I will be guessing the answer because there is no known algorithm for number factorization(I mean that does the factorization in polynomial time). I forgot to mention that I used some online equation solver and it gave me the following solution for my equation above: $x=\frac{\sqrt{y^2+456}-21)}{2}$ and $x=-\frac{\sqrt{y^2+456}+21}{2}$ but the issue here is that I have to guess what is the value of $y^2$ to know the value of x. – Zrieq Sep 14 '15 at 17:24
  • 2
    Nothing do not have to guess. Factorization is a standard procedure. Solution of system of linear equations the same difficulty no. – individ Sep 14 '15 at 17:27
  • 6
    @Zrieq Solving your problem is equivalent to factoring $456$, for any solution $(x,y)$ gives you a factorization $(2x+21-y)(2x+21+y)$. – Hagen von Eitzen Sep 14 '15 at 17:52
  • @HagenvonEitzen because I am searching for a generalization for this question, factoring 456 or any other numbers couldn't be a solution because as I mentioned in my question "I am not interested in guessing solutions" and factoring numbers is at the end of the day guessing because there is no known algorithm that gives you the factors for some $N \in \mathbb Z$ without iterating, if N is large enough then super computers will have nothing to do to find the factors of $N$. if there is a formula that gives you the factor for $N$ then that would be great. – Zrieq Sep 14 '15 at 20:15
  • @Zrieq: Do you really want all solutions $x$, or will you be satisfied with a method for an infinite number of $x$? – Tito Piezas III Sep 16 '15 at 05:12
  • @TitoPiezasIII so I will tell you what makes me satisfied, I know by some derived equations in my research two values of $x$, for the mentioned example I know that $x \in{47,19}$ without doing any guessing. so if you can give me a method to find the first $x$ where $0< x < 19$ then I will be satisfied. Getting all solutions is much better. – Zrieq Sep 16 '15 at 09:19
  • @TitoPiezasIII Please also mention the method for an infinite number of $x$ – Zrieq Sep 16 '15 at 09:28
  • @Zrieq: Here is the rule of thumb you can use in the general case $$ax^2+bx+c = d^2$$ If $(1)$ you have an initial solution; $(2)$ the coefficient $a$ is $not$ a square, then an infinite more can be found by solving the Pell equation $p^2-aq^2=1$. Unfortunately, since yours has $a=4$, then you can't use it. But the method is described in this post. – Tito Piezas III Sep 16 '15 at 13:01
  • @TitoPiezasIII Thanks for reply, I don't know why if $a$ is $not$ a square then it will not work, but what if this doesn't work, does that mean there is no answer for my question ? – Zrieq Sep 16 '15 at 13:17
  • @Zrieq: The method uses the generic Pell equation $p^2-aq^2 = 1$. These only have an infinite number of solutions if $a$ is not a square. And no, you cannot "cheat" by dividing by $2$ since the other end now becomes $(1/2)d^2$. There is still an answer, but as the others have pointed out, it now involves factoring integers. – Tito Piezas III Sep 16 '15 at 13:28
  • Intuitively, @Zrieq, it will not work if $a$ is square because of the following argument. Suppose $a = s^2$. Then the first term in your equation is $(sx)^2$. Now, the only way to get a square from here is to add either $2sx + 1$ or to add $4sx + 4$ etc. (think perimeter of square). So only a specific set of $bx + c$ will work i.e. $bx + c = 2sx + 1$ or $bx + c = 4sx + 4$ etc. – Colm Bhandal Sep 18 '15 at 13:16
  • @ColmBhandal Thanks for your note, I have updated the question accordingly. – Zrieq Sep 18 '15 at 18:36
  • @tito-piezas-iii Does the new update makes it possible to be resolved now? I have initial solutions and $a$ now is not square. (but I think the equation needs to be transformed to Pell Equation form and then solving it). What do you think? – Zrieq Sep 18 '15 at 19:08
  • So; this research... what's it about? Why do you think you need to solve $a x^2 + b x + c = y^2?$ The restrictions you are attempting to place, or attempting to describe rather, are unusual. – Will Jagy Sep 18 '15 at 22:13
  • 1
    @WillJagy I'v a theorem & I reached a point where I can generate equations such the one mentioned.Getting the integer solutions for these equations in Constant time will fallback in a bunch of other equations & proof the theorem is valid. At the end of the day I will write a java program to solve the generated equations, and the coefficients may go too large, so if you have coefficients with length of 40-50 digits then computers will hang searching for factors or even iterating to find some solution with some formula. That's why I have the restrictions for neither factoring nor iterating. – Zrieq Sep 18 '15 at 22:38
  • Well, I guessed correctly. I know no better way than completing the square and solving a Pell type equation. The fastest solution of Pell equations is discussed in an article by H. Lenstra http://www.math.leidenuniv.nl/~psh/ANTproc/01lenstra.pdf but I am not sure how much detail he gives when it is $x^2 - d y^2 = C$ for some constant $C$ rather than $x^2 - d y^2 = 1.$ I can think of no reason to believe in constant time for any of this: go solve $x^2 - 61 y^2 = 1$ with $y \neq 0,$ by any means you like. $61$ is small, you don't need to factor much of anything, however the answer....... – Will Jagy Sep 18 '15 at 22:47
  • 3
    @Zrieq: You miss the point: solutions to your problem give you factorizations of $N$. If $N$ is a number that's too hard to factor, then solving your problem is too hard. If it turned out there was a better way to solve your problem than factoring, then people would devise new factoring algorithms that work by setting up and solving problems if the type you ask about; and once that happens, we are right back to the situation where the best way to solve your problem is to factor. –  Sep 19 '15 at 13:23
  • @Hurkyl Yes, you are right and I know exactly what you said. The idea behind the question is to get another way to solve equation(1) so at the end I find a way to do factorization in very fast time. I have a theorem which I have developed and I am trying to proof it. Solving such equations will gives me a way to do factorization in a very fast way. That's why I am looking if there is something in math that solves such equations without factorization or doing linear search for answers. Thanks for your comment. – Zrieq Sep 19 '15 at 13:32
  • if 4x^2+84x-15 is a square then 84x-15 is a sum of consecutive odd numbers. –  Jun 29 '17 at 13:04
  • @RoddyMacPhee do you have a way to determine what is the first number in this consecutive odd numbers sequence ? – Zrieq Jun 30 '17 at 14:21
  • @Zrieq Well my statement, boils down to the fact that 4x^2 is a square. The difference of squares is a sum of consecutive odd numbers.Therefore 84x-15 has to be, a sum of consecutive odd numbers, for f(x) to be a square. It would either be going down, or up, from 2x. So, either 2x+1 and ascending, or 2x-1 and descending. –  Jun 30 '17 at 14:28
  • we also have properties in the general case. If ax^2 is a perfect square ( aka a is a perfect square) then bx+c has to be a sum of consecutive odd numbers. if bx is a square then ax^2+c must be a sum of consecutive odd numbers and if c is a square then ax^2+bx has to be a sum of consecutive odd numbers. –  Jun 30 '17 at 15:49
  • sorry as (4x^2)=(2x)^2 we actually have 4x+1 or 4x-1 doh. –  Jun 30 '17 at 19:02
  • @RoddyMacPhee Thanks for the info & yes you are right. However, we don't have a solution yet and we either need to know what is the first number in this sequence of odd integers or to find another way to solve it. – Zrieq Jul 03 '17 at 13:59
  • can still do the math algebraically and get to an answer or show there isn't I said 4x+1 or 4x-1 is the first odd number in the sum. using math shows it has to be a sum of less than 21 consecutive odd numbers on the positive side because of the 84. how many of those sums can be interpreted as 84x-15 ? –  Jul 03 '17 at 20:58
  • @RoddyMacPhee Sorry, I didn't get your point. how you know that it is 4x+1 or 4x-1 ? The other question, is there a formula to know what is the first odd number without guessing x ? – Zrieq Jul 05 '17 at 20:34
  • Because, it's going from (2x)^2=4x^2 . The next odd number you would add going up, is 4x+1, the one going down is 4x-1 . But, with x positive integer it's up because 84x-15 stops being below 0 when x=15/84. so it's actually always up but I guess I wanted you ( and myself) to think. –  Jul 05 '17 at 21:15

1 Answers1

4

Try these monsters:

$x_{n_1}=\frac{1}{2a}\left[\frac{\gamma_0 \sqrt{P^2-1}+Q\beta_0}{2\sqrt{P^2-1}}\cdot \left(P+\sqrt{P^2-1}\right)^n+ \frac{\gamma_0 \sqrt{P^2-1}-Q\beta_0}{2\sqrt{P^2-1}}\cdot \left(P-\sqrt{P^2-1}\right)^n-b\right]$

and

$x_{n_2}=\frac{1}{2a}\left[\frac{\gamma_0 \sqrt{P^2-1}-Q\beta_0}{2\sqrt{P^2-1}}\cdot \left(P+\sqrt{P^2-1}\right)^n+ \frac{\gamma_0 \sqrt{P^2-1}+Q\beta_0}{2\sqrt{P^2-1}}\cdot \left(P-\sqrt{P^2-1}\right)^n-b\right]$

6 notes:

  1. $(a,b,c)$ from $f(x)=ax^2+bx+c$
  2. use minimal $(P,Q)$ such that $P^2-aQ^2=1$
  3. use minimal $(\gamma_0,\beta_0)$ such that $a\gamma_0^2-\beta_0^2=a(b^2-4ac)$
  4. for non-square $a$, when a is a square it's analogous to the explanation below
  5. Reasoning for $x_{n_1}$ and $x_{n_2}$ is that some solutions to $ \ a\gamma^2-\beta^2=a(b^2-4ac) \ $ have two separate strands.
  6. In using this as written, it may be that you need to take every $ \ n=2m \ $ or $ \ n=2m-1 \ $ or multiples $n=km$ to meet the $\gamma-b \equiv 0 \pmod {2a}$ constraint (referring to how $ \ 2a \cdot x + b = \gamma \ $ below)

The derivation of the above is arriving at the pell equation: $$\begin{align} ax^2 + bx + c &= f(x)=\alpha^2 \\ a(x+b/2a)^2-\frac{b^2-4ac}{4a} &=\alpha^2 \\ a(2ax+b)^2-a(b^2-4ac)&=4a^2\alpha^2=\beta^2 \\ a\gamma^2-\beta^2&=a(b^2-4ac) \end{align}$$ And solving using standard techniques.Thus $$x_n=\frac{\gamma_n-b}{2a}$$ Such that $\gamma_n$ is the nth solution in the above pell type equation : $a\gamma^2-\beta^2=a(b^2-4ac)$


An explanation as to why in your first problem $(2,10,19,47)$ are the only answers is what follows:

The problem at the top has $(a,b,c)=(4,84,-15)$. Since $a$ is square, that pell equation morphs into a difference of two squares.

$$ \begin{align} 4\gamma^2-\beta^2&=29184 \\ (2\gamma)^2-\beta^2&=29184=2^9\cdot3\cdot19 \end{align}$$

Using this identity: $$\left(\frac{d_1+d_2}{2}\right)^2-\left(\frac{d_1-d_2}{2}\right)^2=d_1\cdot d_2$$

Let $d_1, d_2$ be two divisors (of the same parity) of $29184$. You can see here that since there can only be a limited number of divisors of $29184$, even more so limited that have the same parity, you know right here that there's going to be a limited number of solutions.

Let $2\gamma=\frac{d_1+d_2}{2}$, thus $\gamma=\frac{d_1+d_2}{4}$, and finally putting this back into our $x$, and letting $b=84$ and $a=4$, arrive at

$$x=\frac{\left(\frac{d_1+d_2}{4}\right)-84}{8}$$ or $$x=\frac{d_1+d_2-336}{32}=\frac{d_1+d_2}{32}-\frac{21}{2}$$

Now we observe that both factors must add to something directly proportional to 16:

$$d_1+d_2=16\cdot k$$

for the fraction $21/2$ to become whole when added. This implies that both $d_1$ and $d_2$ need to have a factor of atleast $2^4$. The only two-factor sets that come from $2^9\cdot3\cdot19$ and meet this requirement are:

$$\begin{align} (d_1,d_2) &\to x(d_1,d_2) &&\to x=\frac{d_1+d_2}{32}-\frac{21}{2} \\ \cdots \cdots \cdots \cdots \cdots \cdots \\ (3\cdot 19 \cdot 2^4, 2^5) &\to x(912,32) &&\to x=19 \\ (3\cdot 19 \cdot 2^5, 2^4) &\to x(1824,16) &&\to x=47 \\ (3\cdot 2^4,19 \cdot 2^5) &\to x(48,608) &&\to x=10 \\ (3\cdot 2^5,19 \cdot 2^4) &\to x(96,304) &&\to x=2 \\ \end{align}$$

  • @AmateurMathGuyThanks for your answer, but we already have in the comments of the question that we already know about pell equations, which will solve such equation. However, using pell equation still needs factorization ... So I am leaving this question to make someone think with me of a solution without using factorization nor iterating solutions as this is my question in the first place. – Zrieq Aug 17 '17 at 22:10
  • You're welcome and you have my apologies once again, I became aware right as I was finishing up the response, that you weren't looking for anything with factoring or iterating. I'll keep your question in mind for the future. – MaximusFastidiousIrreverence Aug 17 '17 at 22:25
  • @Zrieq Would a function, such that the input were the natural numbers and the output were x values making a quadratic a square, would that answer your question? Reason I ask is that I don't see any iteration or factoring if all you're doing is inputting naturals...40 digit numbers aside... – MaximusFastidiousIrreverence Aug 25 '17 at 17:26
  • For some reason I am unable to mention you using @ in the beginning of the comment ! @AmateurMathGuy I didn't get what you mean. Can you please explain more? – Zrieq Aug 26 '17 at 20:33
  • @Zrieq Sure, and bear with me if this is something that you've come across already, but, the first equation in my response, the pell equation, does lead to a second order recurrence relation in x, but that recurrence is readily solvable, (given that you know the first two x terms in the sequence, perhaps your main objection, I know), so if you know the first two x values that make the quadratic output a square, you can know the rest. If you want, I can give you the formula, perhaps you know it already, but I can show you a formula with an arbitrary first two x values that you can input. – MaximusFastidiousIrreverence Aug 27 '17 at 02:35
  • So in my original question @AmateurMathGuy, I already mentioned that I always know the first two values of x, which was 47 and 19. I was asking if there is some equation to find out all values where 0 <= x < 19 if there is any x. So if you have the solution for that ... please edit your answer and that will be exactly what I want. Keep in mind, to generate pell equations you really still need to do factorization, if you have some method or way to find out all x without factorization or iteration then please share :) – Zrieq Aug 28 '17 at 03:42
  • @Zrieq that's my best go at it for now at least. – MaximusFastidiousIrreverence Aug 29 '17 at 21:04
  • @Zrieq instead of finding the first two solutions, you need only to find the first solutions of two separate pell equations, then you should be able to find all the others... – MaximusFastidiousIrreverence Aug 29 '17 at 21:32
  • Thanks @AmateurMathGuy, but we are back to the first step ... – Zrieq Aug 30 '17 at 22:07
  • I'll keep it in mind then. Maybe someone else has insight. – MaximusFastidiousIrreverence Aug 30 '17 at 22:15