cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-1 of 1 results.

A385713 Numbers w + x + y + z where (w,x,y,z) are nonnegative solutions to the Diophantine equation w^2 + x^2 + y^2 + z^2 = w*x*y*z.

Original entry on oeis.org

0, 8, 12, 32, 108, 292, 392, 1452, 3392, 3712, 5408, 11808, 20172, 34872, 40332, 50572, 75272, 162212, 280908, 480512, 518252, 595052, 700352, 1048352, 1639308, 3912492, 4599172, 4911172, 5725732, 6049292, 6508932, 7132608, 8279808, 9739812
Offset: 1

Views

Author

Bence Bernáth, Jul 07 2025

Keywords

Comments

The trivial sum with x=y=z=w=0 is included. The solutions are generated by the Vieta jumping discussed in the Numberphile video. The algorithm finds all the quadruplet solutions within the radius of a 4D sphere. Then the quadruplets are sorted based on their sum in increasing order.

Examples

			8 is a term because (w,x,y,z) = (2,2,2,2) is the first nontrivial solution.
12 is a term because (2,2,2,6) is a solution.
		

Crossrefs

Programs

  • Python
    import math
    def is_perfect_square(n):
        return (math.isqrt(n)) ** 2 == n
    def generate_all_solutions(radius):
        solutions = set()
        visited = set()
        # Initial known solution
        seed = (2, 2, 2, 2)
        queue = [seed]
        solutions.add(seed)
        while queue:
            quad = queue.pop(0)
            for ii in range(4):
                # Cyclically rotate variables: solve for the ii-th one
                rotated = list(quad[ii:] + quad[:ii])
                x, y, z, w = rotated
                # Use Vieta's formula: x^2 - (yzw)x + (y² + z² + w²) = 0
                product = y * z * w
                sumsq = y**2 + z**2 + w**2
                D = product**2 - 4 * sumsq
                if D < 0 or not is_perfect_square(D):
                    continue
                sqrt_D = (math.isqrt(D))
                for sign in [+1, -1]:
                    x_new = (product + sign * sqrt_D)
                    if x_new % 2 != 0:
                        continue
                    x_new //= 2
                    if not (0 < x_new < radius):
                        continue
                    new_quad = [x_new, y, z, w]
                    if any(val >= radius for val in new_quad):
                        continue
                    new_quad_sorted = tuple(sorted(new_quad))
                    if new_quad_sorted not in visited:
                        solutions.add(new_quad_sorted)
                        queue.append(tuple(new_quad))
                        visited.add(new_quad_sorted)
        # Return solutions sorted by sum of elements
        return sorted([list(sol) for sol in solutions], key=lambda tup: sum(tup))
    print([sum(sol) for sol in generate_all_solutions(10000000)])
Showing 1-1 of 1 results.