forked from JuliaSymbolics/SymbolicIntegration.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneral.jl
More file actions
228 lines (163 loc) · 10.7 KB
/
Copy pathgeneral.jl
File metadata and controls
228 lines (163 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# ===== Special functions from a lot of packages
# TODO extension to Symbolics?
# function from SpecialFunctions.jl that are not yet registered
@register_symbolic SymbolicUtils.expinti(x)
@register_symbolic SymbolicUtils.expint(nu, z)
@register_symbolic SymbolicUtils.gamma(x, y)
@register_symbolic SymbolicUtils.sinint(x)
@register_symbolic SymbolicUtils.cosint(x)
# other from SpecialFunctions.jl used:
# SymbolicUtils.gamma(x)
# SymbolicUtils.loggamma
# SymbolicUtils.erfi
# SymbolicUtils.erf
using Elliptic
@register_symbolic Elliptic.F(phi, m) # incomplete first kind
@register_symbolic Elliptic.E(phi, m) # incomplete second kind
@register_symbolic Elliptic.E(m) false # complete second kind
@register_symbolic Elliptic.Pi(nu, phi, m) # incomplete third kind
# changing name bc the . does no good in translation script
elliptic_f(phi, m) = Elliptic.F(phi, m)
elliptic_e(m) = Elliptic.E(m)
elliptic_e(phi, m) = Elliptic.E(phi, m)
elliptic_pi(nu, phi, m) = Elliptic.Pi(nu, phi, m)
elliptic_pi(nu, m) = Elliptic.Pi(nu, π/2, m)
using HypergeometricFunctions
hypergeometric2f1(a, b, c, z) = HypergeometricFunctions._₂F₁(Complex(a), Complex(b), Complex(c), Complex(z))
@register_symbolic hypergeometric2f1(a, b, c, z)
hypergeometricpFq(a, b, z) = HypergeometricFunctions.pFq(a, b, Complex(z))
@register_symbolic hypergeometricpFq(a::Vector, b::Vector, z)
appell_f1(a, b, c, d, e, z) = println("AppellF1 function is not implemented yet")
@register_symbolic appell_f1(a, b, c, d, e, z)
using PolyLog
@register_symbolic PolyLog.reli(n, z)
using FresnelIntegrals
@register_symbolic FresnelIntegrals.fresnelc(z)
@register_symbolic FresnelIntegrals.fresnels(z)
sinhintegral(x::Any) = println("hyperbolic sine integral Shi(z) function (https://en.wikipedia.org/wiki/Trigonometric_integral#Hyperbolic_sine_integral) is not implemented yet")
@register_symbolic sinhintegral(x)
coshintegral(x::Any) = println("hyperbolic cosine integral Chi(z) function (https://en.wikipedia.org/wiki/Trigonometric_integral#Hyperbolic_cosine_integral) is not implemented yet")
@register_symbolic coshintegral(x)
# ===== Global variables
# symbolic functions
# ∫(intgerand, intgeration variable)
# subst is just for when integral inside the real subst function is not solved
@syms ∫(var1,var2) subst(var1, var2, var3)
# very big arrays containing rules and their identifiers
const RULES = SymbolicUtils.Rule[]
const IDENTIFIERS = String[]
# to use or not the gamma function in integration results
USE_GAMMA = false # TODO make it work with revise and not just with reloading rules
# to print or not the integration steps
VERBOSE = false
# global array of rules identifiers to not print the corresponding rule
# It's needed otherwise rules with subst_and_int would be printed twice
const SILENCE = String[]
all_rules_paths = [
"9 Miscellaneous/0.1 Integrand simplification rules.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.1 (a+b x)^m.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.2 (a+b x)^m (c+d x)^n.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.3 (a+b x)^m (c+d x)^n (e+f x)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.4 (a+b x)^m (c+d x)^n (e+f x)^p (g+h x)^q.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.2 Quadratic/1.1.2.1 (a+b x^2)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.2 Quadratic/1.1.2.2 (c x)^m (a+b x^2)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.2 Quadratic/1.1.2.3 (a+b x^2)^p (c+d x^2)^q.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.2 Quadratic/1.1.2.4 (e x)^m (a+b x^2)^p (c+d x^2)^q.jl"
# 5, 6, 7, 8, 9
"1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.1 (a+b x^n)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.2 (c x)^m (a+b x^n)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.3 (a+b x^n)^p (c+d x^n)^q.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.4 (e x)^m (a+b x^n)^p (c+d x^n)^q.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.5 (a+b x^n)^p (c+d x^n)^q (e+f x^n)^r.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.6 (g x)^m (a+b x^n)^p (c+d x^n)^q (e+f x^n)^r.jl"
"1 Algebraic functions/1.2 Trinomial products/1.2.1 Quadratic/1.2.1.1 (a+b x+c x^2)^p.jl"
"1 Algebraic functions/1.2 Trinomial products/1.2.1 Quadratic/1.2.1.2 (d+e x)^m (a+b x+c x^2)^p.jl"
"1 Algebraic functions/1.2 Trinomial products/1.2.1 Quadratic/1.2.1.3 (d+e x)^m (f+g x) (a+b x+c x^2)^p.jl" # not most updated version?
"1 Algebraic functions/1.2 Trinomial products/1.2.1 Quadratic/1.2.1.4 (d+e x)^m (f+g x)^n (a+b x+c x^2)^p.jl" # not most updated version?
# 1.2.1.5
"1 Algebraic functions/1.2 Trinomial products/1.2.2 Quartic/1.2.2.1 (a+b x^2+c x^4)^p.jl"
"1 Algebraic functions/1.2 Trinomial products/1.2.2 Quartic/1.2.2.2 (d x)^m (a+b x^2+c x^4)^p.jl"
"1 Algebraic functions/1.2 Trinomial products/1.2.2 Quartic/1.2.2.3 (d+e x^2)^q (a+b x^2+c x^4)^p.jl"
# 1.2.2.4
"1 Algebraic functions/1.2 Trinomial products/1.2.3 General/1.2.3.1 (a+b x^n+c x^(2 n))^p.jl"
# 1.2.3.2, 1.2.3.3, 1.2.3.4
"1 Algebraic functions/1.1 Binomial products/1.1.4 Improper/1.1.4.1 (a x^j+b x^n)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.4 Improper/1.1.4.2 (c x)^m (a x^j+b x^n)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.4 Improper/1.1.4.3 (e x)^m (a x^j+b x^k)^p (c+d x^n)^q.jl"
# 1.2.4.1, 1.2.4.2, 1.2.4.3, 1.2.4.4
# 1.4.1, 1.4.2
"1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.7 P(x) (a+b x)^m (c+d x)^n (e+f x)^p (g+h x)^q.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.6 P(x) (a+b x)^m (c+d x)^n (e+f x)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.5 P(x) (a+b x)^m (c+d x)^n.jl"
"1 Algebraic functions/1.2 Trinomial products/1.2.2 Quartic/1.2.2.5 P(x) (a+b x^2+c x^4)^p.jl"
"1 Algebraic functions/1.2 Trinomial products/1.2.2 Quartic/1.2.2.4 (f x)^m (d+e x^2)^q (a+b x^2+c x^4)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.7 P(x) (a+b x^n)^p.jl"
"1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.8 P(x) (c x)^m (a+b x^n)^p.jl"
# TODO 1.3.4 quale?
"2 Exponentials/2.1 (c+d x)^m (a+b (F^(g (e+f x)))^n)^p.jl"
"2 Exponentials/2.2 (c+d x)^m (F^(g (e+f x)))^n (a+b (F^(g (e+f x)))^n)^p.jl"
"2 Exponentials/2.3 Miscellaneous exponentials.jl"
"3 Logarithms/3.1/3.1.1 (a+b log(c x^n))^p.jl"
"3 Logarithms/3.1/3.1.2 (d x)^m (a+b log(c x^n))^p.jl"
"3 Logarithms/3.1/3.1.3 (d+e x^r)^q (a+b log(c x^n))^p.jl"
"3 Logarithms/3.1/3.1.4 (f x)^m (d+e x^r)^q (a+b log(c x^n))^p.jl"
"3 Logarithms/3.1/3.1.5 u (a+b log(c x^n))^p.jl"
"3 Logarithms/3.2/3.2.1 (f+g x)^m (A+B log(e ((a+b x) over (c+d x))^n))^p.jl"
"3 Logarithms/3.2/3.2.2 (f+g x)^m (h+i x)^q (A+B log(e ((a+b x) over (c+d x))^n))^p.jl"
"3 Logarithms/3.2/3.2.3 u log(e (f (a+b x)^p (c+d x)^q)^r)^s.jl"
"3 Logarithms/3.3 u (a+b log(c (d+e x)^n))^p.jl"
"3 Logarithms/3.4 u (a+b log(c (d+e x^m)^n))^p.jl"
"3 Logarithms/3.5 Miscellaneous logarithms.jl"
"4 Trig functions/4.1 Sine/4.1.0/4.1.0.1 (a sin)^m (b trg)^n.jl"
"4 Trig functions/4.1 Sine/4.1.0/4.1.0.2 (a trg)^m (b tan)^n.jl"
"4 Trig functions/4.1 Sine/4.1.0/4.1.0.3 (a csc)^m (b sec)^n.jl"
"4 Trig functions/4.1 Sine/4.1.1/4.1.1.1 (a+b sin)^n.jl"
"4 Trig functions/4.1 Sine/4.1.1/4.1.1.2 (g cos)^p (a+b sin)^m.jl"
"4 Trig functions/4.1 Sine/4.1.1/4.1.1.3 (g tan)^p (a+b sin)^m.jl"
"4 Trig functions/4.1 Sine/4.1.2/4.1.2.1 (a+b sin)^m (c+d sin)^n.jl"
"4 Trig functions/4.1 Sine/4.1.2/4.1.2.2 (g cos)^p (a+b sin)^m (c+d sin)^n.jl"
"4 Trig functions/4.1 Sine/4.1.2/4.1.2.3 (g sin)^p (a+b sin)^m (c+d sin)^n.jl"
"4 Trig functions/4.1 Sine/4.1.3 (a+b sin)^m (c+d sin)^n (A+B sin).jl"
"4 Trig functions/4.1 Sine/4.1.4/4.1.4.1 (a+b sin)^m (A+B sin+C sin^2).jl"
"4 Trig functions/4.1 Sine/4.1.4/4.1.4.2 (a+b sin)^m (c+d sin)^n (A+B sin+C sin^2).jl"
"4 Trig functions/4.1 Sine/4.1.5 trig^m (a cos+b sin)^n.jl"
"4 Trig functions/4.1 Sine/4.1.6 (a+b cos+c sin)^n.jl"
"4 Trig functions/4.1 Sine/4.1.7 (d trig)^m (a+b (c sin)^n)^p.jl"
# 4.1.8
"4 Trig functions/4.1 Sine/4.1.9 trig^m (a+b sin^n+c sin^(2 n))^p.jl"
"4 Trig functions/4.1 Sine/4.1.10 (c+d x)^m (a+b sin)^n.jl"
"4 Trig functions/4.1 Sine/4.1.11 (e x)^m (a+b x^n)^p sin.jl"
"4 Trig functions/4.1 Sine/4.1.12 (e x)^m (a+b sin(c+d x^n))^p.jl"
"4 Trig functions/4.1 Sine/4.1.13 (d+e x)^m sin(a+b x+c x^2)^n.jl"
"4 Trig functions/4.3 Tangent/4.3.1.1 (a+b tan)^n.jl"
"4 Trig functions/4.3 Tangent/4.3.1.2 (d sec)^m (a+b tan)^n.jl"
"4 Trig functions/4.3 Tangent/4.3.1.3 (d sin)^m (a+b tan)^n.jl"
"4 Trig functions/4.5 Secant/4.5.1.1 (a+b sec)^n.jl"
"4 Trig functions/4.5 Secant/4.5.1.2 (d sec)^n (a+b sec)^m.jl"
"4 Trig functions/4.5 Secant/4.5.1.3 (d sin)^n (a+b sec)^m.jl"
"4 Trig functions/4.5 Secant/4.5.1.4 (d tan)^n (a+b sec)^m.jl"
"4 Trig functions/4.5 Secant/4.5.7 (d trig)^m (a+b (c sec)^n)^p.jl"
"4 Trig functions/4.7 Miscellaneous/4.7.4 (c trig)^m (d trig)^n.jl"
"4 Trig functions/4.7 Miscellaneous/4.7.7 F^(c (a+b x)) trig(d+e x)^n.jl"
"5 Inverse trig functions/5.1 Inverse sine/5.1.1 (a+b arcsin(c x))^n.jl"
"5 Inverse trig functions/5.1 Inverse sine/5.1.2 (d x)^m (a+b arcsin(c x))^n.jl"
"5 Inverse trig functions/5.3 Inverse tangent/5.3.1 (a+b arctan(c x^n))^p.jl"
"5 Inverse trig functions/5.3 Inverse tangent/5.3.2 (d x)^m (a+b arctan(c x^n))^p.jl"
"7 Inverse hyperbolic functions/7.1 Inverse hyperbolic sine/7.1.1 (a+b arcsinh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.1 Inverse hyperbolic sine/7.1.2 (d x)^m (a+b arcsinh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.1 Inverse hyperbolic sine/7.1.3 (d+e x^2)^p (a+b arcsinh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.1 Inverse hyperbolic sine/7.1.4 (f x)^m (d+e x^2)^p (a+b arcsinh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.1 Inverse hyperbolic sine/7.1.5 u (a+b arcsinh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.1 Inverse hyperbolic sine/7.1.6 Miscellaneous inverse hyperbolic sine.jl"
"7 Inverse hyperbolic functions/7.2 Inverse hyperbolic cosine/7.2.1 (a+b arccosh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.2 Inverse hyperbolic cosine/7.2.2 (d x)^m (a+b arccosh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.2 Inverse hyperbolic cosine/7.2.3 (d+e x^2)^p (a+b arccosh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.2 Inverse hyperbolic cosine/7.2.4 (f x)^m (d+e x^2)^p (a+b arccosh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.2 Inverse hyperbolic cosine/7.2.5 u (a+b arccosh(c x))^n.jl"
"7 Inverse hyperbolic functions/7.2 Inverse hyperbolic cosine/7.2.6 Miscellaneous inverse hyperbolic cosine.jl"
"7 Inverse hyperbolic functions/7.3 Inverse hyperbolic tangent/7.3.1 (a+b arctanh(c x^n))^p.jl"
"7 Inverse hyperbolic functions/7.3 Inverse hyperbolic tangent/7.3.2 (d x)^m (a+b arctanh(c x^n))^p.jl"
"7 Inverse hyperbolic functions/7.3 Inverse hyperbolic tangent/7.3.3 (d+e x)^m (a+b arctanh(c x^n))^p.jl"
]
# ===== Rules loading
load_rules()