Metadata-Version: 2.5
Name: taylorize
Version: 0.0.1
Summary: Lazy truncated Taylor series: higher-order automatic differentiation and arbitrary-precision Taylor-method ODE integration.
Project-URL: Homepage, https://github.com/yonesuke/taylorize
Project-URL: Repository, https://github.com/yonesuke/taylorize
Project-URL: Issues, https://github.com/yonesuke/taylorize/issues
Author: Ryosuke Yoneda
License-Expression: MIT
License-File: LICENSE
Keywords: arbitrary-precision,automatic-differentiation,higher-order,ode,taylor-series
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# taylorize

Lazy truncated Taylor series for **higher-order automatic differentiation** and
**arbitrary-precision Taylor-method ODE integration**.

`taylorize` represents a smooth function by its normalized Taylor coefficients
`c[k] = x^(k)(0) / k!` and computes them **lazily**, so you can build an
expression once and then ask for any order afterwards.

> Status: **0.0.1 (pre-alpha seed)**. The API is minimal and will change.

## Install

```bash
pip install taylorize
```

## Quickstart

```python
from taylorize import derivative, taylor_series, exp, sin, ode_step

def f(x):
    return exp(sin(x))

# 5th derivative of exp(sin(x)) at 0
print(derivative(f, k=5)(0.0))          # -8.0

# Taylor coefficients of sin(x)
print(taylor_series(sin, order=9)(0.0)) # [0, 1, 0, -1/6, ...]

# One 16th-order Taylor step of the simple pendulum
def pendulum(u):
    theta, omega = u[0], u[1]
    return [omega, -sin(theta)]

step = ode_step(pendulum, order=16)
print(step([1.0, 0.0], 0.1))
```

See [`examples/basic.py`](examples/basic.py).

## Idea

The core object is a truncated power series in a nilpotent direction `h`:

```
x(h) = c[0] + c[1] h + c[2] h^2 + ... + c[N] h^N
```

Every elementary function is just a recurrence on these coefficients
(e.g. `exp`: `c[k] = (1/k) * sum(j * x[j] * c[k-j])`), and the chain rule turns
any composition into ring operations on series. The same machinery integrates
ODEs one Taylor step at a time.

## Roadmap

- Backend-agnostic coefficients (`math`, `numpy`, `mpmath`, `torch`, `jax`, `sympy`)
- Automatic interception of `math.*` / `np.*` / `torch.*` / `sp.*`
- Functions defined by ODEs (`from_ode`) and coupled systems
- Special functions (`erf`, Airy, Bessel, Jacobi, ...)
- Adaptive-step Taylor ODE solver

## License

MIT
