August 31, 2016

Can you explain how to use PID controller to follow that path?

0 comments
I few months ago I wrote an article about the Hybrid A Star pathfinding algorithm for self-driving cars. It turned out to be a popular article, and someone asked in the comments section: "Can you explain how to use PID controller to follow that path?" And the answer is: yes I can!

PID controller is a technique to minimize an error you have. If you have a self-driving car, this error is the length of the difference between the car's actual position and the position it should have. This error is called Cross Track Error, or just CTE:


The math is simple and you just need a few lines of code to make it work, but the technique is not commonly known among those who haven't taken a course in control technology. I took a course in control technology, but I forgot about the PID controller, only to rediscover it last year when I took a course in self-driving cars.

The PID controller consists of three parts: the P, the I, and the D. I made a video to explain why you need the P and the D, and you only need the I in real-life if there's an error in the technology you have. There aren't many errors in the computer so you will not notice why you need the I in the video:


This was just a tiny introduction, but I've written an entire tutorial on how you can write your own PID controller in Unity (with C#): Minimize an error with a PID controller.

August 30, 2016

Fun with linear algebra

0 comments

Let's have some fun with math, especially linear algebra!

- Is this your idea of fun, Erik?

- Yes, when you see what you've learned is actually working in real life, then that's fun. Not fun as in drinking whiskey, but you get the idea...

When I studied linear algebra in school I had no idea when I would need to know if two vectors are pointing in the same direction or why you would ever need to use the cross product. But a few years later, I've found some practical problems to solve where I actually needed to know if two vectors are pointing in the same direction. I've collected these problems and their mathematical solutions in a new tutorial series: Use Linear Algebra to solve problems in Unity with C#.

The problems I've solved so far are:

The idea is to minimize the text and instead have finished code with comments that you can just copy and paste. Some of these problems you have solve in a rush. When I competed in the Ludum Dare competition, where the idea is to make a game in 48 hours, I needed to know if two line segments are intersecting with each other. But I couldn't solve the problem fast enough so I had to come up with another idea, which took some extra time and thus made the final game worse.



Solve the Uncaught unknown compression method Unity WebGL error

11 comments
This Sunday I had to finish a silly game called Traffic Light Simulator for the Ludum Dare competition.


One of the many problems I encountered happened when I tried to upload the first version of the game to my server. As you may know, Unity has abandoned the WebPlayer option in favor of the WebGL option, which is under development so there will be bugs! It was always super-easy to make the WebPlayer option work online, but with each Unity update you have to learn a new way to make the WebGL option work.

First of all, the offline version worked fine in Firefox, but when uploaded the project to the server I got the following error:
An error occured running the Unity content on this page. See your browser's JavaScript console for more info. The error was: Uncaught unknown compression method.

When you open the Developer Tools console, you will see the following:
  • Failed to load resource: the server responded with a status of 404 (Not Found): Invoking error handler due to Uncaught unknown compression method
  • Uncaught unknown compression method
  • Failed to load resource: net::ERR_CONNECTION_RESET: Could not download Release/Test.datagz
  • Failed to load resource: net::ERR_CONNECTION_RESET: Could not download Release/Test.jsgz
  
So what do you do when you encounter an error you have't seen before? You google it! And if you google these errors you will find a lot of people with the same problem. The solution seems to be to modify the .htaccess file. But in the latest version of Unity, there's no .htaccess file in the WebGL folder! The second link on Google was Unity's own documentation, which is not updated to the latest version which is 5.4, so there was no solution there either. Another solution was to contact the server provider.

After digging around on the web, I found the solution, and it was this super easy solution: What you need to do is to modify the index.html, which is the only file in the WebGL folder. So open it in Notepad or whatever program you are using. At the bottom of the file, you will see the following lines:
  • dataUrl: "Release/Test.data", 
  • codeUrl: "Release/Test.js", 
  • memUrl: "Release/Test.mem", 
To solve the problem you have, you just have to add gz to the end of those lines:
  • dataUrl: "Release/Test.datagz", 
  • codeUrl: "Release/Test.jsgz", 
  • memUrl: "Release/Test.memgz", 

If you upload the new version you should see that everything is working fine!

August 24, 2016

5 books about math you can read on the beach

1 comments
Summer is almost over (at least here in Sweden where we have about one month of summer), but everyone is not living in Sweden or maybe you are visiting a beach during the eleven months of winter. If you are, and if you would like to read a book about math, then here are five books you should consider reading. These books don't require neither a calculator nor a piece of squared paper to understand, so you can read them while drinking your umbrella drink.

A History of Mathematics. This book will give you a brief introduction to the history of mathematics. It's a big book, so it's not brief in that sense, but each individual is being introduced with a brief summary. Beginning with the old Egyptians, continuing with the Greeks, a tour to India, then back to Europe, and ending somewhere around the beginning of the 20th century, you will really learn how the math you saw in school has evolved.

Against the Gods. This book will tell you the history of risk. The title says "against the gods" which means that humans like you and me used to argue that we didn't need to take risk into account because the gods determined our fate. But you will see how we humans stopped believing in the gods and instead began believing in math to determine our fate. So this book will also tell you a history of mathematics but from a risk perspective.


How to Solve It. While reading about the history of mathematics maybe you decide that you want to be a part of the history of mathematics. What if someone would read your name 100 years from now? If that is the case, then you will have to begin solving math, and this book will tell you how to do that. The text is obviously not a magical solution that will make you solve math like you capture Pokemons, but it will get you started.

The Man Who Knew Infinity. Someone who could "solve it" was the Indian mathematician Ramanujan, which this book is all about. He taught himself math in rural India and then he was invited to England because he was so good at it. He who invited Ramanujan to England was the mathematician GH Hardy, so this book is also a biography on him. If you don't want to read the book, at least you should watch the movie with the same name.

Fermat's Enigma. One of the historical characters in the book A History of Mathematics is Fermat. He came up with a problem, and it would take several hundred years before the mathematician Andrew Wiles solved the problem. This book is about how he did it. To solve it he used a lot of math, so this book will also give you an introduction to the history of mathematics.

August 23, 2016

How to write a story for a book, movie, or game

0 comments
When I wrote a book about Elon Musk I learned that there are rules you are recommended to use to make the book you are writing better. These rules are no laws, but you are recommended to use the rules or your readers will give you bad reviews. In hindsight these rules are often obvious, but it's still difficult to learn them on your own if you haven't been told about them.

The first rule is that you should keep it simple. Most aspiring writers tend to write way too complicated, even though the rule says you should make the text as easy as possible. You should remove all unneeded words and text (Stephen King always removes 20 percent of the text after finishing the first draft), and use words like "but" often. To see if this really is true, I made some research on my own, by writing computer software to count the world in top selling books: Top words in top selling books. It turned out that the top selling books included a lot of: the, and, of, to, that.

Another good rule is that you should write about something no-one has heard before. If you are writing a story about a trip you've made to a beach, it's common to write about uninteresting things like how warm the water was and that the sand was soft. The problem is that those stories are boring to read. To make it more exciting for the reader you should tell stories no-one has heard before. So if you've made a trip to a beach, then tell a story from that beach no-one has heard before. Maybe someone was eaten by a shark? When I wrote the book on Elon Musk book I managed to find a story about Winston Churchill, who years before Elon Musk lived in the area was travelling around the country. Reviewers who read the book said that they really liked that connection because the story of Winston Churchill in South Africa is unknown to most people.

A good example of someone who wrote about something no-one has heard of before is Hunter S. Thompson. He wrote an article about the Kentucky Derby called The Kentucky Derby is Decadent and Depraved. While he didn't write anything about the Kentucky Derby (except two lines), he wrote everything about what was happening around it, including the special characters who visited the event and his journey to the event:
And unlike most of the others in the press box, we didn't give a hoot in hell what was happening on the track. We had come there to watch the real beasts perform. Thousands of raving, stumbling drunks, getting angrier and angrier as they lose more an more money.     
"Fuck England," I said. "This is Middle America. These people regard what you're doing to them as brutal, bilious insult. Look what happened last night. I thought my brother was going to tear your head off."
Thompson said himself that the article was a complete failure because he hadn't written anything about the Kentucky Derby, but the readers loved it.

Movies, books, and games are not that far from each other, so I thought it could be a good idea to learn how to write a movie. The book about Elon Musk was a biography, so I couldn't make up what's happening in the book. But if you are writing fiction, then you have to be more creative. After some scientific research with the help of Google, I found the book Save the cat! by Blake Snyder. He's promising that the book is the "The Last Book on Screenwriting You'll Ever Need." Here are some key points from that book:
  • Recommends the books: 
  • The audience has to like the main hero. Liking the person we go on a journey with is the single most important element in drawing us into the story. "Save the cat" is the scene where we meet the hero and the hero does something - like saving a cat - that defines who the hero is and make us, the audience, like him/her so we want the hero to win in the end. But what if the hero is a bad guy? Then you should make the hero's enemy even more horrible. Anyway, this is the save the cat moment in Pulp Fiction:
Scene One of Pulp Fiction, basically, is where we meet John Travolta and Samuel L. Jackson. These are the "heroes." They are also drug-addicted hit-men (with really bad haircuts). Quentin Tarantino does a very smart thing when we meet these two potentially unlikable guys - he makes them funny. And naive. Their discussion about the names of McDonald's hamburgers in France is hilarious. And sort of childlike. We like these guys from the jump - even though they're about to go kill someone - we are "with" them.
  • You have to be able to describe the movie with one line. The customers should understand what the movie is about by looking at the title and the poster and by reading one line only. Otherwise, the customers have to trust other sources, such as rumors or what the star of the movie said in the newspaper, so they might end up seeing another movie. This is why we are seeing so many re-makes of movies, such as Batman 3 and Shrek 4, because the customers understand what the movie is by looking at the title or the poster. What you should do is to summarize what your movie is in one line. And you should spend a lot of time with this single line because it's the key to at least making someone considering watching your movie. For example, the one-line from the movie Die Hard is: "A cop comes to LA to visit his estranged wife and her office building is taken over by terrorists." This line should include irony, like the irony that a cop on holiday ends up in a building filled with terrorists.
  • "Give me the same thing... only different." Most movies are the same, but they are still different. This is actually connected to the travel story I wrote about in the beginning. Most travel stories are the same, but you should add something new. All monster movies are the same, but you need to add a new fresh monster. The author argues there are more categories (monster movies is just one example) and you have to make sure your movie is following the theme of the category but with a fresh twist. And don't worry about stealing what's working as long as you understand why what you are stealing is working in that movie.
  • The main character should have a primal goal. The main character should have a goal we identify with as humans because we are still cave-men/women. So the goal should be a primal goal, such as love, and not just buy a new car. But if the goal is to buy a new car to find love, then that's a primal goal. Primal goals include survival, hunger, sex, protection of loved ones, and fear of death. The primal goal in Die Hard is "the desire to save one's family."
  • Adapt to the target audience. Don't assume that just because you prefer something, everyone else will, too.
  • Follow the author's 15 sections of a movie script. Some of these sections intersect with each other and includes: 
    • The opening image, which will set the mood of the movie. Example includes the motorcycle ride in the movie Lawrence of Arabia, and when the fighter jets launch from the aircraft carrier lit by the morning sun in Top Gun.
    • The set up, which includes the opening image. During the first 10 minutes you really have to capture the audience or they might leave the theater and give it bad reviews. Lawrence has crashed his motorcycle, had his funeral, but now he's traveling on a Camel in the Middle East. Maverick and Goose is being sent to the Top Gun school after some wild flying. 
    • The B-story, which is a side-story, and in most screenplays this is a love story. The purpose is to give the audience a breather. When Maverick in Top Gun falls in love with the instructor the audience will have a break from the flying.   
    • The fun and games section, is a point in the movie that should be less serious, like in Die Hard when Bruce Willis is first outwitting the terrorists, or when Batman in Batman Begins is almost killing himself while wearing the first version of his suit.  
    • In the all is lost section, someone probably dies, like Obi Wan in the "first" Star Wars movie or Goose in Top Gun. A rule-of-thumb is that anything that involves death is good in this section. If you don't have anyone to kill, then make something up, like a dead flower - just show some death.   
  • Even professionals have trouble coming up with new ideas. "...we were taking a time-out from a story we were trying to break, bowed by despair and self-loathing over not knowing how." But as with everything else, the more you practice the easier it will get. "Dude, suckin' at something is the first step to being sorta good at something." 
  • You should use cards on which you write the different scenes in your story. About 40 scenes is enough and you stack multiple cards if multiple things are happening in that scene. But the stacked cards count as 1 card of the 40. This might seem as a waste of time, but the "story is seeping into your subconscious a whole other way." Now it will be much easier to identify holes in the story and, above all, remove unnecessary scenes, just like Stephen King is removing unnecessary text. A scene is here defined as a conflict with an opening, middle, and end, as well as an emotional change. When I wrote that book about Elon Musk I should have used this strategy before writing it, because I remember that I had to shuffle the text around in the word editor once too often. 
  • Keep it simple. It shouldn't have to take 40 minutes to explain the movie plot to the audience. Too many different supernatural themes in the same movie is a bad idea, so don't have both aliens and dinosaurs in the same movie. Less is more!  
  • Every single character in the movie (except the bad guys) must change in the course of your story. Otherwise the story is not worth telling, because the story has to be important to the characters in it and stories are about change. For example, Maverick in Top Gun is flying recklessly because everyone thinks his father wasn't a good pilot. But as the story unfolds he learns that his father was a good pilot and he doesn't have to fly recklessly anymore. It's the good guys that should change, because to succeed in life you have to accept change and see it as something positive, while the bad guys reject change and end up dead. The audience will be inspired and thus like the movie even more.
  • Each character needs its own personality. If you are unsure if your dialogue is unrealistic, try to cover up the names of those who speak, read the dialogue, and see if you tell who is saying what. You should be able to tell the difference between different characters without seeing their name.    

August 17, 2016

What a lot of things I don't need

0 comments
I'm reading the book Sophie's World: A Novel About the History of Philosophy by Jostein Gaarder. As the title says, it's a book about the history of philosophy, but it's not one of those boring text books on philosophy as the author of this book has chosen to dramatize the story. Sophie is the main character in the book and she begins to receive mysterious letters from an unknown sender and each letter includes a little history of philosophy.

I have't finished the book, but I found a section about the Cynics, who were the minimalists of philosophy. It goes like this:
The story goes that one day Socrates stood gazing at a stall that sold all kinds of wares. Finally he said, "What a lot of things I don't need." This statement could be the motto for the Cynic school of philosophy, founded by Antisthenes in Athens around 400 B.C. Antisthenes has been a pupil of Socrates, and had become particularly interested in his frugality.
The Cynics emphasized that true happiness is not found in external advantages such as material luxury, political power, or good health. True happiness lies in not being dependent on such random and fleeting things. And because happiness does not consist in benefits of this kind, it is within everyone's reach. Moreover, having once been attained, it can never be lost.
The best known of the Cynics was Diogenes, a pupil of Antisthenes, who reputedly lived in a barrel and owned nothing but a cloak, a stick, and a bread bag. (So it wasn't easy to steal his happiness from him!) 
One day while he was sitting beside his barrel enjoying the sun, he was visited by Alexander the Great. The emperor stood before him and asked if there was anything he could do for him. Was there anything he desired? "Yes," Diogenes replied. "Stand to one side. You're blocking the sun." Thus Diogenes showed that he was no less happy and rich than the great man before him. He had everything he desired.
The Cynics believed that people did not need to be concerned about their own health. Even suffering and death should not disturb them. Nor should they let themselves be tormented by concern for other people's woes. Nowadays the terms "cynical" and "cynicism" have come to mean a sneering disbelief in human sincerity, and they imply insensitivity to other people's suffering.

August 16, 2016

Are the many smarter than the few?

0 comments

I've read the book The Wisdom of Crowds: Why the many are smarter than the few and how collective wisdom shapes business, economies, societies, and nations written by James Surowiecki. The title is actually a small lie because we will see that in some cases the many are not always smarter than the few, such as when crazy speculators are investing in overpriced Internet stocks. But the idea of the wisdom of crowds is not that a group will always give you the right answer but that on average it will consistently come up with a better answer than any individual could provide.

First of all I'm personally a fan of the idea of using the crowd. One of my favorite sites is a social news site called Hacker News. The basic idea behind that site is that the users are searching through the Internet for news and then they submit what they think are the best news to the site. Then the users of the site are voting on what they think are the best news. The result is much better compared with the traditional online news paper where just a few journalists are searching through the Internet and then they publish what they think the readers want (even though they sometimes write their own articles, but most of it is copy-and-paste from other sources). It's much better if the readers are choosing what they want because they know what they want.

But after reading The Wisdom of Crowd I realized that there's one small problem with Hacker News. The basic idea behind social news sites is that you submit link to something you like, and then the link ends up in the new-section. Now the problem is that most users are voting on links other users already voted on. Far from all users are visiting the new-section because they don't have the time to go through all the useless links, so they are just visiting the best-section, which is the section where the links with the most votes are displayed. So the result is that some links that a lot of users would have liked end up with no votes because everyone is not voting on the new links independently. A better way could be to hide new links among the best links?

Why is a site like Hacker News (or Reddit which is another similar site) working, while journalist, who are supposed to do the same job, are failing? The basic idea from the book is that:
"Even if most of the people within a group are not especially well-informed or rational, it can still reach a collectively wise decision." 
One example from the book is judging how many balls there's in a transparent jar. It turned out that no single person could make a better guess than the average guess of the group. In some experiments, some individuals could make a better guess than the group, but they were most likely just lucky.

So chasing an expert is often a mistake. What you should do is to look at the group's decision. But this is not always the case because groups work well under certain circumstances, and less well under other:
  • Groups need rules to maintain order and coherence.
  • Groups benefit from members talking to and learning from each other. But the members of the group should make the "votes" independently of the other members. Independence doesn't mean in isolation from everyone else, but relative freedom from the influence of others.  
  • Groups can sometimes be big and sometimes small. But small groups risk having too little diversity (not enough different views) and large groups can be unmanageable. 

According to the book, diversity and independence are important because the best collective decisions are the product of disagreement and contest - not consensus or compromise. This is why we sometimes see stock market bubbles, because the investors (or rather speculators) are not making the decision to buy the stocks independently of everyone else. They see that someone has made a million from ABC.com and now they also want to make a million by buying the same company. Neither has this group any diversity in it because everyone is just buying, while those who have the opposite view are ignored.

One example where a diverse group is making the "votes" independently is Google's algorithm. When I wrote the links in this article, I didn't care about what anyone else thought about to which sites I should link. Google will then use these links to determine if the sites to which I link should show up higher in the search results when someone is searching for the book The Wisdom of Crowds. Google has rules that determine which sites should be more important than other sites and the entire Internet is considered a big group, which can be unmanageable, but Google has figured out how to make the Internet more manageable. And since Google is the world's largest search engine, the ideas behind this book are actually working: under the correct circumstances the many are smarter than the few.    

August 12, 2016

Who was the man who knew infinity?

0 comments

This year there's a new movie out called "The man who knew infinity." It's based on a book with the same name written by Robert Kanigel. I haven't seen the movie so I can't tell the difference between them, but I've read the book, which you can find here for free because it's a few years old.

So who was the man who knew infinity? The answer is an Indian by the name Ramanujan (1887-1920). He actually had just the name Ramanujan, but he would add the letter S before the name when signing letters. It was after sending one of these letters to the British mathematician Godfrey Harold Hardy, Ramanujan's life would forever change - both for the better and worse.

Ramanujan had earlier sent letters to other British mathematicians, but Hardy, who was ten years older than Ramanujan, was the only one who replied with at least a slightly positive answer. So they began to exchange letters until Hardy realized that Ramanujan was something special. Hardy was so blown away by Ramanujan's mathematical accomplishments he did everything he could to bring Ramanujan to England. In fact, Hardy, who was one of the most distinguished mathematicians at the time, said his greatest discovery was not an equation, but finding Ramanujan himself. As Hardy was a large part of Ramanujan's life, the book is also a biography about him.

While Ramanujan was mostly into infinity, thus the name of the book, he also knew more than infinity. For example, he devoured areas like Magic Squares. But his favorite area was infinite series. One example of such is a series that found decimals in pi, which we all know has an infinite amount of decimals. So his math didn't always have practical applications (you only need so many decimals in pi), but neither did he care about if someone could use his math for a real purpose. But it turned out that several years after his death, people found practical uses for his math:
Several theorems of Ramanujan are now being widely used in subjects like particle physics, statistical mechanics, computer science, cryptology and space travel in the United States - subjects unheard of during Ramanujan's time.   

To summarize Ramanujan's life, you can say he was both lucky and unlucky:
  • He was unlucky to be born in a poor family, but he was lucky to be born in the correct caste: Brahmin. In India, they had (and still have to some extent) a caste system where you are born into a social class. Ramanujan was lucky enough to be part of a caste which encouraged learning and where the members could become something and were not destined to work with manual labor.
  • He was lucky to be invited to England, but unlucky to be invited at the time of the First World War. This resulted in that most mathematicians were sent to the front, and the ties with the mathematicians in mainland Europe, like Germany, were cut off. So even though the plan was that Ramanujan would spread his knowledge across Europe, and find ideas from other Europeans, he was in the end connected to just a few British mathematicians.
  • While in India, he was unlucky to not afford paper to write math on or a library with math books. The only real math book he had was from the 1860s, so he missed the latest developments in the world of mathematics. But as the book said:  
"He would probably have been a greater mathematician if he had been caught and tamed a little in his youth; he would have discovered more that was new, and that, no doubt, of greater importance. On the other hand he would have been less of Ramanujan, and more of a European professor, and the loss might have been greater than the gain."

Ramanujan was clearly a very bright man, but he wasn't a "rain man" - he had friends and he could take care of himself. So how could someone without any education accomplish so much? First of all, Ramanujan dedicated his life to math. He was so devoted to math that he couldn't bother to study the other subjects he needed to earn a college degree, so he was almost not allowed to study math in England. While in England, he was known to work for 30 hours and then sleep for 20 hours.

Secondly, Ramanujan never cared about proving his findings. This was a problem. When he had moved to England he was forced to prove his findings or he wouldn't be published and thus fail to achieve any sort of recognition. But as he never cared about proofs, he could produce more math, because proving math is really difficult. One good example is Fermat's Last Theorem, published in 1637. It took no less than 358 years to prove that theorem, and the guy who finally put the last pieces together had to dedicate seven years of his life to the proof. In the end it turned out that less than one third of Ramanujan's findings turned out to be incorrect.

Thirdly, Ramanujan was a deeply religious man. His family goddess was the Goddess of Namagiri. According to Ramanujan, Namagiri appeared in his visions, proposing him mathematical formulas, which Ramanujan would then have to verify. But why was his religious beliefs important? To quote the book:
Ramanujan's belief in Hindu gods, it stands repeating, did not explain his mathematical genius. But his openness to supernatural influences hinted at a mind endowed with slippery, flexible, and elastic notions of cause and effects that left him receptive to what those equipped with more purely logical gifts could not see; that found union in what others saw as unrelated; that embraced before prematurely dismissing. His was a mind, perhaps, whose critical faculty was weak compared to its creative and synthetical.
It is the critical faculty, of course, that keeps most people safe - keeps them from rashly embracing foolishness and falsehood. In Ramanujan, it had never developed quite as fully as the creative - thus giving him the credulousness, the appealing innocence, upon which all who knew him unfailingly remarked. Without the protective screen, as it were, he risked falling prey to the silly and the false - as many over the years, would view his belief in palmistry, astrology, and all the rest of the esoterica to which he subscribed. 
And yet, without that screen did he thus remain more open to the mathematical Light? 

Ramanujan's religious belief would in the end cost him his life. His religion forced him to be a vegetarian. When he got sick in tuberculosis, he still refused to eat any other food than Indian-vegetarian, which was difficult to find as there was a war going on and the British chefs couldn't prepare Indian food. He had once eaten non-vegetarian food (by mistake) and he believed it almost cost him his life as his god has punished him when German zeppelins bombed the area around his house just after he had eaten the non-vegetarian food. It's believed that it was the tuberculosis and a severe vitamin deficiency that would kill him at an age of just 32.

August 2, 2016

Lessons learned from the History of Mathematics

0 comments
I've read the book A History of Mathematics by Carl Boyer. It's a few years old, which is good because old books are available for free so you can download your own copy here. Just make sure to download the pdf file in which the text consists of images because the other versions are missing most of the important images. These images are important because the author has included images of old numbers from like Egypt in the main text, so you will not understand what's going on without them because they are missing in the other versions.

The history of mathematics can be characterized by several ups and downs with so-called "Golden Ages" where the development of math really accelerated, followed by a cold winter where not much happened, and then a Golden Age happened once again. But you can say the everything began around the Mediterranean in Egypt and then in Greece. This period was one of those Golden Ages, but then winter arrived when math took a detour to the Middle East.

When the Islamic State conquered Alexandria in 641, which is the city that for many years had been the mathematical center of the world. All mathematical developments so far could now have disappeared because the Islamic State were not that interested in math and were very close to burn all the books in the famous library of Alexandria. Neither the Romans were interested in math so math almost disappeared in Europe. But a few Islamic scholars were interested in trying to develop the math previously developed around the Mediterranean, not at least because they needed to apply the math. Why? Because the complicated nature of laws governing inheritance encouraged the study of math in the Islamic State. The contributions by the Islamic State to the development of mathematics may not be that great, but they saved the knowledge until Europe was once again ready to continue developing mathematics. The book includes chapters on math in China and India, but the key discoveries happened in Europe.

The word mathematics has meant different things to the peoples of the world at different periods in history. As already mentioned, the Islamic State found a purpose with math, but not all famous mathematicians had a practical purpose. A common question young students ask their teacher is: What's the point with math? When will I need this math to solve problems? A common answer is that the student will need the math when shopping. But that's the wrong answer, because math doesn't need to have a practical purpose. Math is math, and then people with problems should use the "useless" math to solve the problems. Or as Bertrand Russell said:
Math is the subject in which no one knows what he is talking about, nor whether what he says is true.   

Working as a mathematician today is far easier than it once was. Today we have computers and we connect with other mathematicians through the Internet - and we risk not to lose our heads in the French revolution, which was the fate of a few mathematicians. The history of mathematics consists of hundreds of mathematicians. You can summarize them like this:
  • Some made the key discoveries when they were young and others when they were old. So the saying that if you are older than 30, you will never be able to develop math is clearly wrong.
  • Some had math education others didn't.
  • Some made the key discoveries alone and others were part of a larger network.
  • Some thought a little too much about math and were admitted to insane asylums, while others lived happily ever after. 
  • Some managed to solve what they were working with, while others failed with the main problem, but instead they discovered something else, which turned out to be their key discovery.
  • Some published their results and others didn't want to publish. So some made key discoveries only to die without any recognition, and then someone found their notes and realized that hey this guy was really on to something. 

Of all mathematicians in the book the one I remember the most is the Frenchman Évariste Galois. His story goes like this:
Galois was born just outside Paris in the village of Bourg-la-Reine, where his father served as mayor. His well-educated parents had not shown any particular aptitude for mathematics, but the young Galois did acquire from them an implacable hatred of tyranny. When he first entered school at the age of twelve, he showed little interest in Latin, Greek, or algebra, but he was fascinated by Legendre's Geometry. Later he read with understanding the algebra and analysis in the works of masters like Lagrange and Abel, but his routine classwork in mathematics remained mediocre, and his teachers regarded him as eccentric. 
By the age of sixteen Galois knew what his teachers had failed to recognize - that he was a mathematical genius. He hoped, therefore, to enter the school that had nurtured so many celebrated mathematicians, the Ecole Polytechnique, but his lack of systematic preparation resulted in his rejection. This was but the first embittering failure. 
Nevertheless, Galois at the age of seventeen worked up his fundamental discoveries in a paper, which he asked Cauchy to present to the Academic. Cauchy not only misplaced the paper, as he had misplaced one of Abel's important articles; he lost the paper! Now Galois hated not only examiners but also academicians. A failure in his second attempt at admission to the Ecole Polytechnique heightened his bitterness; but the heaviest shock of all was yet to fall. 
Under attack because of clerical intrigues, his father felt himself persecuted and committed suicide. Despite the blows that he had experienced, Galois entered the Ecole Normale to prepare for teaching; he also continued his research, in 1830 submitting a memoir in competition for the Academie's prize in mathematics. Fourier, the secretary of the Academie took the paper home, died shortly afterward, and the paper was lost. 
Faced on all sides by tyranny and frustration, Galois made the cause of the 1830 revolution his own. A blistering letter criticizing the indecision of the director of the Ecole Normale resulted in Galois' expulsion; but once more he tried to submit a paper to the Academie, this time through Poisson. The paper contained important results now a part of what is known as Galois theory; but Poisson, the referee, returned it with the remark that it was "incomprehensible." 
Thoroughly disillusioned, Galois joined the National Guard. In 1831, at a gathering of republicans, he proposed a toast that was interpreted as a threat to the life of Louis Philippe, and he was arrested. Although released, he was again arrested some months later and sentenced to six months in jail. Shortly afterward he became involved with a coquette and, under a code of "honor," was unable to avoid a duel. In a letter to friends he wrote, "I have been challenged by two patriots - it was impossible for me to refuse." 
The night before the duel, with forebodings of death, Galois spent the hours jotting down, in a letter to a friend, notes for posterity concerning his discoveries. He asked that the letter be published (as it was within the year) in the Revue Encyclopedique and expressed the hope that Jacobi and Gauss might publicly give their opinion as to the importance of the theorems. 
On the morning of May 30, 1832, Galois met his adversary in a duel with pistols. He was shot through the intestines and lay where he fell until a passing peasant took him to a hospital, where he died of peritonitis the following morning. His funeral was attended by several thousand republicans. He was only twenty years old at the time, the youngest mathematician ever to make such significant discoveries.