17 expression,
context, operation,
"differentiate",
20 context.limits().max_ast_nodes, operation);
24}
catch (
const CasError& error) {
26}
catch (
const std::bad_alloc&) {
28}
catch (
const std::length_error& error) {
30}
catch (
const std::exception& error) {
35 const std::shared_ptr<SymbolicExpr>& f,
const std::string& var,
39 (
context).limits().max_ast_nodes,
"transform");
40 const std::string operation =
"curvature";
50 const auto& f_prime = first.value();
55 const auto& f_double_prime = second.value();
60 "absolute value node construction failed",
64 auto f_prime_sq = SymbolicExpr::power(f_prime, SymbolicExpr::number(2));
65 auto one_plus_fp_sq = SymbolicExpr::add(SymbolicExpr::number(1), f_prime_sq);
67 auto three_half = SymbolicExpr::number(Rational(3, 2));
68 auto denom = SymbolicExpr::power(one_plus_fp_sq, three_half);
69 auto result = SymbolicExpr::divide(abs_f_pp, denom);
72}
catch (
const CasError& error) {
74}
catch (
const std::bad_alloc&) {
76}
catch (
const std::length_error& error) {
78}
catch (
const std::exception& error) {
83 const std::shared_ptr<SymbolicExpr>& f,
const std::string& var)
91 const std::shared_ptr<SymbolicExpr>& x_t,
92 const std::shared_ptr<SymbolicExpr>& y_t,
const std::string&
t,
96 (
context).limits().max_ast_nodes,
"transform");
97 const std::string operation =
"curvature_parametric";
107 const auto& x_prime = x_first.value();
112 const auto& x_double_prime = x_second.value();
118 const auto& y_prime = y_first.value();
123 const auto& y_double_prime = y_second.value();
125 if (x_prime->is_zero() && y_prime->is_zero()) {
127 "parametric curvature is undefined for zero velocity",
131 auto cross_term = SymbolicExpr::add(
132 SymbolicExpr::multiply(x_prime, y_double_prime),
133 SymbolicExpr::multiply(
134 SymbolicExpr::number(-1),
135 SymbolicExpr::multiply(y_prime, x_double_prime)));
140 "absolute value node construction failed",
144 auto x_prime_sq = SymbolicExpr::power(x_prime, SymbolicExpr::number(2));
145 auto y_prime_sq = SymbolicExpr::power(y_prime, SymbolicExpr::number(2));
146 auto sum_sq = SymbolicExpr::add(x_prime_sq, y_prime_sq);
148 auto three_half = SymbolicExpr::number(Rational(3, 2));
149 auto denom = SymbolicExpr::power(sum_sq, three_half);
150 auto result = SymbolicExpr::divide(abs_cross, denom);
153}
catch (
const CasError& error) {
155}
catch (
const std::bad_alloc&) {
157}
catch (
const std::length_error& error) {
159}
catch (
const std::exception& error) {
164 const std::shared_ptr<SymbolicExpr>& x_t,
165 const std::shared_ptr<SymbolicExpr>& y_t,
const std::string&
t)
174 const std::shared_ptr<SymbolicExpr>& f,
175 const std::shared_ptr<SymbolicExpr>& f_prime,
176 const std::shared_ptr<SymbolicExpr>& f_double_prime,
177 const std::shared_ptr<SymbolicExpr>&
point,
const std::string& var,
180 (
context).limits().max_ast_nodes,
"transform");
184 for (
const auto& expression : {
value, first, second}) {
193 "real curve domain at an inflection candidate is unproved",
198}
catch (
const CasError& error) {
200}
catch (
const std::bad_alloc&) {
202}
catch (
const std::length_error& error) {
204}
catch (
const std::exception& error) {
210 const std::shared_ptr<SymbolicExpr>& f_prime,
211 const std::shared_ptr<SymbolicExpr>& f_double_prime,
const std::string& var,
213 std::vector<std::shared_ptr<SymbolicExpr>> points;
214 points.reserve(finite.
values.size());
215 for (
const auto& solution : finite.
values) {
216 auto step =
context.consume_steps(1, operation);
220 "checked solver returned a null inflection candidate", operation);
227 "inflection candidate is not proved unconditionally real", operation);
230 f, f_prime, f_double_prime, solution.value, var, facts, operation,
context);
232 if (!defined.value()) {
continue; }
233 points.push_back(solution.value);
239 const std::shared_ptr<SymbolicExpr>& f,
const std::string& var,
243 (
context).limits().max_ast_nodes,
"transform");
244 const std::string operation =
"inflection_points";
254 const auto& f_prime = first.value();
260 const auto& f_double_prime = second.value();
270 const auto& solutions = solved.
value();
271 if (std::holds_alternative<EmptySolutions>(solutions)) {
274 std::optional<detail::AssumptionFacts> assumed_facts;
275 if (
context.assumptions()) { assumed_facts.emplace(*
context.assumptions()); }
278 if (
const auto* finite = std::get_if<FiniteSolutions>(&solutions)) {
280 *finite, f, f_prime, f_double_prime, var, facts,
context, operation);
286 "inflection equation is outside the finite exact support domain",
288}
catch (
const CasError& error) {
290}
catch (
const std::bad_alloc&) {
292}
catch (
const std::length_error& error) {
294}
catch (
const std::exception& error) {
299 const std::shared_ptr<SymbolicExpr>& f,
const std::string& var)
static Result failure(CasErrc code, std::string message, std::string operation={})
static Result success(std::shared_ptr< SymbolicExpr > value)
std::shared_ptr< SymbolicExpr > calculus_utils_make_abs(const std::shared_ptr< SymbolicExpr > &expr)
Result< void > calculus_utils_validate_two_exprs(const std::shared_ptr< SymbolicExpr > &first, const std::shared_ptr< SymbolicExpr > &second, const std::string &var, ComputationContext &context, const std::string &operation)
Result< void > calculus_utils_validate_expr(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, ComputationContext &context, const std::string &operation)
SymbolicNodePtr differentiate_node(const SymbolicNodePtr &node, const std::string &variable, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
std::shared_ptr<::LMCAS::SymbolicExpr > make_expression_ptr(SymbolicNodePtr root)
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
ExpressionResult checked_transform_expr(const ExprPtr &expression, ComputationContext &context, const char *operation, const char *transform_name, Transform &&transform)
const FactsQuery & no_facts() noexcept
Result< Tribool > query_definedness(const Node &node, const FactsQuery &facts, Domain domain, ComputationContext &context, bool *violated_real_restriction)
Result< Tribool > query_real_value(const Node &node, const FactsQuery &facts, ComputationContext &context)
SymbolicNodePtr normalize_node(const SymbolicNodePtr &node, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
SymbolicNodePtr substitute_node(const SymbolicNodePtr &node, const std::string &variable, const SymbolicNodePtr &replacement, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
const std::string const LimitExprPtr & point
const std::string & variable
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
ExprResult real(const ExprPtr &expression, ComputationContext &context)
static ExpressionResult checked_derivative(const ExprPtr &expression, const std::string &variable, ComputationContext &context, const char *operation)
static Result< bool > inflection_curve_defined(const std::shared_ptr< SymbolicExpr > &f, const std::shared_ptr< SymbolicExpr > &f_prime, const std::shared_ptr< SymbolicExpr > &f_double_prime, const std::shared_ptr< SymbolicExpr > &point, const std::string &var, const FactsQuery &facts, const std::string &operation, ComputationContext &context)
@ True
Property definitely holds
@ False
Property definitely does not hold
LMCAS::SolveResult solve_equation(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, ComputationContext &context, const SolveOptions &opts)
Result< std::shared_ptr< SymbolicExpr > > ExpressionResult
Result of an operation that produces a symbolic expression.
std::vector< FiniteSolution > values
SymbolicExprVectorResult inflection_points_checked(const std::shared_ptr< SymbolicExpr > &f, const std::string &var, ComputationContext &context)
Result< std::vector< std::shared_ptr< SymbolicExpr > > > SymbolicExprVectorResult
std::shared_ptr< SymbolicExpr > ExprPtr
const std::string const ExprPtr & value
ExpressionResult curvature_parametric_checked(const std::shared_ptr< SymbolicExpr > &x_t, const std::shared_ptr< SymbolicExpr > &y_t, const std::string &t, ComputationContext &context)
ExpressionResult curvature_checked(const std::shared_ptr< SymbolicExpr > &f, const std::string &var, ComputationContext &context)
__attribute__((visibility("default"))) VectorCalculusExprResult curve_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult curve_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string & t
static SymbolicExprVectorResult classify_inflection_candidates(const FiniteSolutions &finite, const std::shared_ptr< SymbolicExpr > &f, const std::shared_ptr< SymbolicExpr > &f_prime, const std::shared_ptr< SymbolicExpr > &f_double_prime, const std::string &var, const FactsQuery &facts, ComputationContext &context, const std::string &operation)
方程求解策略调度器 solve_dispatch 及相关选项结构体.