Skip to content

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. Both N and M are compile-time integers, so the optimizer sees through every loop.

  • Fused kernels

    Coupled pairs — sinCos, sinhCosh, sqrtInvSqrt, expSinCos, the invSqrtPow<3> gravity kernel — run in a single recurrence pass. The pure-polynomial surface (arithmetic, square, cube, reciprocal, integer pow) is constexpr and 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 NumTraits specialisation lets TaylorExpansion live 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, and slice/deriv/integ are 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

  • Getting Started

    Install, build, and write your first Taylor expansion.

  • Guide

    How-to walkthroughs: variables and expressions, fused operations, extracting results, storage, named and mixed-order expansions, Eigen integration.

  • Reference

    Exact signatures — the TaylorExpansion API, tax::la, tax::named, and the per-operation recurrence catalog.

  • Internals

    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))

License

BSD 3-Clause.