Saturday 23 May 2015

algorithms - How to add or multiply decimal numbers?

The tag ''calculus'' may not fit for this question but I couldn't think of anything else. Please feel free to change it.



Suppose $a=0,a_{-1}a_{-2}a_{-3}\ldots$ and $b=0,b_{-1}b_{-2}b_{-3}\ldots$ are two decimal numbers. To be precise, I should have add ''representation of'' before ''decimal numbers'' but this is not of what the question is about.




How can I practically add and multiply $a$ and $b$?




If $a$ and $b$ are rational and thus periodic, you could answer, that I should convert them to fractions $a={a'\over a''}$ and $b={b'\over b''}$ and do the obvious thing, but I don't want to do this.




Starting with addition, the problem is about digit sums bigger then $10$. If $a=b=0,111\ldots$ you have no problems adding them digit by digit from the left to $a+b=0,222\ldots$. But when you have something like $a=0,0888\ldots$ and $0,0111\ldots$ you can't write down any digit of the sum until you know what comes next if you start from the left since there may occur a digit sum $>10$ as with $a=0,088890\ldots$ and $0,011110\ldots$, can you? What happens here exactly, if $a$ and $b$ are rational? How does the length of the period of $a+b$ relies to the period lengths of $a$ and $b$?



The problem gets more complicated, if you think of multiplication. For ''finite'' numbers like $a=b=0,2=0,200\ldots$ you just write down a multiplication table and that's it (despite the fact, that $0,2=0,1999\ldots$, but let's ignore this). But how about arbitrary or rational numbers? I have the impression, that the length of the period may be much much bigger in the product. Is there an upper bound depending on the period lengths of $a$ and $b$?



As you define a decimal number as a certain absolutely convergent row, you define the multiplication by the Cauchy product, but this doesn't help when you want to do multiplication practically. Is there an easy algorithm?



Here is a concrete challenge: Multiply $a=b=0,\overline{142857}$.

No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...