10 + 10 + 10 + 40 + 3 + 2 = 75
20 + 20 + 20 + 30 + 1 + 1 + 1 = 93
We could also represent them both like this:
(7*10) + (5*1) = 75 and (9*10) + (3*1) = 93
Now lets multiply them together:
((7*10) + 5*1)) * ((9*10) + (3*1)) =
(7*10)*(9*10) + (5*1)*(9*10) + (7*10)*(3*1) + (5*1)*(3*1) =
(7*9*100) + (5*9*10) + (7*3*10) + (15 * 1) =
(6300) + 450 + 210 + 15 = 6975
Now lets derive the formula. If we substitute the letters for the following set of numbers in the original problem above:
a = 7; b = 5; c = 9; d = 3;
we could represent each number like this:
(a*10) + (b*1) = 75 and (c*10) + (d*1) = 93
But since we are solving for any number we don't have to worry about the numbers on the right hand side at the moment. Also note by convention, 10a is considered to be 10*a.
Now lets multiply the general case together
((a*10) + (b*1)) * ((c*10)+(d*1)) =
((10a + b) * (10c + d)) =
10*10*a*c + 10*b*c + 10*a*d + b*d =
100ac + 10bc + 10ad + bd = The answer to our problem.
Now suppose the two numbers are the same, that is suppose a is the same number as c and b is the same number as d. This means:
a=c <-- They are the same
b=d <-- They are the same
Then we can substitute an 'a' anywhere we find 'c'. We can also substitute a 'b' anywhere we find 'd'. So our formula now becomes:
100a*a + 10b*a + 10a*b + b*b =
Now we know that a*b = b*a so
100a**2 + 20a*b + b**2 <-- This is the generic formula if the two numbers are the same.
Now that we have formulas, its interesting to think of the problem like this: (generic a,b,c,d case)
The original numbers are arranged above the line. The formula generates the grouping below the line and shows them generally aligned according to their units.
Notice in our generic formula, the first digits start in the 100's column. The last digits start in the one's column.
And the middle sets reside between the two (they actually start in the 10's column, and may overlap into the 100's column).
Also note the ad and bc get added together. I find the pictorial way of viewing the numbers with the highlighted groupings a much easier way to solve problems, then just memorizing some formula which you will probably forget .
You can think of the pictures of these numbers as patterns. The idea that there is a pattern is the basis of many computer related concepts.
For Example the Object Oriented Methodology is comprised of identifying and using patterns in a meaningful manner. There have been many books written that teach you how to find patterns in the process of Object Oriented Design.
Another use of the pattern is for really huge number arithmetic and how this relates to computer architecture as a whole. Although today's computers are binary(base 2 arithmetic) based and many operations are simply left and right bit shifts, this mechanism lends itself to the idea of using patterns to solve a problem.
Try to derive a pattern that handles 3 digit numbers multiplied by 3 digit numbers: example 123*456.
I will present the algorithm and pattern soon and you may use that to check your work. The eventual goal is to develop a pattern capable of handling a number of 'n' digits multiplied by a second number of 'm' digits.
Counter Started
01/26/98: |
Thanks for visiting! | Back... |
The 3x3 Pattern
|
Algorithms are a wonderful field to explore. Discovering the patterns of things is what many algorithms are based on. Many algorithms are very simple and by their repetitive nature are easily assimilated into computer programs. However much more complex algorithms take a bit more adaptation to get into a computer program. The concept of Integration (when you learn Calculus) is aproxmiated in the computer world as a series of iterations. Finding the volume in a curve of say perhaps a concrete cap on a wall, can be determined mathematically with simple Integration (calculus), however in the programming world, its done iteratively, that is the volume of piece 1, plus the volume of piece 2, plus the volume of piece 3 and so on. Normally when one models this in the computer world, the pieces will be made quite small thus minimizing error and producing more accurate results. If you want to get an idea of what happens when a programmer wants to model the real world in a program, you should take a look at the following book. You might be able to find it at your local library. However if not you can pick it up at amazon.
The book, Introduction to Algorithms by Thomas H. Cormen is quite well explained and is on many programmer shelfs due to its great indepth coverage of algorithms. |