LMCAS
Lamina Computer Algebra System
Toggle main menu visibility
载入中...
搜索中...
未找到
symbolic_ode.hpp
浏览该文件的文档.
1
/**
2
* @file symbolic_ode.hpp
3
* @brief 常微分方程求解:可分离变量,一阶线性,二阶常系数.
4
*/
5
#pragma once
6
#include "
computation_context.hpp
"
7
#include "
symbolic.hpp
"
8
#include <memory>
9
#include <string>
10
11
namespace
LMCAS
{
12
13
// Forward declaration to avoid circular include.
14
class
AssumptionContext;
15
16
/**
17
* @brief 求解可分离变量型 ODE:dy/dx = rhs(x, y)
18
* @param rhs 方程右端表达式
19
* @param x 自变量名
20
* @param y 因变量名
21
* @param ctx Optional assumption context. When y is known Positive, preserves
22
* the positive-branch marker by returning abs(F). nullptr and the
23
* default argument have identical behavior.
24
* @return For rhs = f(x)*g(y), returns the first integral
25
* F(x,y) = integral(1/g(y), y) - integral(f(x), x), with implicit
26
* solutions F = C, not an explicit y(x). This describes regular regions
27
* of the original ODE where g is finite and nonzero and the selected
28
* primitives are differentiable (logarithms use their chosen branch).
29
* Equilibria at zeros of g and singular points are not enumerated.
30
* For a y-independent rhs, g = 1; in particular rhs = 0 returns y.
31
* The abs(F) marker is differentiable only away from F = 0.
32
* Unsupported primitives may remain as symbolic integrals. Returns
33
* nullptr for invalid input or a rhs not recognized by is_separable.
34
*/
35
LMCAS_API
std::shared_ptr<SymbolicExpr>
solve_separable_ode
(
36
std::shared_ptr<SymbolicExpr>
rhs
,
37
const
std::string& x,
38
const
std::string& y,
39
const
AssumptionContext* ctx =
nullptr
40
);
41
42
/**
43
* @brief 求解一阶线性 ODE:dy/dx + P(x)*y = Q(x)
44
* @param Px 系数函数 P(x)
45
* @param Qx 非齐次项 Q(x)
46
* @param x 自变量名
47
* @param y 因变量名
48
* @param ctx Optional assumption context. When provided and the dependent
49
* variable y is known Positive, the solver prefers positive solution
50
* branches. When a coefficient is known NonZero, the solver skips
51
* zero-coefficient degenerate case checks. When nullptr, behavior is
52
* identical to the unparameterized call.
53
* @return 通解的符号表达式
54
*/
55
LMCAS_API
std::shared_ptr<SymbolicExpr>
solve_linear1_ode
(
56
std::shared_ptr<SymbolicExpr> Px,
57
std::shared_ptr<SymbolicExpr> Qx,
58
const
std::string& x,
59
const
std::string& y,
60
const
AssumptionContext* ctx =
nullptr
61
);
62
63
/**
64
* @brief 求解二阶常系数线性 ODE:a*y'' + b*y' + c*y = f(x)
65
*
66
* 齐次二阶路径与高阶 ODE 共用经过系数归一化、稳定二次公式和后向误差
67
* 验证的特征根实现;统一乘以任意有限非零常数不改变解。
68
* @param a 二阶导数系数
69
* @param b 一阶导数系数
70
* @param c 零阶项系数
71
* @param fx 非齐次项 f(x)
72
* @param x 自变量名
73
* @param y 因变量名
74
* @param ctx Optional assumption context. When the dependent variable y is
75
* known Positive, the solver prefers positive solution branches.
76
* @return 通解的符号表达式
77
*/
78
LMCAS_API
std::shared_ptr<SymbolicExpr>
solve_linear2_ode
(
79
double
a
,
double
b
,
double
c
,
80
std::shared_ptr<SymbolicExpr> fx,
81
const
std::string& x,
82
const
std::string& y,
83
const
AssumptionContext* ctx =
nullptr
84
);
85
86
/**
87
* @brief 求解二阶常系数常微分方程并显式报告错误.
88
*
89
* 当前支持齐次方程,以及 a == 0 且 b != 0 的一阶退化情形。
90
* 二阶非齐次方程通过 `CasErrc::Inconclusive` 表示支持域边界;
91
* 非有限系数及无法表示的特征根不会生成含 NaN/Inf 的伪解。
92
*/
93
LMCAS_API
Result<std::shared_ptr<SymbolicExpr>
>
solve_linear2_ode_checked
(
94
double
a
,
double
b
,
double
c
,
95
std::shared_ptr<SymbolicExpr> fx,
96
const
std::string& x,
97
const
std::string& y,
98
ComputationContext
&
context
,
99
const
AssumptionContext* ctx =
nullptr
100
);
101
102
LMCAS_API
Result<std::shared_ptr<SymbolicExpr>
>
solve_linear2_ode_checked
(
103
double
a
,
double
b
,
double
c
,
104
std::shared_ptr<SymbolicExpr> fx,
105
const
std::string& x,
106
const
std::string& y,
107
const
AssumptionContext* ctx =
nullptr
108
);
109
110
}
LMCAS::ComputationContext
定义
computation_context.hpp:99
LMCAS::Result
定义
result.hpp:39
computation_context.hpp
LMCAS_API
#define LMCAS_API
定义
lmcas_export.hpp:13
LMCAS
定义
assumption.hpp:11
LMCAS::context
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
定义
exact_factorization.hpp:65
LMCAS::c
const VectorField const VectorField & c
定义
vector_calculus_vectors.hpp:60
LMCAS::b
const MultiPoly & b
定义
multivariate_factor.hpp:92
LMCAS::a
__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
定义
vector_calculus_curves.hpp:50
LMCAS::solve_linear2_ode
std::shared_ptr< SymbolicExpr > solve_linear2_ode(double a, double b, double c, std::shared_ptr< SymbolicExpr > fx, const std::string &x, const std::string &y, const AssumptionContext *ctx)
定义
symbolic_ode.cpp:271
LMCAS::solve_linear2_ode_checked
Result< std::shared_ptr< SymbolicExpr > > solve_linear2_ode_checked(double a, double b, double c, std::shared_ptr< SymbolicExpr > fx, const std::string &x, const std::string &y, ComputationContext &context, const AssumptionContext *ctx)
定义
symbolic_ode.cpp:300
LMCAS::solve_separable_ode
ExprPtr solve_separable_ode(ExprPtr rhs, const std::string &x, const std::string &y, const AssumptionContext *ctx)
定义
symbolic_ode.cpp:73
LMCAS::rhs
const ExprPtr & rhs
定义
expr.hpp:150
LMCAS::solve_linear1_ode
ExprPtr solve_linear1_ode(ExprPtr Px, ExprPtr Qx, const std::string &x, const std::string &y, const AssumptionContext *ctx)
定义
symbolic_ode.cpp:131
symbolic.hpp
符号表达式主类 SymbolicExpr 及其工厂方法,运算接口.
include
symbolic_ode.hpp
生成于
, 为 LMCAS使用
1.18.0