From dcf5c6caef9e610aeb30ee5d19bb206dfb2d4b4c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 24 Jun 2024 17:08:34 -0500 Subject: [PATCH] Document convergence functionality --- doc/convergence.rst | 4 ++++ doc/index.rst | 1 + pytools/convergence.py | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 doc/convergence.rst diff --git a/doc/convergence.rst b/doc/convergence.rst new file mode 100644 index 0000000..f4c2877 --- /dev/null +++ b/doc/convergence.rst @@ -0,0 +1,4 @@ +Testing convergence +------------------- + +.. automodule:: pytools.convergence diff --git a/doc/index.rst b/doc/index.rst index 1a1e9c4..f37ab97 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -8,6 +8,7 @@ Welcome to pytools's documentation! reference obj_array persistent_dict + convergence graph tag codegen diff --git a/pytools/convergence.py b/pytools/convergence.py index ead7f97..aa85c20 100644 --- a/pytools/convergence.py +++ b/pytools/convergence.py @@ -1,3 +1,11 @@ +""" +.. autofunction:: estimate_order_of_convergence +.. autoclass:: EOCRecorder +.. autofunction:: stringify_eocs +.. autoclass:: PConvergenceVerifier +""" + + import numbers from typing import List, Optional, Tuple @@ -7,9 +15,11 @@ import numpy as np # {{{ eoc estimation -------------------------------------------------------------- def estimate_order_of_convergence(abscissae, errors): - """Assuming that abscissae and errors are connected by a law of the form + r"""Assuming that abscissae and errors are connected by a law of the form + + .. math:: - error = constant * abscissa ^ (order), + \text{Error} = \text{constant} \cdot \text{abscissa }^{\text{order}}, this function finds, in a least-squares sense, the best approximation of constant and order for the given data set. It returns a tuple (constant, order). -- GitLab