A curve over [a, b] with eight midpoint rectangles filling the area beneath it. The loop multiplies the partition to thirty-two and then dissolves the bars into the solid region they were approximating. It plays as a pingpong, so the reverse leg walks the partition back down and the coarse case gets its moment too.
manim/riemann_sums.py
"""Riemann sums: midpoint rectangles multiplying toward the smooth area.
Render (the driver does this for every palette; these are for eyeballing):
P=/opt/homebrew/opt/python@3.11/bin/python3.11
ASSET_MODE=still $P -m manim -s -t -r 1600,1600 manim/riemann_sums.py RiemannSums
ASSET_MODE=motion $P -m manim -qh -r 1600,1600 manim/riemann_sums.py RiemannSumsLoop
"""
import numpy as np
from manim import (
DOWN,
LEFT,
UP,
FadeIn,
FadeOut,
NumberPlane,
The full Manim source and the rendered video come with a plan.