Description
Meta mathematic
metamath is a tiny headeronly library. It can be used for symbolic computations on singlevariable functions, such as dynamic computations of derivatives. The operator precedence rules are naturally handled by the compiler. The library could be useful for building custom DSL's in C++.
func.h contains definitions for some of the cmath functions: Sin/Cos, Ln, Pow, Abs, Sqrt, Exp, more to come...
Function composition is supported.
metamath alternatives and similar libraries
Based on the "Math" category.
Alternatively, view metamath alternatives based on common mentions on social networks and blogs.

ceressolver
C++ library for modeling and solving large complicated nonlinear least squares problems from google. [BSD] 
Eigen
A highlevel C++ library of template headers for linear algebra, matrix and vector operations, numerical solvers and related algorithms. [MPL2] 
TinyExpr
tiny recursive descent expression parser, compiler, and evaluation engine for math expressions 
NT2
A SIMDoptimized numerical template library that provides an interface with MATLABlike syntax. [Boost] 
LibTomMath
A free open source portable number theoretic multipleprecision integer library written entirely in C. [PublicDomain & WTFPL] website 
ExprTK
The C++ Mathematical Expression Toolkit Library (ExprTk) is a simple to use, easy to integrate and extremely efficient runtime mathematical expression parser and evaluation engine. [CPL] 
GMTL
Graphics Math Template Library is a collection of tools implementing Graphics primitives in generalized ways. [GPL2] 
muparser
muParser is an extensible high performance math expression parser library written in C++. [MIT] 
Boost.Multiprecision
provides higherrange/precision integer, rational and floatingpoint types in C++, headeronly or with GMP/MPFR/LibTomMath backends. [Boost] 
Wykobi
A C++ library of efficient, robust and simple to use C++ 2D/3D oriented computational geometry routines. [MIT] 
Versor
A (fast) Generic C++ library for Geometric Algebras, including Euclidean, Projective, Conformal, Spacetime (etc). 
Xerus
A general purpose library for numerical calculations with higher order tensors, TensorTrain Decompositions / Matrix Product States and other Tensor Networks 
Mission : Impossible (AutoDiff)
A concise C++17 implementation of automatic differentiation (operator overloading) 
GMP
A C/C++ library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floatingpoint numbers. [LGPL3 & GPL2] 
Armadillo
A high quality C++ linear algebra library, aiming towards a good balance between speed and ease of use. The syntax (API) is deliberately similar to Matlab. [MPL2]
Get performance insights in less than 4 minutes
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of metamath or a related project?
README
metamath
Meta mathematic
metamath is a tiny headeronly library. It can be used for symbolic computations on singlevariable functions, such as dynamic computations of derivatives. The operator precedence rules are naturally handled by the compiler. The library could be useful for building custom DSL's in C++.
func.h contains definitions for some of the cmath functions: Sin/Cos, Ln, Pow, Abs, Sqrt, Exp, more to come... Arithmetic operations with functions are supported:
auto f1 = 3 * x;
auto f2 = Ln(x);
auto f = f1 + f2;
auto y1 = f(2);
auto y2 = f(4);
as well as function composition:
auto f = Ln(x);
auto g = 3 * x;
auto h = f(g);
auto y1 = h(2);
Examples of Functions and Derivatives
Example:
using namespace metamath;
auto f = 3 * x * x;
std::cout << "f(x) = " << f << std::endl;
std::cout << "f(4) = " << f(4.f) << std::endl;
std::cout << "" << std::endl;
// take derivative
auto df = derivative(f);
std::cout << "f`(x) = " << df << std::endl;
std::cout << "f`(4) = " << df(4.f) << std::endl;
This will produce the following output:
f(x) = 3 * x * x
f(4) = 48

f`(x) = ((0 * x + 3) * x + 3 * x)
f`(4) = 24
Example:
auto f = 4 * Sin(2 * x);
std::cout << "f(x) = " << f << std::endl;
std::cout << "f(pi) = " << f(M_PI) << std::endl;
std::cout << "f(pi/4) = " << f(M_PI/4.f) << std::endl;
std::cout << "" << std::endl;
//take derivative
auto df = derivative(f);
std::cout << "f`(x) = " << df << std::endl;
std::cout << "f`(pi) = " << df(M_PI) << std::endl;
std::cout << "f`(pi/4) = " << df(M_PI/4.f) << std::endl;
This will produce the following output:
f(x) = 4 * sin(2 * x)
f(pi) = 6.99382e07
f(pi/4) = 4

f`(x) = (0 * sin(2 * x) + 4 * cos(2 * x) * (0 * x + 2))
f`(pi) = 8
f`(pi/4) = 3.49691e07
Build
Requirements
C++14 or later
Steps to build the sample
 Suppose you cloned to [HOME]/work/metamath
For outofsource, create a build folder in [HOME]/work, and go there.
$mkdir build $cd build
Run cmake
$cmake ../metamath
Build it
$make
You can now run a sample (the sample source is in metamath/sample/)
$./sample/mms
The sample output:
Metamath sample ====== f(x) = 3 * x * x f(4) = 48  f`(x) = ((0 * x + 3) * x + 3 * x) f`(4) = 24 ====== ====== f(x) = 3 * x f(2) = 6 f(3) = 9  f`(x) = (0 * x + 3) f`(2) = 3 ====== ====== f(x) = ((1) / (x)) f(2) = 0.5 f(3) = 0.333333  f`(x) = (((0 * x  1)) / (x * x)) f`(2.f) = 0.25 ====== ====== f(x) = ((2 * (x + 1)) / (x)) f(2) = 3 f(3) = 2.66667  f`(x) = ((((0 * (x + 1) + 2 * 1) * x  2 * (x + 1))) / (x * x)) f`(2) = 0.5 ====== ====== f(x) = 4 * sin(2 * x) f(pi) = 6.99382e07 f(pi/4) = 4  f`(x) = (0 * sin(2 * x) + 4 * cos(2 * x) * (0 * x + 2)) f`(pi) = 8 f`(pi/4) = 3.49691e07 ====== ====== f(x) = sqrt(x) f(4) = 2 f(6) = 2.44949  f`(x) = ((1) / (2 * sqrt(x))) f`(4) = 0.25 f`(6) = 0.204124 ====== ====== f(x) = (3 * x^2) f(4) = 144 f(6) = 324  f`(x) = 2 * (3 * x^1) * (0 * x + 3) f`(4) = 72 f`(6) = 108 ====== ====== f(x) = e^(3 * x) f(4) = 162755 f(6) = 6.566e+07  f`(x) = e^(3 * x) * (0 * x + 3) f`(4) = 488264 f`(6) = 1.9698e+08 ====== ====== f(x) = ln(3 * x) f(4) = 2.48491 f(6) = 2.89037  f`(x) = ((1) / (3 * x)) * (0 * x + 3) f`(4) = 0.25 f`(6) = 0.166667 ====== ====== f(x) = 3 * x f(4) = 12 f(6) = 18  f`(x) = ((3 * x) / (3 * x)) * (0 * x + 3) f`(4) = 3 f`(6) = 3 ====== ====== f(x) = ln(x) g(x) = 3 * x h(x) = f(g(x)) = ln(3 * x) h(4) = 2.48491  h`(x) = ((1) / (3 * x)) * (0 * x + 3) h`(4) = 0.25 ======