Multiply 2 terminating numbers and get a repeating decimal?

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

sgfw
Posts: 46
Joined: Wed Jun 19, 2013 11:47 pm UTC

Multiply 2 terminating numbers and get a repeating decimal?

The two terminating numbers in question are 0.3333331901677568 and 1.0000004294967296. When multiplied in base 10, they result in the terminating number 0.33333333333327184418642096816128. The problem arises when they are multiplied in base 4294967295.

As you can see, both 0.3333331901677568 and 1.0000004294967296 terminate when expressed in base 4294967295 according to wolfram alpha:
http://www.wolframalpha.com/input/?i=0.3333331901677568+in+base+4294967295
http://www.wolframalpha.com/input/?i=1.0000004294967296+in+base+4294967295

However, the product does seem to repeat:
http://www.wolframalpha.com/input/?i=0.3333331901677568*1.0000004294967296+in+base+4294967295

I was under the impression that two terminating numbers could not result in a repeating decimal when multiplied. Can someone explain this?

Posts: 33
Joined: Wed Apr 21, 2010 8:33 pm UTC

Re: Multiply 2 terminating numbers and get a repeating decim

If the set of prime factors of the denominator in your base is a subset of the prime factors of the base (without repetition), the decimal expansion will terminate; otherwise it will repeat.

a*b = 7761021455127555974443/23283064365386962890625

23283064365386962890625 = 5^32 -> the fraction will terminate in base 10 (5*2), as well as in base 4294967295 (3*5*17*257*65537).

DavCrav
Posts: 251
Joined: Tue Aug 12, 2008 3:04 pm UTC
Location: Oxford, UK

Re: Multiply 2 terminating numbers and get a repeating decim

If you have two numbers a and b that have a terminating n-ary expansion, then so does their product. The quick way to see this is to multiply a and b by a suitably large power of the base so that they become integers, then product them to get an integer, obviously. Dividing by the (square of the) suitably large power of the base again gets us our original product, and since dividing by the base is just shifting the decimal (n-imal?) point, we must have a terminating n-ary expansion for ab.

sgfw
Posts: 46
Joined: Wed Jun 19, 2013 11:47 pm UTC

Re: Multiply 2 terminating numbers and get a repeating decim

Okay, so is wolfram alpha doing the multiplication/base conversion incorrectly, or does the number just repeat for an absurdly long time before terminating?

gmalivuk
GNU Terry Pratchett
Posts: 26739
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There
Contact:

Re: Multiply 2 terminating numbers and get a repeating decim

Something that doesn't repeat in one base could definitely repeat in another. What you've done is multiply those numbers in base-10 and then converted the result to that other base.

One-tenth in binary is 0.00011001100110011...
Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
---
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome

(he/him/his)

jaap
Posts: 2094
Joined: Fri Jul 06, 2007 7:06 am UTC
Contact:

Re: Multiply 2 terminating numbers and get a repeating decim

sgfw wrote:The two terminating numbers in question are 0.3333331901677568 and 1.0000004294967296. When multiplied in base 10, they result in the terminating number 0.33333333333327184418642096816128. The problem arises when they are multiplied in base 4294967295.

As you can see, both 0.3333331901677568 and 1.0000004294967296 terminate when expressed in base 4294967295 according to wolfram alpha:
http://www.wolframalpha.com/input/?i=0.3333331901677568+in+base+4294967295
http://www.wolframalpha.com/input/?i=1.0000004294967296+in+base+4294967295

However, the product does seem to repeat:
http://www.wolframalpha.com/input/?i=0.3333331901677568*1.0000004294967296+in+base+4294967295

I was under the impression that two terminating numbers could not result in a repeating decimal when multiplied. Can someone explain this?

Wolfram Alpha got the product wrong.
The first two numbers definitely terminate. The numerators of 3333331901677568/10^16 and 10000004294967296/10^16 are cleverly chosen to be multiples of 2^16, so the denominators reduce to 5^16. Therefore they each must terminate after 16 'digits' in base 4294967295, and Wolfram Alpha agrees. Their product therefore must terminate after 32 'digits'.

The product in decimal is in fact equal to
59923104 0489375583 4627910319 4669703951 6481588818 8759571507 3098603836 9977660312 9171702690 0896459477 3671772763 4626966616 4500201855 4522846076 7227016700 9339066513 3424483123 4208379606 0883933410 7307608599 7036088895 0008550700 1766322682 7995438715 1874410277 5241682839 6645097508 3122212717 0678108623 7956579833 2125850283
divided by 4294967295^32.

ETA:
Wolfram gets it right if your inputs are written as rationals rather than decimal notation:
http://www.wolframalpha.com/input/?i=%283333331901677568%2F10%5e16*10000004294967296%2F10%5e16%29+in+base+4294967295

ETA2:
Actually, Wolfram gets the original numbers wrong too, even though these wrong versions also terminate. It must simply be that floating point numbers have less than 16 digits precision.

Parralelex
Posts: 74
Joined: Sun Dec 02, 2012 8:10 am UTC
Location: Location Location

Re: Multiply 2 terminating numbers and get a repeating decim

A number terminates in base b if and only if it can be written as x/y, where x is any integer and y is an integer such that all the prime factors of y are prime factors of b (For example, in base 10 this is pretty clear. Divide a terminating number by 2 or 5, for example, and the result clearly won't go on forever).

So if you have two numbers that terminate in base b, call them p and q, then p = x1/y1 and q = x2/y2, with the x's and y's following above. If y1 and y2 both contain only prime factors found in b, then y1*y2 certainly does as well, so p*q satisfies above, so it doesn't terminate.
I put the "fun" in "mathematics".

And then I took it back out.