Writing a program that will filter the integer solutionsNSolve gives additional solutions that don't satisfy...

IEEE 754 square root with Newton-Raphson

Is it possible to take a database offline when doing a backup using an SQL job?

If someone asks a question using “quién”, how can one shortly respond?

How big would the ice ball have to be to deliver all the water at once?

Lost passport and visa, tried to reapply, got rejected twice. What are my next steps?

Why does `FindFit` fail so badly in this simple case?

How to work around players whose backstory goes against the story?

Create the same subfolders in another folder

Writing a program that will filter the integer solutions

What is the goal of the Shiva Purana?

Do my potential customers need to understand the "meaning" of a logo, or just recognize it?

Is the "spacetime" the same thing as the mathematical 4th dimension?

Did Tolkien ever write about a Heaven or Hell for Men?

Why would an airline put 15 passengers at once on standby?

Realistically, how much do you need to start investing?

Can adverbs modify adjectives?

How do my husband and I get over our fear of having another difficult baby?

Should I be an author on another PhD student's paper if I went to their meetings and gave advice?

How to say "respectively" in German when listing (enumerating) things

How to bring home documents from work?

If a spaceship ran out of fuel somewhere in space between Earth and Mars, does it slowly drift off to the Sun?

Isn't the detector always measuring, and thus always collapsing the state?

Why aren't faces sharp in my f/1.8 portraits even though I'm carefully using center-point autofocus?

Phonetic distortion when words are borrowed among languages



Writing a program that will filter the integer solutions


NSolve gives additional solutions that don't satisfy the equations!How to find integer solutions?why doesn't NSolve find all the solutions that Solve finds?On finding all the positive integral solutions of $x^2+y^2=z^2+1$Solve doesn't give me all the solutions I expectShowing that an integer solution does not existHow to convert an expression a + b*Sqrt[c] to a simpler format?FindInstance fails to find integer solutions to glaringly obvious problemsFind multiple solutions of a non-linear system with more variables that equationsHow to solve equation in integer numbers






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2












$begingroup$


I've the following equation:



b==(-12 + 
Sqrt[3] Sqrt[
3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) +
4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


And $r$ is a given number and I'll run $a$ from $2$ to a given number n, which are all integers.



How can I write a code that will give me only an output of $b$ when the equation gives an integer back?





For example, when I use $r=4$ and use the following code:



Table[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6], {a, 1, 100, 1}]


It will find that $a=24$ gives $b=70$, so I want to see only that solution.



Maybe I can use the If[] function?










share|improve this question









$endgroup$














  • $begingroup$
    try Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], {a, 1, 100, 1}] or shorter Table[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), {a, 1, 100, 1}]?
    $endgroup$
    – kglr
    7 hours ago


















2












$begingroup$


I've the following equation:



b==(-12 + 
Sqrt[3] Sqrt[
3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) +
4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


And $r$ is a given number and I'll run $a$ from $2$ to a given number n, which are all integers.



How can I write a code that will give me only an output of $b$ when the equation gives an integer back?





For example, when I use $r=4$ and use the following code:



Table[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6], {a, 1, 100, 1}]


It will find that $a=24$ gives $b=70$, so I want to see only that solution.



Maybe I can use the If[] function?










share|improve this question









$endgroup$














  • $begingroup$
    try Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], {a, 1, 100, 1}] or shorter Table[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), {a, 1, 100, 1}]?
    $endgroup$
    – kglr
    7 hours ago














2












2








2





$begingroup$


I've the following equation:



b==(-12 + 
Sqrt[3] Sqrt[
3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) +
4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


And $r$ is a given number and I'll run $a$ from $2$ to a given number n, which are all integers.



How can I write a code that will give me only an output of $b$ when the equation gives an integer back?





For example, when I use $r=4$ and use the following code:



Table[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6], {a, 1, 100, 1}]


It will find that $a=24$ gives $b=70$, so I want to see only that solution.



Maybe I can use the If[] function?










share|improve this question









$endgroup$




I've the following equation:



b==(-12 + 
Sqrt[3] Sqrt[
3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) +
4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


And $r$ is a given number and I'll run $a$ from $2$ to a given number n, which are all integers.



How can I write a code that will give me only an output of $b$ when the equation gives an integer back?





For example, when I use $r=4$ and use the following code:



Table[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6], {a, 1, 100, 1}]


It will find that $a=24$ gives $b=70$, so I want to see only that solution.



Maybe I can use the If[] function?







equation-solving programming code-request system code






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









JanJan

2502 silver badges11 bronze badges




2502 silver badges11 bronze badges















  • $begingroup$
    try Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], {a, 1, 100, 1}] or shorter Table[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), {a, 1, 100, 1}]?
    $endgroup$
    – kglr
    7 hours ago


















  • $begingroup$
    try Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], {a, 1, 100, 1}] or shorter Table[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), {a, 1, 100, 1}]?
    $endgroup$
    – kglr
    7 hours ago
















$begingroup$
try Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], {a, 1, 100, 1}] or shorter Table[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), {a, 1, 100, 1}]?
$endgroup$
– kglr
7 hours ago




$begingroup$
try Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], {a, 1, 100, 1}] or shorter Table[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), {a, 1, 100, 1}]?
$endgroup$
– kglr
7 hours ago










2 Answers
2






active

oldest

votes


















4














$begingroup$

You can use Solve. Your equation:



eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


Using Solve (with $r=4$):



Solve[eqn[4] && 1 < a < 100, {a, b}, Integers]



{{a -> 24, b -> 70}}




Using Solve (with $r=11$):



Solve[eqn[11] && 1 < a < 100, {a, b}, Integers]



{{a -> 25, b -> 73}}







share|improve this answer









$endgroup$























    2














    $begingroup$

    You might try IntegerQ



    Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
    If[IntegerQ[b], {b, a}, Nothing], {a, 2, 50}]
    (*{{70, 24}}*)





    share|improve this answer









    $endgroup$


















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "387"
      };
      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: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });















      draft saved

      draft discarded
















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206787%2fwriting-a-program-that-will-filter-the-integer-solutions%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      $begingroup$

      You can use Solve. Your equation:



      eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


      Using Solve (with $r=4$):



      Solve[eqn[4] && 1 < a < 100, {a, b}, Integers]



      {{a -> 24, b -> 70}}




      Using Solve (with $r=11$):



      Solve[eqn[11] && 1 < a < 100, {a, b}, Integers]



      {{a -> 25, b -> 73}}







      share|improve this answer









      $endgroup$




















        4














        $begingroup$

        You can use Solve. Your equation:



        eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


        Using Solve (with $r=4$):



        Solve[eqn[4] && 1 < a < 100, {a, b}, Integers]



        {{a -> 24, b -> 70}}




        Using Solve (with $r=11$):



        Solve[eqn[11] && 1 < a < 100, {a, b}, Integers]



        {{a -> 25, b -> 73}}







        share|improve this answer









        $endgroup$


















          4














          4










          4







          $begingroup$

          You can use Solve. Your equation:



          eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


          Using Solve (with $r=4$):



          Solve[eqn[4] && 1 < a < 100, {a, b}, Integers]



          {{a -> 24, b -> 70}}




          Using Solve (with $r=11$):



          Solve[eqn[11] && 1 < a < 100, {a, b}, Integers]



          {{a -> 25, b -> 73}}







          share|improve this answer









          $endgroup$



          You can use Solve. Your equation:



          eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))


          Using Solve (with $r=4$):



          Solve[eqn[4] && 1 < a < 100, {a, b}, Integers]



          {{a -> 24, b -> 70}}




          Using Solve (with $r=11$):



          Solve[eqn[11] && 1 < a < 100, {a, b}, Integers]



          {{a -> 25, b -> 73}}








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 7 hours ago









          Carl WollCarl Woll

          90.6k3 gold badges120 silver badges232 bronze badges




          90.6k3 gold badges120 silver badges232 bronze badges




























              2














              $begingroup$

              You might try IntegerQ



              Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
              If[IntegerQ[b], {b, a}, Nothing], {a, 2, 50}]
              (*{{70, 24}}*)





              share|improve this answer









              $endgroup$




















                2














                $begingroup$

                You might try IntegerQ



                Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
                If[IntegerQ[b], {b, a}, Nothing], {a, 2, 50}]
                (*{{70, 24}}*)





                share|improve this answer









                $endgroup$


















                  2














                  2










                  2







                  $begingroup$

                  You might try IntegerQ



                  Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
                  If[IntegerQ[b], {b, a}, Nothing], {a, 2, 50}]
                  (*{{70, 24}}*)





                  share|improve this answer









                  $endgroup$



                  You might try IntegerQ



                  Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
                  If[IntegerQ[b], {b, a}, Nothing], {a, 2, 50}]
                  (*{{70, 24}}*)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 7 hours ago









                  Ulrich NeumannUlrich Neumann

                  14.3k7 silver badges23 bronze badges




                  14.3k7 silver badges23 bronze badges


































                      draft saved

                      draft discarded



















































                      Thanks for contributing an answer to Mathematica 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%2fmathematica.stackexchange.com%2fquestions%2f206787%2fwriting-a-program-that-will-filter-the-integer-solutions%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

                      Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                      Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                      Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...