📄 rpncalc.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" xml:lang="en">
<head>
<title>Catalogue of RPN large integer calculator functions</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="author" content="Sjoerd.J.Schaper" />
<meta name="description" content="RPN large integer calculator function catalogue" />
<style type="text/css">
body {
font-family:"Times New Roman",serif;
font-weight:bold;
font-size:108%;
line-height:1.3em;
text-align:justify;
background:#fefaf2;
margin:2% 3% 3% 2%;
padding: 0;
}
h1 {
font-size:140%;
text-align:left;
}
h2 {
font-size:106%;
text-align:left;
}
hr {
width:78%;
text-align:left;
margin-left: 0;
}
ul {
text-align:left;
list-style-type:disc;
margin:0 0 0 2%;
padding: 0;
}
span.blue {
color:#000090;
}
span.green {
color:#006030;
}
</style>
</head>
<body>
<h1>Catalogue of RPN large integer calculator functions.</h1>
<h2>{button caption}<br />
function description,<br />
registers in/out.</h2>
<p>Framewise from left to right:
 
<a href="#f01">1</a>
 
<a href="#f02">2</a>
 
<a href="#f03">3</a>
 
<a href="#f04">4</a>
 
<a href="#f05">5</a>
 
<a href="#f06">6</a></p>
<hr id="f01" />
<p>{confrc}<br />
Continued fraction representation of rational a ⁄ b, truncated at<br />
the first convergent p ⁄ q for which q ≥ n.<br />
In: Z(a), Y(b), X(n); out: Y(p), X(q), Textbox(partial quotients).</p>
<p>{farey}<br />
Find the successor of rational a ⁄ b in the Farey series of order n:<br />
the ascending series of irreducible fractions between 0 and 1 with<br />
denominators ≤ n.<br />
In: Z(a), Y(b), X(n); out: Y(p), X(q).</p>
<p>{bezout}<br />
Find the smallest solution of indeterminate equation
a · x − b · y = c<br />
(aka. Bézout's identity), equivalent to the congruence
a · x ≡ c (mod b).<br />
This fails if the gcd(a, b) does not divide c. Input c = 0 to compute<br />
a · x − b · y = gcd(a, b).<br />
In: Z(a), Y(b), X(c); out: Y(x), X(y).</p>
<p>{gcd}<br />
Greatest common divisor of integers a and b: the largest positive integer<br />
which divides both a and b.<br />
In: Y(a), X(b); out: X(gcd).</p>
<p>{lcm}<br />
Least common multiple of integers a and b: the smallest positive integer<br />
which is divisible by both a and b.<br />
In: Y(a), X(b); out: X(lcm).</p>
<hr id="f02" />
<p>{modpwr}<br />
Modular exponentiation: raise base a to the k-th power and reduce modulo m.<br />
In: Z(a), Y(k), X(m); out: Y(power), X(m).</p>
<p>{modord}<br />
Calculate the Euler totient function φ(m)
and the order of a modulo m:<br />
the smallest positive value of x for which
a^x ≡ 1 (mod m).<br />
This fails if a and m are not coprime or if the calculator
cannot factorize m.<br />
Press F1 to break off, repeat if necessary.<br />
If base a = 1, then the order is set to φ(m).<br />
If φ(m) is equal to the Carmichael λ-function for m,<br />
then the least positive primitive root of m is also given.<br />
In: Y(a), X(m);<br />
out: Z(a), Y(x), X(m), Textbox(φ(m) and either λ(m) or the root).</p>
<p>{modinv}<br />
Multiplicative inverse or associate of a to modulus m: x such that<br />
a · x ≡ 1 (mod m). This fails if a and m are not coprime.<br />
In: Y(a), X(m); out: Y(x), X(m).</p>
<p>{modsqr}<br />
Calculate Kronecker's symbol for a and m, and solve quadratic congruence<br />
x^2 ≡ a (mod m). This fails if a is a quadratic nonresidue
modulo m<br />
or if m is composite and cannot be factorized by the calculator.<br />
In: Y(a), X(m); out: Y(x), X(m), Textbox((a ⁄ m)).</p>
<p>{chinese}<br />
Find the solution of simultaneous congruences
x ≡ a (mod m) and x ≡ b (mod n)<br />
with the Chinese remainder theorem. This fails if the gcd(m, n) does not<br />
divide b − a.<br />
In: S(a), Z(m), Y(b), X(n); out: Y(x), X(modulus).</p>
<hr id="f03" />
<h2>Basic operations</h2>
<p>This frame may be switched into different calculation modes by clicking it.</p>
<ul>
<li>Default mode (colour black, caption Z)<br />
Operations are done on signed integer numbers (ring Z).</li>
<li>Rational mode (<span class="blue">colour blue</span>, caption Q)<br />
Operations are done on rational integers (field Q).<br />
The numbers in registers S, Z, Y and X are interpreted pairwise as<br />
rationals a ⁄ b.</li>
<li>Quadratic mode (<span class="green">colour green</span>, caption K)<br />
Operations are done on integers in quadratic ring K = Z(√d).<br />
The number in register T (the top of the stack) is taken as radicand d,<br />
the numbers in registers S, Z, Y and X are interpreted pairwise as<br />
algebraic integers a + b√d.</li>
</ul>
<p>{mod}<br />
Residue of a to modulus m: positive solution of
x ≡ a (mod m).<br />
In: Y(a), X(m); out: X(x).<br />
<span class="blue">In: S(a), Z(b), Y(p), X(q);
out: Y(0), X(1).</span><br />
<span class="green">In: T(d), S(a), Z(b), Y(u), X(v);
out: Y(x), X(y),<br />
with x + y√d
= w − trunc(w ⁄ z) × z,
w = a + b√d, z = u + v√d.</span></p>
<p>{a^k}<br />
Exponentiation: raise base a to the k-th power.<br />
In: Y(a), X(k); out: X(power).<br />
<span class="blue">In: Z(a), Y(b), X(k);
out: Y(a^k), X(b^k), k ∈ N.</span><br />
<span class="green">In: T(d), Z(a), Y(b), X(k);
out: Y(x), X(y),<br />
with x + y√d
= (a + b√d)^k, k ∈ N.</span></p>
<p>{a^2}<br />
The square of a.<br />
In: X(a); out: X(square).<br />
<span class="blue">In: Y(a), X(b);
out: Y(a^2), X(b^2).</span><br />
<span class="green">In: T(d), Y(a), X(b);
out: Y(x), X(y),<br />
with x + y√d
= (a^2 + b^2·d) + 2ab√d.</span></p>
<p>{sqrt}<br />
Integer square root of a ≥ 0.<br />
In: X(a); out: X(root).<br />
<span class="blue">In: Y(a), X(b);
out: Y(√a), X(√b).</span><br />
<span class="green">In: T(d), Y(a), X(b);
out: Y(x), X(y),<br />
with x + y√d = (a + b√d)^½.</span></p>
<p>{÷}<br />
Integer division.<br />
In: Y(a), X(b); out: X(a ⁄ b).<br />
<span class="blue">In: S(a), Z(b), Y(p), X(q);
out: Y(aq), X(bp).</span><br />
<span class="green">In: T(d), S(a), Z(b), Y(u), X(v);
out: Y(x), X(y),<br />
with x + y√d
= (au − bv·d) ⁄ t + (bu − av)√d ⁄ t,
t = u^2 − v^2·d.</span></p>
<p>{×}<br />
Multiplication.<br />
In: Y(a), X(b); out: X(a × b).<br />
<span class="blue">In: S(a), Z(b), Y(p), X(q);
out: Y(ap), X(bq).</span><br />
<span class="green">In: T(d), S(a), Z(b), Y(u), X(v);
out: Y(x), X(y),<br />
with x + y√d
= (au + bv·d) + (bu + av)√d.</span></p>
<p>{+}<br />
Addition.<br />
In: Y(a), X(b); out: X(a + b).<br />
<span class="blue">In: S(a), Z(b), Y(p), X(q);
out: Y(aq + bp), X(bq).</span><br />
<span class="green">In: S(a), Z(b), Y(u), X(v);
out: Y(a + u), X(b + v).</span></p>
<p>{−}<br />
Subtraction.<br />
In: Y(a), X(b); out: X(a − b).<br />
<span class="blue">In: S(a), Z(b), Y(p), X(q);
out: Y(aq − bp), X(bq).</span><br />
<span class="green">In: S(a), Z(b), Y(u), X(v);
out: Y(a − u), X(b − v).</span></p>
<p>{shr}<br />
Shift a one bit to the right.<br />
In: X(a); out: X(a ⁄ 2).<br />
<span class="blue">In: Y(a), X(b);
out: Y(a), X(b × 2).</span><br />
<span class="green">In: Y(a), X(b);
out: Y(a ⁄ 2), X(b ⁄ 2).</span></p>
<p>{shl}<br />
Shift a one bit to the left.<br />
In: X(a); out: X(a × 2).<br />
<span class="blue">In: Y(a), X(b);
out: Y(a × 2), X(b).</span><br />
<span class="green">In: Y(a), X(b);
out: Y(a × 2), X(b × 2).</span></p>
<p>{inc}<br />
Increment a by one.<br />
In: X(a); out: X(a + 1).<br />
<span class="blue">In: Y(a), X(b);
out: Y(a + 1), X(b).</span><br />
<span class="green">In: Y(a), X(b);
out: Y(a + 1), X(b).</span></p>
<p>{dcr}<br />
Decrement a by one.<br />
In: X(a); out: X(a − 1).<br />
<span class="blue">In: Y(a), X(b);
out: Y(a − 1), X(b).</span><br />
<span class="green">In: Y(a), X(b);
out: Y(a − 1), X(b).</span></p>
<hr id="f04" />
<h2>Memory buttons</h2>
<p>{sto}<br />
Store the contents of registers X (display) and Y (stack bottom) into memory.</p>
<p>{rcl}<br />
Recall the memory contents and put them into registers X and Y.</p>
<h2>Stack manipulation</h2>
<p>[Enter] (has no button equivalent)<br />
Save the value in the display (copy register X to Y and lift the stack).</p>
<p>{last} or [Up Arrow]<br />
Exchange the current stack with the stack before the last operation.</p>
<p>{clear} or [Insert]<br />
Clear the current stack.</p>
<p>{clx} or numeric .[Del]<br />
Cancel entry (clear the display).</p>
<p>{roll} or [Page Up]<br />
Roll the stack one level up.</p>
<p>{drop} or [Page Down]<br />
Drop the stack one level down.</p>
<p>{x«»y} or [Down Arrow]<br />
Swap the X (display) and Y (stack bottom) registers.</p>
<hr id="f05" />
<p>{bino}<br />
Binomial coefficient or combination n choose k: the coefficient of<br />
x^k in (1 + x)^n, also the number of k-subsets possible out of a set of<br />
n distinct items. Positive k ≤ abs(n) < 10^9.<br />
In: Y(n), X(k); out: X(binomial coefficient).</p>
<p>{n!}<br />
Factorial of integer abs(n) < 10^4: the number of ways in which n objects<br />
can be permuted, defined as
n · (n − 1) · · · 2 · 1.<br />
In: X(n); out: X(factorial).</p>
<p>{rnd}<br />
Random positive integer a with length abs(l) < 10^4.<br />
In: X(l); out: X(random a).</p>
<p>{chs}<br />
Change the sign of integer a.<br />
In: X(a); out: X(-a).</p>
<p>{fibo}<br />
Fibonacci number Fn, defined by the recurrence relation
Fn+1 = Fn + Fn-1,<br />
with F1 = F2 = 1 and index abs(n) < 2^16.<br />
In: X(n); out: X(Fn).</p>
<p>{10^k}<br />
Exponentiation: raise base 10 to the k-th power, abs(k) < 10^4.<br />
In: X(k); out: X(power).</p>
<p>{prim}<br />
Find the next probable prime ≥ abs(a) with the 1980 Miller-Rabin strong<br />
pseudoprime test. Press F1 to break off.<br />
In: X(a); out: X(next prime).</p>
<p>{split}<br />
Attempt to split abs(a) in two factors. Press F1 to break off.<br />
If a is prime and a ≡ 1 (mod 4)
then abs(a) is factored into conjugate<br />
Gaussian primes x ± yi in the quadratic ring
K = Z(√−1).<br />
The continued fraction expansion of a ⁄ r,
with r² ≡ −1 (mod a) is also given.<br />
In: X(a); out: Y(f or x), X(a ⁄ f or y),
Textbox(partial quotients).</p>
<hr id="f06" />
<p>{a ⁄ b}<br />
Decimal expansion of rational number a ⁄ b.<br />
In: Y(a), X(b); out: Textbox(decimal fraction).</p>
<p>{1 ⁄ a}<br />
Decimal expansion of the reciprocal of nonzero integer a.<br />
In: X(a); out: Textbox(decimal fraction).</p>
<p>{funit}<br />
Power basis representation of the fundamental unit
(p + q√d) ⁄ 2<br />
for the quadratic ring K = Z(√d),
with positive d < 10^9.<br />
Also given are the continued fraction expansion of the irrational<br />
and a decimal approximation of the real square root.<br />
In: X(d); out: Y(p), X(q), Textbox(partial quotients, decimal root).</p>
<p>{divf}<br />
Divisor functions μ(a), ω(a), Ω(a), δ(a) and σ(a)
of nonzero integer abs(a).<br />
This fails if the calculator cannot factorize a.
Press F1 to break off.<br />
In: X(a); out: Y(σ(a)), Textbox(prime factors and function values).</p>
<p>{bin}<br />
Binary representation of integer a.<br />
In: X(a); out: Textbox(bit vector).</p>
<hr />
<h2>Note on factorization</h2>
<p>A number is first divided by all primes < 2^17, then the Pollard-Brent<br />
Monte Carlo rho-algorithm is applied to the residue. Successive random<br />
mappings are continued for 2^16 iterations each, until a factor is found.<br />
The splitting process is then repeated recursively. Most numbers with<br />
up to 25 figures will be fully factorized, bigger ones only if they're smooth.</p>
<hr />
<p>Copyright © december 2004 by Sjoerd.J.Schaper</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -