English · 简体中文
realviz — Real Analysis Visualizations
See Riemann and Lebesgue integration side by side. Measure theory for the eyes.
Real analysis is abstract until you see it.
realvizdraws the two great theories of integration on the same function — so the difference finally clicks.
What's the big idea?
Every calculus student learns Riemann integration first: chop the x-axis into
vertical strips, add up f(xᵢ)·Δx. Lebesgue integration flips it around — chop the
y-axis instead, group points by their function value, and weigh each slice by
the measure of its preimage: Σ yₖ·m(Eₖ).
| Riemann partitions the x-axis | Lebesgue partitions the y-axis |
|---|---|
| Same-width vertical strips | Same-height horizontal slices |
Sum: Σ f(xᵢ) · Δx |
Sum: Σ yₖ · m(Eₖ) |
| Strip color = x-position | Slice color = y-value |
Same total area. Completely different philosophy.
Where Riemann breaks: the Dirichlet function
D(x) = 1 if x is rational, 0 otherwise. Every sub-interval of [0,1] contains
both a rational and an irrational — so the upper sum is always 1, the lower sum
always 0, and the gap never closes. Riemann gives up.
Lebesgue measures the irrationals (1) and the rationals (0), and gets a clean
answer: ∫D = 0. This single function motivated a whole field.
Install
pip install realviz # once on PyPI
# today:
pip install -e .
Quick start
from realviz import compare_integrals, riemann_plot, lebesgue_plot
# Side-by-side comparison — the main event
compare_integrals(lambda x: x**2, 0, 1, n_partitions=15)
# Or inspect each method alone
riemann_plot(lambda x: x**2, 0, 1, n_partitions=10, method="midpoint")
lebesgue_plot(lambda x: x**2, 0, 1, n_partitions=10)
# The Dirichlet function — where Riemann fails, Lebesgue succeeds
from realviz import dirichlet_illustration
dirichlet_illustration()
Try it yourself
python examples/demo_compare.py # x² and sin(x), side by side
python examples/demo_dirichlet.py # the Dirichlet illustration
Design principles
- Safe by default — strict input validation: functions are sampled defensively,
partition counts are bounded, no
eval/exec/pickle, no network, no file I/O. - Pedagogical color — every strip is colored by what is being partitioned, so the axis-choice is visible at a glance.
- Zero magic — pure NumPy + Matplotlib, ~300 lines of core code, MIT licensed.
Roadmap
-
v0.1.0— Riemann vs Lebesgue integral comparison + Dirichlet illustration -
v0.2.0— Cantor set construction, step by step -
v0.3.0— Simple-function approximation of measurable functions -
v0.4.0— Convergence modes (pointwise, uniform, a.e., in L¹) -
v0.5.0— Vitali set and non-measurable sets (conceptual)
Development
git clone https://github.com/HunterZ549/realviz.git
cd realviz
pip install -e ".[dev]"
pytest # 53 tests, CI runs Python 3.9–3.12
License
MIT — see LICENSE.
Metadata
Release files for realviz 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| realviz-0.1.0.tar.gz | 536.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| realviz-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 547.0 kB
Release files / realviz-0.1.0.tar.gz
| Download URL | realviz-0.1.0.tar.gz |
|---|---|
| Size | 536.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fa75f69b7871cc843f432bc8f7a050fe6cd4fb7dc67367d799b8b57bc7067be
|
|
BLAKE2b-256 checksum How to use checksums |
a63c335165f67cc2ac7c31bf81a7622e1c56cd355fae38d300decb17be22cbce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / realviz-0.1.0-py3-none-any.whl
| Download URL | realviz-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48e2858ad841ed08b8332cad8ee9a2bba8c71d4d6f13b09227e81b1ed38a616e
|
|
BLAKE2b-256 checksum How to use checksums |
f09bfb2fd8d8505b2132e25280ede1136c4500d91f31d65ed9f78282d8a797bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|