Posts

New blog!!!

join the mathspp mailing list Pt En < change language My blog is being migrated to mathspp.com !! O meu blogue está a ser migrado para o meu novo site: mathspp.com !! &nbsp&nbsp- RGS join the mathspp mailing list

Verifying tautologies with Haskell

join the mathspp mailing list Pt En < change language A tautology is a formula that is true regardless of the logical value we attribute to the variables it contains. For example, the propositional formula $P \vee \neg P$ is always true, regardless of $P$ being true or false. But not every tautology is as simple as the one I just showed. For example, showing that $$(P \implies Q) \implies [(Q \implies R) \implies (P \implies R)]$$ is a tautology requires a bit more thought. But thinking is too tiring, so let us write a Haskell program that takes a formula and decides if the formula is a tautology or not! (By the way, said program is available in my GitHub ...) First we need to be able to represent a proposition and we will create a data type just for that. We will call our type "Prop", from proposition, from propositional logic. where we provided data constructors for all sorts of propositional formulas. The idea is that now the formula $P \vee \n

The formula that plots itself

Image
Pt En < change language By the end of this blog post I hope that you know how to make mathematical drawings and why the number $$N \approx 4.85845063618971342358209596 \times 10^{543}$$ is so special. Given a function $f(x, y)$, how can you use it to make a drawing? Well, we just imagine the whole plane as a white, clean grid, and then we fill with black the squares at the positions $(x,y)$ such that $f(x,y) > \frac12$. In a way, it is as if the function $f$ is telling us whether to use white or black, i.e. to leave the square empty ($0$) or filled in ($1$). (more rigorously, we divide the plane in unit squares, and we give each square the coordinates of its lower-left corner) If we take, for example, $f(x, y) = x + y$, then square $(0,0)$ would be white because $f(0, 0) = 0 < \frac12$ but the squares $(0, 1)$ and $(1, 0)$ would be black because $f(0, 1) = f(1, 0) = 1 > \frac12$. As another example, take $f$ to be this function: $$f(x, y) = \left

Pocket maths: mathy broccoli

Image
Pt En < change language This post is about showing you how mathematics is beautiful and how it occurs naturally in the world that is around us. In two previous posts ( here and here ) I talked about fractals. Today I am going to do the same thing, except now I will use broccoli as the example, instead of some weird set on the complex numbers! Here's two pictures of broccoli: which one is bigger? There's only two possible answers: Exhibit A is bigger Exhibit B is smaller right? WRONG ! Don't be fooled like Joey! Options 1 and 2 are the same... Going back to the matter at hand, which one is bigger? The right answer is exhibit A , but I don't really expect you to get that. The actual question is, how much bigger is A , when compared to B ? In fact, B was "removed" from inside A ! But they both look like perfectly fine broccoli, right? This is one of the properties of fractals: self-similarity. Fractals usually exhibit this ver

Generating natural-looking digits with neural networks

Image
Pt En < change language In this post I will show you how I got a neural network to write digits that look like they've been handwritten. In fact, the digits you can see in the first image of this post where generated by said neural network. The code that did all this is here . It all started when I read, some time ago, about this funny way in which you could use neural networks: you are going to train a neural network to take a vector of size $N$ as input, and you are going to teach your network to do nothing. That is, you are going to teach your neural network to behave as the identity function... but with a twist! If your input size is $N$, somewhere in the middle of the network you want to have a layer with less than $N$ neurons! If this happens, you can think that your vector $x$ that is going in, first has to be squeezed through that tight layer, and then it expands again to be the output of the network. If now you slice your network in half, the part of

Generating (better) random mazes

Image
Pt En < change language In this previous post I shared some code and animations of an algorithm that created random mazes. I shared it with you and I got some feedback on Facebook, saying that even the stupidly large mazes I gave you were really easy to solve (I think this link can show you what I am talking about). So it was about time I got you some new mazes! And this time, I don't think they are as easy to solve as the old ones. The mazes I am sharing today were created by code found in this GitHub repo . The README will tell you to run the wilson_generator.py file. You can also download the (windows) executable that is zipped inside the wilsonExe rar. (please notice that in both cases, you can use the wilsonconfig.ini file to change the size of the maze) The way our algorithm works is really simple. It will start a random walk on the top left corner of the window. Whenever the random walk intersects itself (creating a loop), it removes the loop from

Pocket maths: folding halves into thirds

Image
Pt En < change language I have folded a piece of paper in half hundreds of times in my life. And probably so did you. Folding a piece of paper in half is fairly easy: just bend the piece of paper until the corners meet, and then crease. That is it. And with this method one can also fold a piece of paper in $4$, in $8$, etc. We just have to successively divide the sections of the paper in half. But what if we wanted to fold a piece of paper into thirds, as in the picture above? Some people are good at doing that, but they don't really measure anything: they just do it approximately by looking at the paper and folding where it seems about right. I guess it goes without saying, but mathematicians don't like things to be "about right", they want them right... and even though I wasn't a mathematician, when I was a child I thought that maybe there was a way for me to successively fold different parts of the paper in half, until one of the creases w