File: maxima_32.html

package info (click to toggle)
maxima 5.10.0-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 44,268 kB
  • ctags: 17,987
  • sloc: lisp: 152,894; fortran: 14,667; perl: 14,204; tcl: 10,103; sh: 3,376; makefile: 2,202; ansic: 471; awk: 7
file content (804 lines) | stat: -rw-r--r-- 28,646 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on September, 20 2006 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Maxima Manual: 32. Number Theory</title>

<meta name="description" content="Maxima Manual: 32. Number Theory">
<meta name="keywords" content="Maxima Manual: 32. Number Theory">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
body
{
    color: black;
    background: white; 
    margin-left: 8%;
    margin-right: 13%;
}

h1
{
    margin-left: +8%;
    font-size: 150%;
    font-family: sans-serif
}

h2
{
    font-size: 125%;
    font-family: sans-serif
}

h3
{
    font-size: 100%;
    font-family: sans-serif
}

h2,h3,h4,h5,h6 { margin-left: +4%; }

div.textbox
{
    border: solid;
    border-width: thin;
    /* width: 100%; */
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em
}

div.titlebox
{
    border: none;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em;
    background: rgb(200,255,255);
    font-family: sans-serif
}

div.synopsisbox
{
    border: none;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em;
     background: rgb(255,220,255);
    /*background: rgb(200,255,255); */
    /* font-family: fixed */
}

pre.example
{
    border: none;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 1em;
    padding-right: 1em;
    background: rgb(247,242,180); /* kind of sandy */
    /* background: rgb(200,255,255); */ /* sky blue */
    font-family: "Lucida Console", monospace
}

div.spacerbox
{
    border: none;
    padding-top: 2em;
    padding-bottom: 2em
}

div.image
{
    margin: 0;
    padding: 1em;
    text-align: center;
}
-->
</style>

<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Number-Theory"></a>
<a name="SEC128"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="maxima_31.html#SEC127" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC129" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima_31.html#SEC125" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_33.html#SEC130" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 32. Number Theory </h1>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC129">32.1 Definitions for Number Theory</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">  
</td></tr>
</table>

<hr size="6">
<a name="Definitions-for-Number-Theory"></a>
<a name="SEC129"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC128" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima_33.html#SEC130" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC128" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC128" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_33.html#SEC130" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 32.1 Definitions for Number Theory </h2>

<dl>
<dt><u>Function:</u> <b>bern</b><i> (<var>n</var>)</i>
<a name="IDX1046"></a>
</dt>
<dd><p>Returns the <var>n</var>'th Bernoulli number for integer <var>n</var>.
Bernoulli numbers equal to zero are suppressed if <code>zerobern</code> is <code>false</code>.
</p>
<p>See also <code>burn</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) zerobern: true$
(%i2) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
                  1  1       1      1        1
(%o2)       [1, - -, -, 0, - --, 0, --, 0, - --]
                  2  6       30     42       30
(%i3) zerobern: false$
(%i4) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
            1  1    1   5     691   7    3617  43867
(%o4) [1, - -, -, - --, --, - ----, -, - ----, -----]
            2  6    30  66    2730  6    510    798
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>bernpoly</b><i> (<var>x</var>, <var>n</var>)</i>
<a name="IDX1047"></a>
</dt>
<dd><p>Returns the <var>n</var>'th Bernoulli polynomial in the
variable <var>x</var>.
</p>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>bfzeta</b><i> (<var>s</var>, <var>n</var>)</i>
<a name="IDX1048"></a>
</dt>
<dd><p>Returns the Riemann zeta function for the argument <var>s</var>.
The return value is a big float (bfloat);
<var>n</var> is the number of digits in the return value.
</p>
<p><code>load (&quot;bffac&quot;)</code> loads this function.
</p>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>bfhzeta</b><i> (<var>s</var>, <var>h</var>, <var>n</var>)</i>
<a name="IDX1049"></a>
</dt>
<dd><p>Returns the Hurwitz zeta function for the arguments <var>s</var> and <var>h</var>.
The return value is a big float (bfloat);
<var>n</var> is the number of digits in the return value.
</p>
<p>The Hurwitz zeta function is defined as
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">sum ((k+h)^-s, k, 0, inf)
</pre></td></tr></table>
<p><code>load (&quot;bffac&quot;)</code> loads this function.
</p>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>binomial</b><i> (<var>x</var>, <var>y</var>)</i>
<a name="IDX1050"></a>
</dt>
<dd><p>The binomial coefficient <code><var>x</var>!/(<var>y</var>! (<var>x</var> - <var>y</var>)!)</code>.
If <var>x</var> and <var>y</var> are integers, then the numerical value of the binomial
coefficient is computed.
If <var>y</var>, or <var>x - y</var>, is an integer,
the binomial coefficient is expressed as a polynomial.
</p>
<p>Examples:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) binomial (11, 7);
(%o1)                          330
(%i2) 11! / 7! / (11 - 7)!;
(%o2)                          330
(%i3) binomial (x, 7);
        (x - 6) (x - 5) (x - 4) (x - 3) (x - 2) (x - 1) x
(%o3)   -------------------------------------------------
                              5040
(%i4) binomial (x + 7, x);
      (x + 1) (x + 2) (x + 3) (x + 4) (x + 5) (x + 6) (x + 7)
(%o4) -------------------------------------------------------
                               5040
(%i5) binomial (11, y);
(%o5)                    binomial(11, y)
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>burn</b><i> (<var>n</var>)</i>
<a name="IDX1051"></a>
</dt>
<dd><p>Returns the <var>n</var>'th Bernoulli number for integer <var>n</var>.
<code>burn</code> may be more efficient than <code>bern</code> for large, isolated <var>n</var>
(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.
</p>

<p><code>burn</code> exploits the observation that (rational) Bernoulli numbers can be
approximated by (transcendental) zetas with tolerable efficiency.
</p>
<p><code>load (&quot;bffac&quot;)</code> loads this function.
</p>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>cf</b><i> (<var>expr</var>)</i>
<a name="IDX1052"></a>
</dt>
<dd><p>Converts <var>expr</var> into a continued fraction.
<var>expr</var> is an expression
comprising continued fractions and square roots of integers.
Operands in the expression may be combined with arithmetic operators.
Aside from continued fractions and square roots,
factors in the expression must be integer or rational numbers.
Maxima does not know about operations on continued fractions outside of <code>cf</code>.
</p>
<p><code>cf</code> evaluates its arguments after binding <code>listarith</code> to <code>false</code>.
<code>cf</code> returns a continued fraction, represented as a list.
</p>
<p>A continued fraction <code>a + 1/(b + 1/(c + ...))</code>
is represented by the list <code>[a, b, c, ...]</code>.
The list elements <code>a</code>, <code>b</code>, <code>c</code>, ... must evaluate to integers.
<var>expr</var> may also contain <code>sqrt (n)</code> where <code>n</code> is an integer.
In this case <code>cf</code> will give as many
terms of the continued fraction as the value of the variable
<code>cflength</code> times the period.
</p>
<p>A continued fraction can be evaluated to a number
by evaluating the arithmetic representation
returned by <code>cfdisrep</code>.
See also <code>cfexpand</code> for another way to evaluate a continued fraction.
</p>
<p>See also <code>cfdisrep</code>, <code>cfexpand</code>, and <code>cflength</code>.
</p>
<p>Examples:
</p>
<ul>
<li>
<var>expr</var> is an expression comprising continued fractions and square roots of integers.

<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) cf ([5, 3, 1]*[11, 9, 7] + [3, 7]/[4, 3, 2]);
(%o1)               [59, 17, 2, 1, 1, 1, 27]
(%i2) cf ((3/17)*[1, -2, 5]/sqrt(11) + (8/13));
(%o2)        [0, 1, 1, 1, 3, 2, 1, 4, 1, 9, 1, 9, 2]
</pre></td></tr></table>
</li><li>
<code>cflength</code> controls how many periods of the continued fraction
are computed for algebraic, irrational numbers.

<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) cflength: 1$
(%i2) cf ((1 + sqrt(5))/2);
(%o2)                    [1, 1, 1, 1, 2]
(%i3) cflength: 2$
(%i4) cf ((1 + sqrt(5))/2);
(%o4)               [1, 1, 1, 1, 1, 1, 1, 2]
(%i5) cflength: 3$
(%i6) cf ((1 + sqrt(5))/2);
(%o6)           [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
</pre></td></tr></table>
</li><li>
A continued fraction can be evaluated by evaluating the arithmetic representation
returned by <code>cfdisrep</code>.

<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) cflength: 3$
(%i2) cfdisrep (cf (sqrt (3)))$
(%i3) ev (%, numer);
(%o3)                   1.731707317073171
</pre></td></tr></table>
</li><li>
Maxima does not know about operations on continued fractions outside of <code>cf</code>.

<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) cf ([1,1,1,1,1,2] * 3);
(%o1)                     [4, 1, 5, 2]
(%i2) cf ([1,1,1,1,1,2]) * 3;
(%o2)                  [3, 3, 3, 3, 3, 6]
</pre></td></tr></table>
</li></ul>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>cfdisrep</b><i> (<var>list</var>)</i>
<a name="IDX1053"></a>
</dt>
<dd><p>Constructs and returns an ordinary arithmetic expression
of the form <code>a + 1/(b + 1/(c + ...))</code>
from the list representation of a continued fraction <code>[a, b, c, ...]</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) cf ([1, 2, -3] + [1, -2, 1]);
(%o1)                     [1, 1, 1, 2]
(%i2) cfdisrep (%);
                                  1
(%o2)                     1 + ---------
                                    1
                              1 + -----
                                      1
                                  1 + -
                                      2
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>cfexpand</b><i> (<var>x</var>)</i>
<a name="IDX1054"></a>
</dt>
<dd><p>Returns a matrix of the numerators and denominators of the
last (column 1) and next-to-last (column 2) convergents of the continued fraction <var>x</var>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) cf (rat (ev (%pi, numer)));

`rat' replaced 3.141592653589793 by 103993//33102 = 3.141592653011902
(%o1)                  [3, 7, 15, 1, 292]
(%i2) cfexpand (%); 
                         [ 103993  355 ]
(%o2)                    [             ]
                         [ 33102   113 ]
(%i3) %[1,1]/%[2,1], numer;
(%o3)                   3.141592653011902
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Option variable:</u> <b>cflength</b>
<a name="IDX1055"></a>
</dt>
<dd><p>Default value: 1
</p>
<p><code>cflength</code> controls the number of terms of the continued
fraction the function <code>cf</code> will give, as the value <code>cflength</code> times the
period.  Thus the default is to give one period.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) cflength: 1$
(%i2) cf ((1 + sqrt(5))/2);
(%o2)                    [1, 1, 1, 1, 2]
(%i3) cflength: 2$
(%i4) cf ((1 + sqrt(5))/2);
(%o4)               [1, 1, 1, 1, 1, 1, 1, 2]
(%i5) cflength: 3$
(%i6) cf ((1 + sqrt(5))/2);
(%o6)           [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>divsum</b><i> (<var>n</var>, <var>k</var>)</i>
<a name="IDX1056"></a>
</dt>
<dt><u>Function:</u> <b>divsum</b><i> (<var>n</var>)</i>
<a name="IDX1057"></a>
</dt>
<dd><p><code>divsum (<var>n</var>, <var>k</var>)</code> returns the sum of the divisors of <var>n</var>
raised to the <var>k</var>'th power.
</p>
<p><code>divsum (<var>n</var>)</code> returns the sum of the divisors of <var>n</var>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) divsum (12);
(%o1)                          28
(%i2) 1 + 2 + 3 + 4 + 6 + 12;
(%o2)                          28
(%i3) divsum (12, 2);
(%o3)                          210
(%i4) 1^2 + 2^2 + 3^2 + 4^2 + 6^2 + 12^2;
(%o4)                          210
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>euler</b><i> (<var>n</var>)</i>
<a name="IDX1058"></a>
</dt>
<dd><p>Returns the <var>n</var>'th Euler number for nonnegative integer <var>n</var>.
</p>
<p>For the Euler-Mascheroni constant, see <code>%gamma</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) map (euler, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(%o1)    [1, 0, - 1, 0, 5, 0, - 61, 0, 1385, 0, - 50521]
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Constant:</u> <b>%gamma</b>
<a name="IDX1059"></a>
</dt>
<dd><p>The Euler-Mascheroni constant, 0.5772156649015329 ....
</p>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>factorial</b><i> (<var>x</var>)</i>
<a name="IDX1060"></a>
</dt>
<dd><p>Represents the factorial function. Maxima treats <code>factorial (<var>x</var>)</code> the same as <code><var>x</var>!</code>.
See <code>!</code>.
</p>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>fib</b><i> (<var>n</var>)</i>
<a name="IDX1061"></a>
</dt>
<dd><p>Returns the <var>n</var>'th Fibonacci number.
<code>fib(0)</code> equal to 0 and <code>fib(1)</code> equal to 1,
and
<code>fib (-<var>n</var>)</code> equal to <code>(-1)^(<var>n</var> + 1) * fib(<var>n</var>)</code>.
</p>
<p>After calling <code>fib</code>,
<code>prevfib</code> is equal to <code>fib (<var>x</var> - 1)</code>,
the Fibonacci number preceding the last one computed.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) map (fib, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(%o1)         [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>fibtophi</b><i> (<var>expr</var>)</i>
<a name="IDX1062"></a>
</dt>
<dd><p>Expresses Fibonacci numbers in terms of the constant <code>%phi</code>,
which is <code>(1 + sqrt(5))/2</code>, approximately 1.61803399.
</p>
<p>By default, Maxima does not know about <code>%phi</code>.
After executing <code>tellrat (%phi^2 - %phi - 1)</code> and <code>algebraic: true</code>,
<code>ratsimp</code> can simplify some expressions containing <code>%phi</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) fibtophi (fib (n));
                           n             n
                       %phi  - (1 - %phi)
(%o1)                  -------------------
                           2 %phi - 1
(%i2) fib (n-1) + fib (n) - fib (n+1);
(%o2)          - fib(n + 1) + fib(n) + fib(n - 1)
(%i3) ratsimp (fibtophi (%));
(%o3)                           0
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>ifactors</b><i> (<var>n</var>)</i>
<a name="IDX1063"></a>
</dt>
<dd><p>For a positive integer <var>n</var> returns the factorization of <var>n</var>. If
<code>n=p1^e1..pk^nk</code> is the decomposition of <var>n</var> into prime
factors, ifactors returns <code>[[p1, e1], ... , [pk, ek]]</code>.
</p>
<p>Factorization methods used are trial divisions by primes up to 9973,
Pollard's rho method and elliptic curve method.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) ifactors(51575319651600);
(%o1)     [[2, 4], [3, 2], [5, 2], [1583, 1], [9050207, 1]]
(%i2) apply(&quot;*&quot;, map(lambda([u], u[1]^u[2]), %));
(%o2)                        51575319651600
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>inrt</b><i> (<var>x</var>, <var>n</var>)</i>
<a name="IDX1064"></a>
</dt>
<dd><p>Returns the integer <var>n</var>'th root of the absolute value of <var>x</var>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]$
(%i2) map (lambda ([a], inrt (10^a, 3)), l);
(%o2) [2, 4, 10, 21, 46, 100, 215, 464, 1000, 2154, 4641, 10000]
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>inv_mod</b><i> (<var>n</var>, <var>m</var>)</i>
<a name="IDX1065"></a>
</dt>
<dd><p>Computes the inverse of <var>n</var> modulo <var>m</var>. 
<code>inv_mod (n,m)</code> returns <code>false</code>, 
if <var>n</var> is a zero divisor modulo <var>m</var>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) inv_mod(3, 41);
(%o1)                           14
(%i2) ratsimp(3^-1), modulus=41;
(%o2)                           14
(%i3) inv_mod(3, 42);
(%o3)                          false
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>jacobi</b><i> (<var>p</var>, <var>q</var>)</i>
<a name="IDX1066"></a>
</dt>
<dd><p>Returns the Jacobi symbol of <var>p</var> and <var>q</var>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]$
(%i2) map (lambda ([a], jacobi (a, 9)), l);
(%o2)         [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>lcm</b><i> (<var>expr_1</var>, ..., <var>expr_n</var>)</i>
<a name="IDX1067"></a>
</dt>
<dd><p>Returns the least common multiple of its arguments.
The arguments may be general expressions as well as integers.
</p>
<p><code>load (&quot;functs&quot;)</code> loads this function.
</p>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>minfactorial</b><i> (<var>expr</var>)</i>
<a name="IDX1068"></a>
</dt>
<dd><p>Examines <var>expr</var> for occurrences of two factorials
which differ by an integer.
<code>minfactorial</code> then turns one into a polynomial times the other.
</p>

<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) n!/(n+2)!;
                               n!
(%o1)                       --------
                            (n + 2)!
(%i2) minfactorial (%);
                                1
(%o2)                    ---------------
                         (n + 1) (n + 2)
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>power_mod</b><i> (<var>a</var>, <var>n</var>, <var>m</var>)</i>
<a name="IDX1069"></a>
</dt>
<dd><p>Uses a modular algorithm to compute <code>a^n mod m</code> 
where <var>a</var> and <var>n</var> are integers and <var>m</var> is a positive integer. 
If <var>n</var> is negative, <code>inv_mod</code> is used to find the modular inverse.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) power_mod(3, 15, 5);
(%o1)                          2
(%i2) mod(3^15,5);
(%o2)                          2
(%i3) power_mod(2, -1, 5);
(%o3)                          3
(%i4) inv_mod(2,5);
(%o4)                          3
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>next_prime</b><i> (<var>n</var>)</i>
<a name="IDX1070"></a>
</dt>
<dd><p>Returns the smallest prime bigger than <var>n</var>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) next_prime(27);
(%o1)                       29
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>partfrac</b><i> (<var>expr</var>, <var>var</var>)</i>
<a name="IDX1071"></a>
</dt>
<dd><p>Expands the expression <var>expr</var> in partial fractions
with respect to the main variable <var>var</var>.  <code>partfrac</code> does a complete
partial fraction decomposition.  The algorithm employed is based on
the fact that the denominators of the partial fraction expansion (the
factors of the original denominator) are relatively prime.  The
numerators can be written as linear combinations of denominators, and
the expansion falls out.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) 1/(1+x)^2 - 2/(1+x) + 2/(2+x);
                      2       2        1
(%o1)               ----- - ----- + --------
                    x + 2   x + 1          2
                                    (x + 1)
(%i2) ratsimp (%);
                                 x
(%o2)                 - -------------------
                         3      2
                        x  + 4 x  + 5 x + 2
(%i3) partfrac (%, x);
                      2       2        1
(%o3)               ----- - ----- + --------
                    x + 2   x + 1          2
                                    (x + 1)
</pre></td></tr></table></dd></dl>

<dl>
<dt><u>Function:</u> <b>primep</b><i> (<var>n</var>)</i>
<a name="IDX1072"></a>
</dt>
<dd><p>Primality test. If <code>primep (n)</code> returns <code>false</code>, <var>n</var> is a
composite number and if it returns <code>true</code>, <var>n</var> is a prime number
with very high probability.
</p>
<p>For <var>n</var> less than 341550071728321 a deterministic version of Miller-Rabin's
test is used. If <code>primep (n)</code> returns <code>true</code>, then <var>n</var> is a
prime number.
</p>
<p>For <var>n</var> bigger than 34155071728321 <code>primep</code> uses
<code>primep_number_of_tests</code> Miller-Rabin's pseudo-primality tests
and one Lucas pseudo-primality test. The probability that <var>n</var> will
pass one Miller-Rabin test is less than 1/4. Using the default value 25 for
<code>primep_number_of_tests</code>, the probability of <var>n</var> beeing
composite is much smaller that 10^-15.
</p>
</dd></dl>

<dl>
<dt><u>Option variable:</u> <b>primep_number_of_tests</b>
<a name="IDX1073"></a>
</dt>
<dd><p>Default value: 25
</p>
<p>Number of Miller-Rabin's tests used in <code>primep</code>.
</p></dd></dl>

<dl>
<dt><u>Function:</u> <b>prev_prime</b><i> (<var>n</var>)</i>
<a name="IDX1074"></a>
</dt>
<dd><p>Returns the greatest prime smaller than <var>n</var>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) prev_prime(27);
(%o1)                       23
</pre></td></tr></table></dd></dl>

<dl>
<dt><u>Function:</u> <b>qunit</b><i> (<var>n</var>)</i>
<a name="IDX1075"></a>
</dt>
<dd><p>Returns the principal unit of the real quadratic number field
<code>sqrt (<var>n</var>)</code> where <var>n</var> is an integer,
i.e., the element whose norm is unity.
This amounts to solving Pell's equation <code>a^2 - <var>n</var> b^2 = 1</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) qunit (17);
(%o1)                     sqrt(17) + 4
(%i2) expand (% * (sqrt(17) - 4));
(%o2)                           1
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>totient</b><i> (<var>n</var>)</i>
<a name="IDX1076"></a>
</dt>
<dd><p>Returns the number of integers less than or equal to <var>n</var> which
are relatively prime to <var>n</var>.
</p>
</dd></dl>

<dl>
<dt><u>Option variable:</u> <b>zerobern</b>
<a name="IDX1077"></a>
</dt>
<dd><p>Default value: <code>true</code>
</p>
<p>When <code>zerobern</code> is <code>false</code>,
<code>bern</code> excludes the Bernoulli numbers which are equal to zero. 
See <code>bern</code>.
</p>
</dd></dl>

<dl>
<dt><u>Function:</u> <b>zeta</b><i> (<var>n</var>)</i>
<a name="IDX1078"></a>
</dt>
<dd><p>Returns the Riemann zeta function if <var>x</var> is a negative integer, 0, 1,
or a positive even number,
and returns a noun form <code>zeta (<var>n</var>)</code> for all other arguments,
including rational noninteger, floating point, and complex arguments.
</p>
<p>See also <code>bfzeta</code> and <code>zeta%pi</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) map (zeta, [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]);
                                     2              4
           1        1     1       %pi            %pi
(%o1) [0, ---, 0, - --, - -, inf, ----, zeta(3), ----, zeta(5)]
          120       12    2        6              90
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><u>Option variable:</u> <b>zeta%pi</b>
<a name="IDX1079"></a>
</dt>
<dd><p>Default value: <code>true</code>
</p>
<p>When <code>zeta%pi</code> is <code>true</code>, <code>zeta</code> returns an expression
proportional to <code>%pi^n</code> for even integer <code>n</code>.
Otherwise, <code>zeta</code> returns a noun form <code>zeta (n)</code>
for even integer <code>n</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) zeta%pi: true$
(%i2) zeta (4);
                                 4
                              %pi
(%o2)                         ----
                               90
(%i3) zeta%pi: false$
(%i4) zeta (4);
(%o4)                        zeta(4)
</pre></td></tr></table>
</dd></dl>

<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC128" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima_33.html#SEC130" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  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>.
 </font>
 <br>

</p>
</body>
</html>