Ryley's Theorem
Clash 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$$
code-golf math number-theory rational-numbers polynomials
add a comment |Â
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$$
code-golf math number-theory rational-numbers polynomials
add a comment |Â
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$$
code-golf math number-theory rational-numbers polynomials
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
code-golf math number-theory rational-numbers polynomials
edited 2 hours ago
asked 3 hours ago
flawr
25.9k562178
25.9k562178
add a comment |Â
add a comment |Â
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$.
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
 |Â
show 2 more comments
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$.
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
 |Â
show 2 more comments
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$.
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
 |Â
show 2 more comments
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$.
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$.
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
 |Â
show 2 more comments
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
 |Â
show 2 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password