---
title: "Finite Difference Method"
type: concept
related: [Difference Equation, Finite Difference Method, Diffeq Intro]
source: https://www.jemoka.com/posts/kbhfinite_difference_method/
confidence: high
status: active
---

The Finite Difference Method is a method of solving partial Differential Equations. It follows two steps:
Develop discrete difference equations for the desired expression Algebraically solve these equations to yield stepped solutions https://www.youtube.com/watch?v=ZSNl5crAvsw
Follow Along We will try to solve:
\begin{equation} \pdv{p(t,x)}{t} = \frac{1}{2}\pdv[2]{p(t,x)}{x} \end{equation}
To aid in notation, let us:
\begin{equation} p(t_{i}, x_{j}) := p_{i,j} \end{equation}
to represent one distinct value of our function \(p\).
Let&rsquo;s begin by writing our expression above via our new notation:
\begin{equation} \pdv{p_{i,j}}{t}= \frac{1}{2} \pdv[2]{p_{i,j}}{x} \end{equation}
Great. Now, let&rsquo;s think about the left side and try to turn it into a difference eqn:
What exactly is&mdash;
\begin{equation} \pdv{p_{i,j}}{t} \end{equation}
as a finite difference? Well, it is just:
\begin{equation} \frac{p_{i+1,j}-p_{i,{j}}}{\Delta t} \end{equation}
What about second partials?
Well, what is&mdash;
\begin{equation} \pdv[2]{p_{i,j}}{x} \end{equation}
It is:
\begin{equation} \frac{\pdv{p_{i,j+1}}{x}- \pdv{p_{i,j}}{x}}{\Delta x} \end{equation}
Expanding the top expressions even more difference expressions:
\begin{equation} \frac{\frac{p_{i,{j+2}}-p_{i,{j+1}}}{\Delta x}- \frac{p_{i,{j+1}}-p_{i,{j}}}{\Delta x}}{\Delta x} \end{equation}
This equals to:
\begin{equation} \frac{\frac{p_{i,{j+2}}-p_{i,{j+1}} - p_{i,{j+1}}+p_{i,{j}}}{(\Delta x)^{2}} \end{equation}
Finally, substitute this into our expression, then solve for some \(p_{{i+1}, j}\) in terms of \(p_{i, ?}\). We will treat the entire &ldquo;row&rdquo; of \(p_{i,?}\) as our initial condition, then solve for the rest + propagate forward.
