Ask Your Question

# 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.

edit retag close merge delete

## 1 answer

Sort by ยป oldest newest most voted

This works:

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

more

## Comments

@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 12:26:42 -0500 )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-22 19:59:44 -0500 )edit

I see. Thanks.

( 2016-02-23 16:20:38 -0500 )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 03:04:38 -0500 )edit

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

( 2016-02-24 03:05:22 -0500 )edit

## Your Answer

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

Add Answer

## Stats

Asked: 2016-02-22 11:47:38 -0500

Seen: 142 times

Last updated: Feb 22 '16