Finite Difference Method - clarification of a term

In summary, the student is attempting to solve a second order boundary value problem and is unsure of how to account for an O(h^{2}) term in each of the finite difference approximations. They are also unsure of whether to keep the x_i terms as they are or in terms of h.
  • #1
Adyssa
203
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:

[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]

Homework Equations



as above.

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
 
Physics news on Phys.org
  • #2
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.
 
  • #3
OK thanks HallsOfIvy, I'll get to solving it!
 
  • #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.
 
  • #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.
 
  • #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.
 
  • #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.
 

1. What is the Finite Difference Method (FDM) and how does it work?

The Finite Difference Method is a numerical technique used to solve differential equations by approximating the derivatives with finite differences. It works by dividing a continuous function into discrete points and using the difference between these points to approximate the derivatives. This allows for the solution of complex problems that cannot be solved analytically.

2. What are the advantages of using the Finite Difference Method?

Some advantages of the Finite Difference Method include its simplicity and versatility, as it can be applied to a wide range of problems in various fields such as physics, engineering, and finance. It also does not require advanced mathematical knowledge or specialized software, making it accessible to a wider audience.

3. What are the limitations of the Finite Difference Method?

One of the main limitations of the Finite Difference Method is its accuracy, as the approximation of derivatives can introduce errors in the solution. It also requires a fine grid to achieve accurate results, which can be computationally expensive for complex problems.

4. Can the Finite Difference Method be applied to both linear and nonlinear problems?

Yes, the Finite Difference Method can be applied to both linear and nonlinear problems. However, the approach may differ depending on the type of problem and the method used to solve it.

5. How does the Finite Difference Method compare to other numerical techniques?

The Finite Difference Method is one of the oldest and most widely used numerical techniques for solving differential equations. It is relatively easy to implement and does not require specialized knowledge or software. However, it may not be the most accurate method and may require a fine grid for complex problems, which can be computationally expensive.

Similar threads

  • Calculus and Beyond Homework Help
Replies
2
Views
718
  • Calculus and Beyond Homework Help
Replies
6
Views
861
  • Calculus and Beyond Homework Help
Replies
18
Views
1K
  • Calculus and Beyond Homework Help
Replies
7
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
203
  • Calculus and Beyond Homework Help
Replies
10
Views
386
  • Calculus and Beyond Homework Help
Replies
9
Views
553
  • Calculus and Beyond Homework Help
Replies
2
Views
714
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
Back
Top