muparser

C++ library for parsing and evaluating mathematical expressions at runtime.

brewmacoslinux
Try with needOr install directly
Source

About

C++ math expression parser library

Examples

evaluate math formula from user input$ muparser is a library, not a CLI tool. Use it in C++ code: #include <muParser.h>
calculate complex equations with variables$ mu::Parser parser; parser.SetExpr("x*sin(y)"); parser.DefineVar("x", &x); parser.DefineVar("y", &y); double result = parser.Eval();
parse mathematical expressions with custom functions$ mu::Parser parser; parser.DefineFun("myFunc", MyCustomFunction); parser.SetExpr("myFunc(x) + 2*pi"); double result = parser.Eval();
build calculator that supports user defined variables$ mu::Parser parser; double varX = 5.0; parser.DefineVar("x", &varX); parser.SetExpr("x^2 + 3*x + 1"); std::cout << parser.Eval();
compile expression once and evaluate multiple times$ mu::Parser parser; parser.SetExpr("sin(x) + cos(y)"); for(int i=0; i<1000; ++i) { result = parser.Eval(); }