In which I tell you about solving problems with at least 2 different approaches. And the squeeze theorem.
Back when I was writing my thesis, I came across this abbreviation: a.e. It took me a while, but I eventually found that it meant almost every. This might have been almost everywhere in measure theory, but I don’t think so. I seem to recall just “almost every”.
Almost every what, you ask?
Well, I was doing research on computer virus behaviour, so I had books from computer security, graph theory, biological viruses, mathematical models (with exponents and ordinary differential equations and such). I think it was in graph theory. An author was talking about a result or theorem and the proof included almost every type of graph, which was good enough.
I thought that was interesting, because I’ve thought of mathematics as absolute. Maybe this was why I suck at statistics… The idea of some event having a probability of happening, instead of just be or be not, shakes my world somewhat. Of course, I’m less shaken now since life isn’t really absolute…
My greatest accomplishment came when I was in the computer lab, and a Masters student was around. She’s from China, and you know those people are wicked clever. She held up a book, looked at me, then walked over to me.
“Do you know what a.e. means?”
AHA! Me, honours student, knew something a Masters student didn’t!
“I think it means almost every.”
“Oh. OHHHH! Thanks!”
I suspect she asked me because she believed my English was better than hers, and not because I was more knowledgeable in whatever topic that book of hers was about. Have you seen programming books translated to Chinese? I can read the words, but that doesn’t mean I know what the hashbrown that meant… She approached me probably (yay statistics) because she believed a.e. stood for something that someone moderately versed in English will know.
Still, it was an accomplishment. I could tell you I went on to brag about it to all my friends, but truth be told, I continued working on my program code… I was in the computer lab for something, you know…
I made this video because I’ve always been skeptical about reports (such as population census and surveys) with the average as the only statistical measurement.
I received an email from Parker Emmerson. He’s a mathematician, and he’s solved the innate velocity within the Lorentz transformation. And he’s asked me if I was interested in working on a project with him.
Now, I’m flattered by this. I also want to say I’m not really that smart (I had to look up “Lorentz transformation”…). You, on the other hand, are smarter than me. So here’s the document he sent me: The Geometric Pattern of Perception Theorems. I haven’t done academic math in a while. That’s a lot of equations to digest for me…
So here are the few projects he has in mind for collaboration:
- Write the paper in Latex for co-author credit while making it look and feel more official by including outside sources about relativity.
- Figure out why the equation will solve at all. To me, it looks like it shouldn’t solve.
- Write a computer program using the formulae that has some external application beyond making a graph. For instance, the system of a circle transforming through a cone is similar to complex analysis, and I have already done work connecting the two frameworks. We use complex analysis for video games.
- What is the relationship to black holes?
- The algebraic structure of the height of the cone necessitates acceleration. How can we relate this to the acceleration of galaxies?
Just reading through those project descriptions, being a mathematician, a physicist (black holes!), a programmer seems helpful.
If you’re interested, please contact Parker. For security, I’m not listing his email address here, but you can find him at his site (his email’s listed there). Or you can leave a comment here or contact me, and I’ll introduce you to him.
Personally, I think that’s awesome. It’s a pity I’m not that smart. So help Parker if you can. Help science forge a new frontier.
To infinity and beyond!
It was one of those friend meetups. No, my engineer friend did not approach me with a twinkle in his eye to top his last math problem. However, my sociologist friend had something…
“Eh Vince, I got something to show you. You know about the Udja Eye?”
So he showed me this book “The Secret History of the World” by Jonathan Black (or Mark Booth as the author explained).
“It’s got fractions and stuff. Wait, lemme find it for you…”
Then he flipped through the book, and “Here! Udja Eye.” It looks interesting. “I was thinking you could do something with it for one of your Math Wizard powers.” (bless the man) I noted the term down for further research because another friend wanted to read through the book first.
Fast forward maybe a week later, that friend with the book (my engineer friend, coincidentally) practically shoved the book at me. “Vince, you have got to read it.” As of this writing, I haven’t started reading it yet. I wanted to find out more about this Eye first. It looks like this:
According to my research, apparently “Udja Eye” was not a popular term. It was frequently referred to as “Wedjat (Eye)”, “Wadjet (Eye?)”, “Udjat Eye”, “Oudjat” or the easier to pronounce version “Eye of Horus“. It had been Eye of the Moon, and then Eye of Ra. Which is confusing (to me at least), because Ra (or Horus) is the Egyptian god of Sun.
“I see it’s an Egyptian thing…” you say.
“Are you trying to be funny?”
Since Horus was said to be the sky, he was considered to also contain the sun and moon. It became said that the sun was his right eye and the moon his left, and that they traversed the sky when he, a falcon, flew across it.
That kind of explained the eyes of moon and sun thing. Wait, what falcon? Oh nevermind…
So what about the fractions? It turns out that the Eye of Horus is composed of 6 fractions.
Don’t ask me why it’s reversed…
In the Ancient Egyptian measurement system, the Eye Of Horus defined Old Kingdom number one (1) = 1/2 + 1/4 + 1/8 + 1/16 + 1/32 + 1/64, by throwing away 1/64 for any rational number. Eye of Horus numbers created six-term rounded-off numbers. The Old Kingdom definition had dropped a seventh term, a remainder 1/64, that was needed to report exact series.
The confusion sets in…
I did some more research. And Wikipedia failed me. I don’t want to look at any other search results because “Udja Eye” (and its variants) is an esoteric topic, and appears to have connections with the occult. Basically I don’t trust search results on this. I’m looking specifically for the math background, but some historic information is also appreciated. And possibly needed (to explain the math stuff). This feels like a “Da Vinci Code” moment…
So I’m undergoing psychic damage because of:
- What is “Old Kingdom” math? How does it work?
- Why is the 7th term (1/64) dropped? Is it because the Egyptians valued the 5 senses and thought (so total 6)? Or the ancient Egyptians couldn’t work with the higher precision?
- Did the hieroglyphics for the fractions appear first? Or was the Eye of Horus formed, and then individual parts were used to denote the fractions?
- Horus‘ mother, Isis did what to her murdered husband Osiris’ uh, manhood? It was thrown in the Nile and eaten by a catfish?!?
- In a battle, Horus ripped off his uncle Seth’s (who’s the murderer of Osiris) testicles (?!? must they be so graphic)?
- Seth tried to seduce Horus and inseminate him with his, oh I can’t even go on…
- What is wrong with these people?!?
*take deep breath* Ok. So. Maybe the book my sociologist friend lent me will shed some light…
Most traditional board games use squares to segregate space.
Space is divided evenly. Lines are easy to draw. Everything is structured. Bliss.
Except that when you need to move to a diagonal square, you need to move 2 squares instead of √2 squares. Wait, a non-integer movement? That cannot be tracked!
Dungeons & Dragons 4th Edition (a tabletop RPG with physical positional tracking) state that a diagonal square movement costs the same as a perpendicular square movement. Meaning you just move 1 square to reach that diagonal square. This also has its problems.
For example, there’s a concept of push in D&D, where as long as the target being pushed is moved further away, it counts as a push. Bringing us to this situation:
I talked about this briefly on my other blog, but didn’t go into the math details. So the blue dot is you, the red dot is the enemy, and the brown dot is where the enemy is pushed to.
The distance between you and the enemy is (do the Pythagoras thing) 2√2 (approx 2.8284). The distance between you and the final position of the enemy is √10 (approx 3.1623). Sure √10 is greater than 2√2, so mathematically speaking, the enemy is moving away from you. But common sense is telling me otherwise, because the direction of the push emanates from you.
Anyway, to combat the shortcomings of the square terrain, there’s the hexagonal terrain.
Under this division of space, all adjacent spots are equidistant to your position. Well, it still has its problems. You still need 2 hexagons of movement to reach the first hexagon directly above you.
So what’s the actual cost of movement? Let’s look at this extracted diagram:
Let h be half of the actual distance. Doing the Pythagoras thing again, we have
1^2 = h^2 + (1/2)^2
=> 1 = h^2 + 1/4
=> h^2 = 3/4
=> h = √3/2 (h is positive)
Therefore, the actual distance is 2h which is √3 (approx 1.7321). Not quite 2 hexagons, is it?
This is part of the reason why, when games are created on computers, that these limitations disappear. Because computers can do the distance calculations and tracking. You can move in any direction, for any amount of units of movement, as long as you do not hit anything.
And that is called collision detection.
I had a tumultuous past month (or so).
My network adaptor died on me, and since my computer then was about 5 years old, I thought “Why not just get a new computer?” So I did.
Due to some personal reasons, I feel a bit worn out. So I’m putting that ebook project on hold for a while. Partly because I’m also channelling my energy to another blog. Please visit Honeybeech, where I tell stories, mainly about my Dungeons & Dragons gameplay adventures.
Rest assured that I’m still here. So I’ll be writing math and programming topics here at Polymath Programmer, and RPG/fantasy/fiction stuff over at Honeybeech.
Because even programmers need to eat (as in “eat properly”, despite whatever you’ve heard about pizzas and fizzy drinks), I’m writing an ebook as a D&D game supplement. It’s called Math Wizard (I know, it’s so “me”, right?), and the character’s powers are mostly based on math and science concepts.
Considering all my options, I believe I have a better chance at making “Math Wizard” work better than “Discipline and Deflection” (the original ebook project). I also believe the former can inspire more people and ignite their imagination and curiosity than the latter. I will still create both, and I’m just constrained by time and effort.
A friend also introduced me to a book store here in Singapore called BooksActually. They have a sister branch called “Polymath & Crust”. Awesome! They have the word “polymath” in it. I have to visit that book store.
The store is located at No. 86 Club Street Singapore 069454, if you’re interested.
[Disclosure: I’m not paid by them. I even bought a book. See below.]
We went in, and it was a quaint little place, carrying books that you don’t see in major book stores. My friend bought himself a dictionary of symbols, and I bought a dictionary of mathematics.
Even their paper bag is interesting. I wonder what that interesting shape mean?
Now that we’ve gotten the short answer out of the way, let’s discuss this further. Recently, Jeff Atwood asked Should Competent Programmers be “Mathematically Inclined”? I don’t get the need for the quotes, but never mind…
The summary of his article is that the problems involving math that most programmers deal with are the “balancing your checkbook” kind. Meaning simple math is required, meaning you don’t need to be a math whiz to solve that problem with programming. And I agree with him.
My work currently puts me in contact with a lot of numbers. As in quantities in the 10 digits range, with values also in the 10 digits range. And the finance and credit departments of my employer are very interested in those numbers…
Anyway, the manipulation of those numbers require very little math, despite their math origins. How hard can it be to sum up figures, do discrete prorating, calculate percentages or find out the price based on existing rates?
The initial reading of Jeff’s article made me feel indignant (goes off to check that I indeed write about math and programming). How dare he view math as frivolous to programming! How dare he reduce math to insignificance! (wipes spittle from mouth)
Then the cold hard truth of my professional programming experience knocked my senses back into place. I had to remember that the work I did back in university just wasn’t… useful (directly) to my present work. I worked with 3D, image rotations and optimising an airflow simulation. Not quite the business related programming I do now.
I still believe math is useful to programmers. Just as you should learn C, even if you don’t use C in your regular work. I’ll tell you how math and C are related in a bit, but first…
Math is elegant
The earlier parts of math education focus on calculations and memorisations. Oh, there are some proving questions (much to my distaste) alright, but there’s not a lot of them. In university, my math education started to take on a distinct shift; there were fewer numbers in the questions.
I remember there was this linear algebra tutorial. There were only 4 questions in it. I took a grand total of 4 hours to complete it. Even then, I didn’t fully answer the questions. It was proving this, or ransacking notes to find out which theorems were applicable, or wandering into higher dimensional linear spaces (I think I hated the professor at one point during my struggle). I think I even skipped 1 (or 2!) question. That’s how different the questions became.
With this shift, I found math to become more … elegant. Suddenly, plugging in numbers into calculation formulas aren’t important anymore. Even remembering proofs and theorems take backstage. Figuring out which method, proof or theorem to use to solve a question in the simplest manner is paramount.
I started to solve problems elegantly, be they math or programming.
And for me to find elegant solutions, I needed to think more. Much more. Sometimes this fails, and I end up with a less-than-ideal-elegance solution. But that’s ok. If I don’t aim for elegance, I’ll never reach it.
In my earlier stages of education, math was binary. Either my solution was right, or it was wrong. Later on, it was right. And there’s another solution that’s also right, and shorter. Or easier to understand. Math solutions became a little fuzzy.
What I’m saying is that although math isn’t directly useful to my programming, it certainly shaped the way I solve programming problems. Because programming solutions are also a little fuzzy.
Many programming solutions are sub-optimal. And they don’t need to be optimal. They already solve all normal occurring cases, and maybe the edge cases don’t matter that much. Or maybe there isn’t an optimal solution. In which case trying to find the optimal solution is a waste of time. So much for elegance.
So is math really important? I can’t say for you (despite writing an article on it), but C isn’t that important for programmers either.
Learning C makes you think
It’s sometimes hilarious to see Jeff and Joel argue about the importance of learning C. Joel does have a point. Learning C makes you think harder about solving programming problems (pointers and all). It doesn’t mean you’ll ever use any of the solutions (or C for that matter), but it trains your mind to think.
And in this respect, that’s what C and math are to a programmer. Learning both makes you think. You’ll think about just solving the problem. You’ll think about a more elegant solution. Maybe coming up with a less convoluted solution but eminently understandable by your fellow programmers.
But if you never go through the extremes of “slap messy but amazingly it works” and “elegant one liner but takes forever to understand”, then you might find it hard to find a happy in-between state. Because you just don’t know what’s possible.
“So is math important to programming?” an obvious exasperation in your question.
Well … it depends. On you.
I recently came upon a tweet by Kathy Sierra. Here it is:
So I went ahead and downloaded the PDF file and read it through. Man did it resonate! Here’s a quote that practically captured the essence:
Mathematics is an art
– Paul Lockhart
Lockhart was describing how the current education in America was eroding the sense of wonder, discovery and thrill of mathematics in children and young adults. First, go download his article Mathematician’s Lament (about 25 pages) and read at least the first and last few pages if you’re in a hurry.
I don’t know much about the American education system, but the way it’s described, it’s bad. And the Singapore education system (at least with regards to math) is similar (well, at least from what I remember when I was studying). The sense of discovery just wasn’t there.
When I was about ten (I think), my parents bought me an encyclopedia set, Childcraft. The first book I went for? The one on mathematics.
I gorged myself on the puzzles, stories, thought experiments in the book. For example, there was that crossing of river puzzle, with a farmer and a sheep and a wolf. There was a story excerpt of Flat World, where Points and Lines meet the 2 dimensional Squares and Pentagons. And there’s a “proof” of the non-existence of vampires. And … wait, what? You want to know the proof?
Ok, suppose vampires suck blood out of victims and the victims become vampires themselves. Suppose there’s only 1 vampire in the beginning. On the first night, he bites one person. By the next day, there are 2 vampires. 2nd night, each vampire bites another person. So there are 4 the next day. I’m sure you can see how this goes… at some point, the doubling vampire population simply overshot the entire world population. But we’re still here, aren’t we? Hence no vampires.
Of course, that proof goes out the window if vampires don’t need to bite every night… or if they can control who to turn into a vampire… ok, moving along…
Oh yes, with this encyclopedia in hand, I learnt about the fun parts of mathematics. I learnt about the magic numbers of 3, 4 and 5 forming a standard 3^2 + 4^2 = 5^2 Pythagorean triangle long before I actually knew what Pythagoras’ Theorem was. I read about how the ancient Greeks were racking their brains for how to get a right angle, and they used a length of rope with evenly spaced knots. They found that a triangle with sides of 3 knot length, 4 knot length and 5 knot length, created a right angle at one of the corners. That was fascinating.
There was also this section on Fibonacci numbers, and a story about rabbits. The algorithm behind the sequence was presented with an interesting back story of an expanding bunny population. I remember in university, my professor mentioned the sequence and I exclaimed, “Fibonacci sequence!”. And my friend, who’s sitting beside me, turned to me and asked, “You know about this?”. Really? A math university student who don’t know about Fibonacci sequences?
I don’t know about you, but for all the talk about Asians being better (at math) (here and here), I think most of us still don’t get to see math as an art, as something beautiful to contemplate. I started out seeing math as fun, then later on as something scientific and not-so-fun. And after my service in the military, I went to university, and suddenly it’s fun again. I guess it took me a fresh perspective to view math once more…
And I think programming is like math. No, I’m not bringing in the meta-blogging type of “This blog topic is something like that” and go off on some far out analogy. I mean programming, like math, requires one to see the abstract, manipulate pieces of information in the mind’s eye, come up with solutions in the ether, and then bring forth the solution into the world.
Right now if you ask me about math, like really hard core math, I’d probably stumble. Partly from a long disuse of the principles, but mostly because unconsciously, I’m trying to capture that sense of wonder again. That requires me to shed some undesirable shackles and discipline, and allow myself to not know everything on the topic. Math fun is back in vogue.
P.S. The next book in the Childcraft encyclopedia I pounced on? The one with stories. I guess I’m a sucker for fiction. *smile*