# Numerical solutions of partial differential equations

I'm studying mathematical physics and working on numerical solutions of partial differential equations. I am having trouble understanding the way we solve partial dif. equations, e.g.,

$\frac{\partial u}{\partial t} = \frac{\partial^2 u}{\partial x^2}+\frac{2}{x}.\frac{\partial u}{\partial x}$

$\frac{\partial u}{\partial t}=\frac{\partial^2 u}{\partial x^2} \dots$

I mean for first and second order partial derivatives we use backward, forward or central difference formulas. In some solutions for a partial derivative like $\frac{\partial u}{\partial x}$ it is written by using forward difference and sometimes by using central difference formula. How do we decide which formula we should use? Do we decide by looking at the boundary conditions, e.g, Dirichlet, Neumann,$\dots$? Finally, I try to solve problems with $0$ intuiton, can you enlighten me about what and how we do, please?

The advection term, $\frac{\partial u}{\partial x}$ is always tricky part to solve PDE in a numerical way. It has a certain direction as you said.

There are many techniques to treat this term. Instead of explaining all things, I give you a link that has good notation and explanation.

Randall's lecture note in UW

As to the question "How do we decide which formula we should use [to approximate a derivative]?", first think of what a finite difference (FD) scheme does: It approximates the derivative of a function, $f$, at a certain point, $x_k$, on a discrete mesh by a weighted sum of function values at neighbouring points, $f(x_k), \, f(x_{k\pm 1}), \, f(x_{k\pm 2}), \dots$. Thus, to choose a FD scheme we must consider what function values we have available. This is generally different at different points on the mesh. For example, at the left boundary point $x_L$ of a 1D domain we only have access to information that is located further to the right, i.e. $f(x_L), \, f(x_{L+1}), \dots$. Here it may be suitable to use a forward difference formula. The converse is true at the right boundary point, $x_R$, and a backward formula may be the right choice.
Similar situations arise if there is some interface present in the domain, or if the solution has a discontinuity at a critical point, $x_c$, and we don't want to use information from one side of $x_c$ to approximate the derivative at a point on the other side.