Press "Enter" to skip to content

[NumPy] Reminder: use correct norms to evaluate orders of convergence

I wrote this blog post to remind myself of something.

When evaluating the order of convergence of numerical simulation results, we either use infinity norm and L2-norm. In practice, I usually only use L2-norm (unless for some specific numerical methods, infinity and L2 norms have different orders of convergence). But, if using Python and NumPy for the evaluation, be aware that the numpy.linalg.norm (and also scipy.linalg.norm) returns l2-norm, not L2-norm. Though the official documentation does show the equation used, I rarely and seriously read the documentation of this function. It’s just a norm calculation, what could be wrong? I thought.

Checking the order of convergence is an essential measure for the verification of a numerical simulation program. What happened to me is that I couldn’t get a theoretical order of convergence of one of my programs using L2-norm. I thought there might be a bug in the code, and I spent like one day debugging the code and found nothing. Suddenly I decided to use the infinity norm. It did give me a theoretical value. That’s when I first time seriously read the official documentation of numpy.linalg.norm

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.