urn:lsid:ibm.com:blogs:entries-84a1e68f-fa2b-4d83-a240-5f565e7d6248Mainframe Performance Topics with Martin Packer - Tags - maths I'm a well-known mainframe performance guy, with almost 30 years of experience helping customers manage systems. I also dabble in lots of other technology. I've sought to widen the Performance role, incorporating aspects of infrastructural architecture.22015-02-21T16:45:07-05:00IBM Connections - Blogsurn:lsid:ibm.com:blogs:entry-143e9dde-a292-4114-925d-643a2e626046Another Neat Piece Of Algebra - Series SummationMartinPacker11000094DHactiveComment Entriesapplication/atom+xml;type=entryLikes2011-07-19T13:00:56-04:002011-07-19T13:00:56-04:00<p>Here's another neat piece of algebra: A technique for summing series.</p>
<p>You know what b - a + c - b + d - c is. Right?</p><p>
</p><p>Suppose I were to write the same sum as:</p>
<p>(b - a) +</p>
<p>(c - b) +</p>
<p>(d - c)</p>
<p>The answer is still d - a. Right?</p>
<p>Now, suppose I re-label with s<sub style=" vertical-align:-50%;">0</sub> = a, s<sub style=" vertical-align:-50%;">1</sub> = b, s<sub style=" vertical-align:-50%;">2</sub> = c and s<sub style=" vertical-align:-50%;">3</sub> = d. We end up with:</p>
<p>(s<sub style=" vertical-align:-50%;">1</sub> - s<sub style=" vertical-align:-50%;">0</sub>) +</p>
<p>(s<sub style=" vertical-align:-50%;">2</sub> - s<sub style=" vertical-align:-50%;">1</sub>) +</p>
<p>(s<sub style=" vertical-align:-50%;">3</sub> - s<sub style=" vertical-align:-50%;">2</sub>)</p>
<p>This is actually pretty scalable terminology as you can write s<sub style=" vertical-align:-50%;">r</sub> for any arbitrary value of r. And that's one of the strengths of algebra: generalisation.</p>
<p> So let's do that up to n:</p>
<p>(s<sub style=" vertical-align:-50%;">1</sub> - s<sub style=" vertical-align:-50%;">0</sub>) +</p>
<p>(s<sub style=" vertical-align:-50%;">2</sub> - s<sub style=" vertical-align:-50%;">1</sub>) +</p>
<p>...</p>
<p>(s<sub style=" vertical-align:-50%;">n</sub> - s<sub style=" vertical-align:-50%;">n-1</sub>)</p>
<p>which is, of course, s<sub style=" vertical-align:-50%;">n</sub> - s<sub style=" vertical-align:-50%;">0</sub>.</p>
<p>But what has that got to do with summing series?</p>
<p>If we can replace each (s<sub style=" vertical-align:-50%;">r</sub> - s<sub style=" vertical-align:-50%;">r-1</sub>) by a single term u<sub style=" vertical-align:-50%;">r</sub> you may see the relevance...</p>
<p>u<sub style=" vertical-align:-50%;">1</sub> + u<sub style=" vertical-align:-50%;">2</sub> + ... + u<sub style=" vertical-align:-50%;">n</sub> = s<sub style=" vertical-align:-50%;">n</sub> - s<sub style=" vertical-align:-50%;">0</sub>.</p>
<p>The series summation boils down to a "simple" subtraction. The trick is to find these s terms, given the u terms. Let's try it with an example.</p><p> <br /></p>
<hr><br /></hr>
<h3> <br /></h3><h3>Summing The Integers</h3>
<p> <br /></p><p>This is the series 1, 2, 3, ... , n.</p>
<p>The r'th u term is just r. u<sub style=" vertical-align:-50%;">r</sub> = r. So we now have to find the s<sub style=" vertical-align:-50%;">r</sub> term. Remember s<sub style=" vertical-align:-50%;">r</sub> - s<sub style=" vertical-align:-50%;">r-1</sub> has to equal r.</p>
<p>Try s<sub style=" vertical-align:-50%;">r</sub> = r (r + 1).</p>
<p>Then s<sub style=" vertical-align:-50%;">r-1</sub> = (r - 1) r or r (r - 1).</p>
<p>So s<sub style=" vertical-align:-50%;">r</sub> - s<sub style=" vertical-align:-50%;">r-1</sub> = [(r + 1) - (r - 1)] r or 2r. Not quite what we wanted. But we know - dividing by the factor of 2 - we should've guessed s<sub style=" vertical-align:-50%;">r</sub> = ½ r (r + 1).</p>
<p>So s<sub style=" vertical-align:-50%;">n</sub> - s<sub style=" vertical-align:-50%;">0</sub> = ½ n (n + 1) - ½ 0 (0 + 1) = ½ n (n + 1) - 0 = ½ n (n + 1).</p><p>
</p><p>The sum of the first n integers being ½ n (n + 1) is a well-known result. Admittedly it could've been done another way. But it's simple enough to show the method.</p><p> <br /></p>
<hr />
<h3> <br /></h3><h3>Another Example - Summing The Squares Of The Integers</h3>
<p> <br /></p><p>This is the series 1, 4, 9, ... , n² .</p>
<p>In this case we need to do something that will appear slightly perverse:</p>
<p>Rewrite r² as r ( r + 1) - r.</p>
<p>If you can split each of the terms in a series into two terms you can sum these sub terms. I just did the split. We already know how to sum the "r" portion. It's ½ n (n + 1). So we need to sum the r (r+1) portion and subtract ½ n (n+1) from the result.</p>
<p>Try s<sub style=" vertical-align:-50%;">r</sub> = r (r + 1) (r + 2).</p><p>
</p><p>Again we need to find s<sub style=" vertical-align:-50%;">r-1</sub>.</p>
<p>It's:</p>
<p> (r - 1) r (r + 1)</p>
<p>or, rearranging,</p>
<p>r (r+1) (r-1)</p>
<p>So</p>
s<sub style=" vertical-align:-50%;">r</sub> - s<sub style=" vertical-align:-50%;">r-1</sub> = [(r + 2) - (r - 1)] r (r + 1) or 3r (r + 1).<p />
<p>This is 3 times what we want so we should've guessed s<sub style=" vertical-align:-50%;">r</sub> = 1/3 r (r + 1) (r + 2).</p>
<p>So this portion of the sum is 1/3 n (n + 1) (n + 2) - 1/3 0 (0 + 1)(0 + 2) or 1/3 n (n + 1) (n + 2).</p>
<p>But we need to subtract ½ n (n + 1) from this:</p>
<p>1/3 n (n + 1) (n +2) - ½ n (n + 1) = 2/6 n (n + 1) (n +2) - 3/6 n (n + 1)</p><p>
</p><p>or</p>
<p>1/6 n (n + 1) [ 2 (n + 2) - 3] = 1/6 n (n + 1)( 2 n + 1) .</p>
<p>If you try it for a few values you'll see it's right. This <b>isn't</b> such a well known result as for the sum of the integers.</p><p> <br /></p>
<hr />
<p> </p><p>I'm conscious there's been some fiddliness here - which is where <b>I</b> normally fall down. <img src="https://www.ibm.com/developerworks/community/blogs/images/smileys/sad.gif" class="smiley" alt=":-(" title=":-(" /></p>
<p>But I think the "sum a series by converting it to a single subtraction" trick is a neat one - which is why I share it with you.</p>Here's another neat piece of algebra: A technique for summing series.
You know what b - a + c - b + d - c is. Right?
Suppose I were to write the same sum as:
(b - a) +
(c - b) +
(d - c)
The answer is still d - a. Right?
Now, suppose I...102097urn:lsid:ibm.com:blogs:entry-76ce0af7-bf94-46e5-8727-b396e8398cf5Hello, I'm Martin And I'm An Algebraic :-)MartinPacker11000094DHactiveComment Entriesapplication/atom+xml;type=entryLikes2011-07-09T16:13:16-04:002011-07-09T16:13:16-04:00<p>If you're sat next to me on a plane you'll probably notice at take off and landing I do algebra puzzles. You may not have heard of the term "algebra puzzles" before and perhaps think the juxtaposition of the two words to be odd, but I think it apt...</p>
<p>(You may also think this whole post to be showing off, but that's a risk I take in sharing a passion I have.) <img src="https://www.ibm.com/developerworks/community/blogs/images/smileys/smile.gif" class="smiley" alt=":-)" title=":-)" /> </p>
<p>A classic problem with take offs and landings is what to do given you're not allowed to use electronic equipment. I'll readily agree that staring out the window is a good one - which is why I prefer a window seat. I <b>love</b> staring out the window. I love maps - and to me looking out of an airplane window brings maps to life. And figuring out what I'm seeing is another <b>great</b> puzzle. But sometimes there's nothing to see. So what do you do?</p>
<p>I started by taking puzzle books with me. I've done <a href="http://en.wikipedia.org/wiki/Sudoku">Sudoku</a> (but not recently), <a href="http://en.wikipedia.org/wiki/Kakuro">Kakuro</a>, <a href="http://en.wikipedia.org/wiki/Futoshiki">Futoshiki</a>, <a href="http://en.wikipedia.org/wiki/Hashiwokakero">Hashi</a>, <a href="http://en.wikipedia.org/wiki/KenKen">Kenken</a> and any number of others. I enjoy them but each one lacks variety. (And I'm disappointed that by far and away the most common puzzle books are Sudoku.)<br /></p>
<p>But I find the best puzzles of all are algebra problems. I still have a copy of my "high school" Further Mathematics textbook. I don't know why, I just do. <img src="https://www.ibm.com/developerworks/community/blogs/images/smileys/smile.gif" class="smiley" alt=":-)" title=":-)" /></p>
<p>I actually think it's the elegance of expression and the neatness of the right shortcut that appeal to me. As I've said many times I'm a sucker for ingenuity. Below is an example of a neat shortcut that I'd like to share with you. I hope you'll see what I mean.
</p>
<p>One of the nice things about mathematics in general is that you're perpetually "standing on the shoulders of giants". Some of them well known (Newton, Leibnitz, Euclid, Gauss, etc) but many are anonymous. In the example below I've no idea who thought of the shortcut first. (I'm just pleased I understand it and can see its applicability.)</p>
<hr style="width: 100%; height: 2px;" />
<hr\>
<h4>A Simple Example Of Elegance</h4>
<p><b>Problem:</b> Solve (x - 3)² - (x + 2)² = 0</p>
<p>It looks like a difficult puzzle to solve. Of course if it were I wouldn't be offering it here. <img src="https://www.ibm.com/developerworks/community/blogs/images/smileys/smile.gif" class="smiley" alt=":-)" title=":-)" /> You could multiply everything out and gather terms but that's horrid. Thankfully, there is a more elegant way:</p>
<p>Observe x² - y² = (x - y) (x + y) . (Check it if you don't believe me!)</p>
<p>If you substitute a for (x - 3) and b for (x + 2) you get:</p>
<p>a² - b² which, of course, can be rewritten as (a - b) (a + b) .</p>
<p>I think you'll agree working out what (a - b) and (a + b) are is easy:</p>
<p>a - b = (x - 3) - (x + 2) or -5</p>
<p>a + b = (x - 3) + (x + 2) or 2x - 1</p>
<p>Multiply them together and you get:</p>
<p>-5 × (2x - 1) = 5 - 10x </p>
<p>So (x - 3)² - (x + 2)² = 5 - 10x which = 0, as the original problem stated.</p>
<p>If 5 - 10x = 0 then 10x = 5 and so x = ½.</p>
<hr style="width: 100%; height: 2px;" />
<hr\>
<p>See, that wasn't so hard, was it? I think people think mathematics is hard. I don't think algebra is hard. I <b>do</b> thing topology is hard - because of the abstractness of the concepts. I <b>do</b> think proving things is hard - because of the need to not miss any loose ends and to know whether you've actually <span style="font-weight: bold;">proved</span> anything. But algebra is, to me, pure puzzle solving. And elegance is important: In the above example I could quite easily have made a mistake if I'd not known the trick. With the trick I'm much less likely to.</p>
<p>Now someone will probably come along and point out a few things about the example, including a further trick. If they do I'll be <span style="font-weight: bold;">delighted</span>. This "old dog" <b>loves</b> learning new tricks. <img src="https://www.ibm.com/developerworks/community/blogs/images/smileys/smile.gif" class="smiley" alt=":-)" title=":-)" /> And if I <b>am</b> sat next to you on the plane at least I won't be muttering to myself as I manipulate those symbols. <img src="https://www.ibm.com/developerworks/community/blogs/images/smileys/smile.gif" class="smiley" alt=":-)" title=":-)" /></p></hr\></hr\>If you're sat next to me on a plane you'll probably notice at take off and landing I do algebra puzzles. You may not have heard of the term "algebra puzzles" before and perhaps think the juxtaposition of the two words to be odd, but I think it apt......363421