.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_build/auto_examples/convergence/Integration_on_segment.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__build_auto_examples_convergence_Integration_on_segment.py: Convergence analysis of integration methods on segment ====================================================== .. GENERATED FROM PYTHON SOURCE LINES 7-8 Evaluation of relative quadrature error with the following parameters: .. GENERATED FROM PYTHON SOURCE LINES 8-27 .. code-block:: Python fun_names = [ "exp", ] methods = [ 'Gauss', 'Radau_I', 'Radau_II', 'Lobatto_III', ] # all_nsteps = range(2,11) all_nsteps = [5] refinement_lvl = np.array(range(1,100)) # refinement_lvl = np.array([2**i for i in range(18)]) .. GENERATED FROM PYTHON SOURCE LINES 93-94 The following plots give the measured relative error as a function of the number of quadrature subintervals .. GENERATED FROM PYTHON SOURCE LINES 94-98 .. code-block:: Python plt.show() .. image-sg:: /_build/auto_examples/convergence/images/sphx_glr_Integration_on_segment_001.png :alt: Absolute error on integrand exp :srcset: /_build/auto_examples/convergence/images/sphx_glr_Integration_on_segment_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 142-144 The following plots give the measured convergence rate as a function of the number of quadrature subintervals. The dotted lines are theoretical convergence rates. .. GENERATED FROM PYTHON SOURCE LINES 144-149 .. code-block:: Python plt.show() .. image-sg:: /_build/auto_examples/convergence/images/sphx_glr_Integration_on_segment_002.png :alt: Approximate convergence rate on integrand exp :srcset: /_build/auto_examples/convergence/images/sphx_glr_Integration_on_segment_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 212-218 We can see 3 distinct phases on these plots: * A first pre-convergence phase, where the convergence rate is growing towards its theoretical value. the end of the pre-convergence phase occurs for a number of sub-intervals roughtly independant of the convergence order of the quadrature method. * A steady convergence phase where the convergence remains close to the theoretical value * A final phase, where the relative error stagnates arround 1e-15. The value of the integral is computed with maximal accuracy given floating point precision. The approximation of the convergence rate is dominated by seemingly random floating point errors. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.666 seconds) .. _sphx_glr_download__build_auto_examples_convergence_Integration_on_segment.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Integration_on_segment.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Integration_on_segment.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_