#WeHateMath Project Euler 9 – Pythagorean Triplets

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,

For example, 32 + 42 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.

Find the product abc.

Let’s get the problem part out of the way first. It turns out to be pretty easy to generate Pythagorean Triplets (sometimes called Pythagorean triples):

Pick two positive integers, m and n, ,where m < n. Generate your three values like so:

Of course, doing this by hand is annoying and this is just the sort of thing for which spreadsheets were made. I set up the formulas and then starting fiddling with values of m and n and it just took a few tries to range in on the answer:

m

5

n

20

a

375

b

200

c

425

Sum(a,b,c)

1,000

Product(a,b,c)

31,875,000

a^2

140,625

b^2

40,000

a^2 plus b^2

180,625

c^2

180,625

Readers know by now that the point of the Project Euler posts is not to simply get the answer to the problem but to figure out the point of the problem. In this case, that’s not obvious. Though Pythagorean Triples are a surprisingly hot topic of discussion among mathematicians if my casual research is anything to go by. I even found a paper documenting a new way to generate triples that suggests an interesting application of the math to cryptology. It’s especially surprising when you consider that these triples have been around for over 2000 years.

The classic Pythagorean triples are (3, 4, 5) and (5, 12, 13). You can generate new triples by using multiples of each element. In our answer above, (375, 200, 425) is a multiple of (3, 4, 5). There are others, however. For example (4, 3, 5) is also a valid triplet but can’t be generated by the traditional methods.

Pythagorean Triples are connected to both Fibonacci numbers and primes, which we’ve discussed previously.. The two classic triples each have Fibonacci values as two of the three values. In addition, up to two of the legs can be prime numbers but because at least one of the legs must be even, there is no triple where all three elements are primes.

This is a great example of pure mathematics that may (or may not) someday find some practical application. I view mathematics as a way to perform experiments on the universe, but unlike traditional laboratory science, my lab bench is conveniently located between my ears. So the next time someone tells you that studying math is impractical, remind them:


#WeHateMath Introduction to Common Core Math – #TheMelvinProject

(This series was inspired by a recent interview with Arizona state Senator Al Melvin who, after voting to bar implementation of the Common Core standards adopted by his state, was asked by a reporter if he’d actually read the standards, replied, “I’ve been exposed to them.” As an educator, I recognize that phrase as code for “No, I haven’t.”)

There’s a lot of excited political jibber-jabber concerning the Common Core standards. However, this is not a political blog so I just wanted to look at the standards themselves. I’m primarily interested in the Common Core standards for mathematics education. There is also a set of standards for English language arts and literacy but I don’t feel I have the background to do them proper justice. (And this is a blog about math, after all.)

The Common Core State Standards Initiative has a Web site describing their work and you can even download a copy of the standards document if you wish. In theory, the standards adoption policy is entirely voluntary on a state-by-state basis. In actual practice, the Department of Education is making Race For The Top funding (about $4.5 million worth) to individual states contingent on adopting the standards. This seems political but it’s not that different than when the Federal Government wanted the states to adopt a 55 mph speed limit and tied it to interstate highway funding with the National Maximum Speed Law back in 1974 (signed into law by Richard Nixon, as a matter of fact) and people complained about that as well. But that’s politics and that’s not why I’m here.

(That being said, Race For The Top does have it’s issues that aren’t really connected to Common Core Standards and perhaps it might have been smarter to give Common Core it’s own funding bucket rather than tying it to RFTT. But again, that’s politics.)

As a general idea, having national education standards is a good idea. The majority of developed countries have them. For us they would only apply to K-12 and are meant to ensure that a high school diploma from a one room school house in Butte, Montana can be considered equivalent to one from a rich public school in Boston, Massachusetts. Of course, humans being the complicated beings that they are, the reality is much messier.

The standards for math are divided into mathematical practice and mathematical content. The content section has sub-sections for grades K-8 with the sub-section for High School further divided by subjects including: Number and Quantity, Algebra, Functions, Modelling, Geometry, and Statistics and Probability.

The standards for mathematical practice describe the types of expertise that teachers should be developing in their students:

The standards for content describe specific objectives and outcomes for each grade level but (despite using the word ‘content’) do not specify how an objective should be met or with what materials (textbooks, multimedia, etc.). That would be left up to the state and local authorities.

So ‘practice’ covers the overall outcomes for K-12  and ‘content’ states what general topics are covered and when.

Got it.

In addition, even if a state adopts the standards the implementation decisions are made at the state and local level. In addition, implementation of the Common Core standards does not require data collection. Personally, I think this bit is a little weaselly. There’s a saying in business circles: You Can’t Manage What You Don’t Measure. So there will be data collected, but by the states themselves and not Washington or even the United Nations.

So far it doesn’t look that bad to me on the surface. However, looks can be deceiving, you can’t judge a book by its cover, something something freedom. So I’ll be back with a more detailed look in later posts.

 

#WeHateMath Project Euler 8 – Math Makes Everything Better

Find the greatest product of five consecutive digits in the 1000-digit number.

73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450

At first glance this appears to be arithmetic which, as we all know, is boring and mechanical and completely beneath us as humans. Well, actually, at first glance the part of our brains that does arithmetic (you know, the boring part) sees this awful number and just wants to shut down. Since I knew it had to be more than just arithmetic, I tucked it in the back of my mind to ferment a bit before tackling it again.

After a bit of thought, I can see the trick here. The problem statement refers to a 1000-digit number but we’re supposed to deal with individual sets of digits. So we can use math to make this more interesting (since math makes everything better) and simply regard this as a string of 1000 digits.

How does this help? First of all, any string of digits with a zero in it we can disregard. In fact, we can discard any ten consecutive digits that have a zero in the middle since any five digit sequence will multiply out to zero. So we look for digits with this pattern:

XXXX0XXXX

Let’s take another look at our number, clearing out digits within four positions of any zero:

731671765XXXX0XXXX19225119674426574742355349194934
969XXXX0XXXXXXX0XXXX23957XXXX0XXXXXX0XXXX478851843
858XXXX0XXXX12949495XXXX0XXXX95833XXXX0XX0XXXX
XXXX0XXXX4715852XXXX0X0XXXXXXXX0XXXX9522XXXX0XXXX7
668966XXXX0XXXX44523161731XXXX0X0XXXX1121722383113
622298934XXXX0X0XXXX336276614XXXX0XXXX486645238XXX
X0XXXX0XXXXXX0XXXXXXXX0XXXXX0XXXXX0XXXXXXX0XXX0XXXX
0XXXX27121883998XXXX0XXXX274XXXX0XXXXXX0XXX0XXXX6
6572XXXX00X0XXXX78XXXX0XXXXXXX0XXXX2XXXX0XXXX52243
52XXXX0XXXXXX0XXX0XXX0XXXX586XXXX0XXXX415722155397
5369781797784XXXX0XXXX51XXXX0XXXX69321978468622482
8397224137XXXX0XX0XXXX0XXXX0XXXX968652414XXXX00XXXX21XXXX0XXXX0XXXX
XX000XXXX2XXXX0XXXX41227588666881
164271714799244429XXXX0XXXX65674813919123162824586
17866458359124566529476545682848912883XXXX0XXX00XXXX
XXX0XXXXX0XXXX6321XXXX0XXX0XXXXXXX0XXXX6XXXX0X0X
0XXXXX0XXX0XXXX554443629XXXX0XXXX79927244XXXX0XXXX
XXXX0XXXXXX0XXXX9133875XXXX00XXX0XXXX99XXXX0XXXX0X
0XXXX116XXXX0XX0X0XXXXX00XXXXX983XXXX000XXXX5729725
716362695618XXXX0XXXX52XXXX00XXXXXXXX0XX0XXXXXXXX0

Okay, I’ve eliminated all strings of digits whose product will be zero so our new string of digits becomes:

73167176519225119674426574742355349194934969239574788518438581294949595833471852952276689664452316173111217223831136222989343362766144866452382712188399827466572785224352586415722155397536978179778451693219784686224828397224137968652142124122758866688116427171479924442965674813919123162824586178664583591245665294765456828489128836321655444362979927244913387599116983572972571636269561852

(I could have written a script to do this for me but pattern-matching is part of my evolution so I can do it myself without much trouble.)

This is a much more manageable number (still 389 digits long, though) but if we’re ultimately going to be doing arithmetic (and it looks like we’ll have to eventually) we have to think about having a machine do the work and that involves explaining the task to a machine in a way that it can understand. But this brings us to a question:

Do we really have to do any arithmetic at all?

A bit of thought tells us that we may be able to avoid arithmetic after all.  Here’s the logic:

Start scanning the string of digits and split off each set of five. For example, if our string was:

73167176

We would pull out the substrings:

73167

31671

16717

67176

Now, remember, I don’t really want to any arithmetic if I can help it so I do a bit of math thinking and rearrange the numbers in sorted order:

Original           Sorted

73167                77631

31671                76311

16717                77611

67176               77661

I can multiply numbers in any order I want so rearranging the digits won’t change the outcome. However, by sorting numerically, the number with the largest magnitude will automatically give me the largest product. 77661 is the largest number in my sequence here but let’s test my hypothesis just to check my thinking:

Original                     Sorted               Product

73167                          77631                882

31671                          76311                 126

16717                          77611                294

67176                         77661                 1764

Sorting has the added benefit of letting us eliminate strings that have the same digits (and thus the same product). So I only need to find the largest five digit number (after sorting) and then get the product of those five digits. I have now knocked my job down to doing a single multiplication and I bet I can get my computer to do even that little job for me if I’m feeling particularly lazy.

So I just whipped up a quick script to dump out 386 separate five digit strings of digits and sort each set of strings numerically. Then I copied and pasted the output into a spreadsheet and did a quick numerical sort to find the largest numerical quantity. Here is my result:

99972

It’s then a simple matter of using my hand-dandy calculator and determining the product, which is 10,206.

So we took a problem that looked like it would require almost 1000 arithmetic operations and knocked it down to a single calculation with just a bit of thought about the conditions of the problem.

If anyone is interested, I’ve posted my script here.

See, math makes everything better!

#WeHateMath What’s the Difference?

The new school term started yesterday and I’m teaching a course called College Mathematics. Here’s the course description, straight off of the syllabus:

 This course develops problem–solving and decision-making strategies using mathematical tools from arithmetic, algebra, geometry, and statistics. Topics include consumer mathematics, key concepts in statistics and probability, sets of numbers, and geometry. Upon successful completion of this course, students will be able to apply mathematical tools and methods to solve real-world problems.

So this is intended to be a course in functional numeracy, which can be defined as “here’s math you can actually use”. Based on my work on “We Hate Math”, I decided to approach this class in a very different way than I had previously. So my opening remarks (after going over the syllabus and class policies) was an expanded version of this post. The short version was that I was trying to convince them that math and arithmetic are not the same thing and when people think they hate math, what they actually hate is arithmetic (and that’s completely normal).

While I was doing my patter (teaching is one quarter preparation and three-quarters live theater), one of my students raised her hand and asked, “So what’s the difference between math and arithmetic?”

This question stopped me in my tracks. I considered for a moment and this is the explanation I gave her.

Let’s suppose I want to drive to the pet store. I have a choice of two routes to get there, like so:

If I take Belmont, I have a five mile drive but if I take Damon, I have an eight mile drive. I then asked her which route I should take.

“Belmont”, she said.

“And that’s exactly the answer that arithmetic will give you”, I said, “because arithmetic can only really tell you that five is less than eight. Math, on the other hand, knows about speed limits, traffic lights,…”

“Rush hour”, said another student.

Yet another student chimed in, “Road repair.”

“Right!”, I said,scribbling the list on the whiteboard, “so if we go back to our example and I tell you that Belmont has a twenty-five mile per hour speed limit and there are five traffic lights between my home and the pet store. Damon, on the other hand, has a forty-five mile-per-hour speed limit and there are only two traffic lights, one at either end of the route, which one would you take?”

“Damon”, she said.

“That’s the difference between math and arithmetic.”

There’s a reason why the phrase “Do the math” actually means “Think it through”.

 

#WeHateMath Common Core Math: #TheMelvinProject

The Common Core State Standards Initiative, less formally known as Common Core, has raised hackles all over the place.

Now I may be just a Simple Country Lawyer but I thought I’d take a closer look at the standards themselves and try to cut through the noise and see for myself if they make sense and what, if any, potential pitfalls are lurking there in the underbrush.

I’m calling this The Melvin Project, in honor of Arizona Senator Al Melvin who was recently quoted voicing his opposition to implementing the Common Core standards in his state. Since there’s a lot of material to cover, I’ll be doing this across multiple postings and will restrict my inquiry to the proposed standards for math education.

But first a few words about Senator Melvin. When asked if he had actually read the Common Core standards documentation, he replied, “I’ve been exposed to them.” Every teacher (and for that matter, every student) knows exactly what that phrase means. It’s what students say when you ask if they’ve done the reading. In other words, Senator Melvin most likely has no idea what is contained in the Common Core Standards documentation. Here’s the winning quote from the Arizona Daily Star:

“Pressed by Bradley for specifics, Melvin said he understands “some of the reading material is borderline pornographic.” And he said the program uses “fuzzy math,” substituting letters for numbers in some examples.”

This is the part that really drew my attention (and that of several other bloggers as well). Merriam-Webster defines pornography as “the depiction of erotic behavior (as in pictures or writing) intended to cause sexual excitement”. I’m not one to pass judgment on what individuals do in the privacy of their own homes but I wish to extend my sincere sympathies to Mrs. Senator Melvin and just leave it at that.

Now about that “fuzzy math” comment…

Fuzzy math is a real thing and has two definitions. The first involves math that deals with non-binary values. For example, in the real world, we can talk about things being ‘hot’ or ‘cold’ without assigning specific temperatures because these terms represent ranges. Traditional math can only deal with specific numbers but fuzzy math lets us perform useful calculations using values that fall along a continuum. In computer terms, traditional math is digital, the real world is analog and fuzzy math lets us bridge that gap.

The other definition of ‘fuzzy math’ is political. It’s a term used (rightly or wrongly) to criticize your opponent’s numbers. In many cases, it translates as “I don’t understand what you’re talking about, but I just hate you and I hate your ass face.

Finally let’s address that whole “substituting letters for numbers” outrage.

Senator, that’s what those of us who didn’t sleep through our primary education years call Algebra. It’s the simplest possible math that can still be called ‘Math’. I realize that the name comes from the Arabic and perhaps that’s at the root of your objections (I don’t judge), but rest assured when it comes to traditional values, Algebra is no slouch in that department as it dates back to the ancient Babylonians. We use letters in place of (some) numbers as placeholders either because we don’t know all of the numbers yet or because we don’t care about specific values since we’re trying to find a general solution where we can plug in numbers later.

So I invite all of you to join me for The Melvin Project, where I explore the history, reality and (possible) conspiracy of Common Core and see whether we can all just calm the heck down.

#WeHateMath Why I Hate Arithmetic (And Why You Should Too)

I’m Tom and I hate arithmetic. (“Hi, Tom!”)

Let’s face it. Everybody hates arithmetic. It’s boring, mechanical, unnatural and an unfit occupation for a respectable human. We hate arithmetic so much that we’ve spent the past 40,000 years inventing things to do arithmetic for us.

Consider Stonehenge.

  • Up to 165 stones, about half of which were 18 feet long and weighed 25 tons.

  • There is no building stone in the area, so the stones had to be dragged from hundreds of miles away.

  • The entire construction took 30 million hours (about 1500 years).

All of this work and when it comes right down to it, it’s basically a big calculator. We hate arithmetic so much we will go to ridiculous lengths to avoid doing it. Worse yet, if you openly admit that you hate arithmetic, you’re shamed and ridiculed.

Math is not arithmetic but the way we teach both subjects doesn’t make this clear. Arithmetic is mainly memorization which is expected for something so mechanical.

“Here’s the times table. We’ll quiz you on it later.”

“Here’s the transitive property. Memorize it.”

The basic strategy for surviving arithmetic class is memorize, memorize, memorize. Then we get to math class and NOBODY TELLS THAT THIS ISN’T ARITHMETIC ANY MORE. Instead we’re given more things to memorize without any human context. Math is about creativity, imagination, intuition and seeing the patterns that go on all around us and trying to understand them. There’s none of this in a typical math class, much less a typical math textbook.

Let me put it another way. Let’s say that you like stories.  You like to tell them, you like to create your own, you enjoy listening to others tell them to you. So you start school and you’re all excited because you’re finally going to learn how to write these great stories that you’ve been imagining.

You start out and learn about all of the letters. Some of the letters have special names (‘vowels’, ‘consonants’) and you learn them. You learn how the letters go together in words (spelling) and placing words in sentences (grammar). You memorize the structure of a sentence and all of the different parts (‘subject’, ‘verb’, ‘adjective’,’adverb’, ‘gerund’ [yeah, that’s a real thing])

Are we ready to write stories yet?

Nope, still got more stuff to memorize. Subjunctive, declarative, indicative, imperative, the difference between passive and active voice, between first person singular and third person plural, proper use of semi-colons, dangling participles, prepositional phrases….

Okay, I’m officially exhausted and we’ve completely given up on our original goal to be able to write our stories to share with others.

A few years back I was teaching a Pre-Algebra class for some adult learners and I had one older gentleman who was really struggling with the material. One day I had him come up to the board, work a problem and explain how he solved it. He got the right answer, but he did it in a way that I had never seen before. That’s when I asked him what he did outside of class.

It turned out he was a carpenter. He used math all the time, because you need math to create good-looking functional pieces. When he was learning carpentry, he picked up the tools and techniques he needed in service to this. He knew what a correctly proportioned bookshelf that wouldn’t fall over should look like and feel like and the tools of math were just things he picked up on the road to that goal.

Math is about exploring the world around us and trying to understand why things are the way they are. Why do certain combinations of notes sound pleasant and others don’t? Why is the sky blue? How do I throw a stone to make sure it goes as far as possible? Numbers, proportions, sequences, patterns are around us all the time. We can see them and we’re compelled by our very nature to try and understand them. This is what math is about.

#WeHateMath Review: “A Mathematician’s Lament”

(From time to time, I’d like to post a quick review of math-related books or other media in which I think readers might [ or should ] be interested.)

Consider my mind officially blown.

I’ve just finished reading “A Mathematician’s Lament” by Paul Lockhart. It’s not a long read (a bit over 100 pages) but each page is filled with a passion and eloquence that you don’t normally associate with a mathematician. This is the first book about math where I could really feel that the author not only openly admitted his love for the subject but expressed that love in a way that we as readers are swept along with him. Let me give you an example:

“As I said before, the most important thing to understand is that mathematics is an art. Math is something you do. And what you are doing is exploring a very special and peculiar place—a place known as “Mathematical Reality.” This is of course an imaginary place, a landscape of elegant, fanciful structures, inhabited by wonderful, imaginary creatures who engage in all sorts of fascinating and curious behaviors. I want to give you a feeling for what Mathematical Reality looks and feels like and why it is so attractive to me, but first let me just say that this place is so breathtakingly beautiful and entrancing that I actually spend a good part of my waking life there. I think about it all the time, as do most other mathematicians. We like it there, and we just can’t stay away from the place.”

Excerpt From: Paul Lockhart. “A Mathematician’s Lament.” iBooks. https://itun.es/us/X0iYw.l

This is not one of those books where the author presents math as some rarified, ivory tower, ‘secret language of the universe’ life mission. Rather, Lockhart presents a convincing case for math as a quintessentially human activity, on par with art or literature, that requires the best of our intuition, creativity and imagination.

The book is in two parts: Lamentation and Exultation. Part One (Lamentation) is a very angry (but well-reasoned) indictment of the modern system of math education. I think one of the things that drew me to this book was that Lockhart has many of the same complaints that I do but he takes my own thoughts even further. As part of his argument, he inserts an ongoing dialogue between two characters, Salviati and Simplicio, who discuss about the current points that Lockhart brings up. (These are the same names that Galileo used with a similar technique in his pamphlet arguing that the Earth revolved around the Sun) If you teach math, are studying math or have ever taken a math class, this section should get you righteously angry.

Part Two (Exultation) acts as a cool, palate cleansing sorbet. In it, Lockhart not only expresses his love for math but brings you into his world so you can share in his passion. He takes you through several math-related puzzles in a very natural fashion, not with the intent of finding The Solution but rather to show just how wonderful and mysterious this universe of ours insists on being.

“A Mathematician’s Lament” is a breezy (but emotional) read and anyone who is involved in any way with math education (including math students themselves) needs to have a copy. It’s available in both print and electronic format from the usual suspects.

References

Lockhart, P. (2009). A mathematician’s lament. New York, NY: Bellevue Literary Press.