Sum of cubes

This applet finds the decomposition of any integer number not congruent to 4 or 5 (mod 9) into a sum of four cubes.

Formulas

The applet uses the following formulas:

  • 6x = parenthesis(x − 1close parenthesis)³ + parenthesis(−xclose parenthesis)³ + parenthesis(−xclose parenthesis)³ + parenthesis(x + 1close parenthesis)³
  • 6x + 3 = x³ + parenthesis(−x + 4close parenthesis)³ + parenthesis(2x − 5close parenthesis)³ + parenthesis(−2x + 4close parenthesis)³
  • 18x + 1 = parenthesis(2x + 14close parenthesis)³ + parenthesis(−2x − 23close parenthesis)³ + parenthesis(−3x − 26close parenthesis)³ + parenthesis(3x + 30close parenthesis)³
  • 18x + 7 = parenthesis(x + 2close parenthesis)³ + parenthesis(6x − 1close parenthesis)³ + parenthesis(8x − 2close parenthesis)³ + parenthesis(−9x + 2close parenthesis)³
  • 18x + 8 = parenthesis(x − 5close parenthesis)³ + parenthesis(−x + 14close parenthesis)³ + parenthesis(−3x + 29close parenthesis)³ + parenthesis(3x − 30close parenthesis)³
  • 54x + 20 = parenthesis(3x − 11close parenthesis)³ + parenthesis(−3x + 10close parenthesis)³ + parenthesis(x + 2close parenthesis)³ + parenthesis(−x + 7close parenthesis)³
  • 72x + 56 = parenthesis(−9x + 4close parenthesis)³ + parenthesis(x + 4close parenthesis)³ + parenthesis(6x − 2close parenthesis)³ + parenthesis(8x − 4close parenthesis)³
  • 108x + 2 = parenthesis(−x − 22close parenthesis)³ + parenthesis(x + 4close parenthesis)³ + parenthesis(−3x − 41close parenthesis)³ + parenthesis(3x + 43close parenthesis)³
  • 216x + 92 = parenthesis(3x − 164close parenthesis)³ + parenthesis(−3x + 160close parenthesis)³ + parenthesis(x − 35close parenthesis)³ + parenthesis(−x + 71close parenthesis)³
  • 270x + 146 = parenthesis(−60x + 91close parenthesis)³ + parenthesis(−3x + 13close parenthesis)³ + parenthesis(22x − 37close parenthesis)³ + parenthesis(59x − 89close parenthesis)³
  • 270x + 200 = parenthesis(3x + 259close parenthesis)³ + parenthesis(−3x − 254close parenthesis)³ + parenthesis(x + 62close parenthesis)³ + parenthesis(−x − 107close parenthesis)³
  • 270x + 218 = parenthesis(−3x − 56close parenthesis)³ + parenthesis(3x + 31close parenthesis)³ + parenthesis(−5x − 69close parenthesis)³ + parenthesis(5x + 78close parenthesis)³
  • 432x + 380 = parenthesis(−3x + 64close parenthesis)³ + parenthesis(3x − 80close parenthesis)³ + parenthesis(2x − 29close parenthesis)³ + parenthesis(−2x + 65close parenthesis)³
  • 540x + 38 = parenthesis(5x − 285close parenthesis)³ + parenthesis(−5x + 267close parenthesis)³ + parenthesis(3x − 140close parenthesis)³ + parenthesis(−3x + 190close parenthesis)³
  • 810x + 56 = parenthesis(5x − 755close parenthesis)³ + parenthesis(−5x + 836close parenthesis)³ + parenthesis(9x − 1445close parenthesis)³ + parenthesis(−9x + 1420close parenthesis)³
  • 1080x + 380 = parenthesis(−x − 1438close parenthesis)³ + parenthesis(x + 1258close parenthesis)³ + parenthesis(−3x − 4037close parenthesis)³ + parenthesis(3x + 4057close parenthesis)³
  • 1620x + 1334 = parenthesis(−5x − 3269close parenthesis)³ + parenthesis(5x + 3107close parenthesis)³ + parenthesis(−9x − 5714close parenthesis)³ + parenthesis(9x + 5764close parenthesis)³
  • 1620x + 1352 = parenthesis(−5x + 434close parenthesis)³ + parenthesis(5x − 353close parenthesis)³ + parenthesis(9x − 722close parenthesis)³ + parenthesis(−9x + 697close parenthesis)³
  • 2160x + 362 = parenthesis(−5x − 180close parenthesis)³ + parenthesis(5x + 108close parenthesis)³ + parenthesis(−6x − 149close parenthesis)³ + parenthesis(6x + 199close parenthesis)³
  • 6480x + 794 = parenthesis(−5x − 83close parenthesis)³ + parenthesis(5x + 11close parenthesis)³ + parenthesis(−6x − 35close parenthesis)³ + parenthesis(6x + 85close parenthesis)³

If n = 164, 596, 1892, 2324, 2756, 4052, 4484 (mod 6480) the following formula is used:

54x + 2 = parenthesis(29484x² + 2211x + 43close parenthesis)³ + parenthesis(−29484x² − 2157x − 41close parenthesis)³ + parenthesis(9828x² + 485x + 4close parenthesis)³ + parenthesis(−9828x² − 971x − 22close parenthesis)³

If n = 254, 902, 1442, 1874, 1982, 2414, 3062, 3494, 3602, 4034, 4142, 5114, 5222, 5654, 5762, 6302 (mod 6480) a method due to Demjanenko is used. Notice that the results can have hundreds of digits in this case.

In the remaining cases the number n is replaced by −n and then all solutions are multiplied by −1.

If you find any error or you have a comment, please fill in the form.

Expressions

You can enter numbers or numeric expressions in the input box including parentheses. The operations supported are:

  • + for addition
  • - for subtraction
  • * for multiplication
  • / for integer division
  • % for modulus (remainder of the integer division)
  • ^ or ** for exponentiation (the exponent must be greater than or equal to zero).
  • <, ==, >; <=, >=, != for comparisons. The operators return zero for false and -1 for true.
  • AND, OR, NOT for binary logic.
  • n!: factorial (n must be greater than or equal to zero).
  • p#: primorial (product of all primes less or equal than p).
  • B(n): Previous probable prime before n
  • F(n): Fibonacci number Fn
  • L(n): Lucas number Ln = Fn-1 + Fn+1
  • N(n): Next probable prime after n
  • P(n): Unrestricted Partition Number (number of decompositions of n into sums of integers without regard to order).
  • Gcd(m,n): Greatest common divisor of these two integers.
  • Modinv(m,n): inverse of m modulo n, only valid when gcd(m,n)=1.
  • Modpow(m,n,r): finds mn modulo r.
  • IsPrime(n): returns zero if n is not probable prime, -1 if it is.
  • NumDigits(n,r): Number of digits of n in base r.
  • SumDigits(n,r): Sum of digits of n in base r.
  • RevDigits(n,r): finds the value obtained by writing backwards the digits of n in base r.

You can use the prefix 0x for hexadecimal numbers, for example 0x38 is equal to 56.

Batch processing

Write an expression per line, then press the Sum if cubes button. The output will be placed in the lower pane.

Blank lines or comment lines (which start with a numeral '#' character) will be replicated on the lower pane.

Expression loop: with the following syntax you can factor or determine primality of several numbers typing only one line. You have to type four or five expressions separated by semicolons:

  • First expression: It must start with the string 'x=' and it sets the first value of x.
  • Second expression: It must start with the string 'x=' and it sets the next value of x.
  • Third expression: It holds the end expression condition. If it is equal to zero (meaning false) the loop finishes, otherwise the loop continues.
  • Fourth expression: It holds the expression to be expressed as a sum of cubes.
  • Optional fifth expression: If this expression is different from zero (meaning true), the fourth expression is processed, and if is zero (meaning false), the fourth expression is ignored.

Except for the first expression, all other expressions must include the variable x and/or the counter c.

If the end expression is false after processing 1000 numbers, the Continue button will appear. Pressing this button will make the program to process the next 1000 numbers and so on.

Example 1: Find the decomposition in a sum of cubes of the numbers from 0 to 5000. The line to type is: x=0;x=x+1;x<=5000;x. The calculator will show the results in blocks of 1000 values. You will need to press the Continue button to get the next block.

Example 2: Find the decomposition in a sum of cubes of the first 100 numbers of the form prime minus one. The line to type is: x=3;x=n(x);c<=100;x-1.

Source code

You can download the source of the current program and the old sum of four cubes applet from GitHub. Notice that the source code is in C language and you need the Emscripten environment in order to generate Javascript.

Written by Dario Alpern. Last updated 15 January 2018.