1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
3
<!-- Created on September, 20 2006 by texi2html 1.76 -->
5
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
6
Karl Berry <karl@freefriends.org>
7
Olaf Bachmann <obachman@mathematik.uni-kl.de>
9
Maintained by: Many creative people <dev@texi2html.cvshome.org>
10
Send bugs and suggestions to <users@texi2html.cvshome.org>
14
<title>Maxima Manual: 32. Number Theory</title>
16
<meta name="description" content="Maxima Manual: 32. Number Theory">
17
<meta name="keywords" content="Maxima Manual: 32. Number Theory">
18
<meta name="resource-type" content="document">
19
<meta name="distribution" content="global">
20
<meta name="Generator" content="texi2html 1.76">
21
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
22
<style type="text/css">
24
a.summary-letter {text-decoration: none}
25
pre.display {font-family: serif}
26
pre.format {font-family: serif}
27
pre.menu-comment {font-family: serif}
28
pre.menu-preformatted {font-family: serif}
29
pre.smalldisplay {font-family: serif; font-size: smaller}
30
pre.smallexample {font-size: smaller}
31
pre.smallformat {font-family: serif; font-size: smaller}
32
pre.smalllisp {font-size: smaller}
33
span.sansserif {font-family:sans-serif; font-weight:normal;}
34
ul.toc {list-style: none}
47
font-family: sans-serif
53
font-family: sans-serif
59
font-family: sans-serif
62
h2,h3,h4,h5,h6 { margin-left: +4%; }
82
background: rgb(200,255,255);
83
font-family: sans-serif
93
background: rgb(255,220,255);
94
/*background: rgb(200,255,255); */
95
/* font-family: fixed */
105
background: rgb(247,242,180); /* kind of sandy */
106
/* background: rgb(200,255,255); */ /* sky blue */
107
font-family: "Lucida Console", monospace
126
<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
129
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
131
<a name="Number-Theory"></a>
132
<a name="SEC128"></a>
133
<table cellpadding="1" cellspacing="1" border="0">
134
<tr><td valign="middle" align="left">[<a href="maxima_31.html#SEC127" title="Previous section in reading order"> < </a>]</td>
135
<td valign="middle" align="left">[<a href="#SEC129" title="Next section in reading order"> > </a>]</td>
136
<td valign="middle" align="left"> </td>
137
<td valign="middle" align="left">[<a href="maxima_31.html#SEC125" title="Beginning of this chapter or previous chapter"> << </a>]</td>
138
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
139
<td valign="middle" align="left">[<a href="maxima_33.html#SEC130" title="Next chapter"> >> </a>]</td>
140
<td valign="middle" align="left"> </td>
141
<td valign="middle" align="left"> </td>
142
<td valign="middle" align="left"> </td>
143
<td valign="middle" align="left"> </td>
144
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
145
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
146
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
147
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
149
<h1 class="chapter"> 32. Number Theory </h1>
152
<table class="menu" border="0" cellspacing="0">
153
<tr><td align="left" valign="top"><a href="#SEC129">32.1 Definitions for Number Theory</a></td><td> </td><td align="left" valign="top">
158
<a name="Definitions-for-Number-Theory"></a>
159
<a name="SEC129"></a>
160
<table cellpadding="1" cellspacing="1" border="0">
161
<tr><td valign="middle" align="left">[<a href="#SEC128" title="Previous section in reading order"> < </a>]</td>
162
<td valign="middle" align="left">[<a href="maxima_33.html#SEC130" title="Next section in reading order"> > </a>]</td>
163
<td valign="middle" align="left"> </td>
164
<td valign="middle" align="left">[<a href="#SEC128" title="Beginning of this chapter or previous chapter"> << </a>]</td>
165
<td valign="middle" align="left">[<a href="#SEC128" title="Up section"> Up </a>]</td>
166
<td valign="middle" align="left">[<a href="maxima_33.html#SEC130" title="Next chapter"> >> </a>]</td>
167
<td valign="middle" align="left"> </td>
168
<td valign="middle" align="left"> </td>
169
<td valign="middle" align="left"> </td>
170
<td valign="middle" align="left"> </td>
171
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
172
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
173
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
174
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
176
<h2 class="section"> 32.1 Definitions for Number Theory </h2>
179
<dt><u>Function:</u> <b>bern</b><i> (<var>n</var>)</i>
180
<a name="IDX1046"></a>
182
<dd><p>Returns the <var>n</var>'th Bernoulli number for integer <var>n</var>.
183
Bernoulli numbers equal to zero are suppressed if <code>zerobern</code> is <code>false</code>.
185
<p>See also <code>burn</code>.
187
<table><tr><td> </td><td><pre class="example">(%i1) zerobern: true$
188
(%i2) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
190
(%o2) [1, - -, -, 0, - --, 0, --, 0, - --]
192
(%i3) zerobern: false$
193
(%i4) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
194
1 1 1 5 691 7 3617 43867
195
(%o4) [1, - -, -, - --, --, - ----, -, - ----, -----]
196
2 6 30 66 2730 6 510 798
197
</pre></td></tr></table>
201
<dt><u>Function:</u> <b>bernpoly</b><i> (<var>x</var>, <var>n</var>)</i>
202
<a name="IDX1047"></a>
204
<dd><p>Returns the <var>n</var>'th Bernoulli polynomial in the
205
variable <var>x</var>.
210
<dt><u>Function:</u> <b>bfzeta</b><i> (<var>s</var>, <var>n</var>)</i>
211
<a name="IDX1048"></a>
213
<dd><p>Returns the Riemann zeta function for the argument <var>s</var>.
214
The return value is a big float (bfloat);
215
<var>n</var> is the number of digits in the return value.
217
<p><code>load ("bffac")</code> loads this function.
222
<dt><u>Function:</u> <b>bfhzeta</b><i> (<var>s</var>, <var>h</var>, <var>n</var>)</i>
223
<a name="IDX1049"></a>
225
<dd><p>Returns the Hurwitz zeta function for the arguments <var>s</var> and <var>h</var>.
226
The return value is a big float (bfloat);
227
<var>n</var> is the number of digits in the return value.
229
<p>The Hurwitz zeta function is defined as
231
<table><tr><td> </td><td><pre class="example">sum ((k+h)^-s, k, 0, inf)
232
</pre></td></tr></table>
233
<p><code>load ("bffac")</code> loads this function.
238
<dt><u>Function:</u> <b>binomial</b><i> (<var>x</var>, <var>y</var>)</i>
239
<a name="IDX1050"></a>
241
<dd><p>The binomial coefficient <code><var>x</var>!/(<var>y</var>! (<var>x</var> - <var>y</var>)!)</code>.
242
If <var>x</var> and <var>y</var> are integers, then the numerical value of the binomial
243
coefficient is computed.
244
If <var>y</var>, or <var>x - y</var>, is an integer,
245
the binomial coefficient is expressed as a polynomial.
249
<table><tr><td> </td><td><pre class="example">(%i1) binomial (11, 7);
251
(%i2) 11! / 7! / (11 - 7)!;
253
(%i3) binomial (x, 7);
254
(x - 6) (x - 5) (x - 4) (x - 3) (x - 2) (x - 1) x
255
(%o3) -------------------------------------------------
257
(%i4) binomial (x + 7, x);
258
(x + 1) (x + 2) (x + 3) (x + 4) (x + 5) (x + 6) (x + 7)
259
(%o4) -------------------------------------------------------
261
(%i5) binomial (11, y);
262
(%o5) binomial(11, y)
263
</pre></td></tr></table>
267
<dt><u>Function:</u> <b>burn</b><i> (<var>n</var>)</i>
268
<a name="IDX1051"></a>
270
<dd><p>Returns the <var>n</var>'th Bernoulli number for integer <var>n</var>.
271
<code>burn</code> may be more efficient than <code>bern</code> for large, isolated <var>n</var>
272
(perhaps <var>n</var> greater than 105 or so), as <code>bern</code> computes all the Bernoulli numbers up to index <var>n</var> before returning.
275
<p><code>burn</code> exploits the observation that (rational) Bernoulli numbers can be
276
approximated by (transcendental) zetas with tolerable efficiency.
278
<p><code>load ("bffac")</code> loads this function.
283
<dt><u>Function:</u> <b>cf</b><i> (<var>expr</var>)</i>
284
<a name="IDX1052"></a>
286
<dd><p>Converts <var>expr</var> into a continued fraction.
287
<var>expr</var> is an expression
288
comprising continued fractions and square roots of integers.
289
Operands in the expression may be combined with arithmetic operators.
290
Aside from continued fractions and square roots,
291
factors in the expression must be integer or rational numbers.
292
Maxima does not know about operations on continued fractions outside of <code>cf</code>.
294
<p><code>cf</code> evaluates its arguments after binding <code>listarith</code> to <code>false</code>.
295
<code>cf</code> returns a continued fraction, represented as a list.
297
<p>A continued fraction <code>a + 1/(b + 1/(c + ...))</code>
298
is represented by the list <code>[a, b, c, ...]</code>.
299
The list elements <code>a</code>, <code>b</code>, <code>c</code>, ... must evaluate to integers.
300
<var>expr</var> may also contain <code>sqrt (n)</code> where <code>n</code> is an integer.
301
In this case <code>cf</code> will give as many
302
terms of the continued fraction as the value of the variable
303
<code>cflength</code> times the period.
305
<p>A continued fraction can be evaluated to a number
306
by evaluating the arithmetic representation
307
returned by <code>cfdisrep</code>.
308
See also <code>cfexpand</code> for another way to evaluate a continued fraction.
310
<p>See also <code>cfdisrep</code>, <code>cfexpand</code>, and <code>cflength</code>.
316
<var>expr</var> is an expression comprising continued fractions and square roots of integers.
318
<table><tr><td> </td><td><pre class="example">(%i1) cf ([5, 3, 1]*[11, 9, 7] + [3, 7]/[4, 3, 2]);
319
(%o1) [59, 17, 2, 1, 1, 1, 27]
320
(%i2) cf ((3/17)*[1, -2, 5]/sqrt(11) + (8/13));
321
(%o2) [0, 1, 1, 1, 3, 2, 1, 4, 1, 9, 1, 9, 2]
322
</pre></td></tr></table>
324
<code>cflength</code> controls how many periods of the continued fraction
325
are computed for algebraic, irrational numbers.
327
<table><tr><td> </td><td><pre class="example">(%i1) cflength: 1$
328
(%i2) cf ((1 + sqrt(5))/2);
329
(%o2) [1, 1, 1, 1, 2]
331
(%i4) cf ((1 + sqrt(5))/2);
332
(%o4) [1, 1, 1, 1, 1, 1, 1, 2]
334
(%i6) cf ((1 + sqrt(5))/2);
335
(%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
336
</pre></td></tr></table>
338
A continued fraction can be evaluated by evaluating the arithmetic representation
339
returned by <code>cfdisrep</code>.
341
<table><tr><td> </td><td><pre class="example">(%i1) cflength: 3$
342
(%i2) cfdisrep (cf (sqrt (3)))$
344
(%o3) 1.731707317073171
345
</pre></td></tr></table>
347
Maxima does not know about operations on continued fractions outside of <code>cf</code>.
349
<table><tr><td> </td><td><pre class="example">(%i1) cf ([1,1,1,1,1,2] * 3);
351
(%i2) cf ([1,1,1,1,1,2]) * 3;
352
(%o2) [3, 3, 3, 3, 3, 6]
353
</pre></td></tr></table>
358
<dt><u>Function:</u> <b>cfdisrep</b><i> (<var>list</var>)</i>
359
<a name="IDX1053"></a>
361
<dd><p>Constructs and returns an ordinary arithmetic expression
362
of the form <code>a + 1/(b + 1/(c + ...))</code>
363
from the list representation of a continued fraction <code>[a, b, c, ...]</code>.
365
<table><tr><td> </td><td><pre class="example">(%i1) cf ([1, 2, -3] + [1, -2, 1]);
375
</pre></td></tr></table>
379
<dt><u>Function:</u> <b>cfexpand</b><i> (<var>x</var>)</i>
380
<a name="IDX1054"></a>
382
<dd><p>Returns a matrix of the numerators and denominators of the
383
last (column 1) and next-to-last (column 2) convergents of the continued fraction <var>x</var>.
385
<table><tr><td> </td><td><pre class="example">(%i1) cf (rat (ev (%pi, numer)));
387
`rat' replaced 3.141592653589793 by 103993//33102 = 3.141592653011902
388
(%o1) [3, 7, 15, 1, 292]
393
(%i3) %[1,1]/%[2,1], numer;
394
(%o3) 3.141592653011902
395
</pre></td></tr></table>
399
<dt><u>Option variable:</u> <b>cflength</b>
400
<a name="IDX1055"></a>
402
<dd><p>Default value: 1
404
<p><code>cflength</code> controls the number of terms of the continued
405
fraction the function <code>cf</code> will give, as the value <code>cflength</code> times the
406
period. Thus the default is to give one period.
408
<table><tr><td> </td><td><pre class="example">(%i1) cflength: 1$
409
(%i2) cf ((1 + sqrt(5))/2);
410
(%o2) [1, 1, 1, 1, 2]
412
(%i4) cf ((1 + sqrt(5))/2);
413
(%o4) [1, 1, 1, 1, 1, 1, 1, 2]
415
(%i6) cf ((1 + sqrt(5))/2);
416
(%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
417
</pre></td></tr></table>
421
<dt><u>Function:</u> <b>divsum</b><i> (<var>n</var>, <var>k</var>)</i>
422
<a name="IDX1056"></a>
424
<dt><u>Function:</u> <b>divsum</b><i> (<var>n</var>)</i>
425
<a name="IDX1057"></a>
427
<dd><p><code>divsum (<var>n</var>, <var>k</var>)</code> returns the sum of the divisors of <var>n</var>
428
raised to the <var>k</var>'th power.
430
<p><code>divsum (<var>n</var>)</code> returns the sum of the divisors of <var>n</var>.
432
<table><tr><td> </td><td><pre class="example">(%i1) divsum (12);
434
(%i2) 1 + 2 + 3 + 4 + 6 + 12;
436
(%i3) divsum (12, 2);
438
(%i4) 1^2 + 2^2 + 3^2 + 4^2 + 6^2 + 12^2;
440
</pre></td></tr></table>
444
<dt><u>Function:</u> <b>euler</b><i> (<var>n</var>)</i>
445
<a name="IDX1058"></a>
447
<dd><p>Returns the <var>n</var>'th Euler number for nonnegative integer <var>n</var>.
449
<p>For the Euler-Mascheroni constant, see <code>%gamma</code>.
451
<table><tr><td> </td><td><pre class="example">(%i1) map (euler, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
452
(%o1) [1, 0, - 1, 0, 5, 0, - 61, 0, 1385, 0, - 50521]
453
</pre></td></tr></table>
457
<dt><u>Constant:</u> <b>%gamma</b>
458
<a name="IDX1059"></a>
460
<dd><p>The Euler-Mascheroni constant, 0.5772156649015329 ....
465
<dt><u>Function:</u> <b>factorial</b><i> (<var>x</var>)</i>
466
<a name="IDX1060"></a>
468
<dd><p>Represents the factorial function. Maxima treats <code>factorial (<var>x</var>)</code> the same as <code><var>x</var>!</code>.
474
<dt><u>Function:</u> <b>fib</b><i> (<var>n</var>)</i>
475
<a name="IDX1061"></a>
477
<dd><p>Returns the <var>n</var>'th Fibonacci number.
478
<code>fib(0)</code> equal to 0 and <code>fib(1)</code> equal to 1,
480
<code>fib (-<var>n</var>)</code> equal to <code>(-1)^(<var>n</var> + 1) * fib(<var>n</var>)</code>.
482
<p>After calling <code>fib</code>,
483
<code>prevfib</code> is equal to <code>fib (<var>x</var> - 1)</code>,
484
the Fibonacci number preceding the last one computed.
486
<table><tr><td> </td><td><pre class="example">(%i1) map (fib, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
487
(%o1) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
488
</pre></td></tr></table>
492
<dt><u>Function:</u> <b>fibtophi</b><i> (<var>expr</var>)</i>
493
<a name="IDX1062"></a>
495
<dd><p>Expresses Fibonacci numbers in terms of the constant <code>%phi</code>,
496
which is <code>(1 + sqrt(5))/2</code>, approximately 1.61803399.
498
<p>By default, Maxima does not know about <code>%phi</code>.
499
After executing <code>tellrat (%phi^2 - %phi - 1)</code> and <code>algebraic: true</code>,
500
<code>ratsimp</code> can simplify some expressions containing <code>%phi</code>.
502
<table><tr><td> </td><td><pre class="example">(%i1) fibtophi (fib (n));
505
(%o1) -------------------
507
(%i2) fib (n-1) + fib (n) - fib (n+1);
508
(%o2) - fib(n + 1) + fib(n) + fib(n - 1)
509
(%i3) ratsimp (fibtophi (%));
511
</pre></td></tr></table>
515
<dt><u>Function:</u> <b>ifactors</b><i> (<var>n</var>)</i>
516
<a name="IDX1063"></a>
518
<dd><p>For a positive integer <var>n</var> returns the factorization of <var>n</var>. If
519
<code>n=p1^e1..pk^nk</code> is the decomposition of <var>n</var> into prime
520
factors, ifactors returns <code>[[p1, e1], ... , [pk, ek]]</code>.
522
<p>Factorization methods used are trial divisions by primes up to 9973,
523
Pollard's rho method and elliptic curve method.
525
<table><tr><td> </td><td><pre class="example">(%i1) ifactors(51575319651600);
526
(%o1) [[2, 4], [3, 2], [5, 2], [1583, 1], [9050207, 1]]
527
(%i2) apply("*", map(lambda([u], u[1]^u[2]), %));
529
</pre></td></tr></table>
533
<dt><u>Function:</u> <b>inrt</b><i> (<var>x</var>, <var>n</var>)</i>
534
<a name="IDX1064"></a>
536
<dd><p>Returns the integer <var>n</var>'th root of the absolute value of <var>x</var>.
538
<table><tr><td> </td><td><pre class="example">(%i1) l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]$
539
(%i2) map (lambda ([a], inrt (10^a, 3)), l);
540
(%o2) [2, 4, 10, 21, 46, 100, 215, 464, 1000, 2154, 4641, 10000]
541
</pre></td></tr></table>
545
<dt><u>Function:</u> <b>inv_mod</b><i> (<var>n</var>, <var>m</var>)</i>
546
<a name="IDX1065"></a>
548
<dd><p>Computes the inverse of <var>n</var> modulo <var>m</var>.
549
<code>inv_mod (n,m)</code> returns <code>false</code>,
550
if <var>n</var> is a zero divisor modulo <var>m</var>.
552
<table><tr><td> </td><td><pre class="example">(%i1) inv_mod(3, 41);
554
(%i2) ratsimp(3^-1), modulus=41;
556
(%i3) inv_mod(3, 42);
558
</pre></td></tr></table>
562
<dt><u>Function:</u> <b>jacobi</b><i> (<var>p</var>, <var>q</var>)</i>
563
<a name="IDX1066"></a>
565
<dd><p>Returns the Jacobi symbol of <var>p</var> and <var>q</var>.
567
<table><tr><td> </td><td><pre class="example">(%i1) l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]$
568
(%i2) map (lambda ([a], jacobi (a, 9)), l);
569
(%o2) [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]
570
</pre></td></tr></table>
574
<dt><u>Function:</u> <b>lcm</b><i> (<var>expr_1</var>, ..., <var>expr_n</var>)</i>
575
<a name="IDX1067"></a>
577
<dd><p>Returns the least common multiple of its arguments.
578
The arguments may be general expressions as well as integers.
580
<p><code>load ("functs")</code> loads this function.
585
<dt><u>Function:</u> <b>minfactorial</b><i> (<var>expr</var>)</i>
586
<a name="IDX1068"></a>
588
<dd><p>Examines <var>expr</var> for occurrences of two factorials
589
which differ by an integer.
590
<code>minfactorial</code> then turns one into a polynomial times the other.
593
<table><tr><td> </td><td><pre class="example">(%i1) n!/(n+2)!;
597
(%i2) minfactorial (%);
599
(%o2) ---------------
601
</pre></td></tr></table>
605
<dt><u>Function:</u> <b>power_mod</b><i> (<var>a</var>, <var>n</var>, <var>m</var>)</i>
606
<a name="IDX1069"></a>
608
<dd><p>Uses a modular algorithm to compute <code>a^n mod m</code>
609
where <var>a</var> and <var>n</var> are integers and <var>m</var> is a positive integer.
610
If <var>n</var> is negative, <code>inv_mod</code> is used to find the modular inverse.
612
<table><tr><td> </td><td><pre class="example">(%i1) power_mod(3, 15, 5);
616
(%i3) power_mod(2, -1, 5);
620
</pre></td></tr></table>
624
<dt><u>Function:</u> <b>next_prime</b><i> (<var>n</var>)</i>
625
<a name="IDX1070"></a>
627
<dd><p>Returns the smallest prime bigger than <var>n</var>.
629
<table><tr><td> </td><td><pre class="example">(%i1) next_prime(27);
631
</pre></td></tr></table>
635
<dt><u>Function:</u> <b>partfrac</b><i> (<var>expr</var>, <var>var</var>)</i>
636
<a name="IDX1071"></a>
638
<dd><p>Expands the expression <var>expr</var> in partial fractions
639
with respect to the main variable <var>var</var>. <code>partfrac</code> does a complete
640
partial fraction decomposition. The algorithm employed is based on
641
the fact that the denominators of the partial fraction expansion (the
642
factors of the original denominator) are relatively prime. The
643
numerators can be written as linear combinations of denominators, and
644
the expansion falls out.
646
<table><tr><td> </td><td><pre class="example">(%i1) 1/(1+x)^2 - 2/(1+x) + 2/(2+x);
648
(%o1) ----- - ----- + --------
653
(%o2) - -------------------
656
(%i3) partfrac (%, x);
658
(%o3) ----- - ----- + --------
661
</pre></td></tr></table></dd></dl>
664
<dt><u>Function:</u> <b>primep</b><i> (<var>n</var>)</i>
665
<a name="IDX1072"></a>
667
<dd><p>Primality test. If <code>primep (n)</code> returns <code>false</code>, <var>n</var> is a
668
composite number and if it returns <code>true</code>, <var>n</var> is a prime number
669
with very high probability.
671
<p>For <var>n</var> less than 341550071728321 a deterministic version of Miller-Rabin's
672
test is used. If <code>primep (n)</code> returns <code>true</code>, then <var>n</var> is a
675
<p>For <var>n</var> bigger than 34155071728321 <code>primep</code> uses
676
<code>primep_number_of_tests</code> Miller-Rabin's pseudo-primality tests
677
and one Lucas pseudo-primality test. The probability that <var>n</var> will
678
pass one Miller-Rabin test is less than 1/4. Using the default value 25 for
679
<code>primep_number_of_tests</code>, the probability of <var>n</var> beeing
680
composite is much smaller that 10^-15.
685
<dt><u>Option variable:</u> <b>primep_number_of_tests</b>
686
<a name="IDX1073"></a>
688
<dd><p>Default value: 25
690
<p>Number of Miller-Rabin's tests used in <code>primep</code>.
694
<dt><u>Function:</u> <b>prev_prime</b><i> (<var>n</var>)</i>
695
<a name="IDX1074"></a>
697
<dd><p>Returns the greatest prime smaller than <var>n</var>.
699
<table><tr><td> </td><td><pre class="example">(%i1) prev_prime(27);
701
</pre></td></tr></table></dd></dl>
704
<dt><u>Function:</u> <b>qunit</b><i> (<var>n</var>)</i>
705
<a name="IDX1075"></a>
707
<dd><p>Returns the principal unit of the real quadratic number field
708
<code>sqrt (<var>n</var>)</code> where <var>n</var> is an integer,
709
i.e., the element whose norm is unity.
710
This amounts to solving Pell's equation <code>a^2 - <var>n</var> b^2 = 1</code>.
712
<table><tr><td> </td><td><pre class="example">(%i1) qunit (17);
714
(%i2) expand (% * (sqrt(17) - 4));
716
</pre></td></tr></table>
720
<dt><u>Function:</u> <b>totient</b><i> (<var>n</var>)</i>
721
<a name="IDX1076"></a>
723
<dd><p>Returns the number of integers less than or equal to <var>n</var> which
724
are relatively prime to <var>n</var>.
729
<dt><u>Option variable:</u> <b>zerobern</b>
730
<a name="IDX1077"></a>
732
<dd><p>Default value: <code>true</code>
734
<p>When <code>zerobern</code> is <code>false</code>,
735
<code>bern</code> excludes the Bernoulli numbers which are equal to zero.
736
See <code>bern</code>.
741
<dt><u>Function:</u> <b>zeta</b><i> (<var>n</var>)</i>
742
<a name="IDX1078"></a>
744
<dd><p>Returns the Riemann zeta function if <var>x</var> is a negative integer, 0, 1,
745
or a positive even number,
746
and returns a noun form <code>zeta (<var>n</var>)</code> for all other arguments,
747
including rational noninteger, floating point, and complex arguments.
749
<p>See also <code>bfzeta</code> and <code>zeta%pi</code>.
751
<table><tr><td> </td><td><pre class="example">(%i1) map (zeta, [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]);
754
(%o1) [0, ---, 0, - --, - -, inf, ----, zeta(3), ----, zeta(5)]
756
</pre></td></tr></table>
760
<dt><u>Option variable:</u> <b>zeta%pi</b>
761
<a name="IDX1079"></a>
763
<dd><p>Default value: <code>true</code>
765
<p>When <code>zeta%pi</code> is <code>true</code>, <code>zeta</code> returns an expression
766
proportional to <code>%pi^n</code> for even integer <code>n</code>.
767
Otherwise, <code>zeta</code> returns a noun form <code>zeta (n)</code>
768
for even integer <code>n</code>.
770
<table><tr><td> </td><td><pre class="example">(%i1) zeta%pi: true$
776
(%i3) zeta%pi: false$
779
</pre></td></tr></table>
783
<table cellpadding="1" cellspacing="1" border="0">
784
<tr><td valign="middle" align="left">[<a href="#SEC128" title="Beginning of this chapter or previous chapter"> << </a>]</td>
785
<td valign="middle" align="left">[<a href="maxima_33.html#SEC130" title="Next chapter"> >> </a>]</td>
786
<td valign="middle" align="left"> </td>
787
<td valign="middle" align="left"> </td>
788
<td valign="middle" align="left"> </td>
789
<td valign="middle" align="left"> </td>
790
<td valign="middle" align="left"> </td>
791
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
792
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
793
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
794
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
798
This document was generated by <em>Robert Dodier</em> on <em>September, 20 2006</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.