↓ Skip to main content

Programming

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.
Sets in Python: set, frozenset, and Operations

Sets in Python: set, frozenset, and Operations

·2753 words·13 mins
Testing whether an element is in a set takes constant time on average, while in a list the time grows with its size. We will see how set theory becomes Python code: set and frozenset, comprehension, membership and inclusion, union, intersection and difference, hashing, and practical applications.
Infinite Series - Calculus with Python and SymPy

Infinite Series - Calculus with Python and SymPy

·8151 words·39 mins
A good part of the study of calculus is devoted to what are called infinite series. But what, exactly, are infinite series? And how are they related to the paradox of Achilles and the tortoise, one of the so-called paradoxes of Zeno of Elea, the Greek philosopher? What is the connection with quantum mechanics and the uncertainty principle? And where does Python come in? That is what we will find out in this article.
Integrals - Calculus with Python and SymPy

Integrals - Calculus with Python and SymPy

We have already written here on the site about the concepts of limit and derivative and how we can do the related computations with Python. Continuing our journey through calculus, in this article we will see how to work with integrals using SymPy and SciPy, Python packages. Along the way, we will pick up some notions of numerical methods.
Calculus with Python and SymPy: limits

Calculus with Python and SymPy: limits

·2289 words·11 mins
The concept of a limit is the most important one in the study of calculus. Many other concepts and ideas are built on the definition of a limit. In this article, we will see how to find the limit of functions using SymPy and how this package can be a teaching aid in the study of calculus.
Logic for Programmers

Logic for Programmers

·4174 words·20 mins
In programming, the word “logic” can refer to the process of designing an algorithm, to the conditional structures of the language, or to logical operators such as AND and OR. In the last two cases, we are within what is called mathematical logic.
Plots with SymPy and Matplotlib

Plots with SymPy and Matplotlib

·3611 words·18 mins
In this article we will see how to make plots with SymPy and Matplotlib. When people talk about SymPy, we usually focus on solving mathematical problems. But many forget that the library has some basic features for building plots, which we will see in this article.
Git and GitHub: The Definitive Collaboration Guide

Git and GitHub: The Definitive Collaboration Guide

·4495 words·22 mins
Git can be a somewhat scary tool for beginners because of its large number of commands and possibilities. In this article, we demystify the main aspects of Git so that you can collaborate on any project. The famous workflow of forks and pull requests, popularized by GitHub, is covered.
Installing Anaconda on Linux Mint 20

Installing Anaconda on Linux Mint 20

·1164 words·6 mins
You have probably heard of data science or machine learning. And you may also have heard of, or worked with, the R or Python languages. Today’s article is about Anaconda, a distribution that aims to make it easier to install and manage tools for these two languages, especially for scientific applications.