/usr/share/doc/racket/math/base.html is in racket-doc 6.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>1 Constants and Elementary Functions</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">▼</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Math Library</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Constants and Elementary Functions</a></td></tr><tr><td align="right">2 </td><td><a href="flonum.html" class="tocviewlink" data-pltdoc="x">Flonums</a></td></tr><tr><td align="right">3 </td><td><a href="special.html" class="tocviewlink" data-pltdoc="x">Special Functions</a></td></tr><tr><td align="right">4 </td><td><a href="number-theory.html" class="tocviewlink" data-pltdoc="x">Number Theory</a></td></tr><tr><td align="right">5 </td><td><a href="bigfloat.html" class="tocviewlink" data-pltdoc="x">Arbitrary-<wbr></wbr>Precision Floating-<wbr></wbr>Point Numbers (<a name="(tech._bigfloat)"></a><span style="font-style: italic">Bigfloats</span>)</a></td></tr><tr><td align="right">6 </td><td><a href="array.html" class="tocviewlink" data-pltdoc="x">Arrays</a></td></tr><tr><td align="right">7 </td><td><a href="matrices.html" class="tocviewlink" data-pltdoc="x">Matrices and Linear Algebra</a></td></tr><tr><td align="right">8 </td><td><a href="stats.html" class="tocviewlink" data-pltdoc="x">Statistics Functions</a></td></tr><tr><td align="right">9 </td><td><a href="dist.html" class="tocviewlink" data-pltdoc="x">Probability Distributions</a></td></tr><tr><td align="right">10 </td><td><a href="utils.html" class="tocviewlink" data-pltdoc="x">Stuff That Doesn’t Belong Anywhere Else</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">►</a></td><td>1 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Constants and Elementary Functions</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">1.1 </td><td><a href="#%28part._.Constants%29" class="tocviewlink" data-pltdoc="x">Constants</a></td></tr><tr><td align="right">1.2 </td><td><a href="#%28part._.Functions%29" class="tocviewlink" data-pltdoc="x">Functions</a></td></tr><tr><td align="right">1.3 </td><td><a href="#%28part._.Random_.Number_.Generation%29" class="tocviewlink" data-pltdoc="x">Random Number Generation</a></td></tr><tr><td align="right">1.4 </td><td><a href="#%28part._.Measuring_.Error%29" class="tocviewlink" data-pltdoc="x">Measuring Error</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">1.1<tt> </tt></span><a href="#%28part._.Constants%29" class="tocsubseclink" data-pltdoc="x">Constants</a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._phi..0%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">phi.0</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._euler..0%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">euler.0</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._gamma..0%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">gamma.0</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._catalan..0%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">catalan.0</span></span></a></td></tr><tr><td><span class="tocsublinknumber">1.2<tt> </tt></span><a href="#%28part._.Functions%29" class="tocsubseclink" data-pltdoc="x">Functions</a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._float-complex~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">float-<wbr></wbr>complex?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._number-~3efloat-complex%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">number-<wbr></wbr>>float-<wbr></wbr>complex</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._power-of-two~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">power-<wbr></wbr>of-<wbr></wbr>two?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._asinh%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">asinh</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._acosh%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">acosh</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._atanh%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">atanh</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._sum%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">sum</span></span></a></td></tr><tr><td><span class="tocsublinknumber">1.3<tt> </tt></span><a href="#%28part._.Random_.Number_.Generation%29" class="tocsubseclink" data-pltdoc="x">Random Number Generation</a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-natural%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">random-<wbr></wbr>natural</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-integer%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">random-<wbr></wbr>integer</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-bits%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">random-<wbr></wbr>bits</span></span></a></td></tr><tr><td><span class="tocsublinknumber">1.4<tt> </tt></span><a href="#%28part._.Measuring_.Error%29" class="tocsubseclink" data-pltdoc="x">Measuring Error</a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">absolute-<wbr></wbr>error</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._relative-error%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">relative-<wbr></wbr>error</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.7</span></div><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="index.html" title="backward to "Math Library"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Math Library"" data-pltdoc="x">up</a> <a href="flonum.html" title="forward to "2 Flonums"" data-pltdoc="x">next →</a></span> </div><h3 x-source-module="(lib "math/scribblings/math.scrbl")" x-source-pkg="math-doc" x-part-tag=""base"">1<tt> </tt><a name="(part._base)"></a><a name="(mod-path._math/base)"></a>Constants and Elementary Functions</h3><div class="SAuthorListBox"><span class="SAuthorList"><p class="author">Neil Toronto <<a href="mailto:ntoronto@racket-lang.org">ntoronto@racket-lang.org</a>></p></span></div><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">math/base</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">math-lib</span></span></td></tr></table></p><p>For convenience, <a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">math/base</span></a> re-exports <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528mod-path._racket%252Fmath%2529&version=6.7" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket/math</span></a>
as well as providing the values document below.</p><p>In general, the functions provided by <a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">math/base</span></a> are <a name="(tech._elementary)"></a><span style="font-style: italic">elementary</span>
functions, or those functions that can be defined in terms of a finite number of
arithmetic operations, logarithms, exponentials, trigonometric functions, and constants.
For others, see <a href="special.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">math/special-functions</span></a> and <a href="dist.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">math/distributions</span></a>.</p><h4 x-source-module="(lib "math/scribblings/math.scrbl")" x-source-pkg="math-doc" x-part-tag=""Constants"">1.1<tt> </tt><a name="(part._.Constants)"></a>Constants</h4><p>If you need more accurate approximations than the following flonums, see, for example,
<span class="RktSym"><a href="bigfloat.html#%28def._%28%28lib._math%2Fbigfloat..rkt%29._phi..bf%29%29" class="RktValLink" data-pltdoc="x">phi.bf</a></span> and <span class="RktSym"><a href="bigfloat.html#%28def._%28%28lib._math%2Fbigfloat..rkt%29._bigfloat-~3erational%29%29" class="RktValLink" data-pltdoc="x">bigfloat->rational</a></span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>value</p></div></div><p class="RForeground"><a name="(def._((lib._math/base..rkt)._phi..0))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._phi..0%29%29" class="RktValDef RktValLink" data-pltdoc="x">phi.0</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Positive-.Flonum%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Positive-Flonum</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">An approximation of φ, the <a href="http://en.wikipedia.org/wiki/Golden_ratio">golden ratio</a>.
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._phi..0%29%29" class="RktValLink" data-pltdoc="x">phi.0</a></span></td></tr><tr><td><p><span class="RktRes">1.618033988749895</span></p></td></tr></table></blockquote></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>value</p></div></div><p class="RForeground"><a name="(def._((lib._math/base..rkt)._euler..0))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._euler..0%29%29" class="RktValDef RktValLink" data-pltdoc="x">euler.0</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Positive-.Flonum%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Positive-Flonum</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">An approximation of <span style="font-style: italic">e</span>, or <a href="http://en.wikipedia.org/wiki/E_(mathematical_constant)">Euler’s number</a>.
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._euler..0%29%29" class="RktValLink" data-pltdoc="x">euler.0</a></span></td></tr><tr><td><p><span class="RktRes">2.718281828459045</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exp%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">exp</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">2.718281828459045</span></p></td></tr></table></blockquote></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>value</p></div></div><p class="RForeground"><a name="(def._((lib._math/base..rkt)._gamma..0))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._gamma..0%29%29" class="RktValDef RktValLink" data-pltdoc="x">gamma.0</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Positive-.Flonum%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Positive-Flonum</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">An approximation of γ, the <a href="http://en.wikipedia.org/wiki/Euler-Mascheroni_constant">Euler-Mascheroni constant</a>.
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._gamma..0%29%29" class="RktValLink" data-pltdoc="x">gamma.0</a></span></td></tr><tr><td><p><span class="RktRes">0.5772156649015329</span></p></td></tr></table></blockquote></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>value</p></div></div><p class="RForeground"><a name="(def._((lib._math/base..rkt)._catalan..0))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._catalan..0%29%29" class="RktValDef RktValLink" data-pltdoc="x">catalan.0</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Positive-.Flonum%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Positive-Flonum</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">An approximation of <span style="font-style: italic">G</span>, or <a href="http://en.wikipedia.org/wiki/Catalan's_constant">Catalan’s constant</a>.
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._catalan..0%29%29" class="RktValLink" data-pltdoc="x">catalan.0</a></span></td></tr><tr><td><p><span class="RktRes">0.915965594177219</span></p></td></tr></table></blockquote></div></p><h4 x-source-module="(lib "math/scribblings/math.scrbl")" x-source-pkg="math-doc" x-part-tag=""Functions"">1.2<tt> </tt><a name="(part._.Functions)"></a>Functions</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._float-complex~3f))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._float-complex~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">float-complex?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Boolean%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Boolean</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Any%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Any</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> when <span class="RktVar">v</span> is of type <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Float-.Complex%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Float-Complex</a></span>. Analogous to <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._flonum%7E3f%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">flonum?</a></span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._number-~3efloat-complex))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._number-~3efloat-complex%29%29" class="RktValDef RktValLink" data-pltdoc="x">number->float-complex</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Float-.Complex%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Float-Complex</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Number%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Number</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a new complex number with a flonum real part and a flonum imaginary part.
Analogous to <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._real-%7E3edouble-flonum%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">real->double-flonum</a></span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._power-of-two~3f))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._power-of-two~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">power-of-two?</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Boolean%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Boolean</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> when <span class="RktVar">x</span> is an integer power of 2.
</div><div class="SIntrapara"><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._power-of-two~3f%29%29" class="RktValLink" data-pltdoc="x">power-of-two?</a></span><span class="hspace"> </span><span class="RktVal">1.0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._power-of-two~3f%29%29" class="RktValLink" data-pltdoc="x">power-of-two?</a></span><span class="hspace"> </span><span class="RktVal">1/2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._power-of-two~3f%29%29" class="RktValLink" data-pltdoc="x">power-of-two?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="flonum.html#%28def._%28%28lib._math%2Fflonum..rkt%29._flnext%29%29" class="RktValLink" data-pltdoc="x">flnext</a></span><span class="hspace"> </span><span class="RktVal">2.0</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></div></p></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._asinh))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._asinh%29%29" class="RktValDef RktValLink" data-pltdoc="x">asinh</a></span></span><span class="hspace"> </span><span class="RktVar">z</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Number%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Number</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">z</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Number%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Number</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._acosh))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._acosh%29%29" class="RktValDef RktValLink" data-pltdoc="x">acosh</a></span></span><span class="hspace"> </span><span class="RktVar">z</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Number%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Number</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">z</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Number%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Number</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._atanh))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._atanh%29%29" class="RktValDef RktValLink" data-pltdoc="x">atanh</a></span></span><span class="hspace"> </span><span class="RktVar">z</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Number%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Number</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">z</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Number%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Number</a></span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">The inverses of <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528lib._racket%252Fmath..rkt%2529._sinh%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">sinh</a></span>, <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528lib._racket%252Fmath..rkt%2529._cosh%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">cosh</a></span>, and <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528lib._racket%252Fmath..rkt%2529._tanh%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">tanh</a></span>, which are
defined in <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528mod-path._racket%252Fmath%2529&version=6.7" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket/math</span></a> (and re-exported by <a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">math/base</span></a>).</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._sum))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._sum%29%29" class="RktValDef RktValLink" data-pltdoc="x">sum</a></span></span><span class="hspace"> </span><span class="RktVar">xs</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">xs</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Listof%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._apply%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">apply</a></span><span class="stt"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="stt"> </span><span class="RktVar">xs</span><span class="RktPn">)</span>, but incurs rounding error only once when adding inexact numbers.
(In fact, the inexact numbers in <span class="RktVar">xs</span> are summed separately using <span class="RktSym"><a href="flonum.html#%28def._%28%28lib._math%2Fflonum..rkt%29._lgprod%29%29" class="RktValLink" data-pltdoc="x">flsum</a></span>.)</div></p><h4 x-source-module="(lib "math/scribblings/math.scrbl")" x-source-pkg="math-doc" x-part-tag=""Random_Number_Generation"">1.3<tt> </tt><a name="(part._.Random_.Number_.Generation)"></a>Random Number Generation</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._random-natural))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-natural%29%29" class="RktValDef RktValLink" data-pltdoc="x">random-natural</a></span></span><span class="hspace"> </span><span class="RktVar">k</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Natural%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Natural</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">k</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a random natural number less than <span class="RktVar">k</span>, which must be positive.
Use <span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-natural%29%29" class="RktValLink" data-pltdoc="x">random-natural</a></span><span class="stt"> </span><span class="RktVar">k</span><span class="RktPn">)</span> instead of <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._random%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">random</a></span><span class="stt"> </span><span class="RktVar">k</span><span class="RktPn">)</span> when <span class="RktVar">k</span>
could be larger than <span class="RktVal">4294967087</span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._random-integer))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-integer%29%29" class="RktValDef RktValLink" data-pltdoc="x">random-integer</a></span></span><span class="hspace"> </span><span class="RktVar">a</span><span class="hspace"> </span><span class="RktVar">b</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">a</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">b</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a random integer <span class="RktSym">n</span> such that <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%7E3c%7E3d%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x"><=</a></span><span class="stt"> </span><span class="RktVar">a</span><span class="stt"> </span><span class="RktSym">n</span><span class="RktPn">)</span> and <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%7E3c%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x"><</a></span><span class="stt"> </span><span class="RktSym">n</span><span class="stt"> </span><span class="RktVar">b</span><span class="RktPn">)</span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._random-bits))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-bits%29%29" class="RktValDef RktValLink" data-pltdoc="x">random-bits</a></span></span><span class="hspace"> </span><span class="RktVar">num</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Natural%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Natural</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">num</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a random natural smaller than <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._expt%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">expt</a></span><span class="stt"> </span><span class="RktVal">2</span><span class="stt"> </span><span class="RktVar">num</span><span class="RktPn">)</span>; <span class="RktVar">num</span> must be positive.
For powers of two, this is faster than using <span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-natural%29%29" class="RktValLink" data-pltdoc="x">random-natural</a></span>, which
is implemented in terms of <span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-bits%29%29" class="RktValLink" data-pltdoc="x">random-bits</a></span>, using biased rejection sampling.</div></p><p>As an example of use, the significands of the numbers returned by <span class="RktSym"><a href="bigfloat.html#%28def._%28%28lib._math%2Fbigfloat..rkt%29._bfrandom%29%29" class="RktValLink" data-pltdoc="x">bfrandom</a></span>
are chosen by <span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._random-bits%29%29" class="RktValLink" data-pltdoc="x">random-bits</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="bigfloat.html#%28def._%28%28lib._math%2Fbigfloat..rkt%29._bf-precision%29%29" class="RktValLink" data-pltdoc="x">bf-precision</a></span><span class="RktPn">)</span><span class="RktPn">)</span>.</p><h4 x-source-module="(lib "math/scribblings/math.scrbl")" x-source-pkg="math-doc" x-part-tag=""Measuring_Error"">1.4<tt> </tt><a name="(part._.Measuring_.Error)"></a>Measuring Error</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._absolute-error))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="RktValDef RktValLink" data-pltdoc="x">absolute-error</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span><span class="RktVar">r</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">r</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Usually computes <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._abs%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">abs</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._-%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="stt"> </span><span class="RktVar">x</span><span class="stt"> </span><span class="RktVar">r</span><span class="RktPn">)</span><span class="RktPn">)</span> using exact rationals, but handles non-rational
reals such as <span class="RktVal">+inf.0</span> specially.</div></p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="RktValLink" data-pltdoc="x">absolute-error</a></span><span class="hspace"> </span><span class="RktVal">1/2</span><span class="hspace"> </span><span class="RktVal">1/2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="RktValLink" data-pltdoc="x">absolute-error</a></span><span class="hspace"> </span><span class="RktVal">0.14285714285714285</span><span class="hspace"> </span><span class="RktVal">1/7</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">7.93016446160826e-18</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="RktValLink" data-pltdoc="x">absolute-error</a></span><span class="hspace"> </span><span class="RktVal">+inf.0</span><span class="hspace"> </span><span class="RktVal">+inf.0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">0.0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="RktValLink" data-pltdoc="x">absolute-error</a></span><span class="hspace"> </span><span class="RktVal">+inf.0</span><span class="hspace"> </span><span class="RktVal">+nan.0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">+inf.0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="RktValLink" data-pltdoc="x">absolute-error</a></span><span class="hspace"> </span><span class="RktVal">1e-20</span><span class="hspace"> </span><span class="RktVal">0.0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">1e-20</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="RktValLink" data-pltdoc="x">absolute-error</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._-%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace"> </span><span class="RktVal">1.0</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="flonum.html#%28def._%28%28lib._math%2Fflonum..rkt%29._fl%29%29" class="RktValLink" data-pltdoc="x">fl</a></span><span class="hspace"> </span><span class="RktVal">4999999/5000000</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">1/5000000</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">5.751132903242251e-18</span></p></td></tr></table></blockquote></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._math/base..rkt)._relative-error))"></a><span title="Provided from: math/base | Package: math-lib"><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._relative-error%29%29" class="RktValDef RktValLink" data-pltdoc="x">relative-error</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span><span class="RktVar">r</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">r</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Real%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">Real</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Measures how close an approximation <span class="RktVar">x</span> is to the correct value <span class="RktVar">r</span>,
relative to the magnitude of <span class="RktVar">r</span>.</div></p><p>This function usually computes <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._abs%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">abs</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252F%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">/</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._-%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="stt"> </span><span class="RktVar">x</span><span class="stt"> </span><span class="RktVar">r</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktVar">r</span><span class="RktPn">)</span><span class="RktPn">)</span> using exact rationals,
but handles non-rational reals such as <span class="RktVal">+inf.0</span> specially, as well as
<span class="RktVar">r</span><span class="stt"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%7E3d%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">=</a></span><span class="stt"> </span><span class="RktVal">0</span>.</p><p><div class="SIntrapara"><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._relative-error%29%29" class="RktValLink" data-pltdoc="x">relative-error</a></span><span class="hspace"> </span><span class="RktVal">1/2</span><span class="hspace"> </span><span class="RktVal">1/2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._relative-error%29%29" class="RktValLink" data-pltdoc="x">relative-error</a></span><span class="hspace"> </span><span class="RktVal">0.14285714285714285</span><span class="hspace"> </span><span class="RktVal">1/7</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">5.551115123125783e-17</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._relative-error%29%29" class="RktValLink" data-pltdoc="x">relative-error</a></span><span class="hspace"> </span><span class="RktVal">+inf.0</span><span class="hspace"> </span><span class="RktVal">+inf.0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">0.0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._relative-error%29%29" class="RktValLink" data-pltdoc="x">relative-error</a></span><span class="hspace"> </span><span class="RktVal">+inf.0</span><span class="hspace"> </span><span class="RktVal">+nan.0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">+inf.0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._relative-error%29%29" class="RktValLink" data-pltdoc="x">relative-error</a></span><span class="hspace"> </span><span class="RktVal">1e-20</span><span class="hspace"> </span><span class="RktVal">0.0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">+inf.0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._relative-error%29%29" class="RktValLink" data-pltdoc="x">relative-error</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._-%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace"> </span><span class="RktVal">1.0</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="flonum.html#%28def._%28%28lib._math%2Fflonum..rkt%29._fl%29%29" class="RktValLink" data-pltdoc="x">fl</a></span><span class="hspace"> </span><span class="RktVal">4999999/5000000</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">1/5000000</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">2.8755664516211255e-11</span></p></td></tr></table></blockquote></div></p></div><div class="SIntrapara">In the last two examples, relative error is high because the result is near zero. (Compare
the same examples with <span class="RktSym"><a href="#%28def._%28%28lib._math%2Fbase..rkt%29._absolute-error%29%29" class="RktValLink" data-pltdoc="x">absolute-error</a></span>.) Because flonums are particularly dense
near zero, this makes relative error better than absolute error for measuring the error
in a flonum approximation. An even better one is error in <a href="flonum.html#%28tech._ulp%29" class="techoutside" data-pltdoc="x"><span class="techinside">ulps</span></a>; see <span class="RktSym"><a href="flonum.html#%28def._%28%28lib._math%2Fflonum..rkt%29._flulp-error%29%29" class="RktValLink" data-pltdoc="x">flulp-error</a></span>.</div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="index.html" title="backward to "Math Library"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Math Library"" data-pltdoc="x">up</a> <a href="flonum.html" title="forward to "2 Flonums"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|