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












-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.










share|cite|improve this question











$endgroup$

















    -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.










    share|cite|improve this question











    $endgroup$















      -1












      -1








      -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.










      share|cite|improve this question











      $endgroup$




      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.







      diophantine-equations square-numbers sums-of-squares






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Nov 26 '18 at 12:50









      José Carlos Santos

      156k22125227




      156k22125227










      asked Nov 26 '18 at 12:34









      Lyn CassidyLyn Cassidy

      436




      436






















          4 Answers
          4






          active

          oldest

          votes


















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






          share|cite|improve this answer









          $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}2cdotdfrac{b-a}2$$



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



          Trivially $q=1,p=?$






          share|cite|improve this answer









          $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 $0leq a,bleq 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






          share|cite|improve this answer









          $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






          share|cite|improve this answer











          $endgroup$













            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "69"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3014261%2fdiophantine-equation-solving-a24n-b2%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









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






            share|cite|improve this answer









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

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






            share|cite|improve this answer









            $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












            0








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






            share|cite|improve this answer









            $endgroup$



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







            share|cite|improve this answer












            share|cite|improve this answer



            share|cite|improve this answer










            answered Nov 26 '18 at 12:38









            lulululu

            39.8k24778




            39.8k24778












            • $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


















            • $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
















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




            $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}2cdotdfrac{b-a}2$$



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



            Trivially $q=1,p=?$






            share|cite|improve this answer









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

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



            $$n=dfrac{b+a}2cdotdfrac{b-a}2$$



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



            Trivially $q=1,p=?$






            share|cite|improve this answer









            $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












            0








            0





            $begingroup$

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



            $$n=dfrac{b+a}2cdotdfrac{b-a}2$$



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



            Trivially $q=1,p=?$






            share|cite|improve this answer









            $endgroup$



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



            $$n=dfrac{b+a}2cdotdfrac{b-a}2$$



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



            Trivially $q=1,p=?$







            share|cite|improve this answer












            share|cite|improve this answer



            share|cite|improve this answer










            answered Nov 26 '18 at 12:40









            lab bhattacharjeelab bhattacharjee

            224k15156274




            224k15156274












            • $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


















            • $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
















            $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




            $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 $0leq a,bleq 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






            share|cite|improve this answer









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

            Here is a method to compute $0leq a,bleq 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






            share|cite|improve this answer









            $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












            0








            0





            $begingroup$

            Here is a method to compute $0leq a,bleq 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






            share|cite|improve this answer









            $endgroup$



            Here is a method to compute $0leq a,bleq 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







            share|cite|improve this answer












            share|cite|improve this answer



            share|cite|improve this answer










            answered Nov 26 '18 at 13:05









            nafhgoodnafhgood

            1,801422




            1,801422












            • $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


















            • $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
















            $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




            $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






            share|cite|improve this answer











            $endgroup$


















              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






              share|cite|improve this answer











              $endgroup$
















                0












                0








                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






                share|cite|improve this answer











                $endgroup$



                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







                share|cite|improve this answer














                share|cite|improve this answer



                share|cite|improve this answer








                edited Nov 27 '18 at 15:50

























                answered Nov 27 '18 at 15:38









                S. I.S. I.

                112




                112






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematics Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3014261%2fdiophantine-equation-solving-a24n-b2%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to send String Array data to Server using php in android

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Is anime1.com a legal site for watching anime?