13 const std::shared_ptr<SymbolicExpr>& P,
14 const std::shared_ptr<SymbolicExpr>& Q,
15 const std::vector<std::string>&
vars,
16 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
x_bounds,
17 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
y_bounds,
21 context.limits().max_ast_nodes,
"greens_theorem");
22 const std::string operation =
"greens_theorem";
30 "Green's theorem vector-field components cannot be null",
41 auto step =
context.consume_steps(10, operation);
50 }
catch (
const std::bad_alloc&) {
52 "Green's theorem allocation failed",
54 }
catch (
const std::length_error& error) {
56 }
catch (
const std::exception&
e) {
62 const std::shared_ptr<SymbolicExpr>& P,
63 const std::shared_ptr<SymbolicExpr>& Q,
64 const std::vector<std::string>&
vars,
65 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
x_bounds,
66 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
y_bounds)
73 const std::shared_ptr<SymbolicExpr>& P,
74 const std::shared_ptr<SymbolicExpr>& Q,
75 const std::vector<std::string>&
vars,
76 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
x_bounds,
77 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
y_bounds)
81 (
context).limits().max_ast_nodes,
"transform");
83 throw std::invalid_argument(
"greens_theorem: P and Q must not be null");
85 if (
vars.size() != 2) {
86 throw std::invalid_argument(
"greens_theorem: vars must have exactly 2 elements");
90 throw std::invalid_argument(
"greens_theorem: bounds must not be null");
93 const std::string& x_var =
vars[0];
94 const std::string& y_var =
vars[1];
100 if (!dQ_dx) dQ_dx = SymbolicExpr::number(0);
101 if (!dP_dy) dP_dy = SymbolicExpr::number(0);
106 auto integrand = SymbolicExpr::add(
108 SymbolicExpr::multiply(SymbolicExpr::number(-1), dP_dy));
113 std::vector<IntegrationStep>
steps = {
118 if (!result)
throw result.error();
125 const std::string&
t,
126 const std::shared_ptr<SymbolicExpr>&
a,
127 const std::shared_ptr<SymbolicExpr>&
b,
131 context.limits().max_ast_nodes,
"greens_theorem_area");
132 const std::string operation =
"greens_theorem_area";
141 "Green's area parametrization must be two-dimensional",
144 auto step =
context.consume_steps(10, operation);
153 }
catch (
const std::bad_alloc&) {
155 "Green's area allocation failed",
157 }
catch (
const std::length_error& error) {
159 }
catch (
const std::exception&
e) {
166 const std::string&
t,
167 const std::shared_ptr<SymbolicExpr>&
a,
168 const std::shared_ptr<SymbolicExpr>&
b)
176 const std::string&
t,
177 const std::shared_ptr<SymbolicExpr>&
a,
178 const std::shared_ptr<SymbolicExpr>&
b)
181 throw std::invalid_argument(
182 "greens_theorem_area: parametrization must have 2 components (x(t), y(t))");
185 throw std::invalid_argument(
"greens_theorem_area: bounds must not be null");
192 throw std::invalid_argument(
"greens_theorem_area: parametrization components must not be null");
203 return area ? std::move(area.value()) :
nullptr;
209 const std::vector<std::string>&
vars,
210 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
x_bounds,
211 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
y_bounds,
212 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
z_bounds,
216 context.limits().max_ast_nodes,
"divergence_theorem");
217 const std::string operation =
"divergence_theorem";
238 auto step =
context.consume_steps(14, operation);
247 }
catch (
const std::bad_alloc&) {
249 "divergence theorem allocation failed",
251 }
catch (
const std::length_error& error) {
253 }
catch (
const std::exception&
e) {
260 const std::vector<std::string>&
vars,
261 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
x_bounds,
262 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
y_bounds,
263 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
z_bounds)
271 const std::vector<std::string>&
vars,
272 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
x_bounds,
273 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
y_bounds,
274 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
z_bounds)
278 context.limits().max_ast_nodes,
"divergence_theorem");
280 throw std::invalid_argument(
"divergence_theorem: F must have 3 components");
282 if (
vars.size() != 3) {
283 throw std::invalid_argument(
"divergence_theorem: vars must have exactly 3 elements");
288 throw std::invalid_argument(
"divergence_theorem: bounds must not be null");
295 std::vector<IntegrationStep>
steps = {
301 if (!result)
throw result.error();
308 const std::vector<std::string>&
vars,
310 const std::string&
u,
const std::string&
v,
311 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
u_bounds,
312 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
v_bounds,
316 context.limits().max_ast_nodes,
"stokes_theorem");
317 const std::string operation =
"stokes_theorem";
332 auto step =
context.consume_steps(18, operation);
341 }
catch (
const std::bad_alloc&) {
343 "Stokes theorem allocation failed",
345 }
catch (
const std::length_error& error) {
347 }
catch (
const std::exception&
e) {
354 const std::vector<std::string>&
vars,
356 const std::string&
u,
const std::string&
v,
357 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
u_bounds,
358 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
v_bounds)
367 const std::vector<std::string>&
vars,
369 const std::string&
u,
const std::string&
v,
370 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
u_bounds,
371 const std::pair<std::shared_ptr<SymbolicExpr>, std::shared_ptr<SymbolicExpr>>&
v_bounds)
375 (
context).limits().max_ast_nodes,
"transform");
377 throw std::invalid_argument(
"stokes_theorem: F must have 3 components");
379 if (
vars.size() != 3) {
380 throw std::invalid_argument(
"stokes_theorem: vars must have exactly 3 elements");
383 throw std::invalid_argument(
384 "stokes_theorem: parametrization must have 3 components");
388 throw std::invalid_argument(
"stokes_theorem: bounds must not be null");
398 std::shared_ptr<SymbolicExpr>
dot_product =
nullptr;
400 for (
size_t i = 0; i < 3; ++i) {
406 auto curl_i_composed = curl_F[i];
407 for (
size_t j = 0; j < 3; ++j) {
413 auto term = SymbolicExpr::multiply(curl_i_composed, cross[i]);
425 return SymbolicExpr::number(0);
430 std::vector<IntegrationStep>
steps = {
435 if (!result)
throw result.error();
static Result failure(CasErrc code, std::string message, std::string operation={})
Symbolic integration APIs.
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
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)
VectorField vector_calculus_cross_product_partials(const VectorField ¶metrization, const std::string &u, const std::string &v, detail::RewriteBudget &transform_budget)
Result< void > vector_calculus_validate_distinct_vars(const std::vector< std::string > &vars, std::size_t expected, ComputationContext &context, const std::string &operation)
Result< void > vector_calculus_validate_surface_parametrization(const VectorField ¶metrization, const std::string &u, const std::string &v, const std::shared_ptr< SymbolicExpr > &u_lower, const std::shared_ptr< SymbolicExpr > &u_upper, const std::shared_ptr< SymbolicExpr > &v_lower, const std::shared_ptr< SymbolicExpr > &v_upper, ComputationContext &context, const std::string &operation)
VectorCalculusExprResult greens_theorem_area_strict(const VectorField ¶metrization, const std::string ¶meter, const std::shared_ptr< SymbolicExpr > &lower, const std::shared_ptr< SymbolicExpr > &upper, ComputationContext &context, const std::string &operation, detail::RewriteBudget &transform_budget)
std::shared_ptr< SymbolicExpr > divergence_impl(const VectorField &F, const std::vector< std::string > &vars, detail::RewriteBudget &transform_budget)
Result< void > vector_calculus_validate_curve_parametrization(const VectorField ¶metrization, const std::string &t, const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, ComputationContext &context, const std::string &operation)
VectorCalculusExprResult stokes_theorem_strict(const VectorField &field, const std::vector< std::string > &variables, const VectorField ¶metrization, const std::string &u, const std::string &v, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &u_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &v_bounds, ComputationContext &context, const std::string &operation, detail::RewriteBudget &transform_budget)
VectorCalculusExprResult greens_theorem_strict(const std::shared_ptr< SymbolicExpr > &p, const std::shared_ptr< SymbolicExpr > &q, const std::vector< std::string > &variables, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &x_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &y_bounds, ComputationContext &context, const std::string &operation, detail::RewriteBudget &transform_budget)
Result< void > vector_calculus_validate_bound_pair(const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &bounds, ComputationContext &context, const std::string &operation, const std::string &label)
Result< void > vector_calculus_validate_field_vars(const VectorField &field, const std::vector< std::string > &vars, ComputationContext &context, const std::string &operation)
VectorField curl_impl(const VectorField &F, const std::vector< std::string > &vars, detail::RewriteBudget &transform_budget)
VectorCalculusExprResult divergence_theorem_strict(const VectorField &field, const std::vector< std::string > &variables, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &x_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &y_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &z_bounds, ComputationContext &context, const std::string &operation, detail::RewriteBudget &transform_budget)
__attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string const std::string & v
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
__attribute__((visibility("default"))) VectorCalculusFieldResult gradient_checked(const std __attribute__((visibility("default"))) VectorCalculusFieldResult gradient_checked(const std __attribute__((visibility("default"))) VectorField gradient(const std const std::vector< std::string > & vars
std::shared_ptr< SymbolicExpr > divergence_theorem(const VectorField &F, const std::vector< std::string > &vars, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &x_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &y_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &z_bounds)
std::shared_ptr< SymbolicExpr > greens_theorem(const std::shared_ptr< SymbolicExpr > &P, const std::shared_ptr< SymbolicExpr > &Q, const std::vector< std::string > &vars, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &x_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &y_bounds)
VectorCalculusExprResult greens_theorem_area_checked(const VectorField ¶metrization, const std::string &t, const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, ComputationContext &context)
std::shared_ptr< SymbolicExpr > stokes_theorem(const VectorField &F, const std::vector< std::string > &vars, const VectorField ¶metrization, const std::string &u, const std::string &v, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &u_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &v_bounds)
VectorCalculusExprResult greens_theorem_checked(const std::shared_ptr< SymbolicExpr > &P, const std::shared_ptr< SymbolicExpr > &Q, const std::vector< std::string > &vars, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &x_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &y_bounds, ComputationContext &context)
__attribute__((visibility("default"))) std const std::vector< std::string > const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > & z_bounds
VectorCalculusExprResult divergence_theorem_checked(const VectorField &F, const std::vector< std::string > &vars, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &x_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &y_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &z_bounds, ComputationContext &context)
__attribute__((visibility("default"))) std const std::vector< std::string > const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > & x_bounds
__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 const std::shared_ptr< SymbolicExpr > & a
std::vector< std::shared_ptr< SymbolicExpr > > VectorField
向量场由标量表达式组成。
std::shared_ptr< SymbolicExpr > greens_theorem_area(const VectorField ¶metrization, const std::string &t, const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b)
__attribute__((visibility("default"))) std const std::vector< std::string > const VectorField const std::string const std::string const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > & u_bounds
__attribute__((visibility("default"))) std const std::vector< std::string > const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > & y_bounds
__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 & parametrization
Result< SymbolicExpr > integrate_multiple_checked(const SymbolicExpr &integrand, const std::vector< IntegrationStep > &steps, Integrator &integrator, ComputationContext &context)
Result< std::shared_ptr< SymbolicExpr > > VectorCalculusExprResult
VectorCalculusExprResult stokes_theorem_checked(const VectorField &F, const std::vector< std::string > &vars, const VectorField ¶metrization, const std::string &u, const std::string &v, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &u_bounds, const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > &v_bounds, ComputationContext &context)
__attribute__((visibility("default"))) std const std::vector< std::string > const VectorField const std::string const std::string const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > const std::pair< std::shared_ptr< SymbolicExpr >, std::shared_ptr< SymbolicExpr > > & v_bounds
__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
const std::vector< IntegrationStep > Integrator & integrator
VectorCalculusExprResult dot_product(const VectorField &a, const VectorField &b)
__attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string & u