Repeating Decimals

Anything About Anything...
Post Reply
User avatar
Ratchet
Match Winner
Posts: 779
Joined: Sat Mar 15, 2008 5:55 am

Repeating Decimals

Post by Ratchet »

Have you ever been curious and wanted to know how you could take a repeating decimal and represent it as a fraction? Odds are, the answer is “No.”
However, I feel like it’s something you may perhaps find interesting enough to read this post. So, I’m going to teach you! Take a seat.



Prerequisite information

There are two concepts in math called “Sequences” and “Series.” Without going into so much detail as to bore you, I’ll give you a quick working definition just to get the point across.

Sequence: A Sequence is a list of things (usually numbers) that are in order.

Example:
5,10,15,20,25,30,35,40,45,50, . . . 5*(n-1), 5*(n), 5*(n+1) . . .

Essentially, it’s a pattern that continues on to ‘infinity’. The previous sequence can be defined as 5*n with n being the term of the sequence. The first term, as you can see, is 5*1 = 5. The second term is 5*2 = 10. The 100th term, then, would be 5*100 = 500.

Series: A Series is the summation of the first infinite terms in a Sequence. (if we take every term in the sequence to infinity and add them together, what would it equal?)

Example:
Image

If we were to write this out it would look something like this:
Image

The real question is, "Infinity is impossible to reach, so how in the world do we add all of these terms together?"


Fortunately for us, this is a well-studied and commonly used series known as a Geometric Series. In fact, it's exactly what we're going to use to turn decimals into fractions!

Geometric Series:
Image

Where:
a is the first term (what would the value of the Sequence be if we plugged in n=1?)
r is the "common ratio" (how is the value changing between terms?)

The idea is that we can calculate the sum of this special series with the equation a/(1-r) where a and r are the previously defined terms. Here is a quick example:
Image




Application of information
Whew, now that we got the dirty work out of the way!

Ex 1) Represent 0.19191919191919. . . as a fraction

First of all, how can we strategically represent this number? How about:
Image

It should be obvious, then, that the first term is what? (you guessed it!) 19/100
And the common ratio (how the term is changing) is what? (of course!) 1/100

Image

And, for the sake of verification:
https://www.google.com/search?q=19%2F99 ... 2&ie=UTF-8

Yay!




Ex 2) Represent 0.153215321532. . . as a fraction

Based off of the previous example, we have a really good idea of where to start for this one
Image

Similarly, we can see that the first term is (1532/10000) and the common ratio is (1/10000).
Image

Verification




Your turn!

By now, perhaps you've noticed a pattern? How about you try doing the following:

Represent 9.720572057205. . . as a fraction (proper or improper)
Image
"Dream as if you'll live forever,
Live as if you'll die today." -James Dean
Durf
Match Winner
Posts: 426
Joined: Mon Jul 30, 2012 10:35 pm

Re: Repeating Decimals

Post by Durf »

Ratchet wrote:Represent 9.720572057205. . . as a fraction (proper or improper)
8836 / 909
9 + 655 / 909
User avatar
Ratchet
Match Winner
Posts: 779
Joined: Sat Mar 15, 2008 5:55 am

Re: Repeating Decimals

Post by Ratchet »

Good job :D

My solution:

Image




The interesting trick (that you may pick up from the examples) is that you can find any repeating decimal's fraction by making the denominator have the same number of 9's as the numerator has digits. (the denominator is always 9(s))

Maybe that doesn't make sense, so I'll show you visually:

Image
Image
"Dream as if you'll live forever,
Live as if you'll die today." -James Dean
Durf
Match Winner
Posts: 426
Joined: Mon Jul 30, 2012 10:35 pm

Re: Repeating Decimals

Post by Durf »

Just to be more confusing (lol) here's yet another way:

97196 / 9999

The amount of 9s in the denominator determine how many digits are repeated (as was said).
Should the numerator have more digits, this creates an "overlap" in the repeating digits.
Here is an example:
1111 / 9999 = 0.11111111
That is 4 digits that repeat (all are 1s).
Now:
11111 / 9999 = 1.11121112
That is 4 digits that repeat, and what happens to that extra digit (the very left out of 5), it gets added on to the digit place before (before the segment of 4).
In this case, the 1 (whole number, left side of the decimal) was added before the first instance of the repeating 4 digits.
After the first "1111" repeated, sticking on the next will add on an extra 1 just like the whole number was added.
This changes the previous "1111" into "1112":

Code: Select all

0.000000000000
1.111100000000
0.000111110000 (added on)
1.111211110000
0.000000011111 (added on)
1.111211121111
etc..
This is a pattern that can be used to "add" any combination together to get the end results you're looking for.
Not that the repeated digits depend on the denominator, yet the numerator defines the digits that get repeated.
The above examples repeats 4 digit places, using 5 digits each time (the extra digit is added onto the last digit from the previous repetition).

So for this example, you can also do

Code: Select all

0.000000000000
9.719600000000
9.720571960000
9.720572057196
etc..



That's not the way originally did it, but I figure some people might find this pattern also interesting.
Hope that made sense. It should certainly make more sense than the way I originally did it..which might just be luck xD
Though this method will give you an unsimplified and improper fraction, you will still get your answer.
User avatar
Ratchet
Match Winner
Posts: 779
Joined: Sat Mar 15, 2008 5:55 am

Re: Repeating Decimals

Post by Ratchet »

That is definitely cool :) I hadn't tried experimenting with other ways to get the same results. Interesting! Mathgasm!
Image
"Dream as if you'll live forever,
Live as if you'll die today." -James Dean
User avatar
Lucifer
Project Developer
Posts: 8640
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas
Contact:

Re: Repeating Decimals

Post by Lucifer »

**** this shit. I got my first B in college because off this shit.

Y'all are assholes.
Image

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Ratchet
Match Winner
Posts: 779
Joined: Sat Mar 15, 2008 5:55 am

Re: Repeating Decimals

Post by Ratchet »

Yeah! What he said!

I was totally in your shoes, I hated math at first. But, lately, I've started actually applying higher order math to my engineering curriculum and suddenly it's much, much more interesting. You know that argument "blah blah when will we ever use this shit?" Well, I'm proud to say I'm using the shit I learn now :D It's exciting!
Image
"Dream as if you'll live forever,
Live as if you'll die today." -James Dean
User avatar
/dev/null
Shutout Match Winner
Posts: 819
Joined: Sat Sep 04, 2004 6:28 pm
Location: Chicago-ish

Re: Repeating Decimals

Post by /dev/null »

pretty pictures, cpus dont use fractions.

CLAPCLAP!
Durf
Match Winner
Posts: 426
Joined: Mon Jul 30, 2012 10:35 pm

Re: Repeating Decimals

Post by Durf »

http://en.wikipedia.org/wiki/Computer_n ... _in_binary
CPUs do use fractions, just not in the way you might think.


About CPUs as well as how I originally solved this:
Decimals, fractions, whole or mixed numbers, polynomials (and other algebraic junk), etc.; these are all just a method of representing a value.

Fractions are a ratio between (any) 2 numbers.
1 / 2 is a half of the whole. But you can also read it as 1 divided by 2 (all fractions are just a division), which puts out 0.5.

Decimals are a ratio (fraction) between a number and 10 (base 10 math).
0.5 * 10 = 5; 5 / 10 = 1 / 2 = 0.5. A decimal can always be related to 10 (or a multiple thereof, like 100), to put out the corresponding fraction.

These are only ways of representing a value; we aren't actually working with the value itself, the value is being representing in a form we can work with.

IMO - once you can "see" the values for what they are, conversions between them become as natural as knowing your times tables.
Once 0.5 and 1 / 2 become one and the same to you, math gets a whole lot easier.
CPUs don't have to care about representation so long as they can know the value in their own way (they can represent a fraction without using a fraction like you might).
Saying CPUs don't use fractions is like saying a CPU cannot divide or relate numbers as a ratio.
User avatar
/dev/null
Shutout Match Winner
Posts: 819
Joined: Sat Sep 04, 2004 6:28 pm
Location: Chicago-ish

Re: Repeating Decimals

Post by /dev/null »

No, cpus dont use fractions, they divide, then use the resulting number, doing it badly is how the first pentium bug happened. Thats exactly why floats and doubles exist.
Durf
Match Winner
Posts: 426
Joined: Mon Jul 30, 2012 10:35 pm

Re: Repeating Decimals

Post by Durf »

Lol, I'm wondering if you read my post and/or visited that link..
Durf wrote:(all fractions are just a division)
Durf wrote:These are only ways of representing a value; we aren't actually working with the value itself, the value is being representing in a form we can work with.
Durf wrote:CPUs don't have to care about representation so long as they can know the value in their own way
Durf wrote:Saying CPUs don't use fractions is like saying a CPU cannot divide or relate numbers as a ratio.
^ note that last one

/dev/null wrote:No, cpus dont use fractions, they divide, then use the resulting number
^ this is basically what I said. But the difference is that humans like to think that actually matters.
A simple way to put it: a decimal (float or double) is nothing but a fraction, just represented in a way more convenient to a CPU.
The link I provided shows how binary (CPUs) work with fractions.
So yes, they do use "fractions" but to a CPU it is just a value (like any other value).
In the end, a fraction and a decimal are the same thing. (kind of what I was saying for the way I solved this thread's challenge)
A CPU doesn't use a numerator and denominator...it doesn't need to.
User avatar
/dev/null
Shutout Match Winner
Posts: 819
Joined: Sat Sep 04, 2004 6:28 pm
Location: Chicago-ish

Re: Repeating Decimals

Post by /dev/null »

Fractions are not quite the same, though they are similar. Ignoring the difference in how they are presented to humans, there are still notable differences. For instance, in the most common bases used on cpus 1/7th is a ********** to represent accurately.

Now granted, you could make a cpu that used base 7, but I dunno if its been done, or how useful it would be. Thats why we settled on hex, it has the least amount of edge cases without being unwieldly.
Durf
Match Winner
Posts: 426
Joined: Mon Jul 30, 2012 10:35 pm

Re: Repeating Decimals

Post by Durf »

Yea...not much one can do about the limitations of the cpu..


For those who are curious, the basic explanation is that, for something special like 1/7 or pi, a cpu only has a finite number of digits to represent it with.
However, those numbers have infinite digits. Rounding errors will occur, and for some applications; a cpu is not accurate/precise as it should be.
Some explanations


Going off what was said:
1 / 7 = 0.142857142857142857... (142857 repeating)
= 142857 / 999999 :wink:
^ at first that looked weird to me, so I did this:
999999 / 7 = 142857
1000000 / 7 = 142857.142857... (repeating)

^ then later, while working on a song for Melodious Tron (Zelda - Lost Woods), I noticed that number within the midi file:

Code: Select all

MFile 1 14 384
MTrk
0 TimeSig 4/4 24 8
0 Tempo 857142
0 Meta TrkEnd
TrkEnd
Notice the tempo (this was after being put through a tool to convert the midi into text information)
The BPM is 70.
60 / 70 = 6 / 7 = 0.857142857142... (857142 repeating)

^ this interested me quite a bit, so I did some more reading into it:
http://en.wikipedia.org/wiki/142857_(number)
Turns out it is quite the special number.

I wonder if a quantum computer would fair any better at accurately representing 1/7..
Post Reply