PDA

View Full Version : Chapter 6, Problem 7


dstefan
07-02-2008, 06:43 PM
Chapter 6, Problem 7

Consider the following second order ODE:
\label{ch6_ex7_ode}
3 x^2 y''(x) - x y'(x) + y(x) ~=~ 0, ~~\forall~ x \in [0,1];
\label{ch6_ex7_ode_bc}
y(0) = 1; \quad \quad y(1) = \frac{1}{2}

(i) Partition the interval [0,1] into n equal intervals, corresponding to nodes x_i = i h, i=0:n, where h=1/n}. Write the finite difference discretization of the ODE at each node x_i, i=1:(n-1), using central finite difference approximations for both y'(x) and y''(x).

(ii) If n = 6, we find, from the boundary conditions, that y_0 = 1 and y_6 = 1/2. The finite difference discretization scheme presented above will have five
equations can be written as a 5 by 5 linear system A Y = b. Find A and b.


Solution:

(i) By writing the ODE (\ref{ch6_ex7_ode}) at each interior node x_i = i h, i=1:(n-1), we obtain
\label{ch6_ex7_1}
3 x_i^2 y''(x_i) - x_i y'(x_i) + y(x_i) ~=~ 0, ~~\forall~ i = 1:(n-1).
We substitute the second order central difference approximations
y''(x_i) = \frac{y(x_{i+1}) ~-~ 2y(x_i) ~+~ y(x_{i-1})}{h^2} ~+~ O(h^2);
y'(x_i) = \frac{y(x_{i+1}) ~-~ y(x_{i-1})}{2h} ~+~ O(h^2)
into (\ref{ch6_ex7_1}), use the approximate values y_i for the exact values y(x_i), for i=0:n, and ignore the O(h^2) term. The following second order finite difference discretization of (\ref{ch6_ex7_ode}) is obtained:
3 i^2 h^2~\frac{y_{i+1} - 2y_i + y_{i-1}}{h^2} ~-~ i h ~\frac{y_{i+1} - y_{i-1}}{2h} ~+~ y_i ~=~ 0,
since x_i = i h, which can be written as
\label{ch6_ex7_2}
\left( 3 i^2 + \frac{i}{2} \right) y_{i-1} ~-~ (6 i^2 - 1) y_i ~+~ \left( 3 i^2 - \frac{i}{2} \right) y_{i+1} ~=~ 0, ~~\forall~ i = 1:(n-1)
From the boundary conditions (\ref{ch6_ex7_ode_bc}), we find that y_0 = 1 and y_n = 1/2.

(ii) For n=6, the finite difference discretization (\ref{ch6_ex7_2}) of the ODE (\ref{ch6_ex7_ode}) can be written in matrix form as A ~Y ~=~ b, where A is the following tridiagonal 5 by 5 matrix given by
A ~=~ \left( \begin{array}{ccccc}-5 & 2.5 & 0 & 0 & 0 \\13 & -23 & 11 & 0 & 0 \\0 & 28.5 & -53 & 25.5 & 0 \\0 & 0 & 50 & -95 & 0 \\0 & 0 & 0 & 0 & -149\end{array} \right)
and
Y ~=~ \left( \begin{array}{c} y_1\\y_2\\y_3\\y_4\\y_5\end{array} \right); b ~=~ \left( \begin{array}{c}3.5 \\0 \\0 \\0 \\72.5\end{array}\right).