↓ Skip to main content

Welcome to Ciência Programada! This is a space where we explore the intersection of science and programming, offering resources, tutorials and discussions on how to apply programming techniques to solve scientific problems.

See the latest posts below for content updates. You can also search for specific topics using the search bar in the top right corner of the page. Or, if you prefer, you can browse the posts by category, tag or series using the links in the footer or in the previous sentence.

Project developed by Francisco Bustamante.

Recent

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.
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.
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.
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.