Awesome
mathiu.cpp
mathiu : a simple computer algebra system in C++
The library originated as a demo library showing the usage of the C++ pattern matching library match(it)
.
But now it is developed independently.
Features
Differentiation
auto const x = "x"_s;
auto const e = x ^ (2_i / 3_i);
auto const d = diff(e, x);
// prints (* 2/3 (^ x -1/3))
std::cout << toString(d) << std::endl;
Equation Solving
auto const x = "x"_s;
auto const eq = 2_i * x * x - 3_i * x + 1_i == 0_i;
auto const solutions = solve(eq, x);
// prints {1/2 1}
std::cout << toString(solutions) << std::endl;
Inequation Solving
auto const e1 = ("x"_s ^ 2_i) - 1_i;
auto const e2 = (("x"_s - 3_i) ^ 2_i) - 3_i;;
auto const ineq = e1 > e2;
auto const suolutions = solveInequation(ineq, "x"_s);
// prints (OOInterval 7/6 inf)
std::cout << toString(solutions) << std::endl;
Get Function Range
auto e = min(max(-"x"_s, "x"_s), 2_i);
auto const domain = interval(-3_i, true, 3_i, true);
auto const range = functionRange(e, "x"_s, domain);
// prints (CCInterval 0 2)
std::cout << toString(range) << std::endl;