3

"PowersRepresentations[n,k,p] gives the distinct representations of the integer n as a sum of k non-negative p-th integer powers"

Documentation: PowersRepresentations

How does Mathematica do this computation so quickly? Is there a fast algorithm? What is it?

I am particularly interested in the case where $n$ is the sum of $k$ squares of positive integers.

LCarvalho
  • 9,233
  • 4
  • 40
  • 96

1 Answers1

10

You can view the code for PowersRepresentations using

Needs["GeneralUtilities`"]; 
PrintDefinitions @PowersRepresentations
kglr
  • 394,356
  • 18
  • 477
  • 896