Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Global and local convergence

Open In Colab

This notebook is the figure for Global and local. We integrate two zonal-mean fields over μ=sin⁡ϕ∈[−1,1]\mu = \sin \phi \in [-1, 1], where the area of the sphere is uniform in μ\mu, with a global rule (Gauss–Legendre) and a local one (the composite trapezoid rule), and plot the error against the number of nodes NN.

What you’ll learn:

  1. A global rule converges spectrally on a smooth field, O(ρ−2N)O(\rho^{-2N}), while a local rule converges algebraically, O(h2)O(h^2) for the trapezoid rule.

  2. A kink (a sea-ice edge) brings the global rule down to an algebraic rate too.

  3. Both rules are the same call, rule.integrate(weights, samples), with different weights.

Python implementation: CPython
Python version       : 3.13.12
IPython version      : 9.10.0

numpy     : 2.4.4
jax       : 0.12.0.1
matplotlib: 3.11.2
integrix  : 0.0.5

Compiler    : Clang 21.1.4 
OS          : Linux
Release     : 6.8.0-1044-azure
Machine     : x86_64
Processor   : x86_64
CPU cores   : 16
Architecture: 64bit

Two fields on the sphere

The smooth field is a band of tropical moisture, fband(μ)=e−μ2/(2⋅0.32)f_\text{band}(\mu) = e^{-\mu^2 / (2 \cdot 0.3^2)}, whose integral comes from the error function. The rough field is a sea-ice fraction, fice(μ)=max⁡(0,∣μ∣−0.8)f_\text{ice}(\mu) = \max(0, |\mu| - 0.8), which is zero equatorward of about 53° and has a kink at each ice edge; its integral is exactly 0.04.

The sweep

Every estimate is the same call, I^N=∑nwnf(μn)\hat{I}_N = \sum_n w_n f(\mu_n), with the weights of one rule or the other.

<Figure size 1200x500 with 2 Axes>

On the smooth band the Gauss rule reaches the round-off of float64 at a few tens of nodes, while the trapezoid rule follows the N−2N^{-2} line. On the ice edge both rules follow it, and both are noisy, since the error depends on where the nodes fall relative to the kink. The dips in the trapezoid curve are the node counts that put a node on the edge at ∣μ∣=0.8|\mu| = 0.8, where every tile sees a straight line.

Summary

  • A global rule is spectral only while the integrand is smooth on the whole domain; one kink is enough to make it algebraic.

  • A local rule is algebraic everywhere, keeps its error in the tiles that hold the kink, and is exact when a tile edge sits on it.

  • Both are weights against samples, so switching rules is switching one array.