Diab Jerius
and 1 contributors

# NAME

Math::Rational::Approx::MaxD - approximate a number with a rational number up to a given denominator

# SYNOPSIS

``````    use Math::Rational::Approx::MaxD;

# approximate up to denominator of 10
\$rat = Math::Rational::Approx::MaxD->new( x => \$x, maxD => 10 );

(\$n, \$d ) = \$rat->approx;

# approximate up to denominator of 20
(\$n, \$d ) = \$rat->approx( 20 );``````

# DESCRIPTION

This module is an object oriented front end to the Math::Rational::Approx::maxd function

# INTERFACE

new
``    \$obj = Math::Rational::Approx::MaxD->new( %attr );``

Create a new object. The following attributes are available

`x`

The number to approximate.

`maxD`

The limiting maximum denominator to check;

`bounds`

Optional. A reference to a four element array containing the initial bounds on the region to search. It takes the form

``  bounds => [ a, b, c, d ]``

where the elements are all non-negative integers and the bounds are given by

``  a/b < x < c/d``

By default it searches from `float(x)` to `float(x)+1`.

approx
``````  ( \$n, \$d ) = \$obj->approx;
( \$n, \$d ) = \$obj->approx( \$maxD );``````

Return the nominator and denominator for a given maximum value of the denominator. If `\$maxD` is not specified it is that specified in the call to the constructor or in any subsequent call to approx. New values of `\$maxD` less than one already specified are ignored.

bounds
``  \$bounds = \$obj->bounds;``

Return an arrayref which contains the current bounds on the search, in the same format as the `bounds` attribute passed to new.

x
``  \$x = \$obj->x;``

The original number to be approximated.

maxD

The current value of the maximum denominator.

None reported.

# BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to `bug-math-rational-approx@rt.cpan.org`, or through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Math-Rational-Approx.

Math::Rational::Approx

# AUTHOR

Diab Jerius <djerius@cpan.org>