Fundamentals / Numerical mathematics / Approximation and quadrature / Notebooks

Integrating an infinite endpoint with a finite table of samples

A density rises without bound near the edge of a specimen, yet the total inferred amount can be finite. Choose nodes that measure the edge contribution accurately. Derive the tanh–sinh transformation, split two different quadrature errors and detect when refining a grid can no longer answer the physical question.

Change parameters · Explore the workshop parameters

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.

Save notebook (.ipynb)

Python runs on this device. The first run loads the scientific libraries.

The optional OneSimulation calculation uses the local OneSimulation installation. Save this notebook to run that comparison in Jupyter.

Estimate the integral of x raised to minus alpha on [0,1]. The integrand is unbounded, yet its integral exists for alpha below one. Compare the physical midpoint grid with a double-exponential change of variable. All controls and calculations run with NumPy and Matplotlib.

Plot the transformed integrand and separate both errors

The midpoint rule in the original coordinate never evaluates zero. The transformed quadrature additionally concentrates nodes where the original slope diverges. Reducing the transformed step at fixed cutoff eventually leaves the omitted tail exposed.

Check a finite integral independently

A second substitution x = u raised to the power 1/(1−alpha) makes the integrand exactly constant. Try alpha 0.95 before increasing the cutoff. More nodes at fixed cutoff cannot replace the missing area beyond the window.

Check the retained window with an element quadrature

The exact finite-window target equals the full integral minus the two omitted tails. A local OneSimulation installation can measure this finite part by building a physical line mesh in the transformed variable and integrating at mapped Gaussian quadrature points of each element. This is a different sampling grid from the trapezoid. The analytical finite-window check runs in every environment.