EVOLUTION-MANAGER
Edit File: fractions.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Rational Approximation</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for fractions {MASS}"><tr><td>fractions {MASS}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Rational Approximation </h2> <h3>Description</h3> <p>Find rational approximations to the components of a real numeric object using a standard continued fraction method. </p> <h3>Usage</h3> <pre> fractions(x, cycles = 10, max.denominator = 2000, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>Any object of mode numeric. Missing values are now allowed. </p> </td></tr> <tr valign="top"><td><code>cycles</code></td> <td> <p>The maximum number of steps to be used in the continued fraction approximation process. </p> </td></tr> <tr valign="top"><td><code>max.denominator</code></td> <td> <p>An early termination criterion. If any partial denominator exceeds <code>max.denominator</code> the continued fraction stops at that point. </p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>arguments passed to or from other methods. </p> </td></tr></table> <h3>Details</h3> <p>Each component is first expanded in a continued fraction of the form </p> <p><code>x = floor(x) + 1/(p1 + 1/(p2 + ...)))</code> </p> <p>where <code>p1</code>, <code>p2</code>, ... are positive integers, terminating either at <code>cycles</code> terms or when a <code>pj > max.denominator</code>. The continued fraction is then re-arranged to retrieve the numerator and denominator as integers. </p> <p>The numerators and denominators are then combined into a character vector that becomes the <code>"fracs"</code> attribute and used in printed representations. </p> <p>Arithmetic operations on <code>"fractions"</code> objects have full floating point accuracy, but the character representation printed out may not. </p> <h3>Value</h3> <p>An object of class <code>"fractions"</code>. A structure with <code>.Data</code> component the same as the input numeric <code>x</code>, but with the rational approximations held as a character vector attribute, <code>"fracs"</code>. Arithmetic operations on <code>"fractions"</code> objects are possible. </p> <h3>References</h3> <p>Venables, W. N. and Ripley, B. D. (2002) <em>Modern Applied Statistics with S.</em> Fourth Edition. Springer. </p> <h3>See Also</h3> <p><code><a href="rational.html">rational</a></code> </p> <h3>Examples</h3> <pre> X <- matrix(runif(25), 5, 5) zapsmall(solve(X, X/5)) # print near-zeroes as zero fractions(solve(X, X/5)) fractions(solve(X, X/5)) + 1 </pre> <hr /><div style="text-align: center;">[Package <em>MASS</em> version 7.3-51.4 <a href="00Index.html">Index</a>]</div> </body></html>