All posts by Noah William

A tutorial on Maxima

I’ve recently found out about a programming language called “Maxima”.

Maxima is a computer algebra system, which means that it can do algebra (as well as many other kinds of Math) for you. Here is a tutorial on how to use it.

Note that I admittedly haven’t read the tutorial as I already know how to use Maxima, but the tutorial is on its sourceforge page so I’m just going to trust it.

Prolog tutorial

I’ve recently found an interesting programming language called “prolog” (short for programming with logic”). It’s a language that can logically deduct things given some information. here is a tutorial for the language.

Also it’s important to note: the first few pages of this tutorial are assuming that you aren’t actually running their examples until later on. For those who (like me) want to run them: you should take the examples, put them into a file, and in the same directory as the file run
prolog [name of file]
Where “[name of file]” is the name of the file you saved the example in.

My proof that the Earth is at roughly the center of the known universe.

There seems to be some confusion about where the sun and Earth are located in the universe. I am going to attempt to clear up some confusion here by proving something mind blowing.

I realize of course many people are going to navigate away from this page when they see the title (and I can’t blame them) but if you’re willing to spend some time reading this I think you’ll agree with me at the end.

Before I show my proof, let’s talk about the history of our understanding of the universe. Those of you who have lived in cities your entire life might be surprised to learn that once (before bright city lights existed) the sky looked like this:

What you’re seeing in this video is a sped of recording of the night sky which was most likely recorded some place very far away from cities and artificial lights.

Once upon a time the night sky looked like this for everyone all the time. So hopefully it’s easy to understand why some people would be so fascinated by the night sky. Many people tried to keep careful track of the strange lights and objects in the sky.

Around the 16th century the church tried to convince everyone that the Earth was the center of the universe and that all these things that would move through the sky throughout the day and night were actually moving in giant circles around the Earth.

Their reasoning was that God created the entire universe just for mankind, and that therefore mankind was the most important thing in the universe. They thought that since we live on the Earth, and that one of the most interesting parts of the universe is its center, that this therefore meant that the Earth was the center of the universe.

However it was around this time that Galileo Galilei suggested that the sun was the center of the universe and that the Earth orbited the sun. This was his attempt to explain the strange movement of things in the sky that he had noticed.

It’s important to notice the wording here though “the sun is the center of the universe” This was proposed long before anyone fully grasped just how vast the universe truly is. This has confused a lot of people because the sun probably isn’t the center of the entire universe. For one thing it is in orbit around the galaxy and therefore is constantly moving.

Today we realize that the sun is the center of the solar system, and that (of course) the Earth orbits the sun in the solar system.

However consider this for a moment: the Earth is roughly 8 light minutes away from the sun. This is a very small distance in comparison to the vast distances of the entire known universe, so for the moment let’s pretend that the Earth was the center of the solar system (yes I realize this is scientific heresy, but it simplifies the math here).

The “known universe” is defined to be all of the universe that we can see from here on Earth. We can only see a certain distance into space because light from beyond the KNOWN universe has yet to reach us. Interestingly, regardless of which direction we look in the night sky, we will only be able to see the same distance outwards.

So imagine for a second that we started point our telescope in as many different directions as possible and were to somehow mark all of the points that we have seen through these telescopes. If we were to do this then each of those makers would be the same distance from the Earth. These markers would form some kind of shape, where the markers could only be placed on the surface of this shape.

It’s important to know that all points on the surface of a sphere are equally distant to the center of the sphere, and that a sphere is the only 3 dimensional shape that this is true for. Also the center of the sphere is the only point in it that is equally distant to all points on the spheres surface.

Since all of these markers are equally distant to the Earth, and are at the boundary of the KNOWN universe, this must mean that the known universe is a sphere and that the Earth is roughly at the center of it (“roughly” because the Earth isn’t actually at the center of the solar system).

Of course we are probably not the center of the actual universe; however we are at the center of the parts of the universe that we can actually see.

The Method of Least Squares

Recently I got into an on-line “debate” (yes I know, I should have known better, but let’s make this a learning experience for all; shall we?) about the world population. This got me thinking about how useful it would be to show people about “the method of least squares”.

The method of least squares is a mathematical tool used for analyzing scientific data. Here’s how it works: First we take our scientific data. This data could have come from any number of sources. Perhaps it came from some sensor that is used to measure something in a scientific experiment, or perhaps it is just some statistical data about the population; like this chart I made from data I got from here:
population-chart
Now it has been claimed before that the world population is going up exponentially, and who are we to argue with that? Besides it looks kind of like the beginning of exponential growth.
This means that the formula for the world population at any given time will look something kind of like this:
our-formula

Where y is the world population, x is the year, and a, b, and c are some kind of number that we don’t know the values of. Now what if we wanted to predict what the world population will be in the future?
Obviously we need a formula, and obviously we need to find out what a, b, and c are.
Let’s look at that graph again:
population-chart
Did you notice how it’s all bumpy and not a nice smooth curve like this one?
nice-curve
It seems reality doesn’t like making things nice and simple. The people who were finding this world population data probably made a few mistakes. Maybe some people lied on their tax forms (which is probably how they got much of this data) at certain points when their economies were bad, or maybe some people were accidentally counted twice.

In other words these results have some random error in them. This is unfortunately a problem that you face whenever you measure anything: you’re going to get inaccurate results. Whether you’re measuring world population, the charge on fundamental particles, or just distances with a ruler; the result will always be slightly off.

As technology improves measurement tools get more accurate, and don’t introduce as much error, but scientists still have to find some way to deal with this.

So how does one deal with this?
First what we do is take a formula that makes a graph that we think looks like our data. In this case it’s a second degree polynomial; AKA this thing:
our-formula

Now let’s replace a, b, and c with the Greek letter beta (because this will separate the true math nerds from the fakers). So it’ll look like this:
beta-substitute

This way we can maybe we can use this for other crazy formulas in the future like:

crazy-function

What we want to do is find the values of the betas this formula,
beta-substitute

fit the data as closely as possible. So what we could do this for every data point:
least-squares

In other words, every point in that graph is a pair of x and y values. For each one we take the y value, and subtract this from it
the-function
Where x is the x value for that particular pair. This way we’ll find the difference from the value that our theoretical formula gives us, and the actual value from the data. The trick here is to find the beta values that minimize the difference between the theoretical value and the actual value.

If we do this subtraction and squaring for every data point (or more realistically: have a computer do it for us), and add them all up we might end up with something that looks like this horrible mess:
horrible-mess
Not only does this give us what will be the error in our formula, but it’s also the phone number of Satan.

Now we can use calculus and algebra to find out what the betas should be. First we need
to take derivatives with respect to each of the beta variables (here‘s a bunch of Khan Academy videos on how to take derivatives, and what derivatives are. Be sure to look for the videos talking about some rule (like the “exponent rule”, or the “chain rule”)).

Next we set all those derivatives equal to zero.
In this case it’ll look like this crime against nature:
where-did-my-life-go-so-wrong
And yes this will be on the final exam (of your existence).

Next we can use back substitution to find out what the values are. Then that’s it! We’re done! And to think I’ve probably only lost two thirds of my audience when I showed the first picture!
population-formula
This formula will tell us the World population (in billions) at any given time ‘x’. Where ‘x’ is the year.
We can then use the quadratic formula to find out when the we will go extinct from overpopulation!

How to Stop Man in the Middle Attacks Part 3

You may have heard of something called a “trusted third party” before while using a web browser. This is usually used in reference to security certificates. This might seem confusing at first but it’s actually very simple.

The situation:
Alice and Bob have come up with a nearly fool proof way to stop people from eavesdropping on them. The last thing they need to do is get Alice’s public key to Bob through Mallory without Mallory modifying the key or replacing it.

To do this they use Trent. Trent has started his own business of securely transmitting public keys for people.

The idea is that everyone already has Trent’s public key. Alice simply needs to securely send her public key over to Trent and he’ll sign it with his public key and send it out to anyone who asks for it. This way Bob doesn’t need to have Alice’s public key ahead of time just to be able to create an encrypted connection with her.

How to Stop Man in the Middle Attacks Part 2

Continuing my explanation of how encrypted communications work, here’s how public/private key cryptography works: First Alice creates a special file called a “private key” using a public/private key algorithm (like this one) and then uses that file to generate a “public key”.

She gives the public key away to anyone she can and keeps the private key private (sort of like a password except that it’s too big to memorize and is therefore stored in a file). She can use the private key to encrypt a message in such a way that only the public key can decrypt it.

This is pretty useless for encryption since anyone who has the PUBLIC key can decrypt it; however it does solve our problem of detecting someone modifying our message.

Mallory can’t replace our message because if she does she will have to encrypt it with Alice’s private key (which she does not have), and Bob will know it wasn’t encrypted with Alice’s private key because it does not decrypt correctly. She also can’t modify Alice’s messages because that would logically mean making an entirely new message. This is called a “digital signature”.

Now Alice and Bob can exchange keys without Mallory being able to eavesdrop on them so long as Alice encrypts the number that she sends with her private key. Bob does not need to have a private key as he can actually encrypt the number he sends using Alice’s public key in such a way that only Alice’s private key can be used to decrypt it.

They can now communicate with each other safe from both Mallory and Eve; however this method requires “prior secrets”. In other words this method requires that Bob already have Alice’s public key. Alice can’t simply transmit her public key to Bob over the Internet because then Mallory could just replace it with her own. She also can’t sign her public key with her private key (creating a “self-signed certificate”) because Bob doesn’t have Alice’s public key to verify it with.

This is where “trusted third parties” come from.

How to Stop Man in the Middle Attacks Part 1

In an earlier post I linked to a video from Khan Academy that talked about how encrypted communication works. Unfortunately that video series left out a very important thing to be aware of about encryption, and that’s man in the middle attacks.
If you haven’t watched that video series I would recommend watching it again. Here‘s the link to the video again just in case you need it.

The story:
Now that Alice and Bob have figured out the Diffie-Hellman key exchange they are now safe from Eve’s eavesdropping; however Eve doesn’t give up easily and so she calls in her big sister Mallory. You see Alice and Bob are communicating over the Internet. When messages travel through the Internet they don’t just jump from point A to point B. Instead they jump from one computer to another until they reach their destination. Mallory in this analogy is one of the computers that their messages have to pass through.

Mallory can do some things that Eve can’t do. Eve could only read their messages; however all messages have to go through Mallory and thus she has the following abilities:
*Refuse to carry a given message (AKA “dropping packets”),
*Modify a message before delivering it,
*Create a message where she pretends to be Alice or Bob,
*and read the messages being sent through.

Since Mallory has these abilities she can do a “man in the middle attack”. Here’s how it works:
First Alice tries to do a Diffie-Hellman key exchange with Bob.

Alice begins her part of the key exchange thinking that she’s establishing an encrypted connection with Bob when in reality she’s forming an encrypted connection with Mallory and Bob does the same.
Now Mallory has an encrypted connection with Alice and Bob, and can eavesdrop on them by decrypting messages sent by Alice, reading them, encrypting them, and sending them to Bob.

To stop this from happening we need to find some way to either stop Mallory from altering/replacing the messages or detect when she does this.

Unfortunately it’s impossible to stop her from altering/replacing the message so instead we’ll have to detect her tampering with public/private key cryptography. I will go over public/private key encryption in the next post.

How to encrypt your home folder.

Here‘s a brief tutorial on how to encrypt all the files in your home directory so that they will need to be decrypted with a password at startup.

It works by using public and private key cryptography. Basically the computer generates a few small files that are used to encrypt and decrypt all your files as you access them. This encryption key is initially encrypted with your password since passwords are mainly just good for encrypting small files.

The advantage to this is that if you lose your computer no one will be able to get your personal files since they are encrypted. The cost to this is that it will slow your computer down by a small amount and if you delete this encryption key then you won’t be able to decrypt your files.

You should also probably create encrypted backups of all your files in case that key is deleted. For backing up your data I would recommend “backintime-gnome” and here is a tutorial on creating an encrypted partition for backing up your files to.