### Math – Finding Patterns

Everyone learn math at school, but it’s a subject most would rather forget. Simple calculations are fine. Solving problems is a headache. Proving theorem is like climbing mountains.

However, mathematician study math with pleasure. What are they studying, and what pleasure do they get?

If you’re looking for a short answer to the question “What’s math?”, here is one: “Math is the study of **patterns**.”

Yes, to mathematicians, there are patterns — visible or hidden — in their imaginary math world. They seek pleasure in finding patterns, show them off, perhaps apply them to dig out deeper patterns.

You don’t believe this? I’ll let YOU find a pattern.

Math deals with many things: numbers, shapes, changes, structures, patterns, patterns of patterns, … Let’s start with the basic stuff: numbers.

What patterns are hidden in numbers? Nothing much for 1, 2, 3, 4, 5, ….

How about the squares? 1, 4, 9, 16, 25, 36, 49, ….

A pattern is something that repeats. To find a pattern, we may need to see a long list. In this case, compute as many squares as possible — the first 100 squares, 1000 squares, even more. Perhaps you are willing to compute the first 10 squares. Beyond that, you know you have the skills (just multiply a number with itself), but you’d rather not to waste your time doing so. Nowadays, there are computers (most likely you’re using one right now) which can compute at almost lightning speed. I’ll help you to use the computer for this task.

However, it’s rather tricky to teach you how to program (give instructions to) a computer to perform calculations.

Or is it? You’re using a browser to read this blog. You can instruct the browser to ask the computer to do calculations!

Modern browser knows something called Javascript, and you can do wonderful things with it. Also, it helps if your browser allows new tabs. If not, you’ll need to open a new browser instance, in order to keep reading this.

So click for a new tab in your current browser, copy the following line (highlight it, right-click, copy), and paste it in the new tab’s address box (right-click the long blank rectangle near the top, paste). Press ENTER (or click “->”).

`javascript:m=100;for(n=1;n<=m;n++)document.write(n+' sq = '+n*n+'<br>')`

On iPad/iPhone, just select the above line, copy, switch to Safari, tab address box, clear by (x), then paste, “Go”.

You should see the first 100 squares printed in your browser page, one square per line. I won’t teach you Javascript here. I’ll just say that m=100 above means “set maximum to 100”, and “for…” will repeat the computation (in this case printing the squaring line) for the maximum number of times.

If you close the tab, start an new one, and copy/paste again: this time change m=100 to m=500 before “->”. The browser will print the first 500 squares, faster than you can scroll!

Try this in your browser now, and see if you can spot any pattern in the squares.