Math::Rational::Approx::ContFrac - Rational number approximation via continued fractions
use Math::Rational::Approx::ContFrac; $x = Math::Rational::Approx::ContFrac->new( x => 1.234871035, n => 10 ); ( $n, $d ) = $x->approx; # continue for an additonal number of steps ( $n, $d ) = $x->approx( 3 );
This module is an object oriented front end to the Math::Rational::Approx::contfrac function
$obj = Math::Rational::ContFrac->new( %attr );
Construct an object which will maintain state for the continued fraction. The following attributes are available:
( $n, $d ) = $obj->approx; ( $n, $d ) = $obj->approx($n);
Calculate the continued fractions and return the associated nominator and denominator. If
$n is not specified, the number of terms generated is that specified in the call to the constructor, plus any terms requested by additional calls to approx with
$n specifies the number of additional terms to generate beyond what has already been requested.
$x = $obj->x;
The original number to be approximated.
$n = $obj->n;
The number of terms generated.
$arrayref = $obj->terms
Returns an arrayref of the current terms.
The residual of the input number as a Math::BigFloat object. This is not the difference between the input number and the rational approximation.
Math::BigFloat, Moo, MooX::Types::MooseLike::Numeric, Params::Validate
No bugs have been reported.
Please report any bugs or feature requests to
email@example.com, or through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Math-Rational-Approx.
Diab Jerius <firstname.lastname@example.org>
Copyright (c) 2012 The Smithsonian Astrophysical Observatory
Math::Rational::Approx is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.