cfrac.tex 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. \section{CONTINUED\_FRACTION Operator}
  2. \index{approximation}\index{rational number}
  3. The operator CONTINUED\_FRACTION approximates the real number
  4. ( \nameref{rational} number, \nameref{rounded} number)
  5. into a continued fraction. CONTINUE_FRACTION has one or
  6. two arguments, the number to be converted and an optional
  7. precision:
  8. \begin{verbatim}
  9. continued\_fraction(<num>)
  10. or
  11. continued\_fraction(<num>,<size>)
  12. \end{verbatim}
  13. The result is a list of two elements: the
  14. first one is the rational value of the approximation, the second one
  15. is the list of terms of the continued fraction which represents the
  16. same value according to the definition \verb&t0 +1/(t1 + 1/(t2 + ...))&.
  17. Precision: the second optional parameter \meta{size} is an upper bound
  18. for the absolute value of the result denominator. If omitted, the
  19. approximation is performed up to the current system precision.
  20. {\tt Examples:}
  21. \begin{verbatim}
  22. continued_fraction pi;
  23. ->
  24. 1146408
  25. {---------,{3,7,15,1,292,1,1,1,2,1}}
  26. 364913
  27. continued_fraction(pi,100);
  28. ->
  29. 22
  30. {----,{3,7}}
  31. 7
  32. \end{verbatim}