How accurate is K-means clustering as predictor of subcategories in the metal-metalloid-nonmetal trend?

I started with a database containing some of the properties of the chemical elements: Atomic number, atomic weight, electronegativity, ionization potential, atomic radius, atomic volume, boiling point, covalent radius, density, heat of fusion, heat of vaporization, melting point, and specific heat capacity.  A quick...

Interactive Shortest-distance calculations on Triangulations

As a means to bring attention to my latest book, Mastering SciPy, I wrote a blog post summarizing some of the techniques illustrated in one of its chapters: Computational Geometry in Python. On that post, I created an example of computation of shortest distances between two vertices of the constrained conforming De...

Embedding (high quality interactive) plots and data into HTML documents with Bokeh

I am trying to learn a bit of Bokeh to embed plots and data into HTML documents. It looks simple enough, yet the results are pretty impressive. The example below, for instance (which is verbatim from bokeh’s own documentation), took a mere few lines of code in python.

Decanting Problems and Dijkstra's Algorithm (II)

In the previous post, Decanting Problems and Dijkstra’s Algorithm, we presented some scipy hackery to solve the Die Hard puzzle:

Decanting Problems and Dijkstra's Algorithm

Decanting problems (also known as jug-pouring problems) are a set of highly entertaining classical puzzles that require some liquid to be divided in certain proportions. The challenge comes from doing so without sophisticated measuring devices. We usually have only the aid of several jugs for this purpose. The ge...

Menger Sponges

I know it is hard to grasp, but it is mathematically viable: there are solids that require an infinite amount of material to construct, yet they have no volume! Of course, having infinite surface area makes it impossible to actually build these objects, but it is feasible to come up with reasonable approximations. ...

Searching for the SS Central America

On Tuesday, September 8th 1857, the steamboat SS Central America left Havana at 9 AM for New York, carrying about 600 passengers and crew members. Inside of this vessel, there was stowed a very precious cargo: a set of manuscripts by John James Audubon, and three tons of gold bars and coins. The manuscripts docum...

Computational Geometry in Python

This post is a simplified version of the accompanying notebook to chapter 6 of my upcoming book Mastering SciPy. Click anywhere on this box for more information.

Jotto (5-letter Mastermind) in the NAO robot

I would like to show how to code the NAO robot to beat us at Jotto (5-letter Mastermind) with python in Choregraphe. I will employ a brute force technique that does not require any knowledge of the English language, the frequency of its letters, or smart combinations of vowels and consonants to try to minimize the n...

Robot stories

Every summer before school was over, I was assigned a list of books to read. Mostly nonfiction and historical fiction, but in fourth grade there that was that first science fiction book. I often remember how that book made me feel, and marvel at the impact that it had in my life. I had read some science fiction b...

Advanced Problem #18

Another fun problem, as requested by Qinfeng Li in MA598R: Measure Theory

Areas of Mathematics

For one of my upcoming talks I am trying to include an exhaustive mindmap showing the different areas of Mathematics, and somehow, how they relate to each other. Most of the information I am using has been processed from years of exposure in the field, and a bit of help from Wikipedia.

More on Lindenmayer Systems

We briefly explored Lindenmayer systems (or L-systems) in an old post: Toying with Basic Fractals. We quickly reviewed this method for creation of an approximation to fractals, and displayed an example (the Koch snowflake) based on tikz libraries.

Some results related to the Feuerbach Point

Given a triangle \( \triangle ABC \), the circle that goes through the midpoints of each side, \( D, E, F \), is called the Feuerbach circle. It has very surprising properties:

An Automatic Geometric Proof

We are familiar with that result that states that, on any given triangle, the circumcenter, centroid and orthocenter are always collinear. I would like to illustrate how to use Gröbner bases theory to prove that the incenter also belongs in the previous line, provided the triangle is isosceles.

A nice application of Fatou's Lemma

Let me show you an exciting technique to prove some convergence statements using exclusively functional inequalities and Fatou’s Lemma. The following are two classic problems solved this way. Enjoy!


If a pyramid is 250 cubits high and the side of its base 360 cubits long, what is its seked?

Nezumi San

On January first, a pair of mice appeared in a house and bore six male mice and six female mice. At the end of January there are fourteen mice: seven male and seven female.

Ruthless Thieves Stealing a Roll of Cloth

Some thieves stole a long roll of silk cloth from a warehouse. In a bush far from the warehouse, they counted the length of the cloth. If each thief gets 6 hiki, then 6 hiki is left over, but if each thief takes 7 hiki then the last thief gets no cloth at all. Find the number of thieves and the length of the cl...

Stones, balances, matrices

We have four stones identical in size and appearance, but one of them is heavier than the rest. We have a set of scales (a balance): how many weights do we need to determine which stone is the heaviest?


OpArt is, by definition, a style of visual art based upon optical illusions. Let it be a painting, a photograph or any other mean, the objective of this style is to play with the interaction of what you see, and what it really is. A classical OpArt piece involves confusion by giving impression of movement, imposs...

So you want to be an Applied Mathematician

The way of the Applied Mathematician is one full of challenging and interesting problems. We thrive by association with the Pure Mathematician, and at the same time with the no-nonsense, hands-in, hard-core Engineer. But not everything is happy in Applied Mathematician land: every now and then, we receive the dis...

The ultimate metapuzzle

If you have been following this blog for a while, you already know of my fascination with metapuzzles. I have recently found one of the most beautiful examples of these riddles in this August’s edition of Ponder This, and following the advice of Travis, I will leave it completely open for the readers to give it a go...

The Cantor Pairing Function

The objective of this post is to construct a pairing function, that presents us with a bijection between the set of natural numbers, and the lattice of points in the plane with non-negative integer coordinates.

El País' weekly challenge

For a while now, the Spanish newspaper “El País” has been posing a weekly mathematical challenge to promote a collection of books, and celebrate a hundred years of their country’s Royal Mathematical Society.

Math Genealogy Project

I traced my mathematical lineage back into the XIV century at The Mathematics Genealogy Project. Imagine my surprise when I discovered that a big branch in the tree of my scientific ancestors is composed not only by mathematicians but also by big names in the fields of Physics, Chemistry, Physiology and even Anato...

Apollonian gaskets and circle inversion fractals

Recall the definition of an iterated function system (IFS), and how on occasion, their attractors are fractal sets. What happens when we allow more general functions instead of mere affine maps?

Toying with basic fractals

I will skip all the mathematical theory behind Fractals (dimensions, measures, etc) to focus directly into the description and implementation of some of the most basic examples. In this post, I will cover the ideas behind three classical techniques:

Basic examples of Maximum Likelihood Estimation

In this post, we see how to use maximum likelihood to estimate the best parameters for a few of the most common distributions.

Bertrand Paradox

Classically, we define the probability of an event as the ratio of the favorable cases, over the number of all possible cases. Of course, these possible cases need to be all equally likely. This works great for discrete settings, like dice rolls, card games, etc. But when facing non-discrete cases, this definitio...

Pick a point

Three problems in Euclidean Geometry with a common denominator:

Image Processing with numpy, scipy and matplotlibs in sage

In this post, I would like to show how to use  a few different features of numpy, scipy and matplotlibs to accomplish a few basic image processing tasks: some trivial image manipulation, segmentation, obtaining of structural information, etc.  An excellent way to show a good set of these techniques is by working thr...

Using tikz as an IGSE

An IGSE (Interactive Geometry Software Environment) is a computer program that helps you create dynamic diagrams in different Geometries (planar or 3D Euclidean, or even spherical or hyperbolic!). Click here and there to drop points, select two and construct the segment through them, or the circle centered in the f...

Interaction with Sage

The objective of this post is to show a few examples of interaction of sage with \( \LaTeX \) to produce results that, otherwise, would carry extensive writing and computation on the side. We will base it on the figure from the post Sequence of Right Triangles, where right triangles were constructed by halving one...

Application Packages

The problem at hand is the following: a few months before graduation, a Ph.D. candidate usually sends hundreds of application packages to different universities, research institutions and companies, with the intention of gaining a profitable job. We all agree that the process is certainly painful: gathering referen...

Borsuk-Ulam and Fixed Point Theorems

At any given moment on the surface of the Earth there are always two antipodal points with exactly the same temperature and barometric pressure. We can go even further: on each longitude (the North and South lines running from pole to pole) there will also be two antipodal points sharing exactly the same temperatur...

Sequence of right triangles

Consider the right triangle \(\triangle_1 \) with vertices at \((0,0) \), \((0,1) \), and \((1,1). \) Note that the angle at the origin is \(\frac{\pi}{4}. \) Use the hypotenuse of \(\triangle_1 \) as one of the legs of another right triangle, \(\triangle_2, \) with an angle of \(\frac{\pi}{8} \) at the origin,...

Points on a plane

A few puzzles about sets of points, and a nice conjecture following up one of those questions:

Chess puzzles

It is no surprise that the game of chess generates such an amount of mathematical puzzles. The amount of riddles of combinatoric nature alone should have the readers busy for a long while, no matter what their chess strength is. This is a selection of several puzzles designed with that purpose in mind.

Exact Expression

A nice problem to find a closed form for a rather challenging infinite series. Can you get it without using a computer?

What day of the week?

What day of the week was I born? Getting a calendar of that year could prove an impossible task, although if you are in front of a computer, there are *nix utilities that will do that for you. But seriously, who has access to a computer with unix or linux when the question pops?

The Cantor Set

Consider the unit interval in the real line, \( [0,1] \), and remove the middle third open subinterval \( (1/3, 2/3) \).  We have the closed set \( C_1 = [0,1/3] \cup [2/3,1] \), which is the union of two closed intervals.  In a second step, remove the middle third open subintervals of each of the previous two inter...

The Jordan Curve Theorem

The first time I faced this challenge was in the stage of my second Analysis course in College. The instructor needed this result for one of the proofs in class, stated it, and claimed that “you would need some more miles under your belts to be able to find—and understand—a proof of it.”  It goes like this:


These are from Smullyan’s “The Riddle of Scheherazade”. They are of mathematical nature, and serve for appetizers to a nice collection of logic riddles. They go like this:

Convex triangle-square polygons

Consider an infinite supply of cardboard equilateral triangles and squares, all of them with side length of one inch.  With these pieces, we desire to form convex polygons of different sides.  It is trivial to come up with this kind of polygons for sides 3, 4, 5 and 6. Construct examples of these convex p...

Probability and Divisibility by 11

Seven different playing cards, with values from ace to seven, are shaken in a hat, then taken out singly and then placed in a row.  What is the probability that this seven-digit number is divisible by 11?

What is the next number?

A classical problem involving ordered lists of numbers. What is the next term in the following sequence?

A geometric fallacy

A geometric fallacy is basically a geometric construction that leads to a false result.  I once found an obscure russian treatise on this matter (published by мир), that kept me entertained for weeks: Ya.S.Dubnov’s Errores en las demostraciones geométricas.  The edition I have is a decent translation into Spanish, m...

My oldest plays the piano!

Two old friends, Ernie and Bernie, bump into each other in the street.  It was more than twenty years since they last saw each other, so they decide to spend some time together in a nearby coffee shop, catching up.  At some point, Bernie asks the inevitable: "So, you got married?"

The Nonlocal-means Algorithm

The nonlocal-means algorithm [Buades, Coll, Morel] was designed to perform noise reduction on digital images, while preserving the main geometrical configurations, as well as finer structures, details and texture. The algorithm is consistent under the condition that one can find many samples of every image detail w...

The hunt for a Bellman Function.

This is a beautiful and powerful mathematical technique in Harmonic Analysis that allows, among other things, to prove very complicated inequalities in the theory of Singular Integral Operators, without using much of the classical machinery in this field.

Mechanical Geometry Theorem Proving

In 1977, Professor Wen-Tsun Wu succeeded in developing a method of mechanical geometry theorem proving. This method has been applied to prove or even discover hundreds of non-trivial difficult theorems in elementary and differential geometries on a computer in an almost trivial manner. Usign Ritt’s differential alge...