LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
integration_table_elementary.cpp
浏览该文件的文档.
2
4
5void load_exponential_rules(std::vector<detail::IntegrationEntry>& table) {
6 {
7 auto a = wildcard("_a");
8 auto u = wildcard("_u");
9 auto pat = *SymbolicExpr::exp(SymbolicExpr::multiply(detail::make_expression_ptr(a), detail::make_expression_ptr(u)));
10 auto res = *SymbolicExpr::multiply(
11 SymbolicExpr::power(detail::make_expression_ptr(a), SymbolicExpr::number(-1)),
12 SymbolicExpr::exp(SymbolicExpr::multiply(detail::make_expression_ptr(a), detail::make_expression_ptr(u))));
13 table.push_back(detail::IntegrationEntry("exp(a*x)", pat, res, {"_a", "_u"},
14 u_is_var_a_nonzero("_u", "_a"), 50));
15 }
16 {
17 auto u = wildcard("_u");
18 auto u_sq = SymbolicExpr::power(detail::make_expression_ptr(u), SymbolicExpr::number(2));
19 auto pat = *SymbolicExpr::multiply(u_sq, SymbolicExpr::exp(detail::make_expression_ptr(u)));
20
21 auto u_sq_r = SymbolicExpr::power(detail::make_expression_ptr(u), SymbolicExpr::number(2));
22 auto two_u = SymbolicExpr::multiply(SymbolicExpr::number(-2), detail::make_expression_ptr(u));
23 auto poly = SymbolicExpr::add(SymbolicExpr::add(u_sq_r, two_u), SymbolicExpr::number(2));
24 auto res = *SymbolicExpr::multiply(poly, SymbolicExpr::exp(detail::make_expression_ptr(u)));
25 table.push_back(detail::IntegrationEntry("x^2*exp(x)", pat, res, {"_u"}, u_is_var("_u"), 40));
26 }
27 {
28 auto u = wildcard("_u");
29 auto pat = *SymbolicExpr::multiply(detail::make_expression_ptr(u), SymbolicExpr::exp(detail::make_expression_ptr(u)));
30
31 auto u_minus_1 = SymbolicExpr::add(detail::make_expression_ptr(u), SymbolicExpr::number(-1));
32 auto res = *SymbolicExpr::multiply(u_minus_1, SymbolicExpr::exp(detail::make_expression_ptr(u)));
33 table.push_back(detail::IntegrationEntry("x*exp(x)", pat, res, {"_u"}, u_is_var("_u"), 50));
34 }
35 {
36 auto u = wildcard("_u");
37 auto pat = *SymbolicExpr::exp(detail::make_expression_ptr(u));
38 auto res = *SymbolicExpr::exp(detail::make_expression_ptr(u));
39 table.push_back(detail::IntegrationEntry("exp(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
40 }
41}
42
43void load_trig_derivatives_rules(std::vector<detail::IntegrationEntry>& table) {
44 {
45 auto u = wildcard("_u");
46 auto pat = *SymbolicExpr::power(make_unary_function(FT::Sec, detail::make_expression_ptr(u)), SymbolicExpr::number(2));
48 table.push_back(detail::IntegrationEntry("sec(x)^2", pat, res, {"_u"}, u_is_var("_u"), 30));
49 }
50 {
51 auto u = wildcard("_u");
52 auto pat = *SymbolicExpr::power(make_unary_function(FT::Csc, detail::make_expression_ptr(u)), SymbolicExpr::number(2));
53 auto res = *SymbolicExpr::multiply(SymbolicExpr::number(-1), make_unary_function(FT::Cot, detail::make_expression_ptr(u)));
54 table.push_back(detail::IntegrationEntry("csc(x)^2", pat, res, {"_u"}, u_is_var("_u"), 30));
55 }
56 {
57 auto u = wildcard("_u");
58 auto pat = *SymbolicExpr::multiply(make_unary_function(FT::Sec, detail::make_expression_ptr(u)), make_unary_function(FT::Tan, detail::make_expression_ptr(u)));
60 table.push_back(detail::IntegrationEntry("sec(x)*tan(x)", pat, res, {"_u"}, u_is_var("_u"), 30));
61 }
62 {
63 auto u = wildcard("_u");
64 auto pat = *SymbolicExpr::multiply(make_unary_function(FT::Csc, detail::make_expression_ptr(u)), make_unary_function(FT::Cot, detail::make_expression_ptr(u)));
65 auto res = *SymbolicExpr::multiply(SymbolicExpr::number(-1), make_unary_function(FT::Csc, detail::make_expression_ptr(u)));
66 table.push_back(detail::IntegrationEntry("csc(x)*cot(x)", pat, res, {"_u"}, u_is_var("_u"), 30));
67 }
68}
69
70void load_trig_squares_rules(std::vector<detail::IntegrationEntry>& table) {
71 {
72 auto u = wildcard("_u");
73 auto pat = *SymbolicExpr::power(SymbolicExpr::sin(detail::make_expression_ptr(u)), SymbolicExpr::number(2));
74
75 auto u_half = SymbolicExpr::multiply(detail::make_expression_ptr(u), sym_rational(1, 2));
76 auto two_u = SymbolicExpr::multiply(SymbolicExpr::number(2), detail::make_expression_ptr(u));
77 auto sin_2u_over_4 = SymbolicExpr::multiply(SymbolicExpr::sin(two_u), sym_rational(-1, 4));
78 auto res = *SymbolicExpr::add(u_half, sin_2u_over_4);
79 table.push_back(detail::IntegrationEntry("sin(x)^2", pat, res, {"_u"}, u_is_var("_u"), 35));
80 }
81 {
82 auto u = wildcard("_u");
83 auto pat = *SymbolicExpr::power(SymbolicExpr::cos(detail::make_expression_ptr(u)), SymbolicExpr::number(2));
84
85 auto u_half = SymbolicExpr::multiply(detail::make_expression_ptr(u), sym_rational(1, 2));
86 auto two_u = SymbolicExpr::multiply(SymbolicExpr::number(2), detail::make_expression_ptr(u));
87 auto sin_2u_over_4 = SymbolicExpr::multiply(SymbolicExpr::sin(two_u), sym_rational(1, 4));
88 auto res = *SymbolicExpr::add(u_half, sin_2u_over_4);
89 table.push_back(detail::IntegrationEntry("cos(x)^2", pat, res, {"_u"}, u_is_var("_u"), 35));
90 }
91 {
92 auto u = wildcard("_u");
93 auto pat = *SymbolicExpr::power(SymbolicExpr::tan(detail::make_expression_ptr(u)), SymbolicExpr::number(2));
94 auto neg_u = SymbolicExpr::multiply(SymbolicExpr::number(-1), detail::make_expression_ptr(u));
95 auto res = *SymbolicExpr::add(SymbolicExpr::tan(detail::make_expression_ptr(u)), neg_u);
96 table.push_back(detail::IntegrationEntry("tan(x)^2", pat, res, {"_u"}, u_is_var("_u"), 35));
97 }
98}
99
100void load_trig_primitives_rules(std::vector<detail::IntegrationEntry>& table) {
101 {
102 auto u = wildcard("_u");
103 auto pat = *SymbolicExpr::sin(detail::make_expression_ptr(u));
104 auto res = *SymbolicExpr::multiply(SymbolicExpr::number(-1), SymbolicExpr::cos(detail::make_expression_ptr(u)));
105 table.push_back(detail::IntegrationEntry("sin(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
106 }
107 {
108 auto u = wildcard("_u");
109 auto pat = *SymbolicExpr::cos(detail::make_expression_ptr(u));
110 auto res = *SymbolicExpr::sin(detail::make_expression_ptr(u));
111 table.push_back(detail::IntegrationEntry("cos(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
112 }
113 {
114 auto u = wildcard("_u");
115 auto pat = *SymbolicExpr::tan(detail::make_expression_ptr(u));
116 auto res = *SymbolicExpr::multiply(SymbolicExpr::number(-1),
117 SymbolicExpr::ln(make_unary_function(FT::Abs, SymbolicExpr::cos(detail::make_expression_ptr(u)))));
118 table.push_back(detail::IntegrationEntry("tan(x)", pat, res, {"_u"}, u_is_real_var("_u"), 60));
119 }
120 {
121 auto u = wildcard("_u");
122 auto sin_u = SymbolicExpr::sin(detail::make_expression_ptr(u));
123 auto cos_u = SymbolicExpr::cos(detail::make_expression_ptr(u));
124 auto pat = *SymbolicExpr::multiply(
125 sin_u,
126 SymbolicExpr::power(cos_u, SymbolicExpr::number(-1)));
127 auto res = *SymbolicExpr::multiply(
128 SymbolicExpr::number(-1), SymbolicExpr::ln(make_unary_function(FT::Abs, cos_u)));
129 table.push_back(detail::IntegrationEntry("sin(x)/cos(x)", pat, res, {"_u"}, u_is_real_var("_u"), 61));
130 }
131 {
132 auto u = wildcard("_u");
134 auto res = *SymbolicExpr::ln(make_unary_function(FT::Abs, SymbolicExpr::sin(detail::make_expression_ptr(u))));
135 table.push_back(detail::IntegrationEntry("cot(x)", pat, res, {"_u"}, u_is_real_var("_u"), 60));
136 }
137 {
138 auto u = wildcard("_u");
139 auto sin_u = SymbolicExpr::sin(detail::make_expression_ptr(u));
140 auto cos_u = SymbolicExpr::cos(detail::make_expression_ptr(u));
141 auto pat = *SymbolicExpr::multiply(
142 cos_u,
143 SymbolicExpr::power(sin_u, SymbolicExpr::number(-1)));
144 auto res = *SymbolicExpr::ln(make_unary_function(FT::Abs, sin_u));
145 table.push_back(detail::IntegrationEntry("cos(x)/sin(x)", pat, res, {"_u"}, u_is_real_var("_u"), 61));
146 }
147 {
148 auto u = wildcard("_u");
150 auto inner = SymbolicExpr::add(make_unary_function(FT::Sec, detail::make_expression_ptr(u)), make_unary_function(FT::Tan, detail::make_expression_ptr(u)));
151 auto res = *SymbolicExpr::ln(make_unary_function(FT::Abs, inner));
152 table.push_back(detail::IntegrationEntry("sec(x)", pat, res, {"_u"}, u_is_real_var("_u"), 60));
153 }
154 {
155 auto u = wildcard("_u");
157 auto inner = SymbolicExpr::add(make_unary_function(FT::Csc, detail::make_expression_ptr(u)), make_unary_function(FT::Cot, detail::make_expression_ptr(u)));
158 auto res = *SymbolicExpr::multiply(SymbolicExpr::number(-1),
159 SymbolicExpr::ln(make_unary_function(FT::Abs, inner)));
160 table.push_back(detail::IntegrationEntry("csc(x)", pat, res, {"_u"}, u_is_real_var("_u"), 60));
161 }
162}
163
164void load_inverse_trig_rules(std::vector<detail::IntegrationEntry>& table) {
165 {
166 auto u = wildcard("_u");
167 auto pat = *make_unary_function(FT::ArcSin, detail::make_expression_ptr(u));
168 auto x_asin = SymbolicExpr::multiply(detail::make_expression_ptr(u), make_unary_function(FT::ArcSin, detail::make_expression_ptr(u)));
169 auto u_sq = SymbolicExpr::power(detail::make_expression_ptr(u), SymbolicExpr::number(2));
170 auto neg_u_sq = SymbolicExpr::multiply(SymbolicExpr::number(-1), u_sq);
171 auto one_minus_u_sq = SymbolicExpr::add(SymbolicExpr::number(1), neg_u_sq);
172 auto root = SymbolicExpr::sqrt(one_minus_u_sq);
173 auto res = *SymbolicExpr::add(x_asin, root);
174 table.push_back(detail::IntegrationEntry("arcsin(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
175 }
176 {
177 auto u = wildcard("_u");
178 auto pat = *make_unary_function(FT::ArcCos, detail::make_expression_ptr(u));
179 auto x_acos = SymbolicExpr::multiply(detail::make_expression_ptr(u), make_unary_function(FT::ArcCos, detail::make_expression_ptr(u)));
180 auto u_sq = SymbolicExpr::power(detail::make_expression_ptr(u), SymbolicExpr::number(2));
181 auto neg_u_sq = SymbolicExpr::multiply(SymbolicExpr::number(-1), u_sq);
182 auto one_minus_u_sq = SymbolicExpr::add(SymbolicExpr::number(1), neg_u_sq);
183 auto neg_root = SymbolicExpr::multiply(SymbolicExpr::number(-1), SymbolicExpr::sqrt(one_minus_u_sq));
184 auto res = *SymbolicExpr::add(x_acos, neg_root);
185 table.push_back(detail::IntegrationEntry("arccos(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
186 }
187 {
188 auto u = wildcard("_u");
189 auto pat = *make_unary_function(FT::ArcTan, detail::make_expression_ptr(u));
190 auto x_atan = SymbolicExpr::multiply(detail::make_expression_ptr(u), make_unary_function(FT::ArcTan, detail::make_expression_ptr(u)));
191 auto u_sq = SymbolicExpr::power(detail::make_expression_ptr(u), SymbolicExpr::number(2));
192 auto one_plus_u_sq = SymbolicExpr::add(SymbolicExpr::number(1), u_sq);
193 auto half_ln = SymbolicExpr::multiply(SymbolicExpr::ln(one_plus_u_sq), sym_rational(-1, 2));
194 auto res = *SymbolicExpr::add(x_atan, half_ln);
195 table.push_back(detail::IntegrationEntry("arctan(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
196 }
197}
198
199void load_hyperbolic_rules(std::vector<detail::IntegrationEntry>& table) {
200 {
201 auto u = wildcard("_u");
202 auto pat = *make_unary_function(FT::Sinh, detail::make_expression_ptr(u));
203 auto res = *make_unary_function(FT::Cosh, detail::make_expression_ptr(u));
204 table.push_back(detail::IntegrationEntry("sinh(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
205 }
206 {
207 auto u = wildcard("_u");
208 auto pat = *make_unary_function(FT::Cosh, detail::make_expression_ptr(u));
209 auto res = *make_unary_function(FT::Sinh, detail::make_expression_ptr(u));
210 table.push_back(detail::IntegrationEntry("cosh(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
211 }
212 {
213 auto u = wildcard("_u");
214 auto pat = *make_unary_function(FT::Tanh, detail::make_expression_ptr(u));
215 auto res = *SymbolicExpr::ln(make_unary_function(FT::Cosh, detail::make_expression_ptr(u)));
216 table.push_back(detail::IntegrationEntry("tanh(x)", pat, res, {"_u"}, u_is_var("_u"), 60));
217 }
218 {
219 auto u = wildcard("_u");
220 auto sinh_inv = SymbolicExpr::power(make_unary_function(FT::Sinh, detail::make_expression_ptr(u)), SymbolicExpr::number(-1));
221 auto pat = *SymbolicExpr::multiply(make_unary_function(FT::Cosh, detail::make_expression_ptr(u)), sinh_inv);
222 auto res = *SymbolicExpr::ln(make_unary_function(FT::Abs,
224 table.push_back(detail::IntegrationEntry("coth(x)", pat, res, {"_u"}, u_is_real_var("_u"), 60));
225 }
226 {
227 auto u = wildcard("_u");
228 auto pat = *SymbolicExpr::power(make_unary_function(FT::Cosh, detail::make_expression_ptr(u)), SymbolicExpr::number(-1));
229 auto res = *make_unary_function(FT::ArcTan, make_unary_function(FT::Sinh, detail::make_expression_ptr(u)));
230 table.push_back(detail::IntegrationEntry("sech(x)", pat, res, {"_u"}, u_is_var("_u"), 50));
231 }
232 {
233 auto u = wildcard("_u");
234 auto pat = *SymbolicExpr::power(make_unary_function(FT::Sinh, detail::make_expression_ptr(u)), SymbolicExpr::number(-1));
235 auto u_half = SymbolicExpr::multiply(detail::make_expression_ptr(u), sym_rational(1, 2));
236 auto res = *SymbolicExpr::ln(make_unary_function(FT::Abs, make_unary_function(FT::Tanh, u_half)));
237 table.push_back(detail::IntegrationEntry("csch(x)", pat, res, {"_u"}, u_is_real_var("_u"), 50));
238 }
239}
240
241}
std::shared_ptr<::LMCAS::SymbolicExpr > make_expression_ptr(SymbolicNodePtr root)
void load_exponential_rules(std::vector< detail::IntegrationEntry > &table)
void load_trig_primitives_rules(std::vector< detail::IntegrationEntry > &table)
auto u_is_var_a_nonzero(const std::string &u_wc, const std::string &a_wc, bool real_scale=false)
void load_trig_squares_rules(std::vector< detail::IntegrationEntry > &table)
void load_hyperbolic_rules(std::vector< detail::IntegrationEntry > &table)
void load_inverse_trig_rules(std::vector< detail::IntegrationEntry > &table)
void load_trig_derivatives_rules(std::vector< detail::IntegrationEntry > &table)
SymbolicExpr wildcard(const std::string &name)
std::shared_ptr< SymbolicExpr > sym_rational(const BigInt &numerator, const BigInt &denominator)
__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::shared_ptr< SymbolicExpr > make_unary_function(FunctionNode::FuncType type, const std::shared_ptr< SymbolicExpr > &operand)
__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