Is Coding Math? Yes & No.

Recently a friend asked me if programming should be counted as mathematics in school. That is a really good question, and I’m going to tell you why I think it should (and when I think it shouldn’t).

A long time ago, in a high-school far far away, I learned how to program. My teachers would tell horror stories of the old days when they had to program room sized computers using stacks of punch cards, and now it is my turn to regale you with tales of coding uphill both ways in a blinding snowstorm. The computer lab in my high-school had 386s, and the language we used was Turbo Pascal. My buddies showed me a little C++ on the side, because, by the second year of programming, we had learned the basics and more — class had become open lab time. (Programming is a lot like chess, in that once you learn the moves, practice is what makes you better.)

Senior year, my project was an RPG in the style of Final Fantasy and many others. Our family didn’t own a computer (few did then), so at the end of each class I would print off stacks of pages of my code on the dot matrix printer. At home and in my other classes I would hand-write out new code or streamline the existing code so that in class all I would have to do is type, debug, and play test. I never quite finished the game, but I was able to create a program that would turn a simple ASCII map into a world you could walk around in by the end of the year.

I was so enamored with programming that after high-school, I briefly pursued computer science as a major. That was a long, long time ago. Why am I telling you all this? Well, eventually, I went on to study mathematics. Once I was in the upper level stuff, I was stunned at how much my programming knowledge helped out when it was time to do a proof. Proof by Contradiction is an awful lot like tracking down bugs in code (something which I was quite familiar with). Induction and Loops are intertwined in my mind. One of the trickiest things for new math students to learn is conditional statements — If, Thens.

So, even though, by the time I was a student of mathematics, my syntax was hopelessly out of date (and it is even worse now) by learning the logic of problem solving, it made me better at mathematics.

It has been more than 20 years since I wrote my first program in Turbo Pascal, I have a PhD in mathematics, and I’ve been teaching math in various colleges for 13 years. This Summer, I have decided to learn a modern programming language — Python — by working through the Project Euler problems.

Why now, after all these years? Because I realized my kids need the benefit of programming, and I plan to teach them. I believe there is no better modern and practical introduction to logic and problem solving. If this is so, then why doesn’t it count as math, since the purpose of math in the curriculum is mainly to teach logic and problem solving? Some of it is entrenchment. But, some of it is how programming tends to be taught in the lower grades.

I’ve recently come across a fun series from Usborne: Coding for Begineers. I say fun, because it is a very simple tutorial. You read the instructions, type the code they give you, and if you don’t make any syntax errors, you get a little game. Don’t get me wrong, I think this is a fantastic way to introduce some of the things that coding can do, but there is absolutely no logic and problem solving. (There is still come other benefit like attention to detail and looking for syntax issues.) For parents and teachers that don’t understand programming, methods like this are the default method of teaching about programming. Methods like this are no more math than asking students to copy a list of worked out problems.

No bug-free code

How does programming become “math”, then? Not by having them use programing as a calculator. By giving students interesting problems to solve (or even better yet letting them come up with their own problems to solve). Admittedly, this is difficult if you are unsure of what coding can accomplish. Project Euler is great for people with an already strong math background (like an advanced high-school student), but some of the problems can be daunting.  Don’t be afraid to skip around some or even google for help (although beware that many people have put full solutions on-line).

For the younger students, I recommend a choose your own adventure style text adventure. Have them sit down and write or draw out the choices and branches (work together if you can). Then, let them program it a bit at a time. Programs like this make great use of conditional statements and loops can be incorporated as well. When they are done, parents and siblings make great play testers.

Stay tuned for more problems to solve using programming. If you have an idea, share it in the comments.

(By the way, I’m not getting paid by anyone to tell you any of this. Links are only provided to save you time googling.)

Division by Zero

http://vignette1.wikia.nocookie.net/powerlisting/images/9/93/Divded_by_zero_6848.jpg/revision/latest?cb=20130416015539Have you ever been told that division by zero is undefined? What do we mean by undefined, anyway? It sounds like mathematicians just never bothered getting around to defining it. Imagine Newton and Leibniz (the fathers of Calculus) sitting down at a café in Paris, sipping on coffee. Newton says, “Should we define this whole division by zero thing?” Leibniz pauses a moment, swirling the last drops in his mug, “No, let’s order another round instead.”

That’s not actually what we mean by undefined. Perhaps a better term would be undefinable, although that isn’t quite right either. We could define what 5 divided by 0 is. It’s just that our definition would generate contradictions. In math a definition that causes contradictions is said to not be well defined. We could actually make any number of (infinitely many) poor definitions, but no perfect one that works every time. So, we leave it undefined.

Consider 5 divided by 0. Suppose we said it was a number. Any number will work equally well here. Actually any number will work equally unwell, I suppose. Let’s say that 5 divided by 0 is 100. This is silly, but it turns out to be no sillier than anything else.

For any definition we make, we want everything else defined to still work. The usual way to define division is in terms of multiplication. We say 8 divided by 4 is 2 because 2 times 4 is 8, and so on.

Let’s try that with our definition for 5 divided by 0. Since 5 divided by 0 is 100, then 100 times 0 is 5. But, 100 times 0 is supposed to be 0. (That is called, unimaginatively enough, the multiplication property of 0.) This means either our definition is wrong or 0 equals 5. Wait, what? Well we just said 0*100 = 0 and 0*100 = 5. Since both left hand sides are the same, that would imply that the right hand sides are also the same. We know that 0=5 is absurd (properly we call it a contradiction), so we conclude that our definition is wrong.

Perhaps 100 was just a bad choice. Let’s say it is some other number. To save time I’m going to use the number x — a variable. We’ll say 5 divided by 0 is some number x, and that we’ll figure out which one it is later. By the definition of division, that means that 0 times x is 5. So, x is the number that gives you 5 when you multiply it by 0. But any number times 0 is 0, and we’ve already ruled out the possibility that 5 and 0 are the same, so that means any number we choose for x gives us a contradiction. 5 divided by 0 is not a number.

Hey, that’s not too bad. Maybe 5 divided by 0 is a non-number like the word Aardvark. That would cause even more problems. We have only defined our operations like add, subtract, multiply, and divide for numbers. So, 0 times Aardvark is undefined. Oh no! Not that again! Yep. We’ve just pushed the problem on to the next statement. That doesn’t work either.

But, maybe you’ve heard on the street that 5 divided by 0 is infinity. That is unfortunately misinformation spread about by people learning Calculus that haven’t quite grasped it yet. I could go into more detail, but instead I’ll appeal to the Rule of Two. Either infinity is a number or it is not a number. In either case it doesn’t work by our previous discussion. (In fact, infinity is not a number, but that is a discussion for another time.)

I’ve avoided the case 0 divided by 0, because this is long enough already. If you are clever, you’ll see that you could define 0 divided by 0 in such a way to not violate what we said about 5. I promise to show you why we still don’t define 0 divided by 0 in a future post (probably after we’ve discussed whether infinity is a number or not).

Hopefully I’ve convinced you that division by zero is not defined because it cannot be defined well. If I haven’t reached you with this, you should know that in the mid 1990s a secret organization of retired math teachers was formed to combat the problem of people dividing by zero. Equipped with black helicopters, night-vision goggles, and stun guns (all grant funded, I assure you) they take turns listening in to classrooms all over the nation.

When their surveillance detects someone dividing by zero, they swing into action. A strike team of 4 expert pedagogues repel from their helicopter. Unfortunately, retired math teachers are not known for their peak physical condition or combat operations training. They have spent long careers sitting in uncomfortable chairs drinking too much coffee and grumbling as they grade page after page of division by zero errors. To date, every attempted intervention has resulted in at least one heart attack, stroke, or loss of consciousness from misjudging the distance to the ground. To conceal their nature the mission is then aborted and the poor retired teachers are shuttled to the nearest hospital where the luckiest are treated for shortness of breath and high blood pressure.

Some are not so lucky. So far, 431 retired math teachers have given their lives in service to the mathematics community. So, the next time you are tempted to give any other answer besides undefined for a division by 0 problem, please, think of the huddled squad of out of shape, caffeine addicted, former educators. Don’t let number 432 be on your hands.

http://math-fail.com/images-old/divide-by-zero5.jpg