-1
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Hi thank you too for your answer, are you aware of methods to find non-trivial solutions? $\endgroup$ – Lyn Cassidy Nov 26 '18 at 13:02
  • $\begingroup$ all the answers are trivial. Rewrite your equation as $4n=(b-a)(b+a)$. Write $4n=(2m)\times (2k)$ for any factoring, $n=mk$ If $m≥k$ then solve $b+a=2m,b-a=2k$. $\endgroup$ – lulu Nov 26 '18 at 13:07
  • $\begingroup$ So basically to get all the results you need to factorize n. I'll mark this as the correct solution. $\endgroup$ – Lyn Cassidy Nov 26 '18 at 13:27
0
$\begingroup$

$$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=?$

$\endgroup$
  • $\begingroup$ Hi, thanks for your answer. Are you aware of methods to find non-trivial solutions? $\endgroup$ – Lyn Cassidy Nov 26 '18 at 13:00
0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Hi, thanks for the effort, but this is what i was trying to avoid: no loops, just a straight up equation. $\endgroup$ – Lyn Cassidy Nov 26 '18 at 13:24
0
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.