Writing a program that will filter the integer solutionsNSolve 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

How to identify whether a publisher is genuine or not?

How deep is the liquid in a half-full hemisphere?

Worlds with different mathematics and logic

does 'java' command compile the java program?

How many space launch vehicles are under development worldwide?

Can adverbs modify adjectives?

Delete n lines skip 1 line script

grounded outlets and code compliance

How does Monks' Improved Unarmored Movement work out of combat?

Which Catholic priests were given diplomatic missions?

Smallest PRIME containing the first 11 primes as sub-strings

Can I pay some of the cost of an activated ability lots of times to get more out of the effect?

Realistically, how much do you need to start investing?

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

Can a passenger predict that an airline is about to go bankrupt?

What does it mean by "my days-of-the-week underwear only go to Thursday" in this context?

Would a horse be sufficient buffer to prevent injury when falling from a great height?

To what degree did the Supreme Court limit Boris Johnson's ability to prorogue?

How do I introduce dark themes?

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

Beyond Futuristic Technology for an Alien Warship?

Implementation of a Thread Pool in C++

How do we know neutrons have no charge?

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



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

                      Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                      Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                      Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її