Generic 4 digit formula

The case of solving for a 4 digit number multiplied by another 4 digit number is done below. First I shall derive an algorithm and then show how it maps into an easier formula when both numbers are the same. Suppose we have two numbers 2345 and 6789. We have many ways to represent these numbers. For example we could say this:


1500 + 800 + 45 = 2345


1 + 1 + 1 + 6 + 80 + 700 + 2000 + 4000 = 6789


We could also represent them both like this:


(2*1000) + (3*100) + (4*10) + (5*1) = 2345 and (6*1000) + (7*100) + (8*10) + (9*1) = 6789


Now lets multiply them together:


((2*1000) + (3*100) + (4*10) + (5*1)) * ((6*1000) + (7*100) + (8*10) + (9*1)) =


(2*6*1000*1000) + (2*1000*7*100) + (2*1000*8*10) + (2*1000*9*1) + (3*100*6*1000) + (3*100*7*100) + (3*100*8*10) + (3*100*9*1) + (4*10*6*1000) + (4*10*7*100) + (4*10*8*10) + (4*10*9*1) + (5*1*6*1000) + (5*1*7*100) + (5*1*8*10) + (5*1*9*1) =


(12*1000000) + (14*100000) + (16*10000) + (18*1000) + (18*100000) + (21*10000) + (24*1000) + (27*100) + 24*10000 + (28*1000) + (32*100) + 36*10 + 30*1000 + 35*100 + 40*10 + 45 =


12000000 + 1400000 + 160000 + 18000 + 1800000 + 210000 + 24000 + 2700 + 240000 + 28000 + 3200 + 360 + 30000 + 3500 + 400 + 45 =


12000000 + 3200000 + 610000 +100000 + 9400 + 760 + 45 = 15920205



That was a lot of work so now lets derive the formula. If we substitute the letters for the following set of numbers in the original problem above:


a = 2; b = 3; c = 4; d = 5; e = 6; f = 7; g = 8; h = 9;


we could represent each number like this:


(a*1000) + (b*100) + (c*10) + (d*1) = 2345 and (e*1000) + (f*100) + (g*10) + (h*1) = 6789


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, 1000a is considered to be 1000*a.


Now lets multiply the general case together


=



Pattern Identification Opportunity

See if you notice any patterns above... Did you see the '/' pattern? The pattern goes 1, 2, 3, 4, 3 2, 1).





Also note the sum of these groups is 16. Take a look at the 3x3 case and the 2x2 case.


You will note this formula:


Say you have a M digit number, and a N digit number. The number of groupings will be M*N. This holds in general cases. If the digit 0 appears in the string, those grouping are still there for a short time, but then disappear, because the net multiplication of the relative grouping is zero. I call such groupings Ghosts.



Back to our derivation

Note we can also express the same thing this way: =


The answer to our problem.


Now suppose the two numbers are the same, that is suppose a is the same number as d and b is the same number as e and so on. This means:


a=e <-- They are the same


b=f <-- They are the same


c=g <-- They are the same


d=h <-- They are the same


Then we can substitute an 'a' anywhere we find 'e'. We can also substitute a 'b' anywhere we find 'f' and so on. So our formula now becomes:


Again the final result is shown above


Now that we have some formulas, its interesting to think of the problem like this:



The generic a,b,c,d,e,f,g,h 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 10000'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 10000's column). The middle sets themselves break into three groups.




The generic number squared 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 10000'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 10000's column). The middle sets themselves break into three groups.



I find the pictorial way of viewing the numbers with the highlighted groupings a much easier way to solve problems, than 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.


Try to derive a pattern that handles 5 digit numbers multiplied by 5 digit numbers: example 12345*23456. 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.


Introduction to java


Fun with numbers


Side note: If you are interested in java and want to see a quick 'how to' demonstration, feel free to download this zip file that contains the java source and compiled class info. This program takes numbers and converts them to the text equivalent. Its just a demo program so it isn't perfect. For example 123 would become one hundred twenty three



Curious? Send me email if curious...
Where is Saddam's Money? Thanks for visiting! Back...

Tracfone cell phone deal

Get yourself an awesome deal on a cell phone through TracFone and avoid getting stuck in an endless contract.

Take a look at the world famous beaver cam


Copyright ©1997-2004 David Stockwell All rights reserved