Theory of Functional Connections Applied to Linear ODEs Subject to Integral Constraints and Linear Ordinary Integro-Differential Equations

: This study shows how the Theory of Functional Connections (TFC) allows us to obtain fast and highly accurate solutions to linear ODEs involving integrals. Integrals can be constraints and/or terms of the differential equations (e.g., ordinary integro-differential equations). This study ﬁrst summarizes TFC, a mathematical procedure to obtain constrained expressions . These are functionals representing all functions satisfying a set of linear constraints . These functionals contain a free function, g ( x ) , representing the unknown function to optimize. Two numerical approaches are shown to numerically estimate g ( x ) . The ﬁrst models g ( x ) as a linear combination of a set of basis functions, such as Chebyshev or Legendre orthogonal polynomials, while the second models g ( x ) as a neural network. Meaningful problems are provided. In all numerical problems, the proposed method produces very fast and accurate solutions.


Introduction
This paper shows how to solve linear Ordinary Differential Equations (ODEs) and linear Integro-Differential Equations (IDEs) using a new mathematical framework to perform functional interpolation, called Theory of Functional Connections (TFC). TFC derives functionals, called constrained expressions, containing a free function and representing all possible functions satisfying a set of linear constraints [1][2][3][4]. The most important feature of the constrained expressions is: they always satisfy all the constraints no matter what the free function is.
Although it was recently developed (2017), TFC has already found several applications, especially in solving differential equations [5][6][7][8]. The free function can be expressed by any set of linearly independent functions, such as an expansion of orthogonal polynomials (e.g., Chebyshev, Legendre, etc.) or Neural Networks (NN), such as shallow NN with random features, or Deep NNs (DNNs). When the free function is expanded by a set of orthogonal polynomials the method is here identified as "classic TFC". When shallow NNs with random features are used, the method has been identified as Extreme-TFC (X-TFC) [9], and when DNNs are used the method is called Deep-TFC [10].
The best expansion of the free function depends on the differential equation considered. Usually, for linear/nonlinear ODEs and simple bivariate PDEs, orthogonal polynomials represent the best choice in terms of accuracy. Indeed, orthogonal polynomials are generally the best mathematical tools for approximating and for convergence properties [11,12].
Nevertheless, for multivariate and more complex PDEs, orthogonal polynomials suffer the "curse of dimensionality". For these problems, NNs represent a better choice as they better tolerate the curse of dimensionality.
In all previous applications, the free function has been expressed as a linear combination of known basis functions and unknown constant coefficients. These coefficients are then estimated by least-squares for linear Differential Equations (DEs) [5] and by nonlinear least-squares for nonlinear DEs [6]. The problems considered in this work will be solved with classic TFC using Chebyshev orthogonal polynomials and X-TFC.
Note that X-TFC and Deep-TFC are also identified as Physics-Informed Neural Networks (PINN) frameworks [9]. PINNs are recently developed machine-learning methods that employ NNs for data-physics-driven regression, data-physics-driven solution of DEs, and data-physics-driven discovery of parameters governing DEs [13]. Since X-TFC and Deep-TFC use NNs as free function, they are considered part of the PINNs family. Thanks to the constrained expression, developed by TFC, both X-TFC and Deep-TFC are more robust and accurate than the standard PINN frameworks as introduced by Raissi et al. [13].
The aim of this paper is to show how TFC can accommodate integral constraints in linear differential equations and solve linear integro-differential equations, is organized as follows. In Section 2, a summary of the TFC framework is provided, with the explanation of how to derive constrained expressions. In Section 3, the application of TFC to solve ODEs with integral constraints is shown, and some case problems are reported as examples. In Section 4, the TFC framework is used to solve linear integro-differential equations.
In all test problems considered in this article, the results have been obtained using MATLAB R2020a software on an Intel Core i7-9700 CPU PC with 64 GB of RAM. The results' accuracy is provided in terms of the absolute error. That is, where y TFC is the TFC approximated solution, and y true is the true analytical solution.
Since the classic TFC uses Chebyshev or Legendre orthogonal polynomials as a basis set, the final Appendix A provides a definition, orthogonality, derivatives, and integral expressions and properties for both Chebyshev and Legendre orthogonal polynomials.

Theory of Functional Connections Summary
A mathematical generalization of interpolation, called Theory of Functional Connections, has recently been developed and successfully applied to solve, by least-squares, initial, boundary, and multi-value problems of linear [5] and nonlinear [6] ODEs and PDEs [8,10]. The theory has been developed for univariate [1] and multivariate rectangular domains [2,8].
The generalization of interpolation consists of a mathematical procedure to obtain analytical expressions describing all possible functions subject to n linear constraints. These expressions are functionals that are called constrained expressions. Two formally equivalent approaches [1,8] can be used to derive them. These are, where n is the number of the linear constraints, g(x) is a function that can be freely chosen, η k (x, g(x)) are functional coefficients, s(x) = {s 1 (x), · · · , s n (x)} is a set of n user-defined support functions that must be linearly independent (necessary conditions), φ k are switching functions, and ρ k (x, g(x)) are projection functionals. By imposing the n constraints to Equation (1), the values of the n functional coefficients, η k (x, g(x)), are obtained for some set of n user-assigned functions, s k (x). Once the n functional coefficients, η k (x, g(x)), are computed, by substituting them back into Equation (1) we obtain the constrained expression. To give an example, using s 1 (x) = x and s 2 (x) = x 2 , the constrained expression, where the switching functions, φ k (x), and projection functionals, ρ k (x, g(x)), are identified, always satisfies the two derivative constraints, is. In this article, the use of both formulations, provided by Equations (1) and (2), will be shown. The projection functional, ρ k (x, g(x)), projects the free function, g(x), on the k-th constraint. Here is an example of projection functionals associated to a set of constraints, . As for the switching functions, φ k (x), they are expressed as a linear combination of a set of support functions, s(x). These functions satisfy φ k (x) = 1 when the k-th constraint is verified and φ k (x) = 0 when any other constraint is verified. For instance, given the support functions, Reference [4] presents, in detail, how to derive the TFC constrained expressions using the formalism defined by Equation (2).
Constrained expressions have been used to solve differential equations. This is done by expressing the solution using the TFC constrained expressions from Equation (1) or, equivalently, from Equation (2). These functionals allow us to reduce the whole functions space to only the functions subspace satisfying the constraints. This is particularly important when solving differential equations. In fact, when substituting these functionals into the DE, a new differential equation is obtained in terms of g(x). This new DE is subject to no constraints because the constrained expression fully satisfies the constraints. The unknown free function, g(x), is then expressed as a linear combination of basis functions. In the classic TFC, g(x) is a linear combination of orthogonal polynomials. That is, where m is the number of the basis functions h j (x) (orthogonal polynomials). In X-TFC, g(x, ξ) is a shallow NN trained with Extreme Learning Machine (ELM) [33], where L is the number of hidden neurons, w j ∈ R is the input weights vector connecting the j-th hidden neuron and the input nodes, ξ j ∈ R with j = 1, · · · , L is the j-th output weight connecting the j-th hidden neuron and the output node, and b j is the bias of the j-th hidden neuron, σ j (·) are activation functions, and σ = {σ 1 , · · · , σ L } T . According to the ELM algorithm [33], biases and input weights are randomly selected and not tuned during the training, thus they are known hyper-parameters. The activation functions, σ j (·), are also known as they are user selected. Thus, the only unknown NN hyper-parameters to compute are the output weights ξ = {ξ 1 , · · · , ξ L } T . Therefore, for both classic TFC and X-TFC, the unknown vector, ξ, which actually constitutes the only unknown of our problem, is then estimated numerically, as for instance by least-squares for linear [5] and nonlinear [6] differential equation s. In general, the independent variable of the DE (for instance, time) is defined in the t ∈ [t 0 , t f ] range, while the selected basis functions may be defined as a different range, x ∈ [x 0 , x f ] (for instance, Chebyshev and Legendre orthogonal polynomials are defined in the x ∈ [−1, +1]). Thus, a change of variable is needed. The most simple mapping between these two variables is linear, This procedure can be applied to linear differential equations with non-constant coefficients. The final expression obtained is linear in terms of the unknown vector, ξ, and can be written as: To solve the problem numerically, this new equation is discretized for a set of N distinct values of x. A different discretization scheme can be used. Usually, the discretization points are either randomly selected or linearly uniformly spaced. When using Chebyshev polynomials the best discretization is to use the zeros of the Chebyshev polynomials, also called Chebyshev points or nodes or, more formally, Chebyshev-Gauss points [12]. They are defined by the cosine distribution, By specifying Equation (6) for these x k values a system of N linear equations is obtained in m (or L) unknowns that is then solved for ξ by least-squares. Several leastsquares methods can be used to solve (6). The optimal least-squares method to use for each problem depends on the problem itself and on what TFC technique is used to solve the problem (e.g., in this paper, classic TFC or X-TFC). For instance, for the classic TFC and linear DEs, our analysis identifies the QR decomposition on a scaled coefficient matrix as the best approach minimizing the condition number of the matrix to invert.

TFC for ODEs with Integral Constraints
In this section, we show how TFC is applied to solve linear ODEs with integral constraints. After showing how to derive the constrained expression when dealing with a general integral constraint, we will solve a couple of linear ODEs subjects to boundary conditions and integral constraints.
For the first two examples in this section, we will derive the constrained expression by following the formulation of Equation (1). For subsequent examples and problems, however, the second formulation, Equation (2), will be adopted.

Definite Integral Constraint
Let us consider the integral constraint, b a f (x) dx = I.
The constrained expression has the form, where g(x) is a free function and s 1 (x) is a user-defined support function, and η 1 is a coefficient that is derived by imposing the constraint. By integrating Equation (8) the following equation: is obtained, which can be rearranged to obtain the expression for η 1 , Substituting this value into Equation (8), we obtain a constrained expression for f (x), that is, an expression that always satisfies the integral constraint for any expression of g(x), This function becomes undefined when b a s 1 (x) dx = 0, and thus s 1 (x) must be selected to avoid this condition. By simply selecting s 1 (x) = 1 Equation (9) becomes,

Integral and Linear Constraints
In this second example, let us consider the more complex case where, in addition to the integral constraint given in Equation (7), we also consider the additional linear constraints, where α, β, x 0 , and x f are all assigned. A sketch of this example is shown in Figure 1. The constrained expression has the form, Then, by applying the constraints the system of linear equations, is obtained. This system tells us that s 1 (x) and s 2 (x) functions can be any functions with the exception of those making the matrix singular. The matrix singularity occurs when For instance, by selecting s 1 (x) = 1 and s 2 (x) = x, the previous condition becomes, which imply that, in order to avoid singularity, the following relationship must be satisfied, When this condition is satisfied, the matrix of Equation (11) can be inverted and the coefficients, η 1 and η, can be computed. Then, the constrained expression for this problem is obtained by substituting the expressions found for η 1 and η 2 in Equation (10).

Problem #1
Now, let us consider the following DE to be solved on the t ∈ [0, π] range, with a constraint in the form of an integral over the integration range, whose analytical solution is In this problem, we build the constrained expression according to the formulation of Equation (2), where the projection functionals ρ k (x, g(x)) are given by Given the support functions, the switching functions are computed as φ where the α ji coefficients are computed just by inverting a matrix. For this problem, Then, the constrained expression can be built as: where the switching functions are Now, expressing the free function according to g(t, ξ) = ξ T h(x(t)) the terms of the DE become: where the boundary conditions have been mapped to x ∈ [x 0 , x f ]. For classic TFC x ∈ [−1, +1], and for X-TFC x ∈ [0, 1] according to Equations (3)- (5). The mapping coefficient With the function now expressed in terms of ξ the differential equation can now be transformed into a function of ξ, This equation can then be specified for a discrete values of x. This discretization yields to an over-determined linear system that can be solved by least-squares.
In this example, using n = 100 and m = 20, the classic TFC was executed with a computational time is of O 10 −4 s, the average absolute error on the discretization points is of O 10 −16 , the variance of the absolute error on the discretization points is of O 10 −16 . For X-TFC, we set the following hyper-parameters n = 100, L = 100, Gaussian activation function, input weight and bias were sampled from U [−10, +10] . The computational time is of O 10 −4 s, the average absolute error on the discretization points is of O 10 −16 , the variance of the absolute error on the discretization points is of O 10 −16 . Table 1 reports the absolute error with respect to the analytical solutions obtained with classic TFC and X-TFC on 11 points uniformly distributed in the [0, 1] range.

Mixed Constraints
Consider a function subject to a value-level, relative, and integral constraint, (2), the constrained expression has the form,

By using Equation
where the projection functionals, ρ k (t, g(t)), are given by Given the support functions, Once the φ j (t) are known, the constrained expression can be obtained as:

Problem #2
As an ultimate "stress-test" of the TFC method, a mixed-constraint case is considered where point, relative, and integral constraints are used in the solution of a differential equation, on the range t ∈ [−π, π] ... y + sin tÿ + (1 − t)ẏ + ty = f (t) subject to: where the forcing term is This problem admits the analytical solution, Following the procedure explained, the constrained expression for this problem is, where the α ji coefficients of the switching functions φ j (t) = 3 ∑ i=1 α ji s i (t) are computed by solving the following system: Now, expressing the free function according to g(t) = ξ T h(x(t)) and rearranging terms leads us to the final constrained expression, and by substituting this constrained expression into the differential equation (by evaluating its derivatives accordingly), we obtain a linear system that can be solved by least-squares using Equation (12). Even in this case, the differential equation and boundary conditions must be mapped onto x ∈ [x 0 , x f ]. For classic TFC x ∈ [−1, +1], and for X-TFC x ∈ [0, 1] according to

Discussions
The results from these two problems emphasize the utility and convenience of using TFC. Once the constrained expression is defined, the method to solving the differential equation does not change regardless of the use of different constraints. Moreover, this makes the solution accuracy only dependent on the problem complexity. Finally, once the solution is computed (on the discretization points), we have an analytical representation of it. That is, no further manipulations are needed (e.g., interpolation) if we want to evaluate the solutions in points that are different from the discretization points. Indeed, as shown in the results of both problems we do not lose any accuracy when evaluating the solution on test points, as it would happen with some other state-of-the-art methods such as the Finite Element Method (FEM) [34].

TFC for Linear Ordinary Integro-Differential Equation
In this section we show how TFC is applied to solve linear ordinary Integro-Differential Equations (IDEs) using all constrained expressions derived from the formalism of Equation (1).
As first test problem, the linear Fredholm integro-differential equations is considered. Comparisons of the numerical results obtained with TFC, X-TFC, and the method published in Ref. [35] are presented.

Problem #1
Consider the following integro-differential equation: with one constraint y(0) = 0, for x ∈ [0, 1]. The analytical solution is y(x) = x. The constrained expression for this problem is simply where h 0 is the vector of the basis function computed at x = 0. For classic TFC n = 100 discrete points and m = 29 basis functions were used. The computational time is of O 10 −4 s, the average absolute error on the discretization points is of O 10 −5 , and the variance of the absolute error on the discretization points is of O 10 −9 . For X-TFC the hyper-parameters were set to n = 20, L = 20, the activation function was sinusoidal, and the input weight and bias were sampled from U [−1, +1]. The computational time obtained was of O 10 −4 s, the average absolute error on the discretization points of O 10 −4 , the variance of the absolute error on the discretization points of O 10 −8 . The absolute errors obtained with classic TFC and X-TFC on 10 test points are reported in Figure 2 and compared with those reported by Ref. [35].

Problem #2
The second test problem is on the following integro-differential equation: with one constraint y(0) = 0, for x ∈ [0, 1]. The analytical solution is y(x) = xe x . Also for this this problem the constrained expression is For classic TFC n = 25 discretization points and m = 14 basis functions were adopted. The computational time obtained is of O 10 −4 s, the average absolute error on the discretization points is of O 10 −16 , and the variance of the absolute error on the discretization points is of O 10 −32 . For X-TFC the hyper-parameters were set to n = 50, L = 50, the activation function was the hyperbolic tangent, and the input weight and bias were sampled from U [−1, +1]. The computational time is of O 10 −4 s, the average absolute error on the discretization points is of O 10 −14 , and the variance of the absolute error on the discretization points is of O 10 −27 . The absolute errors on the test points obtained with classic TFC and X-TFC, are reported in Figure 3 and compared with those reported by Ref. [35].

Problem #3
The last test problem is a second-order integro-differential equation, subject to the initial value problem, y(0) = 1 andẏ(0) = 1, where x ∈ [0, 1]. The analytical solution is y(x) = e x . The constrained expression for this problem is: To solve this problem, the classic TFC required n = 9000 points and m = 1000 basis functions. The computational time was of O(1) second, the average absolute error on the discretization points was of O 10 −5 , and the variance of the absolute error on the discretization points was of O 10 −10 . For X-TFC the setting was n = 90 and L = 94 hyper-parameters, hyperbolic sine activation function, and input weight and bias were sampled from U [−1, +1]. The computational time was of O 10 −4 s, the average absolute error on the discretization points of O 10 −4 , and the variance of the absolute error on the discretization points of O 10 −7 . The absolute errors on the test points obtained with classic TFC and X-TFC, are reported in Figure 4 and compared with those reported by Ref. [35].

Discussions
The discussions made for the linear ODE subjects to integral constraints are also valid for linear ordinary integro-differential equations. Nevertheless, the attentive reader will notice that there is a significant difference in terms of accuracy among problems 1 and 3 compared to problem 2. This is due to the fact that the kernels in the integral terms of the equations are different than one for problems 1 and 3 (e.g., for the both problems the kernel is t). This can have a negative impact on the solution accuracy as the function to be integrated can become very complex, and this can lead to numerical issues. For instance, when classic TFC is used in problems 1 and 3, where the kernel is simply t, the coefficients in front of the integrated polynomials become enormous as the number of basis functions (e.g., the degree of the Chebyshev polynomials) reaches above ten, causing numerical issues that impact negatively on the accuracy. Moreover, in many real world applications, such as in radiative transfer equation [17,36], the kernel can be very complex, making the analytical evaluation of the integral prohibitive.
The are several ways of mitigating these issues that are worth exploring. For instance, the integral could be evaluated with a Gauss-quadrature scheme or with a Monte Carlo method. The authors of this manuscript are investigating the possibility of evaluating the integral numerically using NNs. However, the investigation of different ways to overcome these limitations is not the focus of this work, and it will be explored by the authors in future papers.

Conclusions
This study presents an extension of the least-squares solution of linear differential equations studied in an earlier publication [5]. This paper aims to explore solutions using different boundary constraints including multi-valued, relative, and integral constraints for linear ordinary differential equations and for linear ordinary integro-differential equations. In all problems, a constrained expression is used to embed the constraints. This allows the integration range to be independent from the constraints location. In these expressions, the free function g(x) was expressed as a linear combination of known basis functions and unknown constant coefficients ξ, either using Chebyshev polynomials, or shallow NNs for the X-TFC framework. Expressing g(x) as a linear combination of basis functions and constant coefficients, the coefficient vector ξ remains linear and is solved by using a leastsquares method. While this paper only solves linear differential equations as a test case, the proposed methodology can easily be extended to nonlinear differential equations by replacing the least-squares method with a nonlinear least-squares technique as introduced in prior research [6].
For all cases explored, the classic TFC and X-TFC methods consistently produce very fast and accurate solutions. Additionally, for all problems, the constraints are analytically satisfied since they are integrated into the constrained expression. In general, this means that the TFC methods decouple the constraints from the solution of the differential equation. Due to this, the solution range of the differential equation and, where the constraints are specified, is independent. This fact makes the TFC method a unified framework to solve differential equations with no more distinctions between the initial and boundary values problems, as well as any other constraints distribution problem. Funding: This research received no external funding.

Acknowledgments:
The authors acknowledge Hunter Johnston for the initial investigation on integral constraints using the Theory of Functional Connections.

Conflicts of Interest:
The author declares no conflict of interest.

Appendix A. Chebyshev and Legendre Orthogonal Polynomials
This appendix provides compact summaries of Chebyshev, T k (x), and Legendre, L k (x), orthogonal polynomials, which are defined in the xß[−1, +1] range. These are: Appendix A. 1

Appendix A.2. Orthogonality
The orthogonality is provided by the following integrals, • Legendre full range.