Friday, January 20, 2012

Product of Negative Integers...Easy as -1, -2, -3

I have been reading One, Two, Three: Absolutely Elementary Mathematics by David Berlinski. While the topic is basic mathematics, the book's content is not elementary my dear Watson.
In a side discussion of negative numbers he presents a proof of a rule that has baffled students since the discussion of positive and negative integers began--namely if when you multiply two positive numbers the product is positive and when you multiply a positive number to a negative number you get a negative outcome, how is it that when two negative numbers are multiplied together the result is a positive number? Berlinski eloquently details the proof on over two pages with this conclusion:
[xy + x(–y)] + (–x)(–y) = xy.
[xy + x(–y)] + (–x)(–y) = –x–y.
Therefore, xy = –x–y.
Berlinski, David (2011-05-10). One, Two, Three: Absolutely Elementary Mathematics (p. 153-154). Pantheon. Kindle Edition.

I thought it would be good to do this in Ruby for fun. And sure enough, the proof stands true.

#-2*-2 = 2*2. In other words, when you
#multiply 2 negative integers it is the
#same as multiplying the same two positive
#integers. -x*-y = x*y
x = 2
y = 3
puts ((x*y + x*-y) + -x*-y == x*y) ==
((x*y + x*-y) + -x*-y == -x*-y)

No comments: