↓ Skip to main content

From Symbol to Number

When symbolic mathematics reaches its limit, numerical mathematics takes over. This series goes through SciPy and NumPy, solving what SymPy cannot: equations with no closed-form solution, integrals with no antiderivative, derivatives from measured data, curve fits with uncertainty, systems of differential equations and the Fourier transform, always starting from concrete problems in physics, chemistry and engineering.

The articles are listed below, in the order they were written.

Polynomials with NumPy

Polynomials with NumPy

·3534 words·17 mins
Stored in float64, the coefficients of Wilkinson’s polynomial no longer return the roots 1 to 20: two of them become a complex pair. Before getting there, we look at roots, derivatives, integrals and division with numpy.polynomial, and at the coefficient-order trap.
Curve Fitting with NumPy

Curve Fitting with NumPy

·5574 words·27 mins
Experimental data rarely falls on a curve. We will see how NumPy fits polynomials to noisy data, what SymPy cannot do, why extrapolating is dangerous, and why Runge’s phenomenon comes from equally spaced nodes, not from high degree.
Numerical Integration with SciPy

Numerical Integration with SciPy

The Gaussian function has no elementary antiderivative, and that is a theorem of Liouville. When the antiderivative does not exist, or all you have is a table of measurements, the way forward is numerical: quad, trapezoid and Simpson, from scipy.integrate, with the care each one demands.
Optimization with SciPy

Optimization with SciPy

·6536 words·31 mins
Differentiating and setting the result to zero solves textbook optimization. With several variables, constraints, or a function without a tractable derivative, that calculation breaks down. We will see minimize, SLSQP and bounds from scipy.optimize, local minima, and global search with differential_evolution.