### Calculating the first m+1 partial quotients of the root of a polynomial using Lagrange's method

f(x) = a[n]xn + ··· + a is a polynomial with integer coefficients, with a[n] > 0, having no rational roots and having exactly one real positive root α, this being > 1. The method of Lagrange (1797) is used to find the first m + 1 partial quotients of α.

### References

1. Number Theory with Computer Applications, R. Kumanduri and C. Romero, Prentice Hall 1997, page 261.
2. Elements of Computer Algebra with Applications, A.G. Akritas, Wiley 1989, 333-399.
3. Art of computer programming, volume 2, D.E. Knuth, problem 13, Ch. 4.5.3.
4. Continued fractions for some algebraic numbers, S. Lang and H. Trotter, J. für Math. 255 (1972) 112-134; Addendum 267 (1974) ibid. 219-220.
5. A new proof of Vincent's theorem, A. Alesina, M. Galuzzi, L'Enseignement Math 44 (1988), 219-256.
6. An explanation of some exotic continued fractions found by Brillart, H.M. Stark, Computers in number theory, Academic Press 1971, 21-35.
The input polynomial is checked to see that (a) it is squarefree and (b) has exactly one positive real root t and that t > 1 holds.
Our program will in fact output the correct answer when t is rational.
For a program that develops the continued fraction of all real roots of a general polynomial with integer coefficients, see the rootexp(f(X),m) function in CALC.

Enter the coefficients a,...,a[n] (n > 1) (separated by spaces):
Enter m (≥ 0):