28 int main(
int argc,
char **argv) {
39 auto f1 = x * x +
sin(y);
41 std::cout << f1 << std::endl;
43 auto f1_xsub =
sub(f1, x = y + 2);
45 std::cout << f1_xsub << std::endl;
47 std::cout <<
sub(f1_xsub, y = 3.14159265359) << std::endl;
50 std::cout << f2 << std::endl;
56 auto three = half + half + two;
59 assert((std::is_same<decltype(three),
C<3> >::value));
61 std::cout << three << std::endl;
65 std::cout << f3 << std::endl;
68 std::cout << f4 << std::endl;
73 std::cout << df5_dx << std::endl;
76 std::cout << taylor_series<3>(
sin(
C<2>() * x),
C<0>(), x) << std::endl;
78 std::cout << x * x * x * x * x << std::endl;
81 std::cout <<
simplify(x * x * x * x * x) << std::endl;
84 auto f6 = taylor_series<3>(
sin(
C<2>() * x),
C<0>(), x);
85 std::cout << f6 << std::endl;
89 std::cout << f6_poly << std::endl;
92 std::cout << f6_poly[0] << std::endl;
94 std::cout << f6_poly[3] << std::endl;
99 std::cout << f6_roots << std::endl;
103 std::cout << f6_roots.size() << std::endl;
107 std::cout << f6_roots[2] << std::endl;
109 Eigen::Matrix<double, 1, 3> r{1.0, 2.0, 3.0};
110 Eigen::Matrix<double, 1, 3> v{1.0, 0.5, 0.1};
111 auto fvec = r + x * v;
112 std::cout <<
sub(fvec, x = 12) << std::endl;
120 auto f =
sin(x) + 2 *
cos(x);
123 auto g =
sub(f, x = y*y);
126 std::cout << g << std::endl;
130 double a =
sub(g, y = 2.3);
131 std::cout << a << std::endl;
134 std::cout << dg_dy << std::endl;
137 auto poly =
expand(taylor_series<5>(dg_dy,
C<0>(), y));
138 std::cout << poly << std::endl;
144 Expr f_rt =
"sin(x) + 2 * cos(x)";
Symbolic representation of a variable.
auto cos(const C< num, den > &a) -> STATOR_AUTORETURN(cos_Cimpl(a, detail::select_overload
A class representing a compile-time rational constant (i.e., std::ratio).
Main header for the stator::symbolic library.
auto expand(const T &a) -> STATOR_AUTORETURN(simplify< ExpandConfig >(a))
A variant of simplify that expands into Polynomial types aggressively.
int main(int argc, char **argv)
StackVector< double, 0 > solve_real_roots(Null f)
Expr simplify(const Expr &f)
auto sin(const C< num, den > &a) -> STATOR_AUTORETURN(sin_Cimpl(a, detail::select_overload
The generic holder/smart pointer for a runtime Abstract Syntax Tree (AST) (expression).
The stator symbolic math library.
auto sub(BinaryOp< LHS, Op, RHS > f, Relation< Var, Arg > x) -> STATOR_AUTORETURN_BYVALUE(Op::apply(sub(f._l, x), sub(f._r, x)))
auto derivative(const Expression &)
Performs a symbolic derivative on the expression.