# Convert from decimal to fraction

I know this sounds silly, and it's easy for many situations. But sometimes i have been completely taken back as i don't know how to do it.

So please tell me is there any way to convert certain numbers into fractions..even with remainder tagging along like 3 1/4 which is 13/4. And if not why is it that certain numbers can't be represented in fraction form.

Also is there way to let's say have number x in decimal form and find a fraction that is most close to it.

Case I: Finite Decimal

Suppose that the decimal is $$.a_1a_2\ldots a_n$$ Then by definition of that notation, the number can be written $$\frac{a_1}{10}+\frac{a_2}{10^2}+\cdots+\frac{a_n}{10^n}$$ You can then combine the fractions and reduce.

Example. $$.18=\frac{18}{100}=\frac{9}{50}$$

Case II: Infinite Repeating Decimal

We already know that the first (finite) non-repeating component may be written as a decimal per the algorithm above. For the repeating part $$.00\ldots 0a_1a_2\ldots a_na_1\ldots a_n\cdots$$ which the sequence $a_1\ldots a_n$ repeated infinitely, we have by the formula $$a+ar+ar^2+\cdots=\frac{a}{1-r}\qquad (|r|<1)$$ that, if there are $m$ zeros initially, \begin{align}.0\ldots 0\overline{a_1\ldots a_n}&=\frac{a_1\ldots a_n}{10^{m+n}}+\frac{a_1\ldots a_n}{10^{m+2n}}+\cdots \\ &=\frac{a_1\ldots a_n}{10^{m+n}}\left(1+10^{-n}+10^{-2n}+\cdots\right) \\ &=\frac{a_1\ldots a_n}{10^{m+n}}\left(\frac{1}{1-10^{-n}}\right)\end{align}

Example. $$0.333\ldots=\frac{3}{10}\left(1+\frac{1}{10}+\frac{1}{10^2}+\cdots\right)=\frac{3}{10}\left(\frac{1}{1-10^{-1}}\right)=\frac{3}{10-1}=\frac{1}{3}$$

Case III: Infinite Non-Repeating Decimal

These types of numbers are called irrational, and cannot be written as fractions of integers (for example, $\sqrt 2$ has no fractional expression).

However, they can be approximated by fractions to any degree of accuracy needed. A straightforward algorithm for doing this is provided by the theory of the Stern-Brocot tree. It provides the "simplest" approximation which starts with the correct $n$ decimal places.

Example. The decimal expansion of $\pi$ (an irrational number) begins $3.141592653589793\ldots$. Using a computer program, I find that the first few best rational approximations for the decimal part $.141592653589793\ldots$ are \begin{align}{1 \over 7} &=0.142... \\ {9 \over 64} &=0.1406... \\ {15\over 106} &=0.14150... \\ {16\over 113}&=0.1415929... \\ &\;\vdots \\ {3612111\over 25510582}&=0.14159265358979267...\end{align}

There are two types of real numbers: rationals, which can be represented as fractions of the form $\frac{p}{q}$, where $p$ and $q$ are integers; and irrational numbers, which cannot be represented by the form $\frac{p}{q}$, with $p, q$ integers.

A consequence of this is that rational numbers have decimal representations that are either a.) terminating (e.g., $\frac14 = 0.25$) or b.) repeating, which means there is a pattern that repeats over and over again forever (e.g., $\frac{1}{7} = 0.142857142857142857\ldots$).

Now, there is a weird property of real numbers: between any two irrational numbers there is a rational number. And likewise, between any two rational numbers there is an irrational number.

This means that if you have any number $x$, either it is rational, or it is irrational. If $x$ is irrational, then there is no closest rational number to it! No matter what number we pick, we can always find another rational number closer to $x$.

Now, suppose we have a decimal expression that terminates. The easiest way to figure out its rational form is to keep multiplying by 10 to shift the decimal place over until there is nothing after the decimal place, then divide. For example, let's say $$x = 0.25.$$ Then, multiply by 10 until nothing is after the decimal place.

$$10x = 2.5 \\ 100x = 25 \\ x = \frac{25}{100} = \frac14.$$

If the number is repeating, it's a little more complicated. Multiply by 10 until you have the entire pattern to the left of the decimal place. For example:

$$x = 0.142857142857\ldots\\ 10x = 1.42857142857\ldots \\ \vdots \\ 1000000x = 142857.142857\ldots$$

Now, notice that our new number is our finite pattern plus $x$, or in other words: $$1000000 x = 142857 + x.$$

Now, subtract $x$ from both sides, and you get $$1000000x-x = 999999x = 142857$$ so $$x = \frac{142857}{999999}.$$

Now, you can simplify!

• For a simpler example, $x = \frac13 = 0.333\ldots$. Then, $10x = 3.333\ldots = 3 + x$. So $10x-x = 3$, which leads to $9x=3$ which can be solved as $x = \frac{3}{9} = \frac13$. May 9 '14 at 23:23