# 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?

It is a rather big question you are asking and it has undoubtedly many answers. I'll try to give an as condensed answer as I can without going in to mathematical detail.

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.

It is often preferred to use a central FD scheme if possible, simply because they are more accurate than the one-sided versions. It is not uncommon to see that central schemes are used in the interior of a computational domain while one-sided FD schemes are applied near boundaries, interfaces and discontinuities.

As to the question "Finally, I try to solve problems with 0 intuition, can you enlighten me about what and how we do, please?". Rule number one: Always, always, always analyse the PDE before attempting any numerical approach! At least try to figure out if the PDE is well-posed or not. If not, don't expect any reliable result from your FD scheme (or any other numerical method for that matter).

Still, if well-posedness is the only information available about the PDE and we have decided to try finite differences, my general recommendation is to use FD schemes on Summation-by-Parts (SBP) form. Why? Because if the PDE is well-posed, the FD scheme will be stable, and without stability, again, don't expect a sensible result. SBP schemes use central FD schemes in domain interiors and progressively more one-sided schemes near boundaries. They are excellent examples of how the various FD formulas can be used together to satisfy certain needs.

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