7
$\begingroup$

I want to approximate $uu'$ with a finite difference. On the one hand, it seems to be $$(uu')_i=u_i\frac{u_{i+1}-u_{i-1}}{2\Delta t}=\frac{u_iu_{i+1}-u_iu_{i-1}}{2\Delta t}$$ On the other hand, $$(uu')_i=\left(\frac{d}{dx}\frac{u^2}{2}\right)_i=\frac{u^2_{i+1}-u^2_{i-1}}{4\Delta x}$$ I might be wrong but I think that they both have truncation error $\mathcal{O}(\Delta x)^2$. Which of these finite differences should I use?

$\endgroup$
6
  • $\begingroup$ Unfortunately this is going to be somewhat dependent on the context. Do you have a particular problem in mind? $\endgroup$ – Kyle Mandli Jan 10 at 14:26
  • $\begingroup$ @KyleMandli E.g. Kuramoto-Sivashinsky $u_t=-uu_x-u_{xx}-u_{xxxx}$, $x\in[0,L_x]$, periodic bc but I would like to know how to approach this in general to be able to deal with other non-linear pde $\endgroup$ – Vladislav Gladkikh Jan 11 at 1:28
  • $\begingroup$ I don’t think both formulas have the same truncation error. In fact, in your first formula you assume that $u$ is constant in the range $[x-\Delta x,x+\Delta x]$ which is not necessarily a good approximation. In fact, this approximation is just a zeroth order approximation. I think better approximation is using trapezoidal rule to take $u$ equal to $\frac{u_{i-1}+u_{i+1}}{2}$ in that range which brings you to your second formula. My final conclusion is that your second formula is more accurate than the first formula and has lower truncation error or its order of accuracy is higher. $\endgroup$ – Alone Programmer Jan 11 at 3:23
  • 4
    $\begingroup$ Both are second order, but truncation errors will be different. Second one is conservative, use that if you think conservation is important for your problem. $\endgroup$ – cfdlab Jan 11 at 3:44
  • $\begingroup$ @cfdlab has this right: You have to think about what the term means and then discretize accordingly. Here, you are probably thinking of it as a flux, so you will want to choose a conservative way to discretize. $\endgroup$ – Wolfgang Bangerth Jan 11 at 16:29
2
$\begingroup$

There is really no such thing as a good finite difference equivalent to an operator. In the earliest days of scientific computing, the thought was that each differential operator would be replaced by some finite difference expression, and that finite difference operator would be the most accurate one available, usually a central difference.

I believe that the issue was first stated properly by Brian Spalding

"There is no best formulation for a first-derivative or second-derivative expression in isolation; it is the combination of the first and second order derivatives, as they appear in a particular differential equation, that require to be represented by an algebraic expression" (Spalding, D.B., 1972. A novel finite difference formulation for differential expressions involving both first and second derivatives. International Journal for Numerical Methods in Engineering, 4(4), pp.551-559.)

This is far more general than just in the context of advection-diffusion equations in which it was made. It applies to ODEs and PDEs of any kind. What matters is not the error in each term, but the error in the entire combination. This is sometimes referred to as error cancellation. It is surprising that, almost fifty years later, this is still not recognised by some communities.

It must also be stressed that accuracy is not the only property required. Stability, conservation, upwinding and behavior at boundaries must also be taken into account, and may sometimes be in conflict. Efficiency (in various senses) and ease of coding are also important.

There is a shortage of books dealing with this, because most authors write from within thir own specialization and its own traditions. However, techniques for investigating this kind of question do exist, such as dispersion analysis and "equivalent equation" analysis. But in the broadest context this is still a research problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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