-1

I am looking to count number of solutions of diophantine equation $k_1a^2+k_2ab+k_3b^2-k_4c^2=0$.

such that $ 1 \le a, b, c \le N$ and $gcd(a, b) = 1$ and $k_1,k_2,k_3,k_4$ are positive constant integers

We don't need all solutions set, we just need to count the number of solutions.

I have an approach in mind which uses Meissel Lehmer's algorithm and solves in $O(N^{3/4}log^2 N)$ but

My guess is this can be solved in something of the order of $O(N^{1/2})$ or similar using different approach.

sibillalazzerini
  • 470
  • 2
  • 10
  • 1
    What have you tried? Alternatively, what is the context behind this problem; where did you find it, and what relevant knowledge do you have? – Christian E. Ramirez Jan 24 '23 at 05:07
  • @C-RAM I have a solution in mind which is of the order of $O(N^{3/4}log^2N)$, I will post that as an answer if no one can suggest something better than that but I dont want to reveal it upfront as it might make people biased. – sibillalazzerini Jan 24 '23 at 05:09
  • @C-RAM given that you commented I am assuming you might be having something in your mind too. What is the best you can think of ? – sibillalazzerini Jan 24 '23 at 05:13
  • @C-RAM you need not reveal your answer yet, can you tell me what is the computational complexity you have in your mind ? – sibillalazzerini Jan 24 '23 at 05:15
  • 2
    I suggest you post it (or some other form of work or context) in your question. MSE guidelines require you to show some amount of work or context, and you might get downvoted otherwise (though, in this case, I don't think you should be, given you've clearly put some work into this problem). I'll give you a preemptive upvote, and let you decide what to do. – Christian E. Ramirez Jan 24 '23 at 05:17
  • Sorry; I'm not an expert on diophantine equations. Perhaps I'll pick up the study some day. It seems quite interesting. – Christian E. Ramirez Jan 24 '23 at 05:19
  • 1
    @C-RAM I haven't put those works, many researchers have put those work over the years, I only read their paper. By the way I have added one liner hint of the solution that I have in mind – sibillalazzerini Jan 24 '23 at 05:37
  • Completing the square gives $\left(a+\dfrac{5}{2}b+\dfrac{c}{2}\right)^2 - \left(\dfrac{c}{2}\right)^2 = 0$. This equation can be satisfied only if $c$ is even, and $a + \dfrac{5}{2}b = -\dfrac{c}{2}$. This means that there are an infinite number of solutions for this equation. – AtKin Jan 24 '23 at 05:59
  • @AtKin not sure you did the squaring correctly , quick check suggest it should satisfy $(1,1,3)$ which isn't doing. – sibillalazzerini Jan 24 '23 at 06:12
  • 1
    Related: https://math.stackexchange.com/questions/4623943/find-more-efficient-solution-to-diophantine-equation-a25ab3b2-c2-0?noredirect=1#comment9754147_4623943 – Servaes Jan 24 '23 at 07:09
  • 1
    Also related: https://math.stackexchange.com/questions/4623410/solve-diophantine-equation-a25ab3b2-c2-0 – Servaes Jan 24 '23 at 07:09
  • 2
    This problem is directly related to https://projecteuler.net/problem=769 It is against the policy of MSE to provide hints for PE problems. – piepie Jan 24 '23 at 10:44
  • @piepie converted the equation to general form. Hopefully now it doesn't match any forums and should be within MSE – sibillalazzerini Jan 24 '23 at 16:53
  • 1
    Note that your general form can be divided through by $k_1$ to give the form $$x^2 + axy + by^2 = cz^2$$ By completing the square, that can then be converted to the generalized Pell-like form $$(2x+ay)^2 + (4b-a^2)y^2 = 4cz^2$$ You can then use whatever solution method you like. Note that it's possible that, for a given set of ${k_i}$, there may be no solutions. – Eric Snyder Jan 24 '23 at 23:37

1 Answers1

0

Let's start from the generalized equation

$$(2x+ay)^2 + (4b-a^2)y^2 = 4cz^2$$

where $a = k_2/k_1, b=k_3/k_1, c=k_4/k_1$, and I've simply used $x,y,z$ rather than $a,b,c$ to make things easier to read.

One of the more interesting solution methods is to note that, because all the terms are degree $2$, any multiple of a solution is also a solution. Which means that we can divide the equation above through by $y^2$ to get:

$$4b-a^2 = 4c \left( \frac z y \right)^2 - \left[ 2 \left( \frac x y \right) + a \right]^2$$

We substitute $Y = z/y, X = x/y$, and we can graph this in the plane as

$$4cY^2 - (2X+a)^2 = 4b-a^2$$ $$\implies cY^2 - X^2 - aX + b = 0$$

This is a hyperbola; whether it opens up/down or left/right depends on the $k_i$. Now the kicker is this: every rational point $(X,Y)$ on this hyperbola corresponds to a family of solutions of the original equation, and this is, I believe, a bijection. The trick, of course, is finding an initial rational point $(s,t)$--though if there is one rational point, there are infinitely many.

Every other rational point can be found by generating a line of rational slope $p/q$ going through the initial rational point, and finding the intersection of the hyperbola and the line

$$Y = \frac p q X + \frac{qt-ps}{q}$$

And if you can do that, you can find a parametrization in $p,q$ for every solution. You can check my algebra--(I probably messed something up!) I did mess up my calculations and have edited to fix, twice, but am pretty certain now--but as a parametrization I get:

\begin{cases} x = \frac{n}{s}(2cpqst+bq^2-cp^2s^2-cq^2t^2) \\ y = n(q^2-cp^2) \\ z = \frac{n}{s}(cp^2st+q^2st+bpq-cpqt^2-pqs^2) \end{cases}

Where $n$ is a rational coefficient that gets you integers; YMMV. This is assuming you can find a rational point $(s,t)$ with $s \neq 0$, of course. I have no idea if this helps with counting the possible solutions below a certain $N$ though. Also note that, like $k_i$ earlier, $p,q \in \Bbb{N}$. Note there is no guarantee of $(x,y)=1$ here, but of course you can easily find that solution.

(Edited twice for algebra)

Eric Snyder
  • 3,147