Finite difference terms for boundaries

In summary, the finite difference formulae for derivatives are given by \frac{dy}{dx}_{i}=\frac{y_{i}-y_{i-1}}{\delta x} and \frac{d^{2}y}{dx^{2}}=\frac{y_{i-1}-2y_{i}+y_{i+1}}{\delta x^{2}}. For boundary terms, the formulae depend on the specific case. For the first derivative at the boundary, the formula is \frac{dy}{dx}_{0}=\frac{y_{1}-y_{0}}{\delta x}, and for the second derivative, it is \frac{d^{2}y}{dx^{2
  • #1
hunt_mat
Homework Helper
1,782
32
Hi,

We all know that the finite difference formulae for the derivatives are given by:
[tex]
\frac{dy}{dx}_{i}=\frac{y_{i}-y_{i-1}}{\delta x}
[/tex]
and
[tex]
\frac{d^{2}y}{dx^{2}}=\frac{y_{i-1}-2y_{i}+y_{i+1}}{\delta x^{2}}
[/tex]
What would be the formulae for the boundary terms? when i=1? I think I can show that:
[tex]
\frac{dy}{dx}_{0}=\frac{4y_{1}-y_{2}}{3}
[/tex]
Are there any other formulae? What about the second order derivative?

This is for a numerical code in matlab, I can use inbuilt functions but I want my code to run as fast as possible.

Mat
 
Physics news on Phys.org
  • #2
lab has some in-built functions for computing derivatives, for example, the 'gradient' function. This function uses a five-point stencil scheme to compute the derivatives, which gives more accurate results. The formula for the second order derivative is:\frac{d^{2}y}{dx^{2}}=\frac{-y_{i-2}+16y_{i-1}-30y_{i}+16y_{i+1}-y_{i+2}}{12\delta x^{2}}For the boundary cases, you can use forward or backward difference formulae depending on what you are trying to do. For example, if you want to approximate the first derivative at the boundary, you can use the formula:\frac{dy}{dx}_{0}=\frac{y_{1}-y_{0}}{\delta x}For the second derivative, you can use the formula:\frac{d^{2}y}{dx^{2}}_{0}=\frac{y_{2}-2y_{1}+y_{0}}{\delta x^{2}}Hope this helps!
 

Related to Finite difference terms for boundaries

1. What is a finite difference term for boundaries?

A finite difference term for boundaries is a mathematical representation of the difference between two adjacent data points in a finite difference approximation. It is used to calculate the boundary values of a function or system using a finite difference method.

2. How is a finite difference term for boundaries calculated?

A finite difference term for boundaries is calculated by taking the difference between two adjacent data points on the boundary and dividing it by the step size. This step size is the distance between each data point in the finite difference approximation.

3. What is the purpose of using finite difference terms for boundaries?

The purpose of using finite difference terms for boundaries is to accurately approximate the values of a function or system at the boundary points. It allows for the calculation of boundary values using a discrete set of data points, making it useful in numerical methods and simulations.

4. What are the limitations of using finite difference terms for boundaries?

One limitation of using finite difference terms for boundaries is that it assumes a constant step size and can be sensitive to changes in the step size. It also requires a large number of data points to accurately represent complex boundary conditions.

5. How do finite difference terms for boundaries differ from finite difference terms for interior points?

Finite difference terms for boundaries differ from finite difference terms for interior points in that they are calculated using data points on the boundary rather than within the interior of the system. The boundary points often have different boundary conditions that need to be taken into account when calculating the finite difference terms.

Similar threads

Replies
7
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
752
  • Programming and Computer Science
Replies
10
Views
1K
  • Differential Equations
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
18
Views
1K
  • Differential Equations
Replies
1
Views
2K
  • Differential Equations
Replies
1
Views
2K
  • Differential Equations
Replies
3
Views
530
  • Differential Equations
Replies
7
Views
2K
  • Differential Equations
Replies
5
Views
2K
Back
Top