11# ########################## Utility functions #########################
22
3- # beautify convers floats to integers/rational numbers with small
3+ # beautify converts floats to integers/rational numbers with small
44# denominators if possible
55function beautify (eq)
66 if is_add (eq)
@@ -47,22 +47,22 @@ function split_terms(eq, x)
4747 end
4848end
4949
50- # is_holonomic checks whether y is a holonomic function, i.e.,
50+ # is_holonomic checks whether y is a holonomic function, i.e.,
5151# is closed under differentiation w.r.t. x
52- #
52+ #
5353# For our purpose, we define a holonomic function as one composed
5454# of the positive powers of x, sin, cos, exp, sinh, and cosh
55- #
55+ #
5656# Args:
5757# y: the expression to check for holonomy
5858# x: independent variable
59- #
59+ #
6060# Returns:
6161# true if y is holonomic
6262function is_holonomic (y, x)
6363 y = value (y)
6464
65- # technically, polynomials are not holonomic, but
65+ # technically, polynomials are not holonomic, but
6666 # practically we can include them
6767 if is_polynomial (y, x)
6868 return true
@@ -90,8 +90,8 @@ function is_holonomic(y, x)
9090 return false
9191end
9292
93- # blender generates a list of ansatzes based on repetative
94- # differentiation. It works for holonomic functions, which
93+ # blender generates a list of ansatzes based on repetitive
94+ # differentiation. It works for holonomic functions, which
9595# are closed under differentiation.
9696function blender (y, x; n = 3 )
9797 basis = value (y)
@@ -111,7 +111,7 @@ function blender(y, x; n = 3)
111111 return split_terms (basis, x)
112112end
113113
114- # subs_symbols returns a dictionary of the symbolic constants
114+ # subs_symbols returns a dictionary of the symbolic constants
115115# in the expression and random real value assignments.
116116#
117117# Args:
@@ -138,8 +138,8 @@ function subs_symbols(eq, x; include_x = false, radius = 5.0, as_complex = true)
138138 return S
139139end
140140
141- # atomize splits terms into a part dependent on x and a part
142- # constant w.r.t. variables in xs.
141+ # atomize splits terms into a part dependent on x and a part
142+ # constant w.r.t. variables in xs.
143143#
144144# For example, `atomize(a*sin(b*x), x)` is `(a, sin(b*x))`)
145145function atomize (eq, xs... )
@@ -165,7 +165,7 @@ function atomize(eq, xs...)
165165 end
166166end
167167
168- # apply_coefs generates the final integral based on the list
168+ # apply_coefs generates the final integral based on the list
169169# of coefficients (q) and a list of ansatzes (ker).
170170function apply_coefs (q, ker)
171171 s = 0
@@ -201,11 +201,11 @@ complex_from_num(x) = Complex(value(real(x)), value(imag(x)))
201201# ########################## Symbolic Integration #############################
202202
203203# integrate_symbolic is the main entry point for symbolic integration.
204- #
204+ #
205205# Argu:
206206# eq: the expression to integrate
207207# x: independent variable
208- #
208+ #
209209# Returns:
210210# the integral or nothing if no solution
211211function integrate_symbolic (eq, x; plan = default_plan ())
@@ -226,10 +226,10 @@ struct Problem
226226 x:: Expression # independent variable
227227 coef:: Expression # coefficient of the integrand
228228 ker:: Array{Expression} # the pruned list of the basis expressions (kernel)
229- plan:: NumericalPlan # the numerial plan, containing various parameters
229+ plan:: NumericalPlan # the numerical plan, containing various parameters
230230end
231231
232- # Constructor to create a Problem for integrand eq
232+ # Constructor to create a Problem for integrand eq
233233function Problem (eq, x; plan = default_plan ())
234234 eq = expand (eq)
235235 coef, eq = atomize (eq, x)
@@ -314,14 +314,14 @@ subs_symbols(prob::Problem) = subs_symbols(prob.eq, prob.x)
314314abstract type IntegrationAlgorithm end
315315
316316struct SymbolicIntegrator <: IntegrationAlgorithm
317- eqs:: Vector{Equation} # list of equations of the form Σ θ[i]*frag[i] ~ 0
317+ eqs:: Vector{Equation} # list of equations of the form Σ θ[i]*frag[i] ~ 0
318318 vars:: Vector{Expression} # list of dummy variables (θ[1], θ[2], ...)
319319 frags:: Dict # Dict of fragments of form frag => expression in θs
320320end
321321
322322@variables θ[1 : 30 ]
323323
324- # Constructor creating a SymbolicIntegrator algorithm
324+ # Constructor creating a SymbolicIntegrator algorithm
325325# from an integration Problem
326326function SymbolicIntegrator (prob:: Problem )
327327 frags = Dict ()
@@ -355,16 +355,16 @@ function solver(prob::Problem, alg::SymbolicIntegrator)
355355 sol = apply_coefs (q, prob. ker)
356356 return sol
357357 catch e
358- # println(e)
358+ # println(e)
359359 end
360360
361361 return nothing
362362end
363363
364364# If the linear system generated by the SymbolicIntegrator solver is
365- # under-determined, make_square uses semi-numerical methods to
365+ # under-determined, make_square uses semi-numerical methods to
366366# generate a full-rank linear system.
367- #
367+ #
368368# The output is another SymbolicIntegrator or nothing if unsuccessful.
369369function make_square (prob:: Problem , alg:: SymbolicIntegrator )
370370 n = length (alg. vars)
@@ -390,10 +390,10 @@ function make_square(prob::Problem, alg::SymbolicIntegrator)
390390end
391391
392392struct NumericIntegrator
393- A:: AbstractMatrix # training dataset as a normalized linear system
393+ A:: AbstractMatrix # training dataset as a normalized linear system
394394 X:: AbstractVector # vector of test points
395395 V:: AbstractMatrix # verification dataset
396- basis:: Vector{Expression} # expand basis
396+ basis:: Vector{Expression} # expand basis
397397end
398398
399399# Constructor to create a NumericIntegrator algorithm from prob
0 commit comments