Solving ODE through least squares
FEM: Introduction
Suddhasheel Ghosh, PhD
Department of Civil Engineering
Jawaharlal Nehru Engineering College
N-6 CIDCO, 431003
Series on Advanced Numerical Methods
shudh (JNEC) Concepts MEStru2k1617 1 / 12
DiffEq1
Introduction to terminology
Given a differential equation
Ψ
d2
y
dx2
,
dy
dx
,y,x = 0, (1)
and the initial conditions,
F1
dy
dx
,y,x = a = 0 F2
dy
dx
,y,x = b = 0
So, given the points a and b, it is desired to find the solution of the
differential equation using the least squares technique.
shudh (JNEC) Concepts MEStru2k1617 2 / 12
DiffEq1
A second-order Boundary Value Problem
A boundary value problem is given as follows:
d2
y
dx2
+P(x)
dx
dy
+Q(x)y = R(x)
along with the conditions
y(x1) = A, y(xn+1) = B
shudh (JNEC) Concepts MEStru2k1617 3 / 12
Least squares method
Recalling least squares
Least squares method
Least squares means that the sum of squares has to be minimised. The
minimization will happen at the internal points.
shudh (JNEC) Concepts MEStru2k1617 4 / 12
Least squares method
Formulation I
Least squares method
From the earlier computations, for x = x1,
α0 +α1x1 +α2x2
1 +···+αnxn
1 = A, (2)
and for x = xn+1,
α0 +α1xn+1 +α2x2
n+1 +···+αnxn
n+1 = B, (3)
From an earlier computation, we have obtained:
n
i=0
αi i(i−1)xi−2
+ixi−1
P(x)+xi
Q(x) = R(x)
Thus, for every xj, j = 2,...,n, we have
(x) =
n
i=0
αi i(i−1)xi−2
+ixi−1
P(xj)+xi
Q(x) −R(x) (4)
shudh (JNEC) Concepts MEStru2k1617 5 / 12
Least squares method
Formulation II
Least squares method
For the least squares issue, we have to compute
F =
b
a
[ (x)]2
dx =
b
a
n
i=0
αi i(i−1)xi−2
+ixi−1
P(xj)+xi
Q(x) −R(x)
2
dx
Therefore,
∂F
∂αi
=
b
a
n
i=0
αi i(i−1)xi−2
+ixi−1
P(x)+xi
Q(x) −R(x) ×
i(i−1)xi−2
+ixi−1
P(x)+xi
Q(x) dx = 0
This, and the equations generated by the boundary conditions can be
solved by using Linear Algebra.
shudh (JNEC) Concepts MEStru2k1617 6 / 12
Least squares method
Example I
Least squares method
Problem: Use the least squares method to solve the following differential
equation:
d2
y
dx2
−y = x
Use the boundary conditions y(x = 0) = 0 and y(x = 1) = 0. (Desai, Eldho,
Shah)
Solution: Let us assume that the solution is in the cubic form
y = α0 +α1x+α2x2
+α3x3
.
shudh (JNEC) Concepts MEStru2k1617 7 / 12
Least squares method
Example II
Least squares method
Then, we will have
dy
dx
= α1 +2α2x+3α3x2
d2
y
dx2
= 2α2 +6α3x (5)
Substituting these into the given differential equation, we have
(2α2 +6α3x)−(α0 +α1x+α2x2
+α3x3
) =x
=⇒ −α0 −α1x+(2−x2
)α2 +(6x−x3
)α3 =x
We can therefore frame the error term as follows:
(x) = α0 −α1x+(2−x2
)α2 +(6x−x3
)α3 −x
shudh (JNEC) Concepts MEStru2k1617 8 / 12
Least squares method
Example III
Least squares method
And therefore
( (x))2
= α0 −α1x+(2−x2
)α2 +(6x−x3
)α3 −x
2
(6)
From the boundary conditions, we will have the following
α0 = 0 (7)
α0 +α1 +α2 +α3 = 0 (8)
Therefore, we have
α3 = −α2 −α1
Substituting these in (6), we have
F = ( (x))2
= −α1x+(2−x2
)α2 +(x3
−6x)(α1 +α2)−x
2
shudh (JNEC) Concepts MEStru2k1617 9 / 12
Least squares method
Example IV
Least squares method
Therefore,
∂F
∂α1
= −α1x+(2−x2
)α2 +(x3
−6x)(α1 +α2)−x x3
−7x
= α1(x3
−7x)+α2(x3
−x2
−6x+2)−x (x3
−7x) (9)
∂F
∂α2
= −α1x+(2−x2
)α2 +(x3
−6x)(α1 +α2)−x x3
−6x−x2
+2
= α1(x3
−7x)+α2(x3
−x2
−6x+2)−x x3
−x2
−6x+2 (10)
Now,
1
0
∂F
∂α1
dx = 0 =⇒ 13.6762α1 +6.6262α2 =−2.1333 (11)
1
0
∂F
∂α2
dx = 0 =⇒ 6.6262α1 +4.2762α2 =−1.05 (12)
shudh (JNEC) Concepts MEStru2k1617 10 / 12
Least squares method
Example V
Least squares method
Thus, we can obtain α1 and α2 using the following
13.6762 6.6262
6.6262 4.2762
α1
α2
=
−2.1333
−1.05
(13)
Thus giving α0 = 0,α1 = −0.1485,α2 = −0.0154, and α3 = 0.1639 (since
α1 +α2 +α3 = 0).
shudh (JNEC) Concepts MEStru2k1617 11 / 12
Least squares method
Thank you!
shudh (JNEC) Concepts MEStru2k1617 12 / 12

Solve ODE - BVP through the Least Squares Method

  • 1.
    Solving ODE throughleast squares FEM: Introduction Suddhasheel Ghosh, PhD Department of Civil Engineering Jawaharlal Nehru Engineering College N-6 CIDCO, 431003 Series on Advanced Numerical Methods shudh (JNEC) Concepts MEStru2k1617 1 / 12
  • 2.
    DiffEq1 Introduction to terminology Givena differential equation Ψ d2 y dx2 , dy dx ,y,x = 0, (1) and the initial conditions, F1 dy dx ,y,x = a = 0 F2 dy dx ,y,x = b = 0 So, given the points a and b, it is desired to find the solution of the differential equation using the least squares technique. shudh (JNEC) Concepts MEStru2k1617 2 / 12
  • 3.
    DiffEq1 A second-order BoundaryValue Problem A boundary value problem is given as follows: d2 y dx2 +P(x) dx dy +Q(x)y = R(x) along with the conditions y(x1) = A, y(xn+1) = B shudh (JNEC) Concepts MEStru2k1617 3 / 12
  • 4.
    Least squares method Recallingleast squares Least squares method Least squares means that the sum of squares has to be minimised. The minimization will happen at the internal points. shudh (JNEC) Concepts MEStru2k1617 4 / 12
  • 5.
    Least squares method FormulationI Least squares method From the earlier computations, for x = x1, α0 +α1x1 +α2x2 1 +···+αnxn 1 = A, (2) and for x = xn+1, α0 +α1xn+1 +α2x2 n+1 +···+αnxn n+1 = B, (3) From an earlier computation, we have obtained: n i=0 αi i(i−1)xi−2 +ixi−1 P(x)+xi Q(x) = R(x) Thus, for every xj, j = 2,...,n, we have (x) = n i=0 αi i(i−1)xi−2 +ixi−1 P(xj)+xi Q(x) −R(x) (4) shudh (JNEC) Concepts MEStru2k1617 5 / 12
  • 6.
    Least squares method FormulationII Least squares method For the least squares issue, we have to compute F = b a [ (x)]2 dx = b a n i=0 αi i(i−1)xi−2 +ixi−1 P(xj)+xi Q(x) −R(x) 2 dx Therefore, ∂F ∂αi = b a n i=0 αi i(i−1)xi−2 +ixi−1 P(x)+xi Q(x) −R(x) × i(i−1)xi−2 +ixi−1 P(x)+xi Q(x) dx = 0 This, and the equations generated by the boundary conditions can be solved by using Linear Algebra. shudh (JNEC) Concepts MEStru2k1617 6 / 12
  • 7.
    Least squares method ExampleI Least squares method Problem: Use the least squares method to solve the following differential equation: d2 y dx2 −y = x Use the boundary conditions y(x = 0) = 0 and y(x = 1) = 0. (Desai, Eldho, Shah) Solution: Let us assume that the solution is in the cubic form y = α0 +α1x+α2x2 +α3x3 . shudh (JNEC) Concepts MEStru2k1617 7 / 12
  • 8.
    Least squares method ExampleII Least squares method Then, we will have dy dx = α1 +2α2x+3α3x2 d2 y dx2 = 2α2 +6α3x (5) Substituting these into the given differential equation, we have (2α2 +6α3x)−(α0 +α1x+α2x2 +α3x3 ) =x =⇒ −α0 −α1x+(2−x2 )α2 +(6x−x3 )α3 =x We can therefore frame the error term as follows: (x) = α0 −α1x+(2−x2 )α2 +(6x−x3 )α3 −x shudh (JNEC) Concepts MEStru2k1617 8 / 12
  • 9.
    Least squares method ExampleIII Least squares method And therefore ( (x))2 = α0 −α1x+(2−x2 )α2 +(6x−x3 )α3 −x 2 (6) From the boundary conditions, we will have the following α0 = 0 (7) α0 +α1 +α2 +α3 = 0 (8) Therefore, we have α3 = −α2 −α1 Substituting these in (6), we have F = ( (x))2 = −α1x+(2−x2 )α2 +(x3 −6x)(α1 +α2)−x 2 shudh (JNEC) Concepts MEStru2k1617 9 / 12
  • 10.
    Least squares method ExampleIV Least squares method Therefore, ∂F ∂α1 = −α1x+(2−x2 )α2 +(x3 −6x)(α1 +α2)−x x3 −7x = α1(x3 −7x)+α2(x3 −x2 −6x+2)−x (x3 −7x) (9) ∂F ∂α2 = −α1x+(2−x2 )α2 +(x3 −6x)(α1 +α2)−x x3 −6x−x2 +2 = α1(x3 −7x)+α2(x3 −x2 −6x+2)−x x3 −x2 −6x+2 (10) Now, 1 0 ∂F ∂α1 dx = 0 =⇒ 13.6762α1 +6.6262α2 =−2.1333 (11) 1 0 ∂F ∂α2 dx = 0 =⇒ 6.6262α1 +4.2762α2 =−1.05 (12) shudh (JNEC) Concepts MEStru2k1617 10 / 12
  • 11.
    Least squares method ExampleV Least squares method Thus, we can obtain α1 and α2 using the following 13.6762 6.6262 6.6262 4.2762 α1 α2 = −2.1333 −1.05 (13) Thus giving α0 = 0,α1 = −0.1485,α2 = −0.0154, and α3 = 0.1639 (since α1 +α2 +α3 = 0). shudh (JNEC) Concepts MEStru2k1617 11 / 12
  • 12.
    Least squares method Thankyou! shudh (JNEC) Concepts MEStru2k1617 12 / 12