1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Finite Difference Method - clarification of a term

  1. Jul 17, 2012 #1
    1. The problem statement, all variables and given/known data

    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:

    [itex]\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[/itex]

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

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

    2. Relevant equations

    as above.

    3. The attempt at a solution

    I don't understand the meaning of the [itex]O(h^{2})[/itex] 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 [itex]O(h^{2})[/itex] term
     
  2. jcsd
  3. Jul 17, 2012 #2

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    It means that the error is no larger than a multiple of [itex]h^2[/itex]. That is, the smaller you make the step the smaller the error is- on the order of [itex]h^2[/itex]. You do NOT include that in the solution.
     
  4. Jul 17, 2012 #3
    OK thanks HallsOfIvy, I'll get to solving it!
     
  5. Jul 17, 2012 #4
    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 [itex]h^2[/itex] terms. This is a good thing to do if you're being extra careful and want to know these approximations are good enough.
     
  6. Jul 19, 2012 #5
    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 [itex]x_{i}[/itex] terms as they are, or put them in terms of [itex]h[/itex] which would allow me to simplify my equations a lot further. The [itex]x_{i}[/itex] is the [itex]x[/itex] term at each step [itex]h[/itex], so [itex]x_{i} = x_{0} + h = 0 + h[/itex]

    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.
     
  7. Jul 19, 2012 #6
    I think given a literal reading of the problem, [itex]x_0 = 0[/itex] and [itex]x_1 = h[/itex]. 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 [itex]x_i[/itex]--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, [itex]y_{i+1}[/itex] as [itex]y_i + h y'_i+ h^2 y''_i/2 + h^3 y'''_i/6 + O(h^4)[/itex]. Similarly, [itex]y_{i-1} = y_i - h y'_i + h^2 y''_i/2 - h^3 y'''_i/6 + O(h^4)[/itex]. Putting these into your formula for [itex]y'_i[/itex] gives

    [tex]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) [/tex]

    The leading, lowest-order residual term is the [itex]h^2 y_i'''/12[/itex], and this is usually just considered the error itself.
     
  8. Jul 19, 2012 #7
    Thanks again Muphrid! I did make a typo in my post, I should have written [itex]x_{i} = x_{0} + ih[/itex], I forgot the [itex]i[/itex] 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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Finite Difference Method - clarification of a term
Loading...