Having trouble with discretization and boundry value problems

431 Views Asked by At

I have the following homework question:

Consider the boundary value problem $y''(x) + 5y'(x) − (2 + x)y(x) = e^x$ on $x ∈ (0, 2)$ with boundary conditions $3y(0) + y'(0) = 5$ and $y'(2) = 7$.

(a) Discretize the differential equation at a generic interior point $x_i$ using a standard grid.

(b) Discretize the left boundary condition$ 3y(0)+y'(0) = 5$ using FD2 on the standard grid.

(c) Discretize the right boundary condition $y'(2) = 7$ using BD2 on the standard grid.

I'm having some trouble figuring this out. My first instinct is to draw a 2x2 grid I should use a 1 dimensional line that looks something like this:

enter image description here

My best guess is that the middle point would be the interior point $x_i$ mentioned in (a). But I'm not really sure what to do from here.

I'm guessing that after I discretize the differential equation (not sure how to do that), I need to simply apply the second order forward and backward difference equations using the given boundry values in order to estimate xi? From my notes it looks like the FD2 and BD2 formulas are

$$FD2 = \frac{-3f(x) + 4f(x+h) - f(x+(2h))}{2h}$$

and

$$BD2 = \frac{3f(x) - 4f(x-h) + f(x-2h)}{2h}$$

but I'm not really too sure about BD2, something seems wrong with it. I may have copied the notes incorrectly.

Can I get some help with this problem?

1

There are 1 best solutions below

8
On BEST ANSWER

The central difference formula for second derivative is

$$f''(x_i)=\frac{f(x_{i+1})-2f(x_i)+f(x_{i-1})}{h^2}+O(h^2)$$

The central difference formula for first derivative is

$$f'(x_i)=\frac{f(x_{i+1})-f(x_{i-1})}{2h}+O(h^2)$$

Both of these formulas are second order. Since the error terms are $O(h^2)$.

So for an interior point $x_i$, plugging these into your equation:

$$\frac{f(x_{i+1})-2f(x_i)+f(x_{i-1})}{h^2}+5 \frac{f(x_{i+1})-f(x_{i-1})}{2h} -(2+x_i)f(x_i) = e^{x_i}$$

You can simplify this by $x_i=\frac{2i}{n}$ and $h=\frac{i}{n}$ since the length of the interval is $2$.

The boundary conditions can be done similarly. Notice that you'll have to use also second order formulas for the boundary conditions since you want to maintain the second order error for the whole system.

Your formula for 2nd order forward difference is correct. For backward difference, see my comments.

For an example of first order formula, the following is the forward difference formula for first derivative(notice this is just to give you an example of first order formula. You shouldn't use this in your problem):

$$f'(x_i)=\frac{f(x_{i+1})-f(x_i)}{h}+O(h)$$