0

Let $f(x,y) = ax^2 + 2bxy + cy^2$ be a binary quadratic form. The discriminant of this is $D = -b^2 + ac$.

Let $N$ be a positive integer. I would like to construct a binary quadratic form $f(x,y)$ that represents $N$ with the constraint that $-\lfloor {\sqrt{N}}\rfloor < D < \lfloor {\sqrt{N}}\rfloor$.

What I have tried so far: Fix $y = 1$ to get $f(x,1) = ax^2 + 2bx + c$. Now, for $x \ge 2 \in \mathbb Z$, get a base-$x$ representation of $N$, but stop after the second division and collect the quotient and remainders. Verify the coefficient of $x$ in the base-$x$ representation is even (i.e., must be $2b$) and then check $-\lfloor {\sqrt{N}}\rfloor < D < \lfloor {\sqrt{N}}\rfloor$. If conditions not met, try the next $x$. While the procedure produces $(a,b,c)$ that yields a binary quadratic form that represents $N$, it doesn't necessarily meet the $-\lfloor {\sqrt{N}}\rfloor < D < \lfloor {\sqrt{N}}\rfloor$ constraint.

The other approach I have tried is quite similar. Fix $c$. We then have $N - c = ax^2 + 2bx = x(ax+2b)$. Therefore, $x|(N-c)$. This approach is suitable to narrow down the $x$ to just the divisors of $N - c$, but unsuitable when $N$ gets large (due to the need for factoring).

How does one go about achieving this, keeping in mind that $N$ is large?

vvg
  • 3,311

1 Answers1

1

One method is to work with the continued fraction for $\sqrt N$

if $\frac{p}{q}$ is a convergent for $\sqrt N$ then $p^2 - N q^2$ is quite small in absolute value (smaller than $2 \sqrt N $ as I recall).

If you go all the way through you get $$ p^2 - N q^2 = 1 $$ with $q \geq 1.$

Then let $$f(x,y) = ax^2 + 2bxy + cy^2 = q^2 x^2 + 2pxy + N y^2$$

Just so you know: if you go through the whole continued fraction business, as above, you have found a quick way to factor $N.$ I put that here. For your purpose, it is likely that stopping early, finding $p^2 - N q^2 = r$ with $|r|$ small and $r$ not a square may be enough.

Plot twist: I took $N = 32045 = 5 \cdot 13 \cdot 17 \cdot 29.$ Going all the way to $x^2 - 32045 y^2 = 1$ gave the trivial factors $1 \cdot 32045.$ However, there are also (primitive) representations $u^2 - 32045 v^2 = 4$ which give different pairs of factors

Will Jagy
  • 139,541