ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 16 Mar 2018 17:16:03 -0500Representation as sums of squares built-in functionhttp://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/
Is there a Sage implementation of writing a number as a sum of k squares for any k as described in the ticket here: trac.sagemath.org/ticket/16308 ?
Thank you!
Please see my comment below the first answer.Mon, 22 Feb 2016 11:47:38 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/Answer by slelievre for <p>Is there a Sage implementation of writing a number as a sum of k squares for any k as described in the ticket here: trac.sagemath.org/ticket/16308 ?</p>
<p>Thank you!</p>
<p>Please see my comment below the first answer.</p>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?answer=32633#post-id-32633This works:
sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
Mon, 22 Feb 2016 12:04:06 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?answer=32633#post-id-32633Comment by Holden for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=41591#post-id-41591@slelievre, cool. Thanks.Fri, 16 Mar 2018 17:16:03 -0500http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=41591#post-id-41591Comment by kcrisman for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32737#post-id-32737(Though see http://trac.sagemath.org/ticket/18888.)Tue, 08 Mar 2016 09:10:48 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32737#post-id-32737Comment by slelievre for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32725#post-id-32725According to [Sage trac ticket #16703](http://trac.sagemath.org/ticket/16703), the interface to Mathematica 10 was fixed.Sun, 06 Mar 2016 11:20:46 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32725#post-id-32725Comment by Holden for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32681#post-id-32681@slelievre, thank you so much. I installed mathematica 10.3(latest issue) and was not able to call mathematica even if I followed all the instructions on how to use mathematica within sage. From what I read around the web, I have to downgrade to version 8 to be able to interface to mathematica from within Sage. Is that true or am I missing something with integrating version 10.3?Sat, 27 Feb 2016 08:58:07 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32681#post-id-32681Comment by slelievre for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32651#post-id-32651@Holden: see also [Waring's problem](http://en.wikipedia.org/wiki/Waring's_problem).Wed, 24 Feb 2016 03:08:13 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32651#post-id-32651Comment by slelievre for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32650#post-id-32650@Holden: maybe open a separate question "Number of representations of an integer as a sum of k squares"Wed, 24 Feb 2016 03:05:22 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32650#post-id-32650Comment by slelievre for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32649#post-id-32649@Holden If you have Mathematica and Sage on the same computer, you should be able to use Mathematica from within Sage.Wed, 24 Feb 2016 03:04:38 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32649#post-id-32649Comment by Holden for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32646#post-id-32646I see. Thanks.Tue, 23 Feb 2016 16:20:38 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32646#post-id-32646Comment by kcrisman for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32636#post-id-32636I don't believe we have that. For some values of `k` this would be easy but for others I think it's an open problem (haven't looked at this for a bit).Mon, 22 Feb 2016 19:59:44 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32636#post-id-32636Comment by Holden for <p>This works:</p>
<pre><code>sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
</code></pre>
http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32634#post-id-32634@slelievre, thank you! I have confused my self a lot and I was actually looking for a built in function that outputs r_k(n) which is the number of ways of writing a given number n as a sum of k-squares. For instance r_4(1) = 8. There is SquaresR[] built-in function in Mathematica but I can't interface to it within Sage. Is there such a built-in function in Sage?Mon, 22 Feb 2016 12:26:42 -0600http://ask.sagemath.org/question/32632/representation-as-sums-of-squares-built-in-function/?comment=32634#post-id-32634