Finite Difference Method - clarification of a term

Click For Summary

Homework Help Overview

The discussion revolves around a second order boundary value problem involving numerical solutions of differential equations, specifically utilizing the finite difference method. The original poster is seeking clarification on the meaning of the O(h²) term in the context of finite difference approximations for derivatives.

Discussion Character

  • Exploratory, Conceptual clarification, Mathematical reasoning

Approaches and Questions Raised

  • The original poster attempts to understand the significance of the O(h²) term and its implications for error in their calculations. They also question whether to express x_{i} in terms of h for simplification in their equations.

Discussion Status

Participants have provided insights regarding the error associated with the finite difference approximations and the utility of Taylor series for estimating this error. There is an ongoing exploration of whether to simplify the x_{i} terms based on the uniform spacing of the grid, with some participants suggesting that it may be beneficial for programming purposes.

Contextual Notes

The original poster notes a gap in their knowledge regarding Taylor series, which may affect their understanding of the finite difference method. They also mention having a condensed computational math curriculum that may have led to missed foundational topics.

Adyssa
Messages
202
Reaction score
3

Homework Statement



I'm doing a class on Numerical Solutions of DE and I have my first assignment. The problem is stated:

Consider the following second order boundary value problem:

\epsilon \frac{d^{2}y}{dx^{2}} + \frac{1}{2+x-x^{2}} \frac{dy}{dx}-\frac{2}{1+x}y = 4sin(3x), y(0) = 2, y(2) = 1, \epsilon = 0.01, h = 2N, x_{i} = ih

We can approximate the derivatives at the N-1 interior points using the following finite difference approximations:

y'(x_{i}) = \frac{-y_{i-1} + y_{i+1}}{2h} + O(h^{2}) and y''(x_{i}) = \frac{y_{i-1} - 2y_{i} + y_{i+1}}{h^{2}} + O(h^{2})

Homework Equations



as above.

The Attempt at a Solution



I don't understand the meaning of the O(h^{2}) term for each of the finite difference approximations. I think it refers to the error but I don't know how to account for it in my workings.

As for solving the boundary problem, my next step is to sub in y'(x) and y''(x) to the equation and work out equations that I can use to form a tri-diagonal matrix and then compute the solution and plot it, I think I can do this part ok, we worked through a similar problem in class but it didn't contain this O(h^{2}) term
 
Physics news on Phys.org
It means that the error is no larger than a multiple of h^2. That is, the smaller you make the step the smaller the error is- on the order of h^2. You do NOT include that in the solution.
 
OK thanks HallsOfIvy, I'll get to solving it!
 
If you want a numerical estimate of the error, you should go back to the Taylor series used to derive the fininte difference approximations and compute those h^2 terms. This is a good thing to do if you're being extra careful and want to know these approximations are good enough.
 
Thanks Muphrid, I will do that. I haven't covered Taylor Series before, I think I have a bit of a gap in my knowledge. I'm doing a fairly condensed 'computational math' major for my comp sci degree and we skipped through calc I-III a bit too quickly.

I have one more question with regards to this boundary value problem. I've created my system of 3 equations but I'm not sure whether to keep the x_{i} terms as they are, or put them in terms of h which would allow me to simplify my equations a lot further. The x_{i} is the x term at each step h, so x_{i} = x_{0} + h = 0 + h

I think it's just a cosmetic operation, but it will also save me some computation when I program my solution. I'm just a bit unsure of the correct protocol to follow.
 
I think given a literal reading of the problem, x_0 = 0 and x_1 = h. In this problem, yes, you have an evenly spaced discretization and can simplify the equations accordingly, and this is a good thing to do--to take advantage of that property.

On the other hand, in general you won't be given an evenly spaced grid and it might be useful to keep the formulas general--just store the array of the actual x_i--so that the program could be reused if at some point you had to change the grid spacing. That might not be relevant for the assignment at hand, but on a practical level, knowing whether you will always have that uniform spacing or might want to change it, make it adaptible or what-have-you, is something I consider important.

Just a little bit about Taylor series: here's an example of calculating the error inherent to a finite-difference approximation. We can approximate, for example, y_{i+1} as y_i + h y'_i+ h^2 y''_i/2 + h^3 y'''_i/6 + O(h^4). Similarly, y_{i-1} = y_i - h y'_i + h^2 y''_i/2 - h^3 y'''_i/6 + O(h^4). Putting these into your formula for y'_i gives

y_i' \approx \frac{y_{i+1}- y_{i-1}}{2h} = \frac{2hy_i' + h^3 y_i'''/6}{2h} + O(h^3) = y_i' + \frac{1}{12} h^2 y_i''' + O(h^3)

The leading, lowest-order residual term is the h^2 y_i'''/12, and this is usually just considered the error itself.
 
Thanks again Muphrid! I did make a typo in my post, I should have written x_{i} = x_{0} + ih, I forgot the i term, but you've clarified the point for me anyway.

I'm about to get stuck into a different assignment for the day, but I will get back to maths again tomorrow and follow your example of the Taylor Series with my notes.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
6
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K