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!

edit retag close merge delete

Sort by ยป oldest newest most voted

This works:

sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)

more

@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?

( 2016-02-22 19:26:42 +0200 )edit

I 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).

( 2016-02-23 02:59:44 +0200 )edit

I see. Thanks.

( 2016-02-23 23:20:38 +0200 )edit

@Holden If you have Mathematica and Sage on the same computer, you should be able to use Mathematica from within Sage.

( 2016-02-24 10:04:38 +0200 )edit

@Holden: maybe open a separate question "Number of representations of an integer as a sum of k squares"

( 2016-02-24 10:05:22 +0200 )edit