Finite difference terms for boundaries

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
0 replies · 2K views
Messages
1,816
Reaction score
33
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