Академический Документы
Профессиональный Документы
Культура Документы
Boundary-value Problems
Outline
This topic to approximating boundary-value problems
We will describe boundary-value problems (BVPs)
We will look at solutions with linear ordinary differential
equations (ODEs)
We will consider solutions for non-linear ODEs
This will require successive approximations using the secant
method
Using Matlab
These methods assume that the student has written the
initial-value problem solver pd45 with the signature
dp45( f, x_rng, u0, h, eps_abs )
which uses the Dormand-Prince method
If this routine is not available, you are welcome to use
the built-in Matlab routine ode45 which has the similar
signature
ode45( f, x_rng, u0 )
2nd-order ODEs
A boundary-value problem in one dimension is any 2ndorder ODE
F(x, u(x), u(1)(x), u(2)(x)) = 0
with two constraints
u(a) = ua
u(b) = ub
In general, we will look at functions of the form
u(2)(x) = f(x, u(x), u(1)(x))
2nd-order ODEs
Consider the corresponding initial-value problem for this
2nd-order ODE
F(x, u(x), u(1)(x), u(2)(x)) = 0
with two constraints
u(a) = ua
u(1)(a) = ua(1)
Here we specify the slope at the left-hand point x = a
2nd-order ODEs
Thus, a boundary-value problem could be restated as:
Given one initial condition u(a) = ua, what slope is required at that
initial point so that the solution to that initial condition passes
through the point (b, ub)?
(b, ub)
(a, ua)
2nd-order ODEs
We will consider two possible cases:
When the ODE is linear, and
When it is not
(b, ub)
(a, ua)
u 3 2.5
10
11
d
d
u
x
cu
x
q
x
u g x cu0 x r x u g x cu0 x
0
2 g
dx
dx
u g 2 x c u0 2 x q x u g 1 x cq x u0 1 x r x u g x cr x u 0 x
g(x)
u g 2 x q x u g 1 x r x u g x c u0 2 x q x u0 1 x r x u 0 x
g x c 0
g x
u 1 a 0
12
13
u 1 2 0
(b, ub)
u 2 x sin x u 1 x u x 0
u 2 0
(a, ua)
ug(x)
u 1 2 1
u0(x)
14
ug(x) + u0(x)
(a, ua)
ug(x)
ug(x) u0(x)
15
ub u g b
u0 b
u g a ua
u g 1 a 0
u0 a 0
u0 1 a 1
16
17
= w1(x)
= w2(x)
= w3(x)
= w4(x)
x sin x u 1 x u x 1
u 2 1.5
u 3 2.5
18
19
20
21
22
23
24
25
26
27
28
29
Secant Method
We will use the secant method for fining this root:
Suppose we are trying to find a root of a real-valued function of a
real variable err(s)
Suppose s1 and s2 are two initial approximations of the root
err(s)
s2
s1
30
Secant Method
We can find a better approximation of the root by finding
the interpolating straight line that passes through these
points
err(s)
s2
s1
31
Secant Method
The formula for this new point is
s3
s1 err s2 s2 err s1
err s2 err s1
err(s)
s3
s2
s1
32
Secant Method
In the first case, we considered linear ODEs
Essentially, what we are doing here is asking:
Given these two approximations,
what would our next approximation be if the ODE was linear?
err(s)
s3
s2
s1
33
Secant Method
Now, suppose we have s2 and s3, the next step is to use
these approximations to find the next approximation, s4,
s2 err s3 s3 err s2
and so on...
s
4
err s3 err s2
err(s)
s3
s2
s1
34
Secant Method
Thus, we will continue to iterate, using the secant
method at each step...
With any iterative numerical method, we must know
under what conditions we will:
Halt with success, and
Indicate a failure to find a solution
35
Secant Method
For the secant method, we must have two
approximations, s1 and s2
First, if |err(s1)| < |err(s2)|, we will swap s1 and s2
Were assuming that s2 is more accurate
36
Secant Method
We will iterate at most Nmax times:
With each iteration, we will approximate a new point s
If |s2 s| < step and |err(s)| < abs, we will assume we are finished
and we will return the value s (shooting, however, will take one
more step)
Otherwise, we will set s1 = s2 and s2 = s
37
38
are as follows:
s1 and s2 are the two approximations of the slopes
f is a function handle for the differential equation: u(2)(x) = f(x, u(x), u(1)(x))
[a, b] is a row vector defining the range on which we are approximating the
boundary-value problem
[ua, ub] is a row vector defining the boundary conditions:
u(a) = ua and u(b) = ub
h is the initial step size for the function dp45
abs is the parameter passed to dp45 and is also the parameter
used by the secant method
step is the parameter used by the secant method for the step size
Nmax is the parameter used by the secant method to define the
39
40
u 3 2.5
41
42
43
44
45
s1 = 3
s2 = 3.1
All others...
u6s(1,end)
Absolute
Error
3.1
3.326745004558498
2.498107476136670
1.893 103
3.323136496135223
2.500021288156047
2.129 105
3.323176635129875
2.500000003879338
3.879 109
3.323176642445732
2.499999999999991
7.105 1015
46
Hints
You will work with various values of s and err(s)
Instead of continually recalculating value err(s), just calculate
err1 = err_shot( s1 );
err2 = err_shot( s2 );
and when you calculate a new value of s, just use a simpler
expression with the variables s1, s2, err1 and err2 and then
immediately calculate
errs = err( s );
When you update s1 and s2, update err1 and err2
47
Summary
We have looked at using the function dp45 to
approximate a boundary-value problem
The shooting method converts a BVP into an IVP
For linear IVPs, we use the ODE and the homogeneous ODE
and find a linear combination of the two solutions
For non-linear IVPs, we use dp45 and the secant method to
guide us to an approximation
48
References
[1]
[2]
[3]
John H. Mathews and Kurtis D. Fink, Numerical Methods using Matlab, 4th
Ed., Prentice Hall, 2004, pp. 529-534.
[4]
49