Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

If we are given an equation $-y''+b y'=0$ how would I construct a forward and backward difference for it. Would I write out the general Taylor series and then rearrange terms to get the needed equation on the LHS?

Thank you.

share|improve this question
    
You are aware of how derivatives are replaced with finite differences, no? Doesn't your book discuss the usual replacements done? –  J. M. Apr 15 '12 at 15:40

1 Answer 1

For 1st order finite difference you don't have to go all the way to Taylor series, start with

$f'(x) = \frac{f(x+h) - f(x)}{h}$ which is of course just the definition of a derivative.

Now if you have a gridsize of L, and you want to divide it evenly in n parts, then we have $ h = L/n$, and we can write

$f'(i) = \frac{f(i+h) - f(i)}{h}$

where $i = 1, 2, 3, ...n$. So you pretty much just replace $f'(i)$ with $\frac{f(i+h) - f(i)}{h}$ and you've got a forward finite difference scheme. Backward would be $\frac{f(i) - f(i-h)}{h}$, and centered would be $\frac{f(i+h) - f(i-h)}{h}$.

Now to move onto what the second order replacements should look like, we can again go back to the definition of a derivative. Since $f''(x) = \frac{d (f'(x))}{dx}$.

So $f''(x) = \frac{ f'(x+h) - f'(x)}{h}$. Now use the 1st order replacement to get

$f''(x) = \frac{(f(x+h +h) - f(x+h))/h - (f(x+h) + f(x))/h}{h}$. Then

$f''(i) = \frac{f(x+2h) - 2f(x+h) + f(x)}{h^2}$ is the 2nd order forward finite difference scheme. You can play the same game and get the centered and backward 2nd order scheme.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.