emacs.d/clones/lisp/www.cliki.net/ratmath.html

58 lines
5 KiB
HTML
Raw Normal View History

2022-10-07 15:47:14 +02:00
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CLiki: ratmath</title>
<link rel="alternate" type="application/atom+xml" title="ATOM feed of edits to current article"
href="https://www.cliki.net/site/feed/article.atom?title=ratmath">
<link rel="stylesheet" href="static/css/style.css">
<link rel="stylesheet" href="static/css/colorize.css">
</head>
<body>
<span class="hidden">CLiki - ratmath</span>
<div id="content"><div id="content-area"><div id="article-title">ratmath</div><div id="article">Utilities for Rational Numbers in Common Lisp (rational approximations and interval arithmetic)<p>Usage examples:<p>Function <code>ratmath:rat</code> is akin to <code>cl:rationalize</code> with keyword arguments <code>:limd</code> and <code>:limn</code> representing the maximum numerator/denominator:<p><div class="code"><span class="nonparen"><span class="paren1">(<span class="nonparen">ratmath:rat <a href="https://www.cliki.net/site/HyperSpec/Body/convar_pi.html" class="symbol">pi</a> <span class="keyword">:limd</span> 255</span>)</span>
<span class="comment">;; =&gt;
</span>355/113
</span></div><p>Function <code>ratmath:infsup</code> can reduce bignum rational to a fixed bit rational interval (here, 16-bit):<p><div class="code"><span class="nonparen">CL-USER&gt; <span class="paren1">(<span class="nonparen"><a href="https://www.cliki.net/site/HyperSpec/Body/any_st.html" class="symbol">*</a> <span class="paren2">(<span class="nonparen"><a href="https://www.cliki.net/site/HyperSpec/Body/any_rational.html" class="symbol">rational</a> <a href="https://www.cliki.net/site/HyperSpec/Body/convar_pi.html" class="symbol">pi</a></span>)</span> <span class="paren2">(<span class="nonparen"><a href="https://www.cliki.net/site/HyperSpec/Body/any_rational.html" class="symbol">rational</a> <span class="paren3">(<span class="nonparen"><a href="https://www.cliki.net/site/HyperSpec/Body/fun_expcm_expt.html" class="symbol">exp</a> 1.0</span>)</span></span>)</span></span>)</span>
2520484590068807905375/295147905179352825856
CL-USER&gt; <span class="paren1">(<span class="nonparen"><a href="https://www.cliki.net/site/HyperSpec/Body/any_values.html" class="symbol">values</a> <span class="paren2">(<span class="nonparen">ratmath:infsup <a href="https://www.cliki.net/site/HyperSpec/Body/any_st.html" class="symbol">*</a> <span class="keyword">:limd</span> 65535 <span class="keyword">:limn</span> 65535</span>)</span></span>)</span>
<span class="paren1">(<span class="nonparen">23749/2781 . 50077/5864</span>)</span>
</span></div><p>More details <a href="https://github.com/jesseoff/ratmath/blob/master/README.md">in README</a>.<p>Repository: <a href="https://github.com/jesseoff/ratmath">GitHub</a><p>License: MIT<p>See Also: <a href="computable-reals.html" class="internal">computable-reals</a><p>Topics: <a href="mathematics.html" class="category">mathematics</a></div></div>
<div id="footer" class="buttonbar"><ul><li><a href="ratmath.html">Current version</a></li>
<li><a href="https://www.cliki.net/site/history?article=ratmath">History</a></li>
<li><a href="https://www.cliki.net/site/backlinks?article=ratmath">Backlinks</a></li><li><a href="https://www.cliki.net/site/edit-article?title=ratmath&amp;from-revision=3790681207">Edit</a></li><li><a href="https://www.cliki.net/site/edit-article?create=t">Create</a></li></ul></div>
</div>
<div id="header-buttons" class="buttonbar">
<ul>
<li><a href="https://www.cliki.net/">Home</a></li>
<li><a href="https://www.cliki.net/site/recent-changes">Recent Changes</a></li>
<li><a href="CLiki.html">About</a></li>
<li><a href="Text&#32;Formatting.html">Text Formatting</a></li>
<li><a href="https://www.cliki.net/site/tools">Tools</a></li>
</ul>
<div id="search">
<form action="https://www.cliki.net/site/search">
<label for="search_query" class="hidden">Search CLiki</label>
<input type="text" name="query" id="search_query" value="" />
<input type="submit" value="search" />
</form>
</div>
</div>
<div id="pageheader">
<div id="header">
<span id="logo">CLiki</span>
<span id="slogan">the common lisp wiki</span>
<div id="login"><form method="post" action="https://www.cliki.net/site/login">
<label for="login_name" class="hidden">Account name</label>
<input type="text" name="name" id="login_name" class="login_input" />
<label for= "login_password" class="hidden">Password</label>
<input type="password" name="password" id="login_password" class="login_input" />
<input type="submit" name="login" value="login" id="login_submit" /><br />
<div id="register"><a href="https://www.cliki.net/site/register">register</a></div>
<input type="submit" name="reset-pw" value="reset password" id="reset_pw" />
</form>
</div>
</div>
</div>
</body></html>