Ryley's Theorem

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite












S. Ryley proved following theorem in 1825:




Every rational number can be expressed as a sum of three rational cubes.




Challenge



Given some rational number $r in mathbb Q $ find three rational numbers $a,b,c in mathbb Q$ such that $$r= a^3+b^3+c^3.$$



Details



Your submission should be able to compute a solution for every input given enough time and memory, that means having for instance two 32-bit int representing a fraction is not sufficient.



Examples



$$ beginalign
30 &= 3982933876681^3 - 636600549515^3 - 3977505554546^3 \
52 &= 60702901317^3 + 23961292454^3 - 61922712865^3 \
frac3071728 &= left(frac12right)^3 + left(frac13right)^3 + left(frac14right)^3 \
0 &= 0^3 + 0^3 + 0^3 \
1 &= left(frac12right)^3 + left(frac23right)^3 + left(frac56right)^3\
42 &= left(frac1810423509232right)^3 + left(frac-1495210609right)^3 + left(frac-25454944right)^3
endalign$$












share|improve this question



























    up vote
    6
    down vote

    favorite












    S. Ryley proved following theorem in 1825:




    Every rational number can be expressed as a sum of three rational cubes.




    Challenge



    Given some rational number $r in mathbb Q $ find three rational numbers $a,b,c in mathbb Q$ such that $$r= a^3+b^3+c^3.$$



    Details



    Your submission should be able to compute a solution for every input given enough time and memory, that means having for instance two 32-bit int representing a fraction is not sufficient.



    Examples



    $$ beginalign
    30 &= 3982933876681^3 - 636600549515^3 - 3977505554546^3 \
    52 &= 60702901317^3 + 23961292454^3 - 61922712865^3 \
    frac3071728 &= left(frac12right)^3 + left(frac13right)^3 + left(frac14right)^3 \
    0 &= 0^3 + 0^3 + 0^3 \
    1 &= left(frac12right)^3 + left(frac23right)^3 + left(frac56right)^3\
    42 &= left(frac1810423509232right)^3 + left(frac-1495210609right)^3 + left(frac-25454944right)^3
    endalign$$












    share|improve this question

























      up vote
      6
      down vote

      favorite









      up vote
      6
      down vote

      favorite











      S. Ryley proved following theorem in 1825:




      Every rational number can be expressed as a sum of three rational cubes.




      Challenge



      Given some rational number $r in mathbb Q $ find three rational numbers $a,b,c in mathbb Q$ such that $$r= a^3+b^3+c^3.$$



      Details



      Your submission should be able to compute a solution for every input given enough time and memory, that means having for instance two 32-bit int representing a fraction is not sufficient.



      Examples



      $$ beginalign
      30 &= 3982933876681^3 - 636600549515^3 - 3977505554546^3 \
      52 &= 60702901317^3 + 23961292454^3 - 61922712865^3 \
      frac3071728 &= left(frac12right)^3 + left(frac13right)^3 + left(frac14right)^3 \
      0 &= 0^3 + 0^3 + 0^3 \
      1 &= left(frac12right)^3 + left(frac23right)^3 + left(frac56right)^3\
      42 &= left(frac1810423509232right)^3 + left(frac-1495210609right)^3 + left(frac-25454944right)^3
      endalign$$












      share|improve this question















      S. Ryley proved following theorem in 1825:




      Every rational number can be expressed as a sum of three rational cubes.




      Challenge



      Given some rational number $r in mathbb Q $ find three rational numbers $a,b,c in mathbb Q$ such that $$r= a^3+b^3+c^3.$$



      Details



      Your submission should be able to compute a solution for every input given enough time and memory, that means having for instance two 32-bit int representing a fraction is not sufficient.



      Examples



      $$ beginalign
      30 &= 3982933876681^3 - 636600549515^3 - 3977505554546^3 \
      52 &= 60702901317^3 + 23961292454^3 - 61922712865^3 \
      frac3071728 &= left(frac12right)^3 + left(frac13right)^3 + left(frac14right)^3 \
      0 &= 0^3 + 0^3 + 0^3 \
      1 &= left(frac12right)^3 + left(frac23right)^3 + left(frac56right)^3\
      42 &= left(frac1810423509232right)^3 + left(frac-1495210609right)^3 + left(frac-25454944right)^3
      endalign$$









      code-golf math number-theory rational-numbers polynomials






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago

























      asked 3 hours ago









      flawr

      25.9k562178




      25.9k562178




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote














          Haskell, 95 89 76 bytes



          • -18 bytes thanks to H.PWiz

          f x=[w|n<-[1..],w<-mapM((/)<$>[-n..n]<*>)$[1..n]<$"IOU",x==sum((^3)<$>w)]!!0


          Try it online!



          Simple bruteforce: enumerates all triples $(a,b,c)$ of rationals and verifies whether $x=a^3+b^3+c^3$.






          share|improve this answer






















          • What does the "IOU" do?
            – Solomon Ucko
            51 mins ago










          • @SolomonUcko Nothing special, it's as good as any other list of length 3
            – Delfad0r
            48 mins ago










          • @Delfad0r I see, that makes sense.
            – Solomon Ucko
            46 mins ago










          • @H.PWiz I couldn't find any consensus on Meta on whether assuming typed input is accepted, but I still found a way to shorten the code without that assumption. Thanks!
            – Delfad0r
            33 mins ago






          • 1




            @Delfad0r There is a "consensus" that you do not have to count a possible import, that is only needed to construct the type needed, if you do not explicitly need anything from that import for defining your function. (And you can assume that the correct type is passed to your function, when it is called.)
            – flawr
            31 mins ago











          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.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "200"
          ;
          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',
          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/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
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175201%2fryleys-theorem%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote














          Haskell, 95 89 76 bytes



          • -18 bytes thanks to H.PWiz

          f x=[w|n<-[1..],w<-mapM((/)<$>[-n..n]<*>)$[1..n]<$"IOU",x==sum((^3)<$>w)]!!0


          Try it online!



          Simple bruteforce: enumerates all triples $(a,b,c)$ of rationals and verifies whether $x=a^3+b^3+c^3$.






          share|improve this answer






















          • What does the "IOU" do?
            – Solomon Ucko
            51 mins ago










          • @SolomonUcko Nothing special, it's as good as any other list of length 3
            – Delfad0r
            48 mins ago










          • @Delfad0r I see, that makes sense.
            – Solomon Ucko
            46 mins ago










          • @H.PWiz I couldn't find any consensus on Meta on whether assuming typed input is accepted, but I still found a way to shorten the code without that assumption. Thanks!
            – Delfad0r
            33 mins ago






          • 1




            @Delfad0r There is a "consensus" that you do not have to count a possible import, that is only needed to construct the type needed, if you do not explicitly need anything from that import for defining your function. (And you can assume that the correct type is passed to your function, when it is called.)
            – flawr
            31 mins ago















          up vote
          3
          down vote














          Haskell, 95 89 76 bytes



          • -18 bytes thanks to H.PWiz

          f x=[w|n<-[1..],w<-mapM((/)<$>[-n..n]<*>)$[1..n]<$"IOU",x==sum((^3)<$>w)]!!0


          Try it online!



          Simple bruteforce: enumerates all triples $(a,b,c)$ of rationals and verifies whether $x=a^3+b^3+c^3$.






          share|improve this answer






















          • What does the "IOU" do?
            – Solomon Ucko
            51 mins ago










          • @SolomonUcko Nothing special, it's as good as any other list of length 3
            – Delfad0r
            48 mins ago










          • @Delfad0r I see, that makes sense.
            – Solomon Ucko
            46 mins ago










          • @H.PWiz I couldn't find any consensus on Meta on whether assuming typed input is accepted, but I still found a way to shorten the code without that assumption. Thanks!
            – Delfad0r
            33 mins ago






          • 1




            @Delfad0r There is a "consensus" that you do not have to count a possible import, that is only needed to construct the type needed, if you do not explicitly need anything from that import for defining your function. (And you can assume that the correct type is passed to your function, when it is called.)
            – flawr
            31 mins ago













          up vote
          3
          down vote










          up vote
          3
          down vote










          Haskell, 95 89 76 bytes



          • -18 bytes thanks to H.PWiz

          f x=[w|n<-[1..],w<-mapM((/)<$>[-n..n]<*>)$[1..n]<$"IOU",x==sum((^3)<$>w)]!!0


          Try it online!



          Simple bruteforce: enumerates all triples $(a,b,c)$ of rationals and verifies whether $x=a^3+b^3+c^3$.






          share|improve this answer















          Haskell, 95 89 76 bytes



          • -18 bytes thanks to H.PWiz

          f x=[w|n<-[1..],w<-mapM((/)<$>[-n..n]<*>)$[1..n]<$"IOU",x==sum((^3)<$>w)]!!0


          Try it online!



          Simple bruteforce: enumerates all triples $(a,b,c)$ of rationals and verifies whether $x=a^3+b^3+c^3$.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 24 mins ago

























          answered 1 hour ago









          Delfad0r

          1,193315




          1,193315











          • What does the "IOU" do?
            – Solomon Ucko
            51 mins ago










          • @SolomonUcko Nothing special, it's as good as any other list of length 3
            – Delfad0r
            48 mins ago










          • @Delfad0r I see, that makes sense.
            – Solomon Ucko
            46 mins ago










          • @H.PWiz I couldn't find any consensus on Meta on whether assuming typed input is accepted, but I still found a way to shorten the code without that assumption. Thanks!
            – Delfad0r
            33 mins ago






          • 1




            @Delfad0r There is a "consensus" that you do not have to count a possible import, that is only needed to construct the type needed, if you do not explicitly need anything from that import for defining your function. (And you can assume that the correct type is passed to your function, when it is called.)
            – flawr
            31 mins ago

















          • What does the "IOU" do?
            – Solomon Ucko
            51 mins ago










          • @SolomonUcko Nothing special, it's as good as any other list of length 3
            – Delfad0r
            48 mins ago










          • @Delfad0r I see, that makes sense.
            – Solomon Ucko
            46 mins ago










          • @H.PWiz I couldn't find any consensus on Meta on whether assuming typed input is accepted, but I still found a way to shorten the code without that assumption. Thanks!
            – Delfad0r
            33 mins ago






          • 1




            @Delfad0r There is a "consensus" that you do not have to count a possible import, that is only needed to construct the type needed, if you do not explicitly need anything from that import for defining your function. (And you can assume that the correct type is passed to your function, when it is called.)
            – flawr
            31 mins ago
















          What does the "IOU" do?
          – Solomon Ucko
          51 mins ago




          What does the "IOU" do?
          – Solomon Ucko
          51 mins ago












          @SolomonUcko Nothing special, it's as good as any other list of length 3
          – Delfad0r
          48 mins ago




          @SolomonUcko Nothing special, it's as good as any other list of length 3
          – Delfad0r
          48 mins ago












          @Delfad0r I see, that makes sense.
          – Solomon Ucko
          46 mins ago




          @Delfad0r I see, that makes sense.
          – Solomon Ucko
          46 mins ago












          @H.PWiz I couldn't find any consensus on Meta on whether assuming typed input is accepted, but I still found a way to shorten the code without that assumption. Thanks!
          – Delfad0r
          33 mins ago




          @H.PWiz I couldn't find any consensus on Meta on whether assuming typed input is accepted, but I still found a way to shorten the code without that assumption. Thanks!
          – Delfad0r
          33 mins ago




          1




          1




          @Delfad0r There is a "consensus" that you do not have to count a possible import, that is only needed to construct the type needed, if you do not explicitly need anything from that import for defining your function. (And you can assume that the correct type is passed to your function, when it is called.)
          – flawr
          31 mins ago





          @Delfad0r There is a "consensus" that you do not have to count a possible import, that is only needed to construct the type needed, if you do not explicitly need anything from that import for defining your function. (And you can assume that the correct type is passed to your function, when it is called.)
          – flawr
          31 mins ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175201%2fryleys-theorem%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          Installing NextGIS Connect into QGIS 3?

          One-line joke