Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

How to compute the decimal digits of irrational number(non-transcendental) with an arbitrary precision?

eg. Expansion of $\sqrt{ 2}$ with a precision of 500.

share|improve this question
1  
Some irrational numbers are easier to compute than other irrational numbers. Do you really want to talk about all irrational numbers, or just certain types of them (like the roots of polynomials, for example?) –  Thomas Andrews Apr 23 '12 at 14:50
    
There are a few methods: find an approximate sequence, use continued fraction expansion. And after that you need to program the algorithm in a good programming language. I think that the easiest one for this purpose is Pari/GP, which will give you the result for free. –  Beni Bogosel Apr 23 '12 at 14:50
    
Non-trancendental numbers. –  Guru Prasad Apr 23 '12 at 14:50
    
@GuruPrasad: i.e. roots of polynomials. –  Beni Bogosel Apr 23 '12 at 14:53
    
@BeniBogosel: Can you explain how to do using continued fraction expansion? I'm at a loss here. –  Guru Prasad Apr 23 '12 at 14:53

4 Answers 4

up vote 1 down vote accepted

The solutions to Pell's equation can approximate $\sqrt{2}$ or in general any squarefree radical. It is known that Pell's equation has infinitely many solutions, and a recurrence form (you can find the recurrence here) of the solution can be found. As the solutions of $x^2−2y^2=1$ grow larger, the approximation is better. So you just iterate the recurrence until you have the desired precision. After that it remains to calculate the ratio $x/y$ with the $500$ digits precision you want.

In Pari-GP you can get the desired result like this:

? \p=501

? sqrt(2) The answer is:

1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623091229702492483605585073721264412149709993583141322266592750559275579995050115278206057147010955997160597027453459686201472851741864088919860955232923048430871432145083976260362799525140798968725339654633180882964062061525835239505474575028775996172983557522033753185701135437460340849884716038689997069900481503054402779031645424782306849293691862158057846311159666871301301561856898723724

If you like programming I suggest trying to solve some of the Project Euler problems.

share|improve this answer
    
Actually, I think this probably is for a Project Euler problem. Not sure I can blame anyone for looking this one up though. Most computer languages don't do that kind of precision normally. It took quite a while to find an algorithm just about made for a computer. –  Mike Apr 23 '12 at 18:00

In the case of $\sqrt a$, Newton's method converges very fast: $$ x_{n+1}=\frac12\big(x_n+\frac{a}{x_n}\big), \qquad x_0=a $$

It doubles the number of correct digits every iteration and so to get 500 digits you'd have to do around 10 iterations. However, note that you need arbitrary precision arithmetic, at least for division and addition.

Wikipedia lists several other methods.

share|improve this answer
    
I think you approach and Beni's can be combined nicely: use the continued fraction to yield a starting point, and then polish with Newton-Raphson. –  J. M. Apr 28 '12 at 16:02

An approach I really like for $\sqrt 2$ and $\sqrt 3$ is due to Apostol.

Note that

$$\sqrt 2 = \frac 7 5 \left(1- \frac 1 {50} \right)^{-1/2}$$

and that

$$\sqrt 3 = \frac {1732}{1000} \left(1- \frac {176} {3\,000\,000} \right)^{-1/2}$$

Using the Taylor series

$$\frac 1 {\sqrt{1-x}}=1+\frac 1 2 x+\frac 3 8 x^2+\frac 5 {16} x^3+\frac {35} {128} x^4+\frac {63} {256} x^5+\cdots$$

you can get great aproximations for such constants. Note how for $\sqrt 3$ you'll get a dramatic effect from the $3\,000\,000$ in the denominator. I think you can obtain the same with any $\sqrt r$, with a little bit of trickery, putting it as

$$\sqrt r= \frac {a}{b} \left(1- \frac {c} {d} \right)^{-1/2}$$

I'll try and find an analog for $\sqrt 5$.

For $\sqrt 5 $ you can go with

$$\sqrt 5 = \frac{{2236}}{{1000}}{\left( {1 - \frac{{304}}{{5000000}}} \right)^{ - 1/2}}$$

In general you need

$$d-c=a^2$$

$$d=rb^2$$

Just checked, and a $6^{th}$ degree polynomial gives 15 exact decimals (if more)

$$\sqrt 3 \approx 1.732050807568877$$

$$\sqrt 5 \approx 2.236067977499790$$

$$\sqrt 2 \approx 1.414213562373095$$

share|improve this answer

Since you're interested in algebraic numbers -- i.e. irrational numbers that are not transcendental -- there are some basic methods.

First, given a complex number, you can always take it's real and imaginary parts to reduce it to a problem of real numbers.

Sturm's theorem is a general purpose way to locate the real roots of a real polynomial. You can do a binary search to narrow down the locations of the roots.

Once you have a sufficiently good approximation, Newton's algorithm is the standard way to produce more approximations of greater accuracy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.