%I #35 Feb 10 2024 12:18:02
%S 0,3,-9,15,-21,27,-33,39,-45,51,-57,63,-69,75,-81,87,-93,99,-105,111,
%T -117,123,-129,135,-141,147,-153,159,-165,171,-177,183,-189,195,-201,
%U 207,-213,219,-225,231,-237,243,-249,255,-261,267,-273,279,-285,291
%N a(n) = (3 - 6*n)*(-1)^n.
%C Optimal simple continued fraction (with signed denominators) of tan(1/3).
%C This expansion is a simple continued fraction a(0) + 1/(a(1) + 1/(a(2) + ...)) with all numerators 1, and the numbers a(n) are signed integers computed with an algorithm that guarantees the fastest convergence for this type of continued fraction.
%C The algorithm is the same described in A133593. It is as usually based on the Euclidean division algorithm, but instead of taking the floor of the quotients, as it happens for standard continued fractions, the nearest integer is taken, so the remainders can be also negative and the quotients also.
%C Generally the convergents of this expansion are a subset of the convergents of the standard continued fraction expansion, and they are no more alternatively lesser and greater than the given number: in this special case of tan(1/3) they are all lesser.
%C The terms of this sequence can be generated by this formula: a(n) = -3*(-1)^n*(2n-1) for n > 0 (the first term is a(0)=0).
%C Repeating the expansion for other numbers of type 1/k a common pattern seems to emerge. Examples:
%C tan(1/4) gives 0, 4, -12, 20, -28, 36, -44, 52, -60, 68, -76, 84, ...
%C tan(1/5) gives 0, 5, -15, 25, -35, 45, -55, 65, -75, 85, -95, 105, ...
%C so it seems that in general the terms of tan(1/k) are generated by the formula a(n) = (-1)^(n+1)*k*(2n-1) for n > 0. This formula gives this expansion for tan(1/k):
%C tan(1/k) = 1/(k+1/(-3k+1/(5k-1/(-7k+1/(9k+1/...))))).
%C This expansion can be rewritten in an equivalent form:
%C tan(1/k) = 1/(k-1/(3k-1/(5k-1/(7k-1/(9k-1/...))))).
%C The rule for converting the first form to the second is this: if two consecutive terms have different sign put a minus before the fraction line, otherwise put plus, and take the absolute value of the terms in the denominators.
%C This general expansion seems to be valid for any real value of k and resembles Lambert's expansion of tan(k).
%C The unsigned version of this sequence is A016945. - _Colin Barker_, Oct 26 2013
%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (-2,-1).
%F a(n) = A016945(n-1)*(-1)^(n-1).
%F Formulae for the general case tan(1/k):
%F a(0)=0; for n > 0, a(n) = (-1)^(n+1)*k*(2n-1).
%F tan(1/k) = 1/(k + 1/(-3k + 1/(5k - 1/(-7k + 1/(9k + 1/...))))) or equivalently
%F tan(1/k) = 1/(k - 1/(3k - 1/(5k - 1/(7k - 1/(9k - 1/...))))).
%F From _Colin Barker_, Oct 26 2013: (Start)
%F a(n) = -2*a(n-1) - a(n-2) for n > 2.
%F G.f.: 3*x*(1-x) / (x+1)^2. (End)
%e tan(1/3) = 0 + 1/(3 + 1/(-9 + 1/(15 + 1/(-21 + 1/(27 + ...))))) or
%e tan(1/3) = 0 + 1/(3 - 1/(9 - 1/(15 - 1/(21 - 1/(27 - ...))))).
%p SCF := proc (n, q::posint)::list; local L, i, z; Digits := 10000; L := [round(n)]; z := n; for i from 2 to q do if z = op(-1, L) then break end if; z := 1/(z-op(-1, L)); L := [op(L), round(z)] end do; return L end proc
%p SCF(tan(1/3), 50) # _Giovanni Artico_, Oct 26 2013
%t Join[{0},LinearRecurrence[{-2,-1},{3,-9},50]] (* _Harvey P. Dale_, Mar 10 2015 *)
%o (PARI) Vec(3*x*(1-x)/(x+1)^2+O(x^100)) \\ _Colin Barker_, Oct 26 2013
%Y Cf. A016945, A133593, A228936.
%K sign,cofr,easy
%O 0,2
%A _Giovanni Artico_, Oct 25 2013