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

  • $\begingroup$ There is a little man inside the computer who is good at sums $\endgroup$ – wolfies Dec 5 '16 at 4:43

You can view the code for PowersRepresentations using

PrintDefinitions @PowersRepresentations
  • $\begingroup$ Can one view codes this way for any function? $\endgroup$ – Mirko Aveta Dec 4 '16 at 20:46
  • 3
    $\begingroup$ @Mirko, unfortunately, 'PrintDefinitions' does not give the code for Kernel functions; it just returns '<Kernel Function>'. $\endgroup$ – kglr Dec 4 '16 at 21:50
  • $\begingroup$ @kglr That's because closed-source software hates its users :) $\endgroup$ – cat Dec 4 '16 at 22:04
  • $\begingroup$ @kglr You will find any function is kernel function when you arive v11.2. Even this :) $\endgroup$ – yode Oct 19 '17 at 11:59
  • $\begingroup$ @yode, interesting. $\endgroup$ – kglr Oct 19 '17 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.