I am trying to write a code in Python to do the following. We can express the Erdős-Straus-conjecture in function of some polynomials $x(k), y(k), z(k) \in \mathbb{Q}[k]$ such that $\frac4k = \frac{1}{x(k)} + \frac{1}{y(k)} + \frac{1}{z(k)}$. Notice that the coefficients are rational numbers, but they have to be integers to be able to use them for this conjecture. Following formulas are given:
- $ \frac4k = \frac1{uk} + \frac1{vk} + \frac{4uv - u - v}{uvk} \quad(P1)$
- $ \frac4k = \frac1{uk} + \frac{4u-1}{uk+v} + \frac{(4u-1)v}{uk(uk+v)}\quad (P2) $
- $ \frac4k = \frac{4u}{uk+v+1} + \frac4{k(uk+v+1)} + \frac{4v}{k(uk+v+1)}\quad (P3)$
- $ \frac4k = \frac4{k+v} + \frac{4v}{k(k+4u+v)} + \frac{16uv}{k(k+v)(k+4u+v)} \quad (P4) $
The following theorem is used to determine when polynomials yield integer values: Consider $f \in \mathbb{Q}[k]$ en choose $m \in \mathbb{Z}$ such that $m \cdot f$ only has integer coefficients. Now consider $n = am+b \in \mathbb{Z}$ with $0 \le b < m$. Then $f(n) \in \mathbb{Z}$ iff $(m\cdot f)(b) \equiv 0\,\,(mod\,\,m)$.
This theorem implies that only looking at the residue classes modulo $m$ is sufficient to find out for which integers $n$ also $f(n)$ will be an integer.
For the Erdös-Straus-conjucture I have three polynomials $f_1(n), f_2(n), f_3(n)$. I want to find out for which $n$ all three polynomials have integer coefficients. Consider the corresponding $m$-values $m_1,m_2,m_3$ and let $m$ be equal to $lcm(m_1,m_2,m_3)$. Applying the above theorem (with the $m$ found), it's enough to check for which residue classes modulo $m$ all three polynomials $f_1,f_2,f_3$ will be integers.
So, I'd like to write a function in Python that has concrete values of $u$ and $v$ as input. I want to calculate the correct value for $m$ and to check for which residue classes modulo $m$ the polynomials have integer values. Therefore, the output should be a tuple ($m$,L) with L the list of residue classes modulo $m$ (that satisfy the conditions). I want to be able to use this function for (P1), (P2), (P3) and (P4).
This is what I've got so far:
P.<k> = PolynomialRing(QQ)
var('x,y,z')
def P1(u,v):
x = u*k
y = v*k
z = (u*v*k)/(4*u*v-u-v)
return (x,y,z)
def P2(u,v):
x = u*k
y = (u*k+v)/(4*u-1)
z = (u*k*(u*k+v))/((4*u-1)*v)
return (x,y,z)
def P3(u,v):
x = (u*k+v+1)/(4*u)
y = (k*(u*k+v+1))/4
z = (k*(u*k+v+1))/(4*v)
return (x,y,z)
def P4(u,v):
x = (k+v)/4
y = (k*(k+4*u+v))/(4*v)
z = (k*(k+v)*(k+4*u+v))/(16*u*v)
return (x,y,z)
var('m,k')
def findM(f):
m = (f(k=1)^-1).denominator()
return m
var('u,v,P,m1,m2,m3,m,k')
def mP(u,v,P):
D = P(u,v)
m1 = findM(D[0])
m2 = findM(D[1])
m3 = findM(D[2])
m = lcm([m1,m2,m3])
L = []
for i in xrange(1,m-1):
if((D[0](k=i)^-1).denominator() == 1 and (D[1](k=i)^-1).denominator() == 1 and (D[2](k=i)^-1).denominator() == 1 and Mod(m*((D[0]^-1) + (D[1]^-1) + (D[2]^-1))(k=b),m) == 0):
L.append(i)
return (m,L)
The problem is a keep getting an empty list. I'm using Sage Math to compute this (which is based on Python - kinda). Can someone please help me.
Infinitely grateful!