mathnet/mathnet-symbolics

Continued Fraction

diluculo opened this issue · 2 comments

Is there any plan to support the continued fraction (CF)?

Examples I want to cover with CF:

  1. For rational number : p / q
    • ContinuedFraction( 1.23 ) => [1, 4, 2, 1, 7]
    • FromContinuedFraction ( [1, 4, 2, 1, 7] ) => 123 / 100 = 1.23
  2. For quadratic irrational number : ( p + sqrt(d) ) / q
    • ContinuedFraction( (1 + sqrt(2)) / 3 ) => [0, 1, [4, 8]] where [4, 8] is a periodic part
    • FromContinuedFraction( [0, 1, [4, 8]] ) => (1 + sqrt(2)) / 3 ~ 0.804738
  3. Infinite CF : Personally, I'd like to calculate the Bessel Ratio, I(1, z) / I(0, z) which can be expressed with infinite CF.
    • ContinuedFraction( I(1, 1) / I(0, 1), 10 ) => [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22] where 10 is the number of terms
    • FromContinuedFraction( [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22] ) => 45164504281/101177239032 ~ 0.44639

References:

  1. https://en.wikipedia.org/wiki/Continued_fraction
  2. https://rosettacode.org/wiki/Continued_fraction
  3. http://duckmaestro.com/2011/05/31/f-sharp-and-continued-fractions/

probably this issue better fits for MathNet.Numerics project

@FoggyFinder You are right. The CF as a number theory can be added to the Numerics for numerical calculation and codes of Beta and ExponentialIntegral functions are based on the CF. However, I need the CF as Symbolic expression.