Michael Somos on Mon, 4 Nov 2002 19:15:07 -0500

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

gp: contfracpnqn(x) documentation


     I have a question about the help documentation :

? ??contfracpnqn

   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. Shalom, Michael