Ask Your Question

Representation as sums of squares built-in function

asked 2016-02-22 18:47:38 +0200

Holden gravatar image

updated 2016-02-22 19:31:24 +0200

Is there a Sage implementation of writing a number as a sum of k squares for any k as described in the ticket here: ?

Thank you!

Please see my comment below the first answer.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-02-22 19:04:06 +0200

slelievre gravatar image

This works:

sage: sum_of_k_squares(4, 2016)
(0, 4, 8, 44)
edit flag offensive delete link 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?

Holden gravatar imageHolden ( 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).

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

I see. Thanks.

Holden gravatar imageHolden ( 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.

slelievre gravatar imageslelievre ( 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"

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-02-22 18:47:38 +0200

Seen: 438 times

Last updated: Feb 22 '16