Corrected LEASTSQUARE
Corrected LEASTSQUARE
Abstract
In this study, solution of a class of second order ordinary differential equation was
considered using the least square method and an orthogonal basis function, the
Chebyshev polynomial function. The solution method was done in three steps.
Firstly, the solution of the differential equation was assumed to be a linear combina-
tion of the Shifted Chebyshev basis function of the first kind, then a residual function
was defined for the domain and boundary. The residual functions were equated to 0
and an error function was generated from the residual function. Finally, we applied
the Least Square (continous) Method which is finding the coefficients of the linear
combination explained earlier, which will minimize the error function in L2 norm.
These coefficients were obtained and substituted to obtain the approximate solution
of the differential equation. Error analysis was made using the exact solution of
some examples considered.
1
Nasara Journal of Sci. and Tech., Vol.7. 2018 ISSN: 2141-3622 2018
1 Introduction
Ordinary differential equations (ODEs) appear in a lot of problems in almost all sci-
entific disciplines. Differential equations (DEs) are studies from several different per-
spectives mostly concerned with their solutions. Several laws in Biology, Chemistry,
Physics, Economics e.t.c are all based upon empirical observations which describes
the change in state of systems. These change of states of systems are described by
Mathematical models which are frequently expressed in terms of derivatives. This
gives rise to differential equations. (Strang, 2015).
There are many different techniques which are used to obtain approximate solution
of differential equation. The Runge - Kutta methods are the most widely used for
initial value problem while shooting methods for boundary value problems. (Dor-
mand & Prince, 1980).
Differential equation can be found in the Mathematical formulation of physical phe-
nomena in a wide variety of application especially in science and engineering. De-
pending upon the form of the boundary conditions to be satisfied by the solution.
Problems involving ordinary differential equations can be divided into two main
categories; Initial Value Problems (IVPs) and Boundary Value Problems (BVPs).
Analytical solutions for these are not generally available and hence numerical meth-
ods must be applied.
The Least Square Method (LSM) is a newly introduced meshless method based on
the least square concept. The method is based on the minimization of a least square
functional defined as the weighted summation of the square residual of the governing
DE and its boundary conditions at nodal points used to describe the domain and
its boundaries. (Lin et. ol, 2008).
2
method. The method was used to solve the governing nonlinear coupled equations
of the described problem and compared it with numerical method (Runge-Kutta 4th
order method). Result showed that least square method is so suitable computational
process. (Pourmehran et. ol., 2017).
Calver, J. & Enright, W. investigated the performance of the adjoint approach
and the variational approach for computing the sensitivities of the least squares
objective function commonly used when fitting models to observations.(Calver &
Enright, 2017).
Bjorck discussed Least Square problem and solution techniques in (Bjorck, 2001).
4 Problem Statement
In this research work, the following class of second order ODE will be considered
d2 u(t) du(t)
!
φ , , u(t), t = f (t) (1)
dt2 dt
with boundary conditions u(0) = u0 , u(T ) = uT and t ∈ [0, T ]
5 Methodology
The following steps was used to solve the research problem:
¨
STEP 3: Substitute û(t), ˙
û(t) and û(t) into equation (1): Equation (1) now be-
comes
n n n
!
X X X
φ αi T̈i (t), αi Ṫi (t), αi Ti (t), t = f (t) (5)
i=0 i=0 i=0
3
STEP 5: Form the Residual Function R: The residual function for the research
problem
d2 u(t) du(t)
!
φ , , u(t), t = f (t) (8)
dt2 dt
is given by
d2 û(t) dû(t)
!
R(t) = φ , , û(t), t − f (t) (9)
dt2 dt
STEP 6: Find the set of αi s that minimize the Square Error E: To minimize
the square error, we need to set up
Z T
E = R2 (t)dt (10)
0
The best αi s that minimize the square error is determined by finding the min-
imal value of E, that is find the set of αi s such that
∂E
= 0, i = 1, 2, 3, ..., n − 1 (11)
∂αi
!
∂ ZT 2
R (t)dt = 0, i = 1, 2, 3, ..., n − 1 (12)
∂αi 0
Z T
∂R(t)
R(t) dt = 0, i = 1, 2, 3, ..., n − 1 (13)
0 ∂αi
STEP 7: Obtain the αi s using equations (3), (4) and (13): These 3 equations
n
X
αi Ti (0) = u0
i=0
Z T
∂R(t)
R(t) dt = 0, i = 1, 2, 3, ..., n − 1
0 ∂αi
n
X
αi Ti (T ) = uT
i=0
6 Numerical Examples
6.1 Problem One
Consider the following problem: Solve the 2nd order ODE
4
STEP 1: Assume an Approximate Solution û(t): The Chebychev polynomial
Ti (τ ) of the first kind defined on the interval [-1,1] is given by:
T0 (τ ) = 1
T1 (τ ) = τ
T2 (τ ) = 2τ 2 − 1
T3 (τ ) = 4τ 3 − 3τ
.
.
.
Tn+1 (τ ) = 2τ Tn (τ ) − Tn−1 (τ ) for n ≥ 1, τ ∈ [−1, 1]
Since the research problem is defined on the interval [0,1], then in order to
use the Chebychev Polynomial Basis we must obtain the Shifted Chebychev
Polynomial Basis for the interval [0,1] using the affine transformation which
transforms τ ∈ [−1, 1] to t ∈ [0, T ] as follows:
T −0 T +0 2t − T
t=τ+ ⇒τ =
2 2 T
Therefore,the Shifted Chebychev Polynomial for the interval [0,1] is:
T0 (t) = 1
T1 (t) = 2t − 1
T2 (t) = 8t2 − 8t + 1
T3 (t) = 32t3 − 48t2 + 18t + 1
.
.
.
Tn+1 (t) = (4t − 2)Tn (t) − Tn−1 (t) for n ≥ 1, t ∈ [0, 1]
where:
T0 (t) = 1
T1 (t) = 2t − 1
T2 (t) = 8t2 − 8t + 1
T3 (t) = 32t3 − 48t2 + 18t + 1
T4 (t) = 128t4 − 256t3 + 160t2 − 32t + 1
¨
STEP 2: Find û(t) ˙
and û(t): We need to differentiate the basis polynomials Ti (t)
twice, thus for Ṫi (t) we have:
5
Ṫ0 (t) = 0
Ṫ1 (t) = 2
Ṫ2 (t) = 16t − 8
Ṫ3 (t) = 96t2 − 96t + 18
Ṫ4 (t) = 512t3 − 768t2 + 320t − 32
and for T̈i (t) we have:
T̈0 (t) = 0
T̈1 (t) = 0
T̈2 (t) = 16
T̈3 (t) = 192t − 96
T̈4 (t) = 1536t2 − 1536t + 320
Therefore,
4
¨ =
X
û(t) αi T̈i (t)
i=0
and
4
˙
X
û(t) = αi Ṫi (t)
i=0
¨
STEP 3: Substitute û(t), ˙
û(t) and û(t) into the DE: The equation
which gives
4
X 4
X 4
X
αi T̈i (t) + αi Ṫi (t) − 2 αi Ti (t) = 0 (18)
i=0 i=0 i=0
¨
STEP 4: Substitute û(t), ˙
û(t) and û(t) into the Boundary Conditions: For the
first boundary condition u(0) = 2 we have,
4
X
αi Ti (0) = 2 (19)
i=0
α0 − α1 + α2 − α3 + α4 = 2 (20)
and for the second boundary condition u(1) = 1
4
X
αi Ti (1) = 1 (21)
i=0
α0 + α1 + α2 + α3 + α4 = 1 (22)
6
STEP 6: Find the set of αi s that minimize the Square Error E: To minimize
the square error, we need to set up
Z 1
E = R2 (t)dt (25)
0
The best αi s that minimize the square error is determined by finding the min-
imal value of E, that is find the set of αi s such that
Z 1
∂R(t)
R(t) dt = 0, i = 1, 2, 3, 4 (26)
0 ∂αi
For i = 1, 2, 3 we get the following 3 equations
4α0 − 4α1 − (33.3333)α2 − 4α3 + 8α4 = 0 (27)
(−33.3333)α0 + 28α1 + (300.5333)α2 + 284α3 + (1.4095)α4 = 0 (28)
−4α0 − (60.8)α1 + 284α2 + 3.2095 × 103 α3 + 5.1429α4 = 0 (29)
STEP 7: Obtain the αi s: Using equations (20), (22), (27), (28) and (29) we ob-
tain
α0 − α1 + α2 − α3 + α4 = 2
4α0 − 4α1 − (33.3333)α2 − 4α3 + 8α4 = 0
(−33.3333)α0 + 28α1 + (300.5333)α2 + 284α3 + (1.4095)α4 = 0
−4α0 − (60.8)α1 + 284α2 + 3.2095 × 103 α3 + 5.1429α4 = 0
α0 + α1 + α2 + α3 + α4 = 1
which give the following system of equations
1 -1 1 -1 1 α0 2
4 -4 -33.3333 -4 8
α1
0
-33.3333 28 300.5333 284 1.4095
α2
=
0
-4 -60.8 284 3.2095 × 103 5.1429 α3 0
1 1 1 1 1 α4 1
solving this system of equations gives
α0 = 1.2988
α1 = −0.4738
α2 = 0.2130
α3 = −0.0262
α4 = −0.0118
with these values for αi s we obtain the approximate solution as
û(t) = 2 − 2.7456t + 1.0736t2 + 2.1824t3 − 1.5102t4 (30)
7
STEP 1: Assume an Approximate Solution û(t): The Chebychev polynomial
Ti (τ ) of the first kind defined on the interval [-1,1] is given by:
T0 (τ ) = 1
T1 (τ ) = τ
T2 (τ ) = 2τ 2 − 1
T3 (τ ) = 4τ 3 − 3τ
.
.
.
Tn+1 (τ ) = 2τ Tn (τ ) − Tn−1 (τ ) for n ≥ 1, τ ∈ [−1, 1]
Since the research problem is defined on the interval [0,1], then in order to
use the Chebychev Polynomial Basis we must obtain the Shifted Chebychev
Polynomial Basis for the interval [0,1] using the affine transformation which
transforms τ ∈ [−1, 1] to t ∈ [0, T ] as follows:
T −0 T +0 2t − T
t=τ+ ⇒τ =
2 2 T
Therefore,the Shifted Chebychev Polynomial for the interval [0,1] is:
T0 (t) = 1
T1 (t) = 2t − 1
T2 (t) = 8t2 − 8t + 1
T3 (t) = 32t3 − 48t2 + 18t + 1
.
.
.
Tn+1 (t) = (4t − 2)Tn (t) − Tn−1 (t) for n ≥ 1, t ∈ [0, 1]
where:
T0 (t) = 1
T1 (t) = 2t − 1
T2 (t) = 8t2 − 8t + 1
T3 (t) = 32t3 − 48t2 + 18t + 1
T4 (t) = 128t4 − 256t3 + 160t2 − 32t + 1
¨
STEP 2: Find û(t) ˙
and û(t): We need to differentiate the basis polynomials Ti (t)
twice, thus for Ṫi (t) we have:
8
Ṫ0 (t) = 0
Ṫ1 (t) = 2
Ṫ2 (t) = 16t − 8
Ṫ3 (t) = 96t2 − 96t + 18
Ṫ4 (t) = 512t3 − 768t2 + 320t − 32
and for T̈i (t) we have:
T̈0 (t) = 0
T̈1 (t) = 0
T̈2 (t) = 16
T̈3 (t) = 192t − 96
T̈4 (t) = 1536t2 − 1536t + 320
Therefore,
4
¨ =
X
û(t) αi T̈i (t)
i=0
and
4
˙
X
û(t) = αi Ṫi (t)
i=0
¨
STEP 3: Substitute û(t), ˙
û(t) and û(t) into the DE: The equation
which gives
4
X 4
X 4
X
αi T̈i (t) − 5 αi Ṫi (t) + 6 αi Ti (t) = 0 (34)
i=0 i=0 i=0
¨
STEP 4: Substitute û(t), ˙
û(t) and û(t) into the Boundary Conditions: For the
first boundary condition u(0) = 3 we have,
4
X
αi Ti (0) = 3 (35)
i=0
α0 − α1 + α2 − α3 + α4 = 3 (36)
and for the second boundary condition u(1) = 12
4
X
αi Ti (1) = 12 (37)
i=0
α0 + α1 + α2 + α3 + α4 = 12 (38)
9
STEP 6: Find the set of αi s that minimize the Square Error E: To minimize
the square error, we need to set up
Z 1
E = R2 (t)dt (41)
0
The best αi s that minimize the square error is determined by finding the min-
imal value of E, that is find the set of αi s such that
Z 1
∂R(t)
R(t) dt = 0, i = 1, 2, 3, 4 (42)
0 ∂αi
For i = 1, 2, 3 we get the following 3 equations
−60α0 + 112α1 − 220α2 + 284α3 − 700α4 = 0 (43)
84α0 − 140α1 + 208.8α2 − 268α3 + (1.2927 × 103 )α4 = 0 (44)
−60α0 + 284.8α1 − 268α2 + 4.2391 × 103 α3 − 5820α4 = 0 (45)
STEP 7: Obtain the αi s: Using equations (36), (38), (43), (44) and (45) we ob-
tain
α0 − α1 + α2 − α3 + α4 = 3
−60α0 + 112α1 − 220α2 + 284α3 − 700α4 = 0
84α0 − 140α1 + 208.8α2 − 268α3 + (1.2927 × 103 )α4 = 0
−60α0 + 284.8α1 − 268α2 + 4.2391 × 103 α3 − 5820α4 = 0
α0 + α1 + α2 + α3 + α4 = 12
which give the following system of equations
1 -1 1 -1 1 α0 3
-60 112 -220 284 -700
α1
0
84 -140 208.8 -268 1.2927 × 103
α2
=
0
-60 284.8 -268 4.2391 × 103 -5820 α3 0
1 1 1 1 1 α4 12
solving this system of equations gives
α0 = 7.2919
α1 = 4.7793
α2 = 0.2650
α3 = −0.2793
α4 = −0.0569
with these values for αi s we obtain the approximate solution as
û(t) = 3 + 4.2320t + 6.4224t2 + 5.6288t3 − 7.2832t4 (46)
7 Discussion
Results:
Problem One:
We are considering the problem of solving
ü(t) + u̇(t) − 2u(t) = 0 (47)
10
with boundary conditions u(0) = 2 and u(1) = 1
And we obtained the following solution
û(t) = 2 − 2.7456t + 1.0736t2 + 2.1824t3 − 1.5102t4 (48)
We now compare with the exact solution to the problem (from other methods) which
is
11
Title: Graph of u(t) and û(t)
Title: Error Table for Problem One
t u(t) û(t) Error Rel. Error (%)
0 2 2 0 0
0.1 1.718350537 1.7382072 0.019856663 1.155565312
0.2 1.496263232 1.508864 0.012600768 0.842149111
0.3 1.323835977 1.3196216 0.004214377 0.318345861
0.4 1.193055723 1.1745024 0.018553323 1.555109472
0.5 1.097465947 1.0739 0.023565947 2.147305557
0.6 1.031895442 1.0145792 0.017316242 1.678100402
0.7 0.992237407 0.989676 0.002561407 0.258144571
0.8 0.97526987 0.9886976 0.01342773 1.376822029
0.9 0.978510052 0.9975224 0.019012348 1.94298958
1.0 1.000096695 0.9984 0.001696695 0.169653062
12
Problem Two:
We are considering the problem of solving
ü(t) − 5u̇(t) + 6u(t) = 0 (50)
13
Title: Graph of u(t) and û(t)
14
Title: Error Table for Problem Two
t u(t) û(t) Error Rel. Error (%)
0 3 3 0 0
0.1 3.561344709 3.49232448 0.069020229 1.938038426
0.2 4.210983885 4.13667328 0.074310605 1.764685086
0.3 4.955874893 4.94059968 0.015275213 0.308224341
0.4 5.800110238 5.89417728 0.094067042 1.62181472
0.5 6.742742045 6.97 0.227257955 3.370408564
0.6 7.774585646 8.12318208 0.348596434 4.483794379
0.7 8.873587613 9.29135808 0.417770467 4.708022109
0.8 9.998185723 10.39468288 0.396497157 3.965691052
0.9 11.07787252 11.33583168 0.257959155 2.328598334
1 11.99987936 12 0.000120636 0.001005309
8 Conclusion
In this reseach work, we have applied the LSM to solve a class second order dif-
ferential equation by using Chebychev basis functions as basis to approximate the
solution. This was achieved by the following objectives:
1. Discretize the ODE and formulation of residual and error function
2. Finding the coefficient that minimizes the Least Square error function
3. Obtaining an approximate solution for the ODE and conducting an error anal-
ysis
Moreover, discussion was made on the result obtained where the numerical error
were analyzed with the aid of graphs and an error table. Comparison was made
between the exact solution (obtained analytically) and the approximated solution
(obtain from our method) and it shows that there was an agreement between the
two solutions.
15
9 References
Bjorck, A. (2001): Least Square Problems. Encyclopedia of Optimization. Kluwer
Academic Publishers, Dordrecht, Holland. pp 160 - 170.
Bogdan, M. & Ioana M. (2002): Numerical Approximations Using Chebyshev Poly-
nomial Expansions. J. Phys. A: Math. Gen. 35, 731.
Calver, J. & Enright, W. (2017): Numerical methods for computing sensitivities for
ODEs and DDEs. Numer Algor (2017) 74: 1101. https://doi.org/10.1007/s11075-
016-0188-6.
Dormand, J.R. & Prince, P.J. (1980): A Family of Embedded Runge-Kutta For-
mulae. J. Comp. Appl. Math., 6, 19 - 26.
Lin, Y.; Enszer, J.A. & Stadtherr, M.A. (2008): Enclosing all Solutions of Two-
Point Boundary Value Problems for ODEs. Comput. Chem. Eng., 32, 17141725.
Pourmehran, O., Rahimi-Gorji, M.& Ganji, D. D. (2017): Analysis of Nano Fluid in
a Porous Media Rotating System Between Two Permeable Sheets Considering
Thermophoretic and Brownian Motion. Thermal Science. 2017,Vol. 21 Issue
5, pp2057-2067.
Strang, G. (2015): Differential Equations and Linear Algebra; Wellesley-Cambridge
Press: Wellesley, MA, USA; ISBN 9780980232790.
16