0

I have the equation $x^2+xy+y^2=z^2$ to solve it in natural numbers.

The discriminant of it $D=4z^2-3y^2$ and must be perfect square.

I wrote Python program to get solutions for $1<x<100$ by enumeration.

def Solution():
    A=[]
    nMaximum=10**2
    for x in range(1,nMaximum):
        dTemp1a=3*x**2
        for z in range(x+1, nMaximum):
            dDiscriminant=4*z**2-dTemp1a
            dTemp5=int(dDiscriminant**0.5)
            if dTemp5**2!=dDiscriminant:
                continue
            dTemp6=(-1*x+dTemp5)/2
            y=int(dTemp6)
            if not CheckIfExists(A, z):
                A.append([x,y,z])
    return A

def CheckIfExists(arr, z): bResult=False for s in arr: if s[2]==z: bResult=True break return bResult

a = Solution() print(len(a)) print(a)

[3, 5, 7], [5, 16, 19], [6, 10, 14], [7, 8, 13] ...

Three variable, second degree diophantine equation doesn't explain how to get other solutions when we know the first solution $(3,5,7)$

Could you give me a hint ?

UPDATE asked by Shean: I need to get all solutions based on $(3,5,7)$. See my question as the example of what I am looking for:

First 30 solutions of Pell's equation.

or see these formulas for all solutions of Pell's equation

http://mathworld.wolfram.com/PellEquation.html

yW0K5o
  • 367
  • The first answer by Daniel Shepler to the article you link to explains how to get more solutions from any starting solution, giving explicit formulas for the "next" solution from a given solution. This is not guaranteed to produce all solutions from a single one; there are some such equations which end up having several different start solutions from which to generate the rest. – coffeemath Mar 31 '24 at 09:52
  • https://www.math.utoronto.ca/barbeau/vig23.pdf – Shean Mar 31 '24 at 09:57
  • 1
    @Sil That link is to a parametric solution. However OP asks about the method to generate new solutions from old. – coffeemath Mar 31 '24 at 10:34
  • @Shean They have partial number of solutions like coffeemath said. https://www.math.utoronto.ca/barbeau/vig23.pdf has $(x,y,z)=(2k+1,k^2-1,k^2+k+1)$ where $k>1$. – yW0K5o Mar 31 '24 at 10:57
  • @coffeemath Just multiply a solution by an integer to produce infinitely many other solutions.... – Shean Mar 31 '24 at 12:12
  • @yW0K5o haven't verified everything, but they claim that every 120 triangle arises that way. – Shean Mar 31 '24 at 12:17
  • @Shean I verified "Geometry" section of document with 2 conditions for $120^o$ triangles (additional: $2t+1, t(3t+2), 3t*(t+1)+1$). I found that it was missing 50% solutions to compare with enumeration. – yW0K5o Mar 31 '24 at 13:03
  • @Shean the equation here is homogeneous, so "multiply one solution by an integer" produces nothing but trivial variations of a given solution. – coffeemath Mar 31 '24 at 17:24
  • @yW0K5o enumeration also produces answers which have $gcd(x,y,z)\neq 1$. These are called non-primitive solutions. The formulas above are for producing primitive solutions. See my answer. – Shean Mar 31 '24 at 21:01
  • "From here, all primitive solutions can be obtained by dividing a, b, and c by their greatest common divisor. " From https://en.wikipedia.org/wiki/Integer_triangle#Integer_triangles_with_a_120.C2.B0_angle – Shean Mar 31 '24 at 21:01

1 Answers1

1

Can't fit this into a comment so I'll make it an answer.

Firstly, your question isn't clear.

Three variable, second degree diophantine equation doesn't explain how to get other solutions when we know the first solution $(3,5,7)$

If you are expecting to generate ALL triples from $(3,5,7)$ then I don't think this is possible (actually it may be possible, see Will's comment). If you simply want more solutions then take the triple $(3k,5k,7k)$ for any positive integer $k$.

Now if you're wondering why the solutions to formulas such as \begin{equation} x=m^2-n^2\\ y=2mn+n^2\\\tag{1} z=m^2+mn+n^2 \end{equation} where $n<m$ and $\gcd(m,n)=1$ produce less results to: simply plugging in values for $x$ and $y$ and checking if $x^2+xy+y^2$ is a square, is because $(1)$ generates primitive solutions, that is $\gcd(x,y,z)=1$.

(Note: $(1)$ sometimes produces non-primitive solutions, to remedy this, simply divide $x,y,z$ by $\gcd(x,y,z)$)

Some example code using the system $(1)$ producing only primitive triples:

import math

limit = 10 triples = []

for n in range(1, limit): for m in range(n + 1, limit): if math.gcd(m, n) == 1: x = m2 - n2 y = 2 * m * n + n2 z = m2 + m * n + n**2 if y<x: x_temp = x x=y y=x_temp d=math.gcd(x,math.gcd(y,z)) #removing non-primitives triples.append((int(x/d), int(y/d), int(z/d)))

#remove duplicates triples= list(dict.fromkeys(triples))

Sort the triples based on x and then y

sorted_triples = sorted(triples, key=lambda triple: (triple[0], triple[1]))

for triple in sorted_triples: print("x =", triple[0]) print("y =", triple[1]) print("z =", triple[2]) print()

Some example code plugging values for $x$ and $y$ and simply verifying the equation (This is what your code above was doing):

limit = 100
x=1
y=1
while x<limit:
    y=x
    while y<limit:
        z=(x**2+x*y+y**2)**0.5
        if z==int(z):
            print("x="+str(x)+"\ny="+str(y)+"\nz="+str(int(z))+"\n")
        y+=1
    x+=1

You can verify for yourself that any solution from the second code is a non-primitive. Or, you can run a variant of the first code which multiplies each primitive by $k=2,3,4,5$ and notice that the outputs are the same. Simply replace:

d=math.gcd(x,math.gcd(y,z)) #removing non-primitives
triples.append((int(x/d), int(y/d), int(z/d)))

with

for k in range(2,5):
    triples.append((x*k,y*k,z*k))
Shean
  • 1,022
  • If you want to pursue: there should be a method similar to https://en.wikipedia.org/wiki/Tree_of_primitive_Pythagorean_triples by replacing Barning's matrix $B$ with $$ B = \left( \begin{array}{rrr} 4 & 3 & 4 \ 3 & 4 & 4 \ 6 & 6 & 7 \ \end{array} \right) $$ – Will Jagy Mar 31 '24 at 21:44
  • Very interesting! I'll check out the proof in the morning – Shean Mar 31 '24 at 22:00
  • https://arxiv.org/abs/1904.11782 by Noam Zimhoni – Will Jagy Apr 01 '24 at 02:05
  • the published article includes the very nice Figure 3 on journal page 632, the forest for angle $2 \pi / 3.$ In the arxiv version he just gives $\pi/3$ American Mathematical Monthly, volume 127 (2020), number 7, pages 629-637 – Will Jagy Apr 01 '24 at 02:32
  • @Shean I updated my question. – yW0K5o Apr 01 '24 at 03:16