Diophantine equation: solving $a^2+4n=b^2$

56 Views Asked by At

I found myself working with diophantine equations but I have no experience at all with them. Given an integer $n$, can I find two integers, $a$ and $b$, such that $$a^2+4n=b^2$$ How would you guys approach the problem?

Thank you in advance.

4

There are 4 best solutions below

3
On BEST ANSWER

Sure. With $a=n-1, b=n+1$ we have $$a^2+4n=n^2-2n+1+4n=n^2+2n+1=b^2$$

1
On

$$4n=b^2-a^2$$

$$n=\dfrac{b+a}2\cdot\dfrac{b-a}2$$

If $n=p\cdot q,\dfrac{b+a}2=p, \dfrac{b-a}2=q$

Trivially $q=1,p=?$

1
On

Here is a method to compute $0\leq a,b\leq 1000$ given n.

public static long[][] diophantine(long n)
    {
        long fourn= 4*n;
        long[][] results = new long[2][1000];
        int index=0;
        for(int a=1;a<1000;a++)
        {
            double b=Math.sqrt(Math.pow((double)a, 2.0)+(double)fourn); 
            if((b % 1) == 0)
            {
                results[0][index]=a;
                results[1][index]=(long)b;
                index++;
            }
        }
        return results;

    }

SO for example, when $n=50$ gives(first column is the values of a and the second is the values of b :

enter image description here

0
On

4 n = b^2 - a^2
n = g * h
4 n = (b - a) (b + a)
4 n = 2 g * 2 h
b - a = 2 g; b + a = 2 h

n = g h
a = h - g
b = h + g

if n = 7 then
(g=-7; h=-1 => a=6; b=-8 or
g=-1; h=-7 => a=-6; b=-8 or
g=1; h=7 => a=6; b=8 or
g=7; h=1 =>a=-6; b=8)
https://www.youtube.com/watch?v=dkf2xnmGHuA&index=8&list=PLfd6TTV3Dn5JUp6IDep5jV9wzOEmkpv4O