Solve high-degree polynomials without drift.

PolySolve pairs a Numba and CUDA genetic algorithm with exact polynomial calculus to find real and complex roots where standard solvers diverge.

Open live solver

p(x) = 0.085(x + 2.2)(x + 1.1)(x - 0.15)(x - 1.35)(x - 2.3)

MAE 0.480Gen 1/20

Start solving in thirty seconds

Create a polynomial with a coefficient list, then inspect real roots, complex roots, derivatives, integrals, or GPU-accelerated solves using one consistent interface.

Works with Python 3.9+ and standard NumPy arrays. Optional CuPy support enables CUDA execution without rewriting your model.

roots.py
import polysolve
# Define f(x) = 2x^2 - 3x - 5
f = polysolve.Function(2)
f.set_coeffs([2, -3, -5])
# Fast Numba-accelerated CPU solver for real roots
real_roots = f.get_real_roots()
print(f"Real roots: {real_roots}")
# [-1.0, 2.5]
# Search the full complex plane (v0.7.0+)
all_roots = f.get_roots(options={"find_complex": True})
print(f"All roots: {all_roots}")
# [-1.+0.j, 2.5+0.j]

Built for numerical stability from degree 2 to 100

Every part of PolySolve is designed so scientific computing code stays readable, predictable, and verifiable as polynomial degrees scale up.

Stable roots at high degree

A genetic algorithm searches directly for roots without ill-conditioned companion matrices, avoiding the floating-point blowups that break standard solvers.

GPU speed when scale grows

Switch on CUDA acceleration with a single flag to run large candidate populations in parallel on NVIDIA GPUs for 15x to 24x faster solves.

Fast CPU execution out of the box

No GPU required. The default CPU backend compiles with Numba and runs across CPU threads so everyday workloads stay responsive.

Natural Python arithmetic

Add, subtract, multiply, differentiate, and integrate polynomials using familiar Python operators and a clean Function object.

Full complex plane coverage

Find both real and complex roots from a single call, with native support for complex coefficients across arithmetic and calculus.

Measured against NumPy up to degree 100

Compare numerical error, wall-clock runtime, and CUDA acceleration across random high-degree polynomials.

Stable accuracy at high degree

Companion-matrix solvers such as NumPy are quick on low-degree polynomials, yet suffer catastrophic numerical instability as degree climbs, producing mean absolute errors exceeding 10^30. PolySolve's genetic algorithm stays grounded across every tested degree up to 100.

Lower is better. PolySolve CPU and GPU track near zero error while NumPy spikes sharply beyond degree 20.

Full methodology and reproducible Python script are published in the benchmark documentation.

Log-scale chart comparing Mean Absolute Error of NumPy CPU against PolySolve CPU and PolySolve GPU from degree 3 to 100.

Ready to integrate PolySolve into your workflow?

Browse versioned API references, genetic algorithm tuning guides, and CUDA setup instructions.

Read the documentation