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,a1a2a3 and b=0,b1b2b3 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=aa and b=bb 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 you have no problems adding them digit by digit from the left to a+b=0,222. But when you have something like a=0,0888 and 0,0111 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 and 0,011110, 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 you just write down a multiplication table and that's it (despite the fact, that 0,2=0,1999, 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,¯142857.

No comments:

Post a Comment

real analysis - How to find limhrightarrow0fracsin(ha)h

How to find lim without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...