Download Lecture: 10

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Mathematical optimization wikipedia , lookup

Inverse problem wikipedia , lookup

Relativistic quantum mechanics wikipedia , lookup

Simplex algorithm wikipedia , lookup

Perturbation theory wikipedia , lookup

Mathematical descriptions of the electromagnetic field wikipedia , lookup

Routhian mechanics wikipedia , lookup

Navier–Stokes equations wikipedia , lookup

Computational fluid dynamics wikipedia , lookup

Computational electromagnetics wikipedia , lookup

Transcript
Lecture: 10
Boundary Value Problems of Ordinary Differential Equations

The lecture discusses deriving difference equations and solving the difference equations.
Introduction
In a one-dimensional boundary value problem of ordinary differential
equations, the solution is required to satisfy boundary conditions at both
ends of the one-dimensional domain. Definition of boundary conditions is
an important part of a boundary value problem. For example a thin metal
rod of length H with each end connected to a different heat source. If heat
escapes from the surface of the rod to the air only by convection heat
transfer, the equation for the temperature may be written as
A - d/dx k(x) d/dx T(x) + hc PT(x) = hc PT + As(x)
where T(x) is a temperature at distance x from the left end, A the constant
cross sectional area of the rod, k the thermal conductivity, P the perimeter
of the rod, hc the convection heat transfer coefficient, and T is the bulk
temperature of the air, S is the heat source. The boundary conditions are
T(0) = TL
T(H) = TR
where TL and TR are the given temperatures of the body at the left and right
ends, respectively.
To explain the principle of the method, we consider the linear equation
F(x, y ,y ,y) = 0
(1.1)
with the linear boundary conditions in the interval [a,b]
1[y(a), y(a)] = 0
(1.2)
2[y(b), y(b)] = 0
For the linear boundary problem Equation (1.1) and boundary conditions
may be written as
y + p(x) y + q(x) y = f(x)
(1.3)
0y(a) + 1y(a) = A
(1.4)
0y(b) + 1y(b) = B
where p(x), q(x), f(x) are known continues functions in the interval [a,b] ,
0, 1, 0, 1, A, B, are the given constant values, with
0 + 1  0 and
0 + 1  0.
2.
Finite
difference
equations
for
second-order
ordinary
differential equations
By dividing the domain into n equispaced intervals, we obtain a grid, where
the grid intervals are h = (b - a)/n and
pi = p(xi), qi = q(xi), fi = f(xi) for xi = x0 + ih (i = 1,2, ... , n-1; x0 = a, xn = b).
Applying the difference approximations
yi = (yi+1 - yi)/h, yi = (yi+2 - 2yi+1 + yi)/h2,
(2.1)
y0 = (y1 - y0)/h, yn = (yn - yn-1)/h
(2.2)
the difference equations for grid i are derived as
(yi+2 - 2yi+1 + yi)/h2 + pi (yi+1 - yi)/h + gi yi = fi (i = 0, 1, 2, ... , n -2)
(2.3)
0y0 + 1(y1 - y0)/h = A, 0yn + 1(yn - yn-1)/h = B
Applying the central difference approximations
yi = (yi+1 - yi-1)/2h, yi = (yi+1 - 2yi + yi-1)/h2,
(2.4)
the difference equations for grid i are derived as
(yi+1 - 2yi+1 + yi-1)/h2 + pi (yi+1 - yi-1)/2h + gi yi = fi (i = 1, 2, ... , n - 1)
(2.5)
0y0 + 1(y1 - y0)/h = A, 0yn + 1(yn - yn-1)/h = B
Example 2.1 Derive difference equations and find solution for the
following boundary value problem:
x2y + xy = 1,
y(1) = 0, y(1.4) = 0.5 ln2(1.4) = 0.0566
Assume that the grid spacing is 0.1.
Solution. The difference equations for i = 1 through 3 are as follows:
x2i (yi+1 - 2yi+1 + yi-1)/h2 + xi (yi+1 - yi-1)/2h = 1
or equivalently after some transformations
yi-1(2 x2i - h xi) - 4 x2i yi + yi+1(2x2i + hxi) = 2h2
A set of 5 equations is presented by
2.31y0 - 4.84 y1 + 2.53 y2 = 0.02
2.76y1 - 5.76 y2 + 3.00 y3 = 0.02
3.25y2 - 6.76 y3 + 3.51 y4 = 0.02
y0 = 0
y4 = 0.0566
From the solution we have
y1 = 0.0046, y2 = 0.0167, y3 = 0.0345
3. Solution algorithm for tridiagonal equations (Sweep method)
The solution algorithm for the tridiagonal equation
(yi+1 - 2yi+1 + yi-1)/h2 + pi (yi+1 - yi-1)/2h + gi yi = fi (i = 1, 2, ... , n - 1)
(3.6)
0y0 + 1(y1 - y0)/h = A,
0yn + 1(yn+1 - yn-1)/2h = B
is called the tridiagonal solution.
We write first n -1 equations in the form
yi+1 + miyi + kiyi-1 = 2h2fi/(2 + hpi) = i
(3.7)
where
mi = (2qih2 - 4)/(2 + hpi), ki = (2 - hpi)/ (2 + hpi)
Then we bring the equation to the form:
yi = ci(di - yi+1) (i = 1,2, ... , n - 1)
(3.8)
where the coefficients ci,di are for i = 1
c1 = (1 - 0h)/[m1(1 - 0h) + k11],
(3.9)
d1 = 2f1h2/(2 + p1h) + k1 Ah/(1 - 0h) = 1 - k1 Ah/(1 - 0h)
and for i = 2,3, ... , n
ci = 1/(mi - kici-1,
(3.10)
di = 2fih2/(2 + pih) - ki ci-1di-1 = I - ki ci-1di-
The solution is given next:
 Forward step
According to the Equations (3.7) we calculate mi , ki. Then we calculate c1,
d1 and using Equations (3.10) recurrently calculate ci, di ( i = 2, ... ,n).
 Backward step
Consider Equation (3.8) for i = n, i = n - 1 and last equation of the system
(3.6). They become
yn = cn(dn - yn+1)
yn-1 = cn-1(dn-1 - yn)
(3.11)
0yn + 1(yn+1 - yn-1)/2h = B
Calculate the solution for the last unknown by
yn = [2Bh - 1(dn - cn-1 dn-1)]/[ 20h + 1(cn-1 - 1/cn)]
(3.12)
Calculate yi (i = n -1, ... , 1) in decreasing order of i by using Equation
(3.8).
Calculate the solution for the first unknown by using next to the last
Equation (3.6)
y0 = (1y1 - Ah)/ (1 - 0h)/
Example 3.1 Consider the equation
y - 2xy -2y = -4x,
y(0) - y(0)= 0, 2y(1) - y(1)= 1
Assume that the grid spacing h is 0.1.
Solve the difference equation by the sweep method
Solution. The difference equations for i = 1 through 9 are as follows:
(yi+1 - 2yi + yi-1)/h2 - 2xi (yi+1 - yi-1)/2h -2yi = 4xi
and
y0 - (y1 - y0)/h = 0, 2y10 - (y11 - y0)/h = 1
After some transformations
yi+1 - (2 + 2h2)/(1 - xi h) yi + (1 + xih)/(1 - xih) yi-1= -4h2/(1 - xih) xi
Calculate the variables
mi = -(2 + 2h2)/(1 - xih), ki = (1 + xih)/ (1 - xih), i = -2h2/(1 - xih)
for (i = 0,1,2, ... , 10)
0 = 1, 1 = -1, 0 = 2, 1 = -1, A = 0, B = 1
Forward step. The results of calculating mi, ki, and i are summarized in
stated below Table . Then according to Equation (3.9) we find
c1 = -1.1/(2.040 1.1 -1.020) = -0.899, d1 = -0.004
and calculate ci, di according to Equation (3.10). For instance, for i = 2 it
yields
c2 = 1/(m2 -k2c1) = 1/(-2.060 + 1.040 0.899) = -0.899
d2 = 2 - k2c1d1 = -0.008 - 1.040 0.899 0.004 = - 0.012
mi
ki
i
ci
di
0.1
-2.040
1.020
-0.004
-0.899
-0.004
2
0.2
-2.061
1.040
-0.008
-0.889
-0.012
3
0.3
-2.083
1.062
-0.012
-0878
-0.023
4
0.4
-2.105
1.083
-0.017
-0.868
-0.039
5
0.5
-2.127
1.105
-0.021
-0.856
-0.058
6
0.6
-2.149
1.128
-0.025
-0.845
-0.081
7
0.7
-2.172
1.151
-0.030
-0.833
-0.109
8
0.8
-2.196
1.174
-0.035
-0.822
-0.142
9
0.9
-2.220
1.198
-0.040
-0.810
-0.180
10
1
-2.244
1.222
-0.044
-0.797
-0.222
i
xi
0
0.0
1
Backward step. According to Equation (3.12) determine
y10 = (0.2 -0.222 - 0.810 0.180)/(0.4 + 0.810 - 1/0.787) = 3.73
Then define yi ( i = 9, 8, ... , 1) according to Equations (3.8):
y9 = c9(d9 - d10) = -0.810(-0.18 -3.73) = 3.17
y8 = c8(d8 - d9) = -0.822(-0.14 -3.17) = 2.72
and so on
y7 = 2.36, y6 = 2.06, y5 = 1.81, y4 = 1.60, y3 = 1.41, y2 = 1.26, y1 = 1.13
Finally, according to (3.13)
y0 = -1.13/-1.1 = 1.03
4. Boundary value problem of nonlinear second-order ordinary
differential equations
An ordinary differential equation is non linear if the unknown appears in a
nonlinear form, or if its coefficient(s) depends on the solution. Solution
methods for nonlinear boundary value problems require iterative
applications of a solution method for linear boundary value problems. We
note some peculiar aspects of non linear boundary value problems. First,
unlike a linear boundary value problem, existence of the solution is not
guaranteed. Second, a nonlinear boundary value problem can have more
than one solution. Indeed, different solutions may be obtained for different
initial guesses for an iterative algorithm.
Two general methods will be discussed concerning a nonlinear equation
(diffusion equation) given by
-y + 0.01 y2 = exp(-x), 0 < x < H
(4.1)
y(0) = y(H) = 0
Successive substitution. Equation (4.1) is now rewritten as
-y + (x) y2 = exp(-x)
(4.2)
where
(x) = 0.01y(x).
The method proceeds as follows:
(a) Set (x) to an estimate, for example (x) = 0.01.
(b) Solve Equation (4.1) numerically as a linear boundary value problem
(since  is fixed, the equation is linear).
(c) Revise (x) = 0.01y(x) with the updated value of y(x) from (b).
(d) Repeat (b) and (c) until y(x) in two consecutive solutions agree within a
prescribed tolerance.
Newton’s method. Suppose an estimate for y(x) denoted by (x) is
available. The exact solution may then be expressed as
y(x) = (x) + (x),
(4.3)
where (x) is a correction for the estimate. Introducing Equation (4.3) into
(4.1) gives
- + (0.01)[2  + ()2] =  - 0.012 + exp(-x)
Ignoring the second order term ()2 yields
(4.4)
- + 0.02    - 0.012 + exp(-x)
(4.5)
which may be solved as a linear boundary problem. An approximate
solution for Equation (4.1) is then obtained by (x) + (x). The solution
may be further improved by repeating the procedure.
5. Galerkin’s method
Galerkin’s method let us an opportunity to find an analytical approximate
solution. Consider linear value problem (1.3), (1.4). After denoting it
becomes
L[y] = y + p(x) y + q(x) y
a = 0y(a) + 1y(a)
(5.1)
b = 0y(b) + 1y(b)
Let us given functions of x, called the basis functions
u0(x), u1(x), ... ,, un(x), ... ,
(5.2)
on the interval [a,b], which satisfy the following conditions:
1. The system (5.2) is the orthogonal one, that is
b

ui(x) uj(x)dx = 0 for i  j
a
(5.3)
b

a
u2i(x)dx  0
2. The system (5.2) is a complete system, that means there is no one another
function not equal zero, which could be orthogonal to all functions ui(x).
3. To construct an orthogonal set of the functions, the function u0(x) is
ordered to satisfy not uniform boundary conditions
a = A
(5.4)
b = B
and the functions ui(x) (i = 1,2, ... , n) are ordered to satisfy homogeneous
or uniform boundary conditions
a[ui]= b[ui] = 0 (i = 1,2, ... , n).
(5.5)
Solution of Equations (1.3), (1.4) can be written as
n
y(x) = u0(x) +

ciui(x).
(5.6)
i 1
Define the residual function as
n
R(x, c1, c2, ... , cn ) = L[u0] +

ci L[ui] - f(x).
(5.7)
i 1
We have to find the coefficients ci according to the following minimum
condition
b

a
R2(x, c1, c2, ... , cn )dx = min
(5.8)
It can be shown that we can satisfy this condition if the residual function is
orthogonal to all basic functions ui, namely
b

uk(x)R2(x, c1, c2, ... , cn )dx = 0 (k = 1,2, ... , n)
a
or in the form
n
b
i 1
a
 ci 
b
uk(x)L[ui]dx =

uk(x){f(x) - L[u0]}dx.
(5.9)
a
Finally, the solution for ci is obtained from the system of linear algebraic
equations.
Example 5.1. Consider the equation
y - y cos x + y sin x = sin x,
(5.10)
with boundary conditions
y(-) = y() = 2.
(5.11)
Solve the difference equation by Galerkin’s method.
Solution. Define the basic function for i =0 through 4 as follows:
u0 = 2, u1 = sin x, u2 = cos x = 1, u3 = sin 2x, u4 = cos 2x - 1
Function u0 satisfies the boundary condition (5.11), and the rest satisfies
zero boundary conditions. The unknown solution of the equation can be
written as
4
y(x) = u0(x) +

i1
ciui(x)
(5.12)
We define L[ui] (i = 0,1,2,3,4) :
L[u0] = 2 sin x
L[u1] = -sin x - cos 2x
L[u2] = -sin x - cos x + sin 2x
L[u3] = -1/2 cos x - 4 sin 2x -3/2 cos 3x
L[u4] = -1/2 sin x - 4 cos 2x + 3/2 cos 3x
f(x) - L[u0] = - sin x
We calculate the coefficients of the system (5.9) according to the following
designations
b
aik =
b

uk(x)L[ui]dx, bk =
a

uk(x){f(x) - L[u0]}dx
a
and taking into account the orthogonality of the given set of trigonometric
functions we obtain the computed values:

b1 = -  sin2 x dx = - , b2 = b3 = b4 =0


a11 = -  sin2 x dx = - , a12 = , a13 = 0, a14 = -/2


a21 = 0, a22 = -  cos2 x dx = - , a23 = -/2, a24 = 0


a31 = 0, a32 = -  sin2 2x dx = , a33 = -4, a34 = 0


a41 = -  cos2 2x dx = -, a42 = 0, a43 = 0, a44 = - 4

Reduction yields four equations:
c1 - c2 +
c1
0.5c4 = 1
c2 + 0.5c3
=1
c2 -
=1
4c3
+ 4c4 = 1
The solution gives
c1 = 8/7, c2 = c3 =0, c4 = -2/7
Therefore, we get
y  2 + 8/7 sin x + 4/7 sin2 x
6. Collocation method
The solution of Equations (1.3), (1.4) can be written as
n
y(x) = u0(x) +

ciui(x)
(6.1)
i 1
where ui(x) ( i = 0,1, ... , n) is the system of linearly independent functions
meeting the conditions (5.4), (5.5).
It will be necessary that the residual function
n
R(x, c1, c2, ... , cn ) = L[y] - f(x) = L[u0] +

i 1
ci L[ui] - f(x)
vanishes on some set of collocation points x1, x2, ... , xn in the interval
[a,b].
Moreover, the number of the points is equal the number of the coefficients
ci .
Then we got the system of equations
R(x1, c1, c2, ... , cn ) = 0
R(x2, c1, c2, ... , cn ) = 0
...
R(xn, c1, c2, ... , cn ) = 0
Exercises
1. Consider the equation
y + 2xy +2y = 4x,
y(0) = 1, y(0.5) = e-0.25 + 0.5 = 1.279
Assume that the grid spacing h is 0.1.
Solve the difference equation by the sweep method
2. Consider the equation
y + y + x = 0
with boundary conditions
y(0) = y(1) = 0
Solve the difference equation by Galerkin’s method.
Define the basic functions for i =0 through 2 as follows:
u0 = 0, u1 = x(1-x), u2 = x2(1-x).
3. Consider the equation
y + (1 + x2)y + 1 = 0
with boundary conditions
y(-1) = y(1) = 0.
Solve the difference equation by collocation method.
Define the basic functions for i =0 through 2 as follows:
u0 = 0, u1 = 1-x2, u2 = x2(1-x2).
Use collocation points x0 = 0, x1 = ½.