Math

Overview

Mathematical computation forms the backbone of quantitative analysis in science, engineering, finance, and data science. This comprehensive library of mathematical functions extends Excel’s capabilities far beyond native formulas, providing access to sophisticated numerical methods implemented in SciPy, NumPy, CasADi, and specialized Python libraries.

Modern mathematical computing requires far more than basic arithmetic—it demands robust algorithms for solving differential equations, fitting complex models to data, optimizing multivariate functions, and performing matrix operations with numerical stability. These functions bridge the gap between Excel’s spreadsheet interface and the power of production-grade scientific computing libraries, enabling researchers and engineers to tackle challenging mathematical problems directly from within a familiar spreadsheet environment.

Calculus and Differential Equations form the foundation for modeling dynamic systems. Whether computing derivatives of multivariable functions through differentiation, evaluating integrals numerically, or solving systems of ordinary differential equations, these tools enable accurate analysis of continuous change. Applications range from sensitivity analysis in optimization to pharmacokinetic modeling in drug development and epidemic modeling in public health.

Curve Fitting and Data Approximation allow you to discover the relationships hidden within data. Using least-squares regression, you can fit symbolic models or pre-defined curves to experimental measurements. This is essential across fields: chemists use adsorption and binding models to understand molecular interactions; biologists apply dose-response and enzyme kinetics models; engineers work with rheological and spectroscopic models. Advanced methods like CasADi-based fitting provide automatic differentiation for complex symbolic expressions, while spline-based interpolation reconstructs smooth curves from scattered or structured data.

Interpolation and Approximation bridge discrete data points with smooth continuous functions. Methods range from simple univariate splines and polynomial interpolation to sophisticated multidimensional approaches like radial basis functions. These are invaluable when you need to evaluate functions at arbitrary points, smooth noisy measurements, or reconstruct surfaces from scattered measurements.

Linear Algebra provides the computational foundation for modern numerical analysis. From matrix decompositions (QR, SVD, Cholesky) to solving linear systems and pseudoinverse computations, these operations underpin virtually every scientific computation. They are essential for solving overdetermined and underdetermined systems, analyzing system stability through eigenvalue problems, and transforming data for machine learning applications.

Optimization addresses the central computational challenge: finding the best solution within constraints. Assignment problems like the Hungarian algorithm match resources optimally. Local methods converge rapidly near a solution, suitable when good starting points are available. Global methods like differential evolution and dual annealing explore broader solution spaces to escape local minima. Linear and quadratic programming handle structured problems efficiently, while root-finding tools solve systems of nonlinear equations that arise throughout engineering and science. The reference figure illustrates these key mathematical domains and their interconnections.

Figure 1: Mathematical Computing Landscape: (A) Core mathematical domains and their primary applications. (B) Optimization landscape showing local minima and global structure.

Calculus

Differentiation

Tool Description
HESSIAN Compute the Hessian matrix (second derivatives) of a scalar function using CasADi symbolic differentiation.
JACOBIAN Calculate the Jacobian matrix of mathematical expressions with respect to specified variables.
SENSITIVITY Compute the sensitivity of a scalar model with respect to its parameters using CasADi.

Integration

Tool Description
DBLQUAD Compute the double integral of a function over a two-dimensional region.
QUAD Numerically integrate a function defined by a table of x, y values over [a, b] using adaptive quadrature.
TRAPEZOID Integrate sampled data using the composite trapezoidal rule.

Ode Models

Tool Description
BRUSSELATOR Numerically solves the Brusselator system of ordinary differential equations for autocatalytic chemical reactions.
COMPARTMENTAL_PK Numerically solves the basic one-compartment pharmacokinetics ODE using scipy.integrate.solve_ivp.
FITZHUGH_NAGUMO Numerically solves the FitzHugh-Nagumo system of ordinary differential equations for neuron action potentials using scipy.integrate.solve_ivp.
HODGKIN_HUXLEY Numerically solves the Hodgkin-Huxley system of ordinary differential equations for neuron action potentials.
LORENZ Numerically solves the Lorenz system of ordinary differential equations for chaotic dynamics.
LOTKA_VOLTERRA Numerically solves the Lotka-Volterra predator-prey system of ordinary differential equations.
MICHAELIS_MENTEN Numerically solves the Michaelis-Menten system of ordinary differential equations for enzyme kinetics using scipy.integrate.solve_ivp.
SEIR Numerically solves the SEIR system of ordinary differential equations for infectious disease modeling using scipy.integrate.solve_ivp.
SIR Solves the SIR system of ordinary differential equations for infection dynamics using scipy.integrate.solve_ivp (see scipy.integrate.solve_ivp).
VAN_DER_POL Numerically solves the Van der Pol oscillator system of ordinary differential equations.

Ode Systems

Tool Description
SOLVE_BVP Solve a boundary value problem for a second-order system of ODEs.
SOLVE_IVP Solve an initial value problem for a system of ODEs of the form dy/dt = A @ y.

Curve Fitting

Least Squares

Tool Description
CA_CURVE_FIT Fit an arbitrary symbolic model to data using CasADi and automatic differentiation.
CURVE_FIT Fit a model expression to xdata, ydata using scipy.optimize.curve_fit.
LM_FIT Fit data using lmfit’s built-in models with optional model composition.
MINUIT_FIT Fit an arbitrary model expression to data using iminuit least-squares minimization with uncertainty estimates.

Models

Tool Description
ADSORPTION Fits adsorption models to data using scipy.optimize.curve_fit.
AGRICULTURE Fits agriculture models to data using scipy.optimize.curve_fit.
BINDING_MODEL Fits binding_model models to data using scipy.optimize.curve_fit.
CHROMA_PEAKS Fits chroma_peaks models to data using scipy.optimize.curve_fit.
DOSE_RESPONSE Fits dose_response models to data using scipy.optimize.curve_fit.
ELECTRO_ION Fits electro_ion models to data using scipy.optimize.curve_fit.
ENZYME_BASIC Fits enzyme_basic models to data using scipy.optimize.curve_fit.
ENZYME_INHIBIT Fits enzyme_inhibit models to data using scipy.optimize.curve_fit.
EXP_ADVANCED Fits exp_advanced models to data using scipy.optimize.curve_fit.
EXP_DECAY Fits exp_decay models to data using scipy.optimize.curve_fit.
EXP_GROWTH Fits exponential growth models to data using scipy.optimize.curve_fit.
GROWTH_POWER Fits growth_power models to data using scipy.optimize.curve_fit.
GROWTH_SIGMOID Fits growth_sigmoid models to data using scipy.optimize.curve_fit.
MISC_PIECEWISE Fits misc_piecewise models to data using scipy.optimize.curve_fit.
PEAK_ASYM Fits peak_asym models to data using scipy.optimize.curve_fit.
POLY_BASIC Fits poly_basic models to data using scipy.optimize.curve_fit.
RHEOLOGY Fits rheology models to data using scipy.optimize.curve_fit.
SPECTRO_PEAKS Fits spectro_peaks models to data using scipy.optimize.curve_fit.
STAT_DISTRIB Fits stat_distrib models to data using scipy.optimize.curve_fit.
STAT_PARETO Fits stat_pareto models to data using scipy.optimize.curve_fit.
WAVEFORM Fits waveform models to data using scipy.optimize.curve_fit.

Interpolation

Approximation

Tool Description
LAGRANGE_INTERP Compute the Lagrange interpolating polynomial through a set of points.
PADE Compute Pade rational approximation to a polynomial.

Multivariate

Tool Description
GRID_INTERP Interpolator on a regular grid in 2D.
GRIDDATA Interpolate unstructured D-D data.
INTERPN Multidimensional interpolation on regular grids (2D).
LINEAR_ND_INTERP Piecewise linear interpolator in N > 1 dimensions.
NEAREST_ND_INTERP Nearest neighbor interpolation in N > 1 dimensions.
RBF_INTERPOLATOR Radial basis function interpolation in N dimensions.

Splines

Tool Description
INTERP_UV_SPLINE 1-D interpolating spline for data.
MAKE_INTERP_SPLINE Compute interpolating B-spline and evaluate at new points.
MAKE_LSQ_SPLINE Compute LSQ-based fitting B-spline.
SMOOTH_SPLINE Smoothing cubic spline.
UNIVARIATE_SPLINE 1-D smoothing spline fit to data.

Univariate

Tool Description
AKIMA_INTERP Akima 1D interpolation.
BARYCENTRIC_INTERP Interpolating polynomial for a set of points using barycentric interpolation.
CUBIC_SPLINE Cubic spline data interpolator.
HERMITE_SPLINE Piecewise-cubic interpolator matching values and first derivatives.
INTERP1D Interpolate a 1-D function.
KROGH_INTERPOLATE Krogh polynomial interpolation.
PCHIP_INTERPOLATE PCHIP 1-D monotonic cubic interpolation.

Linear Algebra

Tool Description
CHOLESKY Compute the Cholesky decomposition of a real, symmetric positive-definite matrix.
EXPM Compute the matrix exponential of a square matrix using scipy.linalg.expm
LSQ_LINEAR Solve a bounded linear least-squares problem.
LSTSQ Compute the least-squares solution to Ax = B using scipy.linalg.lstsq.
PINV Compute the Moore-Penrose pseudoinverse of a matrix using singular value decomposition (SVD).
QR Compute the QR decomposition of a matrix and return either Q or R.
SVD Compute the Singular Value Decomposition (SVD) of a matrix using scipy.linalg.svd.

Optimization

Assignment Problems

Tool Description
LINEAR_ASSIGNMENT Solve the linear assignment problem using scipy.optimize.linear_sum_assignment.
QUAD_ASSIGN Solve a quadratic assignment problem using SciPy’s implementation.

Global Optimization

Tool Description
BASIN_HOPPING Minimize a single-variable expression with SciPy’s basinhopping algorithm.
BRUTE Perform a brute-force grid search to approximate the global minimum of a function.
DIFF_EVOLUTION Minimize a multivariate function using differential evolution.
DUAL_ANNEALING Minimize a multivariate function using dual annealing.
SHGO Find global minimum using Simplicial Homology Global Optimization.

Linear Programming

Tool Description
CA_QUAD_PROG Solve a quadratic programming problem using CasADi’s qpsol solver.
LINEAR_PROG Solve a linear programming problem using SciPy’s linprog function.
MILP Solve a mixed-integer linear program using scipy.optimize.milp.

Local Optimization

Tool Description
CA_MINIMIZE Minimize a multivariate function using CasADi with automatic differentiation.
MINIMIZE Minimize a multivariate function using SciPy’s minimize routine.
MINIMIZE_SCALAR Minimize a single-variable function using SciPy’s minimize_scalar.

Root Finding

Tool Description
CA_ROOT Solve a system of nonlinear equations using CasADi with automatic Jacobian.
FIXED_POINT Find a fixed point x such that f(x) = x for a scalar function expression.
ROOT Solve a square nonlinear system using SciPy’s root solver.
ROOT_SCALAR Find a real root of a scalar function using SciPy’s root_scalar.