In this example, a continued fraction approximation of order to the tangent function around is computed:
In this example, all the "numerators" are powers of (up to sign), and the "denominators" exhibit an obvious pattern. Again, the convergents form approximations of of higher and higher orders. In this case, we obtain the convergents by calling cfrac twice, since applying cfrac to a continued fraction returns the rational function (or rational number) it represents:
In fact, the convergents provide better approximations to then tangent function around than the Taylor expansion of the same order. Below, this is illustrated for and the Taylor expansion to with the same error term, , by plotting the two differences and :
For example, the absolute errors for the two approximations at are:
The ability to compute a continued fraction at an expansion point other than was added in Maple 16: