# Finding the first $n$ digits in a multiplication

I'm not sure how to best approach this type of problem. It seems reasonable that there's going to be use of exponents, scientific notation. But I'm not familiar with doing this type of problem.

I would be grateful to see worked solutions to these so that I could apply the method in future.

Here's the problem Since an integer $m$ has $\lfloor \log_{10}(m) \rfloor + 1$ digits, when $m = ab$ the formula is simply $$\lfloor \log_{10}(a) + \log_{10}(b) \rfloor + 1$$

For the second question, I don't think there's a general way to solve it. You could start by multiplying the first digits and adding digits until the first three are fixed. As an example, by taking the first pair: \begin{align*} 34 \times 36 &= \color{green}{12}24\\ 342 \times 365 &= \color{green}{12}4830\\ 3429 \times 3659 &= \color{green}{125}46711\\ 34297 \times 36598 &= \color{green}{12552}01606\\ 342973 \times 365989 &= \color{green}{125524}345297\\ &\hspace{0.57em}\vdots \end{align*}

The actual result is $1255246429631375257630154145266670$. Intuitively, this "converges" to the actual result because at each step, the error is decreasing (and eventually will be zero), so the left hand-side digits are increasing in accuracy. You would have to prove this rigorously though.

An interesting exercise would be to determine how many digits you have to take to be guaranteed to get the first $n$ digits of the product correct.

• Well, at least we have a rough idea of how to get the first three significant digits of $0.365989\cdots\times0.34297\cdots$ Jul 29, 2016 at 13:12
• @rubik thanks - i feel as though the log solution might be tricky without a calc. Re the approach to increasing the amount of digits used and noting what they converge to, that makes sense. I feel that the exercise you suggest at the end is getting at the meat of the problem
– baxx
Jul 29, 2016 at 15:55

The first factor is $3.659893456789325678\times 10^{18}$, the second is $3.42973489379265\times 10^{14}$. Hence their product is certainly larger than $$3.659\times 3.42 \times 10^{18}\times10^{14}=12.51378\times 10^{32}$$ and smaller than $$3.66\times 3.43\times 10^{18}\times10^{14}=12.5538\times10^{32}$$ From these two estimates we know for certain that the product looks like $$1.25{*}.{*}{*}{*}.{*}{*}{*}.{*}{*}{*}.{*}{*}{*}.{*}{*}{*}.{*}{*}{*}.{*}{*}{*}.{*}{*}{*}.{*}{*}{*}.{*}{*}{*}$$

For the second problem, $2^{64}$, we can first use the rule of thumb that $2^{10}=1024\approx 10^3$. Hence we (very roughly) have $2^{64}= 2^4\cdot (2^{10})^6\approx 16\cdot (10^3)^6=1.6\cdot 10^{19}$. While this estimate is good enough to tell us that $2^{64}$ has twenty digits, it is not good enough to "guess" the leading three digits (we already get the first three digits of $2^{10}$ wrong). Instead, we use that $\log_{10}2\approx 0.30103$ (or more precisely: that $0.30102<\log_{10}2<0.30103$. Then for $\log_{10}(2^{64})=64\log_{10}2$ we obtain $$19.26528 < \log_{10}(2^{64})< 19.26592$$ and this is good enough to find the answer by de-logarithming. An alternative method would be to do repeated squaring: In order to show that $2^{64}$ has twenty digits, beginning with $184$, it suffices (why?)to show that $2^{32}$ has ten digits, beginning with $429$, etc.

• thanks - i'm not able to answer the why that you posit towards the end of your post there though, it would be nice to have an explanation for that.
– baxx
Jul 29, 2016 at 16:04

Ad 1: There is no universal bound on the number of figures to consider in order to get the first three figures in the end result correct. Consider the following example: \eqalign{31622776601683793319\,^2\ &=999999999999999999937454230741109035761\ ,\cr 31622776601683793320\,^2&=1000000000000000000000699783944476622400\ .\cr} The two numbers that are squared here (of value about $3\cdot 10^{19}$) differ by $1$ only. Nevertheless the decimal representations of their squares look completely different.

Ad 2: Begin with $$2^{64}=16\cdot(2^{10})^6=16\cdot 10^{18}\cdot 1.024\,^6\ ,$$ and use the binomial formula: $$1.024\,^6\approx1+{6\choose 1}0.024+{6\choose2}0.000576=1.15264\ .$$ This leads to $$2^{64}\approx16\cdot1.15264\cdot10^{18}=1.84422\cdot10^{19}\ ,$$ while in reality $2^{64}=18\,446\,744\,073\,709\,551\,616$.

Well I've found a "simple" solution for finding the number of digits of the multiplication:

Notice that the number 3515, for example, can be written as $3515 = 10^3 \times 3 + 10^2 \times 5 + 10 ^ 1 + 10^0 \times 5$. Therefore, the number of digits will be the greater exponent of 10 + the digits of its coeficient.

Example: $3515 \times 98543$, the number of digits is equal to $(10^3 \times 3) \times (10^4 \times 9) = 10^3 \times 10^4 \times 9 \times 3 = 10^7 \times 27$, hence the number of digits is 7 + 2 (2 is the number of digits of 27 in this case), that is 9. Now multily those numbers by yourself and check it out.

Well regarding the three left-hand digits I still couldn't think about any certain solution.