tax¶
Truncated Algebraic eXpansions — a header-only C++23 library for computing truncated multivariate Taylor polynomials as first-class numerical objects.
Write a natural mathematical expression and tax propagates the full Taylor series through it, yielding the function value and every partial derivative up to order \(N\) in a single evaluation pass.
#include <tax/tax.hpp>
auto x = tax::TE<9>::variable(0.0); // 9-th order univariate variable at x₀ = 0
tax::TE<9> f = tax::sin(x); // one recurrence pass: value + all derivatives
f.value(); // sin(0) = 0
f.derivative<1>(); // cos(0) = 1
f.derivative<3>(); // −cos(0) = −1
f.eval(0.3); // sin(0.3) within machine precision
Active development
APIs and behavior may change between minor versions until 1.0.
Why tax?¶
-
Fixed-shape, allocation-free
Coefficient storage is
std::array<T, C(N+M, M)>on the stack. BothNandMare compile-time integers, so the optimizer sees through every loop. -
Fused kernels
Coupled pairs —
sinCos,sinhCosh,sqrtInvSqrt,expSinCos, theinvSqrtPow<3>gravity kernel — run in a single recurrence pass. The pure-polynomial surface (arithmetic,square,cube,reciprocal, integerpow) isconstexprand works in constant evaluation. -
Mixed-order axes
MTE<Axes...>gives every axis its own truncation order, so you pay for high-order sensitivity only where the problem needs it. -
Eigen-native
A
NumTraitsspecialisation letsTaylorExpansionlive inside Eigen vectors and matrices; helpers extract values, gradients, Jacobians, and Hessians. -
Named expansions
NamedTaylorExpansion<T, N, Axes...>attaches compile-time named axes to an expansion; values over different axis sets compose in their union, andslice/deriv/integare addressed by name.
At a glance¶
| What you write | What you get |
|---|---|
tax::TE<N>::variable(x0) |
univariate TE at \(x_0\), order \(N\) |
tax::TE<N, M>::variable<I>(x0) |
\(I\)-th coordinate variable, others as parameters |
tax::variables<TE<N,M>>(x0) |
Eigen column vector of all \(M\) coordinate variables |
tax::sin(x) * tax::exp(y) |
full Taylor series of the product, one kernel pass per op |
tax::expSinCos(v, u) |
{exp(v)·sin(u), exp(v)·cos(u)} fused in one coupled pass |
constexpr auto g = tax::square(x) + 2.0*x + 1.0; |
polynomial pipeline evaluated at compile time |
f.derivative<2, 1>() |
\(\partial^3 f / \partial x^2 \partial y\) at \(x_0\) |
f.eval(dx) |
Horner evaluation of the polynomial at \(x_0 + \delta x\) |
tax::jacobian(F, M) |
Eigen Jacobian of a vector function |
tax::MixedTE<Group<Dim,Order>...> |
anisotropic per-axis order caps (see Named & Mixed-Order expansions) |
tax::NamedTaylorExpansion<T, N, Axes...> |
TE with named, type-level variables |
Navigating the docs¶
-
Install, build, and write your first Taylor expansion.
-
How-to walkthroughs: variables and expressions, fused operations, extracting results, storage, named and mixed-order expansions, Eigen integration.
-
Exact signatures — the
TaylorExpansionAPI,tax::la,tax::named, and the per-operation recurrence catalog. -
Architecture, kernels, recurrence relations.
Requirements¶
- C++23 compiler — GCC 13+, Clang 17+, Apple Clang 16+
- CMake 3.28+
- Eigen 3.4+ (linked via
find_package(Eigen3))