Skip to main content

taylorize

PyPI Python versions License: MIT publish

Lazy truncated Taylor series for higher-order automatic differentiation, arbitrary-precision Taylor-method ODE integration, and non-commutative / skew formal power series.

taylorize represents a formal series sum_{k>=0} c[k] h^k (for smooth functions, c[k] = x^(k)(0) / k!) and computes coefficients lazily, so you can build an expression or recurrence once and query any order afterwards.

Status: 0.0.3 (pre-alpha), published on PyPI. The API is evolving.

Install

pip install taylorize
# or
uv add taylorize

Quickstart

Use your existing NumPy or mpmath functions directly—no need to import sin or exp from taylorize:

import numpy as np
from taylorize import Taylor, derivative, taylor_series

# 5th derivative of np.exp(np.sin(x)) at 0
print(derivative(lambda x: np.exp(np.sin(x)), k=5)(0.0))  # -8.0

# Normalized Taylor coefficients of np.sin(x) up to order 9
print(taylor_series(np.sin, order=9)(0.0))  # [0.0, 1.0, 0.0, -1/6, ...]

# Coupled ODE system (simple pendulum: theta'' = -sin(theta))
theta, omega = Taylor.pending(1.0), Taylor.pending(0.0)
theta.bind_ode(omega)
omega.bind_ode(-np.sin(theta))
print(theta.eval(0.1, order=16))

Arbitrary-precision Taylor expansions with mpmath:

from mpmath import mp
from taylorize import variable

mp.dps = 50
x = variable(mp.mpf(0))

# 60th-order Taylor evaluation at x = 0.5 in 50-digit precision
val = mp.exp(mp.sin(x)).eval(mp.mpf("0.5"), order=60)
print(abs(val - mp.exp(mp.sin(mp.mpf("0.5")))))  # < 1e-47

Exact rational expansions at regular singular points, higher-order ODEs, and non-commutative / skew rings:

from fractions import Fraction
from taylorize import bessel_j0, variable
from taylorize.functions import painleve_I

# Fuchsian expansion of Bessel J_0 at the regular singular origin x = 0
j0 = bessel_j0(variable(Fraction(0)))
print([j0.coeff(k) for k in range(5)])  # [1, 0, -1/4, 0, 1/64]

# Direct 2nd-order ODE (Painlevé I: y'' = 6y^2 + x) without auxiliary variables
y = painleve_I(variable(Fraction(0)), Fraction(1), Fraction(0))
print([y.coeff(k) for k in range(6)])  # [1, 0, 3, 1/6, 3, 1/10]

See examples/basic.py and examples/noncommutative_and_singular.py.

Architecture

The core object Taylor[T] is a lazy formal power series over any (possibly non-commutative or skew) coefficient ring T:

x(h) = c[0] + c[1] h + c[2] h^2 + ... + c[N] h^N
  • taylorize.core — Pure lazy non-commutative / Ore-skew power-series ring with zero external dependencies:
    • Level 0 (Ring): +, -, *, rdiv / ldiv, shift, integer **, compose, optional derivation
    • Level 1 (Algebraic / Implicit): Taylor.solve_algebraic for P(h, Y) = 0
    • Level 2 (Liouville): diff, euler_diff, integrate, exp_integrate_left / exp_integrate_right, log_diff_left / log_diff_right
    • Level 3 (Holonomic / Fuchsian): bind_euler_ode for regular singular equations I(theta) Y = RHS
    • Level 4 (ODEs & Recurrences): bind_ode(dy, order=...) and universal bind_recurrence
  • taylorize.functions — Elementary and special functions (exp, sin, tan, erf, Airy, Bessel including singular x0 = 0, Jacobi elliptic, Weierstrass $\wp$, Painlevé I/II) declared via the differential equations they satisfy.
  • taylorize.backends — Resolves 0th-order initial values across float/complex (math/cmath/scipy.special), exact Fraction, arbitrary-precision mpmath, symbolic sympy, and numpy.
  • taylorize.transforms — Function transforms (derivative, taylor_series).
  • taylorize.interop — Host-library protocol dispatch (__array_ufunc__, __torch_function__, mpmath import hook).

Roadmap

  • Adaptive-step Taylor ODE solver
  • JAX jvp / jet interop

License

MIT

Metadata

Release files for taylorize 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taylorize 0.0.3
File Size Uploaded Provenance Actions
taylorize-0.0.3.tar.gz 54.0 kB With provenance Details for taylorize-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for taylorize 0.0.3
File Interpreter ABI Platform Actions
taylorize-0.0.3-py3-none-any.whl Python 3 none any Details for taylorize-0.0.3-py3-none-any.whl

Total release size: 71.0 kB

Release files / taylorize-0.0.3.tar.gz

Download URL taylorize-0.0.3.tar.gz
Size 54.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a6c926df0e7c2d18bbadce01591c5bcc5a34d557a5e7c678c3c3bb28b25121fd
BLAKE2b-256 checksum
How to use checksums
0abaaf0d6518079e739462d68f3828aa32254a6656842267658a9344b8b2f0a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / taylorize-0.0.3-py3-none-any.whl

Download URL taylorize-0.0.3-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9aa02766891c770a8245e8a3dfcad26221a1b29a692a43e297ffb9d5c9704ad
BLAKE2b-256 checksum
How to use checksums
30c10502cf1d6a43239c600731e964165f39f92c7c3e2317df1867a405373b59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for taylorize 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for taylorize-0.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page