Karim BELABAS on Sun, 19 Jan 2003 12:31:53 +0100 (MET)

 Re: gp: contfracpnqn(x) documentation

```On Mon, 4 Nov 2002, Michael Somos wrote:
>      I have a question about the help documentation :
>
> ? ??contfracpnqn
> contfracpnqn(x):
>
>   when  x  is  a  vector  or a one-row matrix,  x is considered as the list of
>partial quotients [a_0,a_1,...,a_n] of a rational number, and the result is the
>2  by  2 matrix [p_n,p_{n-1};q_n,q_{n-1}] in the standard notation of continued
>fractions,  so p_n/q_n = a_0+1/(a_1+...+1/a_n)...).   If x is a matrix with two
>rows  [b_0,b_1,...,b_n]  and  [a_0,a_1,...,a_n],   this is then considered as a
>generalized continued fraction and we have similarly p_n/q_n =
>1/b_0(a_0+b_1/(a_1+...+b_n/a_n)...). Note that in this case one usually has b_0
> = 1.
>
>    The library syntax is pnqn(x).
>
> I wondered why the subscripting started at 0 instead of 1. For example :
>
> ? print(contfracpnqn([]))
> [1, 0; 0, 1]
> ? print(contfracpnqn([a1]))
> [a1, 1; 1, 0]
> ? print(contfracpnqn([a1,a2]))
> [a2*a1 + 1, a1; a2, 1]
> ? print(contfracpnqn([a1,a2,a3]))
> [(a3*a2 + 1)*a1 + a3, a2*a1 + 1; a3*a2 + 1, a2]
>
> seems more natural when subscripting begins at 1. Was there a particular
> reason for using 0 instead in this situation? I can see reasons why 0 may
> be used, but not strong ones.

[a_0, ... , a_n] is understood to be the output of contfrac(), i.e the
continued fraction of some real number x. Some authors indeed start the
indexing at 1, but I believe the above is more widespread ( in which a_0 is
the integer part of x, hence not part of the continued fraction proper ).

Karim.
--
Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
--