~ubuntu-branches/debian/squeeze/maxima/squeeze

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
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on April, 24 2010 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 5.21.1 Manual: 38. Sets</title>

<meta name="description" content="Maxima 5.21.1 Manual: 38. Sets">
<meta name="keywords" content="Maxima 5.21.1 Manual: 38. Sets">
<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: 1px solid gray;
    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 */
    background-color: #F1F5F9; /* light blue-gray */
    /* font-family: "Lucida Console", monospace */
}

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

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

div.categorybox
{
    border: 1px solid gray;
    padding-top: 0px;
    padding-bottom: 0px;
    padding-left: 1em;
    padding-right: 1em;
    background: rgb(247,242,220);
}


-->
</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="Sets"></a>
<a name="SEC166"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="maxima_37.html#SEC165" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima_37.html#SEC163" 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_39.html#SEC173" 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_79.html#SEC331" 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"> 38. Sets </h1>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC167">38.1 Introduction to Sets</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">       
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC172">38.2 Functions and Variables for Sets</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">       
</td></tr>
</table>

<p><a name="Item_003a-Introduction-to-Sets"></a>
</p><hr size="6">
<a name="Introduction-to-Sets"></a>
<a name="SEC167"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC166" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC168" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC166" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC166" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_39.html#SEC173" 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_79.html#SEC331" 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"> 38.1 Introduction to Sets </h2>

<p>Maxima provides set functions, such as intersection and 
union, for finite sets that are defined by explicit enumeration.
Maxima treats 
lists and sets as distinct objects. This feature makes it possible to
work with sets that have members that are either lists or sets.
</p>
<p>In addition to functions for finite sets, Maxima provides some
functions related to combinatorics; these include the Stirling
numbers of the first and second kind, the Bell numbers, multinomial
coefficients, partitions of nonnegative integers, and a few others. 
Maxima also defines a Kronecker delta function.
</p>
<hr size="6">
<a name="SEC168"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC167" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC169" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC166" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_39.html#SEC173" 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_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 38.1.1 Usage </h3>

<p>To construct a set with members <code>a_1, ..., a_n</code>, write
<code>set(a_1, ..., a_n)</code> or <code>{a_1, ..., a_n}</code>;
to construct the empty set, write <code>set()</code> or <code>{}</code>.
In input, <code>set(...)</code> and <code>{ ... }</code> are equivalent.
Sets are always displayed with curly braces.
</p>
<p>If a member is listed more than
once, simplification eliminates the redundant member.
</p>
<pre class="example">(%i1) set();
(%o1)                          {}
(%i2) set(a, b, a);
(%o2)                        {a, b}
(%i3) set(a, set(b));
(%o3)                       {a, {b}}
(%i4) set(a, [b]);
(%o4)                       {a, [b]}
(%i5) {};
(%o5)                          {}
(%i6) {a, b, a};
(%o6)                        {a, b}
(%i7) {a, {b}};
(%o7)                       {a, {b}}
(%i8) {a, [b]};
(%o8)                       {a, [b]}
</pre>
<p>Two would-be elements <var>x</var> and <var>y</var> are redundant
(i.e., considered the same for the purpose of set construction)
if and only if <code>is(<var>x</var> = <var>y</var>)</code> yields <code>true</code>.
Note that <code>is(equal(<var>x</var>, <var>y</var>))</code> can yield <code>true</code>
while <code>is(<var>x</var> = <var>y</var>)</code> yields <code>false</code>;
in that case the elements <var>x</var> and <var>y</var> are considered distinct.
</p>
<pre class="example">(%i1) x: a/c + b/c;
                              b   a
(%o1)                         - + -
                              c   c
(%i2) y: a/c + b/c;
                              b   a
(%o2)                         - + -
                              c   c
(%i3) z: (a + b)/c;
                              b + a
(%o3)                         -----
                                c
(%i4) is (x = y);
(%o4)                         true
(%i5) is (y = z);
(%o5)                         false
(%i6) is (equal (y, z));
(%o6)                         true
(%i7) y - z;
                           b + a   b   a
(%o7)                    - ----- + - + -
                             c     c   c
(%i8) ratsimp (%);
(%o8)                           0
(%i9) {x, y, z};
                          b + a  b   a
(%o9)                    {-----, - + -}
                            c    c   c
</pre>
<p>To construct a set from the elements of a list, use <code>setify</code>.
</p>
<pre class="example">(%i1) setify ([b, a]);
(%o1)                        {a, b}
</pre>
<p>Set members <code>x</code> and <code>y</code> are equal provided <code>is(x = y)</code> 
evaluates to <code>true</code>. Thus <code>rat(x)</code> and <code>x</code> are equal as set
members; consequently, 
</p>
<pre class="example">(%i1) {x, rat(x)};
(%o1)                          {x}
</pre>
<p>Further, since <code>is((x - 1)*(x + 1) = x^2 - 1)</code> evaluates to <code>false</code>, 
<code>(x - 1)*(x + 1)</code> and <code>x^2 - 1</code> are distinct set members; thus 
</p>
<pre class="example">(%i1) {(x - 1)*(x + 1), x^2 - 1};
                                       2
(%o1)               {(x - 1) (x + 1), x  - 1}
</pre>
<p>To reduce this set to a singleton set, apply <code>rat</code> to each set member:
</p>
<pre class="example">(%i1) {(x - 1)*(x + 1), x^2 - 1};
                                       2
(%o1)               {(x - 1) (x + 1), x  - 1}
(%i2) map (rat, %);
                              2
(%o2)/R/                    {x  - 1}
</pre>
<p>To remove redundancies from other sets, you may need to use other
simplification functions. Here is an example that uses <code>trigsimp</code>:
</p>
<pre class="example">(%i1) {1, cos(x)^2 + sin(x)^2};
                            2         2
(%o1)                {1, sin (x) + cos (x)}
(%i2) map (trigsimp, %);
(%o2)                          {1}
</pre>
<p>A set is simplified when its members are non-redundant and
sorted. The current version of the set functions uses the Maxima function
<code>orderlessp</code> to order sets; however, <i>future versions of 
the set functions might use a different ordering function</i>.
</p>
<p>Some operations on sets, such as substitution, automatically force a 
re-simplification; for example,
</p>
<pre class="example">(%i1) s: {a, b, c}$
(%i2) subst (c=a, s);
(%o2)                        {a, b}
(%i3) subst ([a=x, b=x, c=x], s);
(%o3)                          {x}
(%i4) map (lambda ([x], x^2), set (-1, 0, 1));
(%o4)                        {0, 1}
</pre>
<p>Maxima treats lists and sets as distinct objects;
functions such as <code>union</code> and <code>intersection</code> complain
if any argument is not a set. If you need to apply a set
function to a list, use the <code>setify</code> function to convert it
to a set. Thus
</p>
<pre class="example">(%i1) union ([1, 2], {a, b});
Function union expects a set, instead found [1,2]
 -- an error.  Quitting.  To debug this try debugmode(true);
(%i2) union (setify ([1, 2]), {a, b});
(%o2)                     {1, 2, a, b}
</pre>
<p>To extract all set elements of a set <code>s</code> that satisfy a predicate
<code>f</code>, use <code>subset(s, f)</code>. (A <i>predicate</i> is a 
boolean-valued function.) For example, to find the equations 
in a given set that do not depend on a variable <code>z</code>, use
</p>
<pre class="example">(%i1) subset ({x + y + z, x - y + 4, x + y - 5},
                                    lambda ([e], freeof (z, e)));
(%o1)               {- y + x + 4, y + x - 5}
</pre>
<p>The section <a href="#SEC172">Functions and Variables for Sets</a> has a complete list of
the set functions in Maxima.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


<hr size="6">
<a name="SEC169"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC168" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC170" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC166" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_39.html#SEC173" 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_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 38.1.2 Set Member Iteration </h3>

<p>There two ways to to iterate over set members. One way is the use
<code>map</code>; for example:
</p>
<pre class="example">(%i1) map (f, {a, b, c});
(%o1)                  {f(a), f(b), f(c)}
</pre>
<p>The other way is to use <code>for <var>x</var> in <var>s</var> do</code>
</p>
<pre class="example">(%i1) s: {a, b, c};
(%o1)                       {a, b, c}
(%i2) for si in s do print (concat (si, 1));
a1 
b1 
c1 
(%o2)                         done
</pre>
<p>The Maxima functions <code>first</code> and <code>rest</code> work
correctly on sets. Applied to a set, <code>first</code> returns the first
displayed element of a set; which element that is may be
implementation-dependent. If <code>s</code> is a set, then 
<code>rest(s)</code> is equivalent to <code>disjoin(first(s), s)</code>.
Currently, there are other Maxima functions that work correctly
on sets.
In future versions of the set functions,
<code>first</code> and <code>rest</code> may function differently or not at all.
</p>
<hr size="6">
<a name="SEC170"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC169" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC171" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC166" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_39.html#SEC173" 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_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 38.1.3 Bugs </h3>

<p>The set functions use the Maxima function <code>orderlessp</code> to 
order set members and the (Lisp-level) function <code>like</code> to test for set
member equality. Both of these functions have known bugs
that may manifest if you attempt to use
sets with members that are lists or matrices that contain expressions
in canonical rational expression (CRE) form. An example is
</p>
<pre class="example">(%i1) {[x], [rat (x)]};
Maxima encountered a Lisp error:

  The value #:X1440 is not of type LIST.

Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
</pre>
<p>This expression causes Maxima to halt with an error (the error message
depends on which version of Lisp your Maxima uses). Another
example is
</p>
<pre class="example">(%i1) setify ([[rat(a)], [rat(b)]]);
Maxima encountered a Lisp error:

  The value #:A1440 is not of type LIST.

Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
</pre>
<p>These bugs are caused by bugs in <code>orderlessp</code> and <code>like</code>; they
are not caused by bugs in the set functions. To illustrate, try the expressions
</p>
<pre class="example">(%i1) orderlessp ([rat(a)], [rat(b)]);
Maxima encountered a Lisp error:

  The value #:B1441 is not of type LIST.

Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i2) is ([rat(a)] = [rat(a)]);
(%o2)                         false
</pre>
<p>Until these bugs are fixed, do not construct sets with members that
are lists or matrices containing expressions in CRE form; a set with a 
member in CRE form, however, shouldn't be a problem:
</p>
<pre class="example">(%i1) {x, rat (x)};
(%o1)                          {x}
</pre>
<p>Maxima's <code>orderlessp</code> has another bug that can cause problems
with set functions, namely that the ordering predicate <code>orderlessp</code> is
not transitive. The simplest known example that shows this is
</p>
<pre class="example">(%i1) q: x^2$
(%i2) r: (x + 1)^2$
(%i3) s: x*(x + 2)$
(%i4) orderlessp (q, r);
(%o4)                         true
(%i5) orderlessp (r, s);
(%o5)                         true
(%i6) orderlessp (q, s);
(%o6)                         false
</pre>
<p>This bug can cause trouble with all set functions as well as with
Maxima functions in general. It is probable, but not certain, that 
this bug can be avoided
if all set members are either in CRE form or have been simplified
using <code>ratsimp</code>.
</p>
<p>Maxima's <code>orderless</code> and <code>ordergreat</code> mechanisms are 
incompatible with the set functions. If you need to use either <code>orderless</code>
or <code>ordergreat</code>, call those functions before constructing any sets,
and do not call <code>unorder</code>. 
</p>

<p>If you find something that you think might be a set function bug, please 
report it to the Maxima bug database. See <code>bug_report</code>.
</p>
<hr size="6">
<a name="SEC171"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC170" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC172" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC166" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_39.html#SEC173" 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_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 38.1.4 Authors </h3>

<p>Stavros Macrakis of Cambridge, Massachusetts and Barton Willis of the
University of Nebraska at Kearney (UNK) wrote the Maxima set functions and their
documentation. 
</p>
<p><a name="Item_003a-Functions-and-Variables-for-Sets"></a>
</p><hr size="6">
<a name="Functions-and-Variables-for-Sets"></a>
<a name="SEC172"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC171" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima_39.html#SEC173" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC166" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC166" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_39.html#SEC173" 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_79.html#SEC331" 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"> 38.2 Functions and Variables for Sets </h2>

<p><a name="adjoin"></a>
<a name="Item_003a-adjoin"></a>
</p><dl>
<dt><u>Function:</u> <b>adjoin</b><i> (<var>x</var>, <var>a</var>) </i>
<a name="IDX1335"></a>
</dt>
<dd><p>Returns the union of the set <var>a</var> with <code>{<var>x</var>}</code>.
</p>
<p><code>adjoin</code> complains if <var>a</var> is not a literal set.
</p>
<p><code>adjoin(<var>x</var>, <var>a</var>)</code> and <code>union(set(<var>x</var>), <var>a</var>)</code>
are equivalent;
however, <code>adjoin</code> may be somewhat faster than <code>union</code>.
</p>
<p>See also <code>disjoin</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) adjoin (c, {a, b});
(%o1)                       {a, b, c}
(%i2) adjoin (a, {a, b});
(%o2)                        {a, b}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="belln"></a>
<a name="Item_003a-belln"></a>
</p><dl>
<dt><u>Function:</u> <b>belln</b><i> (<var>n</var>)</i>
<a name="IDX1336"></a>
</dt>
<dd><p>Represents the <em>n</em>-th Bell number.
<code>belln(n)</code> is the number of partitions of a set with <var>n</var> members.
</p>
<p>For nonnegative integers <var>n</var>,
<code>belln(<var>n</var>)</code> simplifies to the <em>n</em>-th Bell number.
<code>belln</code> does not simplify for any other arguments.
</p>
<p><code>belln</code> distributes over equations, lists, matrices, and sets.
</p>
<p>Examples:
</p>
<p><code>belln</code> applied to nonnegative integers.
</p>
<pre class="example">(%i1) makelist (belln (i), i, 0, 6);
(%o1)               [1, 1, 2, 5, 15, 52, 203]
(%i2) is (cardinality (set_partitions ({})) = belln (0));
(%o2)                         true
(%i3) is (cardinality (set_partitions ({1, 2, 3, 4, 5, 6})) =
                       belln (6));
(%o3)                         true
</pre>
<p><code>belln</code> applied to arguments which are not nonnegative integers.
</p>
<pre class="example">(%i1) [belln (x), belln (sqrt(3)), belln (-9)];
(%o1)        [belln(x), belln(sqrt(3)), belln(- 9)]
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="cardinality"></a>
<a name="Item_003a-cardinality"></a>
</p><dl>
<dt><u>Function:</u> <b>cardinality</b><i> (<var>a</var>)</i>
<a name="IDX1337"></a>
</dt>
<dd><p>Returns the number of distinct elements of the set <var>a</var>. 
</p>
<p><code>cardinality</code> ignores redundant elements
even when simplification is disabled.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) cardinality ({});
(%o1)                           0
(%i2) cardinality ({a, a, b, c});
(%o2)                           3
(%i3) simp : false;
(%o3)                         false
(%i4) cardinality ({a, a, b, c});
(%o4)                           3
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="cartesian_005fproduct"></a>
<a name="Item_003a-cartesian_005fproduct"></a>
</p><dl>
<dt><u>Function:</u> <b>cartesian_product</b><i> (<var>b_1</var>, ... , <var>b_n</var>)</i>
<a name="IDX1338"></a>
</dt>
<dd><p>Returns a set of lists of the form <code>[<var>x_1</var>, ..., <var>x_n</var>]</code>, where
<var>x_1</var>, ..., <var>x_n</var> are elements of the sets <var>b_1</var>, ... , <var>b_n</var>,
respectively.
</p>
<p><code>cartesian_product</code> complains if any argument is not a literal set.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) cartesian_product ({0, 1});
(%o1)                      {[0], [1]}
(%i2) cartesian_product ({0, 1}, {0, 1});
(%o2)           {[0, 0], [0, 1], [1, 0], [1, 1]}
(%i3) cartesian_product ({x}, {y}, {z});
(%o3)                      {[x, y, z]}
(%i4) cartesian_product ({x}, {-1, 0, 1});
(%o4)              {[x, - 1], [x, 0], [x, 1]}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>


<p><a name="disjoin"></a>
<a name="Item_003a-disjoin"></a>
</p><dl>
<dt><u>Function:</u> <b>disjoin</b><i> (<var>x</var>, <var>a</var>)</i>
<a name="IDX1339"></a>
</dt>
<dd><p>Returns the set <var>a</var> without the member <var>x</var>.
If <var>x</var> is not a member of <var>a</var>, return <var>a</var> unchanged.
</p>
<p><code>disjoin</code> complains if <var>a</var> is not a literal set.
</p>
<p><code>disjoin(<var>x</var>, <var>a</var>)</code>, <code>delete(<var>x</var>, <var>a</var>)</code>, and
<code>setdifference(<var>a</var>, set(<var>x</var>))</code> are all equivalent. 
Of these, <code>disjoin</code> is generally faster than the others.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) disjoin (a, {a, b, c, d});
(%o1)                       {b, c, d}
(%i2) disjoin (a + b, {5, z, a + b, %pi});
(%o2)                      {5, %pi, z}
(%i3) disjoin (a - b, {5, z, a + b, %pi});
(%o3)                  {5, %pi, b + a, z}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="disjointp"></a>
<a name="Item_003a-disjointp"></a>
</p><dl>
<dt><u>Function:</u> <b>disjointp</b><i> (<var>a</var>, <var>b</var>) </i>
<a name="IDX1340"></a>
</dt>
<dd><p>Returns <code>true</code> if and only if the sets <var>a</var> and <var>b</var> are disjoint.
</p>
<p><code>disjointp</code> complains if either <var>a</var> or <var>b</var> is not a literal set.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) disjointp ({a, b, c}, {1, 2, 3});
(%o1)                         true
(%i2) disjointp ({a, b, 3}, {1, 2, 3});
(%o2)                         false
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>


</dd></dl>

<p><a name="divisors"></a>
<a name="Item_003a-divisors"></a>
</p><dl>
<dt><u>Function:</u> <b>divisors</b><i> (<var>n</var>)</i>
<a name="IDX1341"></a>
</dt>
<dd><p>Represents the set of divisors of <var>n</var>.
</p>
<p><code>divisors(<var>n</var>)</code> simplifies to a set of integers
when <var>n</var> is a nonzero integer.
The set of divisors includes the members 1 and <var>n</var>.
The divisors of a negative integer are the divisors of its absolute value.
</p>
<p><code>divisors</code> distributes over equations, lists, matrices, and sets.
</p>
<p>Examples:
</p>
<p>We can verify that 28 is a perfect number:
the sum of its divisors (except for itself) is 28.
</p>
<pre class="example">(%i1) s: divisors(28);
(%o1)                 {1, 2, 4, 7, 14, 28}
(%i2) lreduce (&quot;+&quot;, args(s)) - 28;
(%o2)                          28
</pre>
<p><code>divisors</code> is a simplifying function.
Substituting 8 for <code>a</code> in <code>divisors(a)</code>
yields the divisors without reevaluating <code>divisors(8)</code>.
</p>
<pre class="example">(%i1) divisors (a);
(%o1)                      divisors(a)
(%i2) subst (8, a, %);
(%o2)                     {1, 2, 4, 8}
</pre>
<p><code>divisors</code> distributes over equations, lists, matrices, and sets.
</p>
<pre class="example">(%i1) divisors (a = b);
(%o1)               divisors(a) = divisors(b)
(%i2) divisors ([a, b, c]);
(%o2)        [divisors(a), divisors(b), divisors(c)]
(%i3) divisors (matrix ([a, b], [c, d]));
                  [ divisors(a)  divisors(b) ]
(%o3)             [                          ]
                  [ divisors(c)  divisors(d) ]
(%i4) divisors ({a, b, c});
(%o4)        {divisors(a), divisors(b), divisors(c)}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Integers">Integers</a>
</p>
</div>


</dd></dl>

<p><a name="elementp"></a>
<a name="Item_003a-elementp"></a>
</p><dl>
<dt><u>Function:</u> <b>elementp</b><i> (<var>x</var>, <var>a</var>)</i>
<a name="IDX1342"></a>
</dt>
<dd><p>Returns <code>true</code> if and only if <var>x</var> is a member of the 
set <var>a</var>.
</p>
<p><code>elementp</code> complains if <var>a</var> is not a literal set.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) elementp (sin(1), {sin(1), sin(2), sin(3)});
(%o1)                         true
(%i2) elementp (sin(1), {cos(1), cos(2), cos(3)});
(%o2)                         false
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>


</dd></dl>

<p><a name="emptyp"></a>
<a name="Item_003a-emptyp"></a>
</p><dl>
<dt><u>Function:</u> <b>emptyp</b><i> (<var>a</var>)</i>
<a name="IDX1343"></a>
</dt>
<dd><p>Return <code>true</code> if and only if <var>a</var> is the empty set or
the empty list.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) map (emptyp, [{}, []]);
(%o1)                     [true, true]
(%i2) map (emptyp, [a + b, {{}}, %pi]);
(%o2)                 [false, false, false]
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>


</dd></dl>
       
<p><a name="equiv_005fclasses"></a>
<a name="Item_003a-equiv_005fclasses"></a>
</p><dl>
<dt><u>Function:</u> <b>equiv_classes</b><i> (<var>s</var>, <var>F</var>)</i>
<a name="IDX1344"></a>
</dt>
<dd><p>Returns a set of the equivalence classes of the set <var>s</var> with respect
to the equivalence relation <var>F</var>.
</p>
<p><var>F</var> is a function of two variables defined on the Cartesian product of <var>s</var> with <var>s</var>.
The return value of <var>F</var> is either <code>true</code> or <code>false</code>,
or an expression <var>expr</var> such that <code>is(<var>expr</var>)</code> is either <code>true</code> or <code>false</code>.
</p>
<p>When <var>F</var> is not an equivalence relation,
<code>equiv_classes</code> accepts it without complaint,
but the result is generally incorrect in that case.
</p>

<p>Examples:
</p>
<p>The equivalence relation is a lambda expression which returns <code>true</code> or <code>false</code>.
</p>
<pre class="example">(%i1) equiv_classes ({1, 1.0, 2, 2.0, 3, 3.0},
                        lambda ([x, y], is (equal (x, y))));
(%o1)            {{1, 1.0}, {2, 2.0}, {3, 3.0}}
</pre>
<p>The equivalence relation is the name of a relational function
which <code>is</code> evaluates to <code>true</code> or <code>false</code>.
</p>
<pre class="example">(%i1) equiv_classes ({1, 1.0, 2, 2.0, 3, 3.0}, equal);
(%o1)            {{1, 1.0}, {2, 2.0}, {3, 3.0}}
</pre>
<p>The equivalence classes are numbers which differ by a multiple of 3.
</p>
<pre class="example">(%i1) equiv_classes ({1, 2, 3, 4, 5, 6, 7},
                     lambda ([x, y], remainder (x - y, 3) = 0));
(%o1)              {{1, 4, 7}, {2, 5}, {3, 6}}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="every"></a>
<a name="Item_003a-every"></a>
</p><dl>
<dt><u>Function:</u> <b>every</b><i> (<var>f</var>, <var>s</var>)</i>
<a name="IDX1345"></a>
</dt>
<dt><u>Function:</u> <b>every</b><i> (<var>f</var>, <var>L_1</var>, ..., <var>L_n</var>)</i>
<a name="IDX1346"></a>
</dt>
<dd><p>Returns <code>true</code> if the predicate <var>f</var> is <code>true</code> for all given arguments.
</p>
<p>Given one set as the second argument, 
<code>every(<var>f</var>, <var>s</var>)</code> returns <code>true</code>
if <code>is(<var>f</var>(<var>a_i</var>))</code> returns <code>true</code> for all <var>a_i</var> in <var>s</var>.
<code>every</code> may or may not evaluate <var>f</var> for all <var>a_i</var> in <var>s</var>.
Since sets are unordered,
<code>every</code> may evaluate <code><var>f</var>(<var>a_i</var>)</code> in any order.
</p>
<p>Given one or more lists as arguments,
<code>every(<var>f</var>, <var>L_1</var>, ..., <var>L_n</var>)</code> returns <code>true</code>
if <code>is(<var>f</var>(<var>x_1</var>, ..., <var>x_n</var>))</code> returns <code>true</code> 
for all <var>x_1</var>, ..., <var>x_n</var> in <var>L_1</var>, ..., <var>L_n</var>, respectively.
<code>every</code> may or may not evaluate 
<var>f</var> for every combination <var>x_1</var>, ..., <var>x_n</var>.
<code>every</code> evaluates lists in the order of increasing index.
</p>
<p>Given an empty set <code>{}</code> or empty lists <code>[]</code> as arguments,
<code>every</code> returns <code>false</code>.
</p>
<p>When the global flag <code>maperror</code> is <code>true</code>, all lists 
<var>L_1</var>, ..., <var>L_n</var> must have equal lengths.
When <code>maperror</code> is <code>false</code>, list arguments are
effectively truncated to the length of the shortest list. 
</p>
<p>Return values of the predicate <var>f</var> which evaluate (via <code>is</code>)
to something other than <code>true</code> or <code>false</code>
are governed by the global flag <code>prederror</code>.
When <code>prederror</code> is <code>true</code>,
such values are treated as <code>false</code>,
and the return value from <code>every</code> is <code>false</code>.
When <code>prederror</code> is <code>false</code>,
such values are treated as <code>unknown</code>,
and the return value from <code>every</code> is <code>unknown</code>.
</p>
<p>Examples:
</p>
<p><code>every</code> applied to a single set.
The predicate is a function of one argument.
</p>
<pre class="example">(%i1) every (integerp, {1, 2, 3, 4, 5, 6});
(%o1)                         true
(%i2) every (atom, {1, 2, sin(3), 4, 5 + y, 6});
(%o2)                         false
</pre>
<p><code>every</code> applied to two lists.
The predicate is a function of two arguments.
</p>
<pre class="example">(%i1) every (&quot;=&quot;, [a, b, c], [a, b, c]);
(%o1)                         true
(%i2) every (&quot;#&quot;, [a, b, c], [a, b, c]);
(%o2)                         false
</pre>
<p>Return values of the predicate <var>f</var> which evaluate
to something other than <code>true</code> or <code>false</code>
are governed by the global flag <code>prederror</code>.
</p>
<pre class="example">(%i1) prederror : false;
(%o1)                         false
(%i2) map (lambda ([a, b], is (a &lt; b)), [x, y, z],
                   [x^2, y^2, z^2]);
(%o2)              [unknown, unknown, unknown]
(%i3) every (&quot;&lt;&quot;, [x, y, z], [x^2, y^2, z^2]);
(%o3)                        unknown
(%i4) prederror : true;
(%o4)                         true
(%i5) every (&quot;&lt;&quot;, [x, y, z], [x^2, y^2, z^2]);
(%o5)                         false
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>
 
<p><a name="extremal_005fsubset"></a>
<a name="Item_003a-extremal_005fsubset"></a>
</p><dl>
<dt><u>Function:</u> <b>extremal_subset</b><i> (<var>s</var>, <var>f</var>, max)</i>
<a name="IDX1347"></a>
</dt>
<dt><u>Function:</u> <b>extremal_subset</b><i> (<var>s</var>, <var>f</var>, min)</i>
<a name="IDX1348"></a>
</dt>
<dd><p>Returns the subset of <var>s</var> for which the function <var>f</var> takes on maximum or minimum values.
</p>
<p><code>extremal_subset(<var>s</var>, <var>f</var>, max)</code> returns the subset of the set or 
list <var>s</var> for which the real-valued function <var>f</var> takes on its maximum value.
</p>
<p><code>extremal_subset(<var>s</var>, <var>f</var>, min)</code> returns the subset of the set or 
list <var>s</var> for which the real-valued function <var>f</var> takes on its minimum value.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) extremal_subset ({-2, -1, 0, 1, 2}, abs, max);
(%o1)                       {- 2, 2}
(%i2) extremal_subset ({sqrt(2), 1.57, %pi/2}, sin, min);
(%o2)                       {sqrt(2)}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="flatten"></a>
<a name="Item_003a-flatten"></a>
</p><dl>
<dt><u>Function:</u> <b>flatten</b><i> (<var>expr</var>)</i>
<a name="IDX1349"></a>
</dt>
<dd><p>Collects arguments of subexpressions which have the same operator as <var>expr</var>
and constructs an expression from these collected arguments.
</p>
<p>Subexpressions in which the operator is different from the main operator of <code>expr</code>
are copied without modification,
even if they, in turn, contain some subexpressions in which the operator is the same as for <code>expr</code>.
</p>
<p>It may be possible for <code>flatten</code> to construct expressions in which the number
of arguments differs from the declared arguments for an operator;
this may provoke an error message from the simplifier or evaluator.
<code>flatten</code> does not try to detect such situations.
</p>
<p>Expressions with special representations, for example, canonical rational expressions (CRE), 
cannot be flattened; in such cases, <code>flatten</code> returns its argument unchanged.
</p>
<p>Examples:
</p>
<p>Applied to a list, <code>flatten</code> gathers all list elements that are lists.
</p>
<pre class="example">(%i1) flatten ([a, b, [c, [d, e], f], [[g, h]], i, j]);
(%o1)            [a, b, c, d, e, f, g, h, i, j]
</pre>
<p>Applied to a set, <code>flatten</code> gathers all members of set elements that are sets.
</p>
<pre class="example">(%i1) flatten ({a, {b}, {{c}}});
(%o1)                       {a, b, c}
(%i2) flatten ({a, {[a], {a}}});
(%o2)                       {a, [a]}
</pre>
<p><code>flatten</code> is similar to the effect of declaring the main operator n-ary.
However, <code>flatten</code> has no effect on subexpressions which have an operator
different from the main operator, while an n-ary declaration affects those.
</p>
<pre class="example">(%i1) expr: flatten (f (g (f (f (x)))));
(%o1)                     f(g(f(f(x))))
(%i2) declare (f, nary);
(%o2)                         done
(%i3) ev (expr);
(%o3)                      f(g(f(x)))
</pre>
<p><code>flatten</code> treats subscripted functions the same as any other operator.
</p>
<pre class="example">(%i1) flatten (f[5] (f[5] (x, y), z));
(%o1)                      f (x, y, z)
                            5
</pre>
<p>It may be possible for <code>flatten</code> to construct expressions in which the number
of arguments differs from the declared arguments for an operator;
</p>
<pre class="example">(%i1) 'mod (5, 'mod (7, 4));
(%o1)                   mod(5, mod(7, 4))
(%i2) flatten (%);
(%o2)                     mod(5, 7, 4)
(%i3) ''%, nouns;
Wrong number of arguments to mod
 -- an error.  Quitting.  To debug this try debugmode(true);
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="full_005flistify"></a>
<a name="Item_003a-full_005flistify"></a>
</p><dl>
<dt><u>Function:</u> <b>full_listify</b><i> (<var>a</var>)</i>
<a name="IDX1350"></a>
</dt>
<dd><p>Replaces every set operator in <var>a</var> by a list operator,
and returns the result.
<code>full_listify</code> replaces set operators in nested subexpressions,
even if the main operator is not <code>set</code>.
</p>
<p><code>listify</code> replaces only the main operator.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) full_listify ({a, b, {c, {d, e, f}, g}});
(%o1)               [a, b, [c, [d, e, f], g]]
(%i2) full_listify (F (G ({a, b, H({c, d, e})})));
(%o2)              F(G([a, b, H([c, d, e])]))
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="fullsetify"></a>
<a name="Item_003a-fullsetify"></a>
</p><dl>
<dt><u>Function:</u> <b>fullsetify</b><i> (<var>a</var>)</i>
<a name="IDX1351"></a>
</dt>
<dd><p>When <var>a</var> is a list, replaces the list operator with a set operator,
and applies <code>fullsetify</code> to each member which is a set.
When <var>a</var> is not a list, it is returned unchanged.
</p>
<p><code>setify</code> replaces only the main operator.
</p>
<p>Examples:
</p>
<p>In line <code>(%o2)</code>, the argument of <code>f</code> isn't converted to a set
because the main operator of <code>f([b])</code> isn't a list.
</p>
<pre class="example">(%i1) fullsetify ([a, [a]]);
(%o1)                       {a, {a}}
(%i2) fullsetify ([a, f([b])]);
(%o2)                      {a, f([b])}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="identity"></a>
<a name="Item_003a-identity"></a>
</p><dl>
<dt><u>Function:</u> <b>identity</b><i> (<var>x</var>)</i>
<a name="IDX1352"></a>
</dt>
<dd><p>Returns <var>x</var> for any argument <var>x</var>.
</p>
<p>Examples:
</p>
<p><code>identity</code> may be used as a predicate when the arguments
are already Boolean values.
</p>
<pre class="example">(%i1) every (identity, [true, true]);
(%o1)                         true
</pre></dd></dl>

<p><a name="integer_005fpartitions"></a>
<a name="Item_003a-integer_005fpartitions"></a>
</p><dl>
<dt><u>Function:</u> <b>integer_partitions</b><i> (<var>n</var>)</i>
<a name="IDX1353"></a>
</dt>
<dt><u>Function:</u> <b>integer_partitions</b><i> (<var>n</var>, <var>len</var>)</i>
<a name="IDX1354"></a>
</dt>
<dd><p>Returns integer partitions of <var>n</var>, that is,
lists of integers which sum to <var>n</var>.
</p>
<p><code>integer_partitions(<var>n</var>)</code> returns the set of
all partitions of the integer <var>n</var>.
Each partition is a list sorted from greatest to least.
</p>
<p><code>integer_partitions(<var>n</var>, <var>len</var>)</code>
returns all partitions that have length <var>len</var> or less; in this
case, zeros are appended to each partition with fewer than <var>len</var>
terms to make each partition have exactly <var>len</var> terms.
Each partition is a list sorted from greatest to least.
</p>
<p>A list <em>[a_1, ..., a_m]</em> is a partition of a nonnegative integer
<em>n</em> when (1) each <em>a_i</em> is a nonzero integer, and (2) 
<em>a_1 + ... + a_m = n.</em> Thus 0 has no partitions.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) integer_partitions (3);
(%o1)               {[1, 1, 1], [2, 1], [3]}
(%i2) s: integer_partitions (25)$
(%i3) cardinality (s);
(%o3)                         1958
(%i4) map (lambda ([x], apply (&quot;+&quot;, x)), s);
(%o4)                         {25}
(%i5) integer_partitions (5, 3);
(%o5) {[2, 2, 1], [3, 1, 1], [3, 2, 0], [4, 1, 0], [5, 0, 0]}
(%i6) integer_partitions (5, 2);
(%o6)               {[3, 2], [4, 1], [5, 0]}
</pre>
<p>To find all partitions that satisfy a condition, use the function <code>subset</code>;
here is an example that finds all partitions of 10 that consist of prime numbers.
</p>
<pre class="example">(%i1) s: integer_partitions (10)$
(%i2) cardinality (s);
(%o2)                          42
(%i3) xprimep(x) := integerp(x) and (x &gt; 1) and primep(x)$
(%i4) subset (s, lambda ([x], every (xprimep, x)));
(%o4) {[2, 2, 2, 2, 2], [3, 3, 2, 2], [5, 3, 2], [5, 5], [7, 3]}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Integers">Integers</a>
</p>
</div>


</dd></dl>

<p><a name="intersect"></a>
<a name="Item_003a-intersect"></a>
</p><dl>
<dt><u>Function:</u> <b>intersect</b><i> (<var>a_1</var>, ..., <var>a_n</var>)</i>
<a name="IDX1355"></a>
</dt>
<dd><p><code>intersect</code> is the same as <code>intersection</code>, which see.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="intersection"></a>
<a name="Item_003a-intersection"></a>
</p><dl>
<dt><u>Function:</u> <b>intersection</b><i> (<var>a_1</var>, ..., <var>a_n</var>)</i>
<a name="IDX1356"></a>
</dt>
<dd><p>Returns a set containing the elements that are common to the 
sets <var>a_1</var> through <var>a_n</var>.
</p>
<p><code>intersection</code> complains if any argument is not a literal set.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) S_1 : {a, b, c, d};
(%o1)                     {a, b, c, d}
(%i2) S_2 : {d, e, f, g};
(%o2)                     {d, e, f, g}
(%i3) S_3 : {c, d, e, f};
(%o3)                     {c, d, e, f}
(%i4) S_4 : {u, v, w};
(%o4)                       {u, v, w}
(%i5) intersection (S_1, S_2);
(%o5)                          {d}
(%i6) intersection (S_2, S_3);
(%o6)                       {d, e, f}
(%i7) intersection (S_1, S_2, S_3);
(%o7)                          {d}
(%i8) intersection (S_1, S_2, S_3, S_4);
(%o8)                          {}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-kron_005fdelta"></a>
</p><dl>
<dt><u>Function:</u> <b>kron_delta</b><i> (<var>x</var>, <var>y</var>)</i>
<a name="IDX1357"></a>
</dt>
<dd><p>Represents the Kronecker delta function.
</p>
<p><code>kron_delta</code> simplifies to 1 when <var>x</var> and <var>y</var> are identical or demonstrably equivalent,
and it simplifies to 0 when <var>x</var> and <var>y</var> are demonstrably not equivalent.
Otherwise,
it is not certain whether <var>x</var> and <var>y</var> are equivalent,
and <code>kron_delta</code> simplifies to a noun expression.
<code>kron_delta</code> implements a cautious policy with respect to floating point expressions:
if the difference <code><var>x</var> - <var>y</var></code> is a floating point number,
<code>kron_delta</code> simplifies to a noun expression when <var>x</var> is apparently equivalent to <var>y</var>.
</p>
<p>Specifically,
<code>kron_delta(<var>x</var>, <var>y</var>)</code> simplifies to 1
when <code>is(x = y)</code> is <code>true</code>.
<code>kron_delta</code> also simplifies to 1
when <code>sign(abs(<var>x</var> - <var>y</var>))</code> is <code>zero</code>
and <code><var>x</var> - <var>y</var></code> is not a floating point number
(neither an ordinary float nor a bigfloat).
<code>kron_delta</code> simplifies to 0
when <code>sign(abs(<var>x</var> - <var>y</var>))</code> is <code>pos</code>.
</p>
<p>Otherwise, <code>sign(abs(<var>x</var> - <var>y</var>))</code> is
something other than <code>pos</code> or <code>zero</code>,
or it is <code>zero</code> and <code><var>x</var> - <var>y</var></code>
is a floating point number.
In these cases, <code>kron_delta</code> returns a noun expression.
</p>
<p><code>kron_delta</code> is declared to be symmetric.
That is,
<code>kron_delta(<var>x</var>, <var>y</var>)</code> is equal to <code>kron_delta(<var>y</var>, <var>x</var>)</code>.
</p>
<p>Examples:
</p>
<p>The arguments of <code>kron_delta</code> are identical.
<code>kron_delta</code> simplifies to 1.
</p>
<pre class="example">(%i1) kron_delta (a, a);
(%o1)                           1
(%i2) kron_delta (x^2 - y^2, x^2 - y^2);
(%o2)                           1
(%i3) float (kron_delta (1/10, 0.1));
(%o3)                           1
</pre>
<p>The arguments of <code>kron_delta</code> are equivalent,
and their difference is not a floating point number.
<code>kron_delta</code> simplifies to 1.
</p>
<pre class="example">(%i1) assume (equal (x, y));
(%o1)                     [equal(x, y)]
(%i2) kron_delta (x, y);
(%o2)                           1
</pre>
<p>The arguments of <code>kron_delta</code> are not equivalent.
<code>kron_delta</code> simplifies to 0.
</p>
<pre class="example">(%i1) kron_delta (a + 1, a);
(%o1)                           0
(%i2) assume (a &gt; b)$
(%i3) kron_delta (a, b);
(%o3)                           0
(%i4) kron_delta (1/5, 0.7);
(%o4)                           0
</pre>
<p>The arguments of <code>kron_delta</code> might or might not be equivalent.
<code>kron_delta</code> simplifies to a noun expression.
</p>
<pre class="example">(%i1) kron_delta (a, b);
(%o1)                   kron_delta(a, b)
(%i2) assume(x &gt;= y)$
(%i3) kron_delta (x, y);
(%o3)                   kron_delta(x, y)
</pre>
<p>The arguments of <code>kron_delta</code> are equivalent,
but their difference is a floating point number.
<code>kron_delta</code> simplifies to a noun expression.
</p>
<pre class="example">(%i1) 1/4 - 0.25;
(%o1)                          0.0
(%i2) 1/10 - 0.1;
(%o2)                          0.0
(%i3) 0.25 - 0.25b0;
Warning:  Float to bigfloat conversion of 0.25
(%o3)                         0.0b0
(%i4) kron_delta (1/4, 0.25);
                                  1
(%o4)                  kron_delta(-, 0.25)
                                  4
(%i5) kron_delta (1/10, 0.1);
                                  1
(%o5)                  kron_delta(--, 0.1)
                                  10
(%i6) kron_delta (0.25, 0.25b0);
Warning:  Float to bigfloat conversion of 0.25
(%o6)               kron_delta(0.25, 2.5b-1)
</pre>
<p><code>kron_delta</code> is symmetric.
</p>
<pre class="example">(%i1) kron_delta (x, y);
(%o1)                   kron_delta(x, y)
(%i2) kron_delta (y, x);
(%o2)                   kron_delta(x, y)
(%i3) kron_delta (x, y) - kron_delta (y, x);
(%o3)                           0
(%i4) is (equal (kron_delta (x, y), kron_delta (y, x)));
(%o4)                         true
(%i5) is (kron_delta (x, y) = kron_delta (y, x));
(%o5)                         true
</pre>
</dd></dl>

<p><a name="listify"></a>
<a name="Item_003a-listify"></a>
</p><dl>
<dt><u>Function:</u> <b>listify</b><i> (<var>a</var>)</i>
<a name="IDX1358"></a>
</dt>
<dd><p>Returns a list containing the members of <var>a</var> when <var>a</var> is a set.
Otherwise, <code>listify</code> returns <var>a</var>.
</p>
<p><code>full_listify</code> replaces all set operators in <var>a</var> by list operators.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) listify ({a, b, c, d});
(%o1)                     [a, b, c, d]
(%i2) listify (F ({a, b, c, d}));
(%o2)                    F({a, b, c, d})
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="lreduce"></a>
<a name="Item_003a-lreduce"></a>
</p><dl>
<dt><u>Function:</u> <b>lreduce</b><i> (<var>F</var>, <var>s</var>)</i>
<a name="IDX1359"></a>
</dt>
<dt><u>Function:</u> <b>lreduce</b><i> (<var>F</var>, <var>s</var>, <var>s_0</var>)</i>
<a name="IDX1360"></a>
</dt>
<dd><p>Extends the binary function <var>F</var> to an n-ary function by composition,
where <var>s</var> is a list.
</p>
<p><code>lreduce(<var>F</var>, <var>s</var>)</code> returns <code>F(... F(F(s_1, s_2), s_3), ... s_n)</code>.
When the optional argument <var>s_0</var> is present,
the result is equivalent to <code>lreduce(<var>F</var>, cons(<var>s_0</var>, <var>s</var>))</code>.
</p>
<p>The function <var>F</var> is first applied to the
<i>leftmost</i> list elements, thus the name &quot;lreduce&quot;. 
</p>
<p>See also <code>rreduce</code>, <code>xreduce</code>, and <code>tree_reduce</code>.
</p>
<p>Examples:
</p>
<p><code>lreduce</code> without the optional argument.
</p>
<pre class="example">(%i1) lreduce (f, [1, 2, 3]);
(%o1)                     f(f(1, 2), 3)
(%i2) lreduce (f, [1, 2, 3, 4]);
(%o2)                  f(f(f(1, 2), 3), 4)
</pre>
<p><code>lreduce</code> with the optional argument.
</p>
<pre class="example">(%i1) lreduce (f, [1, 2, 3], 4);
(%o1)                  f(f(f(4, 1), 2), 3)
</pre>
<p><code>lreduce</code> applied to built-in binary operators.
<code>/</code> is the division operator.
</p>
<pre class="example">(%i1) lreduce (&quot;^&quot;, args ({a, b, c, d}));
                               b c d
(%o1)                       ((a ) )
(%i2) lreduce (&quot;/&quot;, args ({a, b, c, d}));
                                a
(%o2)                         -----
                              b c d
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="makeset"></a>
<a name="Item_003a-makeset"></a>
</p><dl>
<dt><u>Function:</u> <b>makeset</b><i> (<var>expr</var>, <var>x</var>, <var>s</var>)</i>
<a name="IDX1361"></a>
</dt>
<dd><p>Returns a set with members generated from the expression <var>expr</var>,
where <var>x</var> is a list of variables in <var>expr</var>,
and <var>s</var> is a set or list of lists.
To generate each set member,
<var>expr</var> is evaluated with the variables <var>x</var> bound in parallel to a member of <var>s</var>.
</p>
<p>Each member of <var>s</var> must have the same length as <var>x</var>.
The list of variables <var>x</var> must be a list of symbols, without subscripts.
Even if there is only one symbol, <var>x</var> must be a list of one element,
and each member of <var>s</var> must be a list of one element.
</p>

<p>See also <code>makelist</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) makeset (i/j, [i, j], [[1, a], [2, b], [3, c], [4, d]]);
                           1  2  3  4
(%o1)                     {-, -, -, -}
                           a  b  c  d
(%i2) S : {x, y, z}$
(%i3) S3 : cartesian_product (S, S, S);
(%o3) {[x, x, x], [x, x, y], [x, x, z], [x, y, x], [x, y, y], 
[x, y, z], [x, z, x], [x, z, y], [x, z, z], [y, x, x], 
[y, x, y], [y, x, z], [y, y, x], [y, y, y], [y, y, z], 
[y, z, x], [y, z, y], [y, z, z], [z, x, x], [z, x, y], 
[z, x, z], [z, y, x], [z, y, y], [z, y, z], [z, z, x], 
[z, z, y], [z, z, z]}
(%i4) makeset (i + j + k, [i, j, k], S3);
(%o4) {3 x, 3 y, y + 2 x, 2 y + x, 3 z, z + 2 x, z + y + x, 
                                       z + 2 y, 2 z + x, 2 z + y}
(%i5) makeset (sin(x), [x], {[1], [2], [3]});
(%o5)               {sin(1), sin(2), sin(3)}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="moebius"></a>
<a name="Item_003a-moebius"></a>
</p><dl>
<dt><u>Function:</u> <b>moebius</b><i> (<var>n</var>)</i>
<a name="IDX1362"></a>
</dt>
<dd><p>Represents the Moebius function.
</p>
<p>When <var>n</var> is product of <em>k</em> distinct primes,
<code>moebius(<var>n</var>)</code> simplifies to <em>(-1)^k</em>;
when <em><var>n</var> = 1</em>, it simplifies to 1;
and it simplifies to 0 for all other positive integers. 
</p>
<p><code>moebius</code> distributes over equations, lists, matrices, and sets.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) moebius (1);
(%o1)                           1
(%i2) moebius (2 * 3 * 5);
(%o2)                          - 1
(%i3) moebius (11 * 17 * 29 * 31);
(%o3)                           1
(%i4) moebius (2^32);
(%o4)                           0
(%i5) moebius (n);
(%o5)                      moebius(n)
(%i6) moebius (n = 12);
(%o6)                    moebius(n) = 0
(%i7) moebius ([11, 11 * 13, 11 * 13 * 15]);
(%o7)                      [- 1, 1, 1]
(%i8) moebius (matrix ([11, 12], [13, 14]));
                           [ - 1  0 ]
(%o8)                      [        ]
                           [ - 1  1 ]
(%i9) moebius ({21, 22, 23, 24});
(%o9)                      {- 1, 0, 1}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Integers">Integers</a>
</p>
</div>


</dd></dl>
 
<p><a name="multinomial_005fcoeff"></a>
<a name="Item_003a-multinomial_005fcoeff"></a>
</p><dl>
<dt><u>Function:</u> <b>multinomial_coeff</b><i> (<var>a_1</var>, ..., <var>a_n</var>)</i>
<a name="IDX1363"></a>
</dt>
<dt><u>Function:</u> <b>multinomial_coeff</b><i> ()</i>
<a name="IDX1364"></a>
</dt>
<dd><p>Returns the multinomial coefficient.
</p>
<p>When each <var>a_k</var> is a nonnegative integer, the multinomial coefficient
gives the number of ways of placing <code><var>a_1</var> + ... + <var>a_n</var></code> 
distinct objects into <em>n</em> boxes with <var>a_k</var> elements in the 
<em>k</em>'th box. In general, <code>multinomial_coeff (<var>a_1</var>, ..., <var>a_n</var>)</code>
evaluates to <code>(<var>a_1</var> + ... + <var>a_n</var>)!/(<var>a_1</var>! ... <var>a_n</var>!)</code>.
</p>
<p><code>multinomial_coeff()</code> (with no arguments) evaluates to 1.
</p>
<p><code>minfactorial</code> may be able to simplify the value returned by <code>multinomial_coeff</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) multinomial_coeff (1, 2, x);
                            (x + 3)!
(%o1)                       --------
                              2 x!
(%i2) minfactorial (%);
                     (x + 1) (x + 2) (x + 3)
(%o2)                -----------------------
                                2
(%i3) multinomial_coeff (-6, 2);
                             (- 4)!
(%o3)                       --------
                            2 (- 6)!
(%i4) minfactorial (%);
(%o4)                          10
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Integers">Integers</a>
</p>
</div>


</dd></dl>

<p><a name="num_005fdistinct_005fpartitions"></a>
<a name="Item_003a-num_005fdistinct_005fpartitions"></a>
</p><dl>
<dt><u>Function:</u> <b>num_distinct_partitions</b><i> (<var>n</var>)</i>
<a name="IDX1365"></a>
</dt>
<dt><u>Function:</u> <b>num_distinct_partitions</b><i> (<var>n</var>, list)</i>
<a name="IDX1366"></a>
</dt>
<dd><p>Returns the number of distinct integer partitions of <var>n</var>
when <var>n</var> is a nonnegative integer.
Otherwise, <code>num_distinct_partitions</code> returns a noun expression.
</p>
<p><code>num_distinct_partitions(<var>n</var>, list)</code> returns a 
list of the number of distinct partitions of 1, 2, 3, ..., <var>n</var>. 
</p>
<p>A distinct partition of <var>n</var> is
a list of distinct positive integers <em>k_1</em>, ..., <em>k_m</em>
such that <em><var>n</var> = k_1 + ... + k_m</em>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) num_distinct_partitions (12);
(%o1)                          15
(%i2) num_distinct_partitions (12, list);
(%o2)      [1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 15]
(%i3) num_distinct_partitions (n);
(%o3)              num_distinct_partitions(n)
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Integers">Integers</a>
</p>
</div>


</dd></dl>

<p><a name="num_005fpartitions"></a>
<a name="Item_003a-num_005fpartitions"></a>
</p><dl>
<dt><u>Function:</u> <b>num_partitions</b><i> (<var>n</var>)</i>
<a name="IDX1367"></a>
</dt>
<dt><u>Function:</u> <b>num_partitions</b><i> (<var>n</var>, list)</i>
<a name="IDX1368"></a>
</dt>
<dd><p>Returns the number of integer partitions of <var>n</var>
when <var>n</var> is a nonnegative integer.
Otherwise, <code>num_partitions</code> returns a noun expression.
</p>
<p><code>num_partitions(<var>n</var>, list)</code> returns a
list of the number of integer partitions of 1, 2, 3, ..., <var>n</var>.
</p>
<p>For a nonnegative integer <var>n</var>, <code>num_partitions(<var>n</var>)</code> is equal to
<code>cardinality(integer_partitions(<var>n</var>))</code>; however, <code>num_partitions</code> 
does not actually construct the set of partitions, so it is much faster.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) num_partitions (5) = cardinality (integer_partitions (5));
(%o1)                         7 = 7
(%i2) num_partitions (8, list);
(%o2)            [1, 1, 2, 3, 5, 7, 11, 15, 22]
(%i3) num_partitions (n);
(%o3)                   num_partitions(n)
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Integers">Integers</a>
</p>
</div>


</dd></dl>



<p><a name="partition_005fset"></a>
<a name="Item_003a-partition_005fset"></a>
</p><dl>
<dt><u>Function:</u> <b>partition_set</b><i> (<var>a</var>, <var>f</var>)</i>
<a name="IDX1369"></a>
</dt>
<dd><p>Partitions the set <var>a</var> according to the predicate <var>f</var>.
</p>
<p><code>partition_set</code> returns a list of two sets.
The first set comprises the elements of <var>a</var> for which <var>f</var> evaluates to <code>false</code>,
and the second comprises any other elements of <var>a</var>.
<code>partition_set</code> does not apply <code>is</code> to the return value of <var>f</var>.
</p>
<p><code>partition_set</code> complains if <var>a</var> is not a literal set.
</p>
<p>See also <code>subset</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) partition_set ({2, 7, 1, 8, 2, 8}, evenp);
(%o1)                   [{1, 7}, {2, 8}]
(%i2) partition_set ({x, rat(y), rat(y) + z, 1},
                     lambda ([x], ratp(x)));
(%o2)/R/              [{1, x}, {y, y + z}]
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="permutations"></a>
<a name="Item_003a-permutations"></a>
</p><dl>
<dt><u>Function:</u> <b>permutations</b><i> (<var>a</var>)</i>
<a name="IDX1370"></a>
</dt>
<dd><p>Returns a set of all distinct permutations of the members of 
the list or set <var>a</var>. Each permutation is a list, not a set. 
</p>
<p>When <var>a</var> is a list, duplicate members of <var>a</var> are included
in the permutations.
</p>
<p><code>permutations</code> complains if <var>a</var> is not a literal list or set.
</p>
<p>See also <code>random_permutation</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) permutations ([a, a]);
(%o1)                       {[a, a]}
(%i2) permutations ([a, a, b]);
(%o2)           {[a, a, b], [a, b, a], [b, a, a]}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="powerset"></a>
<a name="Item_003a-powerset"></a>
</p><dl>
<dt><u>Function:</u> <b>powerset</b><i> (<var>a</var>)</i>
<a name="IDX1371"></a>
</dt>
<dt><u>Function:</u> <b>powerset</b><i> (<var>a</var>, <var>n</var>)</i>
<a name="IDX1372"></a>
</dt>
<dd><p>Returns the set of all subsets of <var>a</var>, or a subset of that set.
</p>
<p><code>powerset(<var>a</var>)</code> returns the set of all subsets of the set <var>a</var>.
<code>powerset(<var>a</var>)</code> has <code>2^cardinality(<var>a</var>)</code> members.
</p>
<p><code>powerset(<var>a</var>, <var>n</var>)</code> returns the set of all subsets of <var>a</var> that have 
cardinality <var>n</var>.
</p>
<p><code>powerset</code> complains if <var>a</var> is not a literal set,
or if <var>n</var> is not a nonnegative integer.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) powerset ({a, b, c});
(%o1) {{}, {a}, {a, b}, {a, b, c}, {a, c}, {b}, {b, c}, {c}}
(%i2) powerset ({w, x, y, z}, 4);
(%o2)                    {{w, x, y, z}}
(%i3) powerset ({w, x, y, z}, 3);
(%o3)     {{w, x, y}, {w, x, z}, {w, y, z}, {x, y, z}}
(%i4) powerset ({w, x, y, z}, 2);
(%o4)   {{w, x}, {w, y}, {w, z}, {x, y}, {x, z}, {y, z}}
(%i5) powerset ({w, x, y, z}, 1);
(%o5)                 {{w}, {x}, {y}, {z}}
(%i6) powerset ({w, x, y, z}, 0);
(%o6)                         {{}}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-random_005fpermutation"></a>
</p><dl>
<dt><u>Function:</u> <b>random_permutation</b><i> (<var>a</var>)</i>
<a name="IDX1373"></a>
</dt>
<dd><p>Returns a random permutation of the set or list <var>a</var>,
as constructed by the Knuth shuffle algorithm.
</p>
<p>The return value is a new list, which is distinct
from the argument even if all elements happen to be the same.
However, the elements of the argument are not copied.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) random_permutation ([a, b, c, 1, 2, 3]);
(%o1)                  [c, 1, 2, 3, a, b]
(%i2) random_permutation ([a, b, c, 1, 2, 3]);
(%o2)                  [b, 3, 1, c, a, 2]
(%i3) random_permutation ({x + 1, y + 2, z + 3});
(%o3)                 [y + 2, z + 3, x + 1]
(%i4) random_permutation ({x + 1, y + 2, z + 3});
(%o4)                 [x + 1, y + 2, z + 3]
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="rreduce"></a>
<a name="Item_003a-rreduce"></a>
</p><dl>
<dt><u>Function:</u> <b>rreduce</b><i> (<var>F</var>, <var>s</var>)</i>
<a name="IDX1374"></a>
</dt>
<dt><u>Function:</u> <b>rreduce</b><i> (<var>F</var>, <var>s</var>, <var>s_{n + 1}</var>)</i>
<a name="IDX1375"></a>
</dt>
<dd><p>Extends the binary function <var>F</var> to an n-ary function by composition,
where <var>s</var> is a list.
</p>
<p><code>rreduce(<var>F</var>, <var>s</var>)</code> returns <code>F(s_1, ... F(s_{n - 2}, F(s_{n - 1}, s_n)))</code>.
When the optional argument <var>s_{n + 1}</var> is present,
the result is equivalent to <code>rreduce(<var>F</var>, endcons(<var>s_{n + 1}</var>, <var>s</var>))</code>.
</p>
<p>The function <var>F</var> is first applied to the
<i>rightmost</i> list elements, thus the name &quot;rreduce&quot;. 
</p>
<p>See also <code>lreduce</code>, <code>tree_reduce</code>, and <code>xreduce</code>.
</p>
<p>Examples:
</p>
<p><code>rreduce</code> without the optional argument.
</p>
<pre class="example">(%i1) rreduce (f, [1, 2, 3]);
(%o1)                     f(1, f(2, 3))
(%i2) rreduce (f, [1, 2, 3, 4]);
(%o2)                  f(1, f(2, f(3, 4)))
</pre>
<p><code>rreduce</code> with the optional argument.
</p>
<pre class="example">(%i1) rreduce (f, [1, 2, 3], 4);
(%o1)                  f(1, f(2, f(3, 4)))
</pre>
<p><code>rreduce</code> applied to built-in binary operators.
<code>/</code> is the division operator.
</p>
<pre class="example">(%i1) rreduce (&quot;^&quot;, args ({a, b, c, d}));
                                 d
                                c
                               b
(%o1)                         a
(%i2) rreduce (&quot;/&quot;, args ({a, b, c, d}));
                               a c
(%o2)                          ---
                               b d
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="setdifference"></a>
<a name="Item_003a-setdifference"></a>
</p><dl>
<dt><u>Function:</u> <b>setdifference</b><i> (<var>a</var>, <var>b</var>)</i>
<a name="IDX1376"></a>
</dt>
<dd><p>Returns a set containing the elements in the set <var>a</var> that are
not in the set <var>b</var>.
</p>
<p><code>setdifference</code> complains if either <var>a</var> or <var>b</var> is not a literal set.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) S_1 : {a, b, c, x, y, z};
(%o1)                  {a, b, c, x, y, z}
(%i2) S_2 : {aa, bb, c, x, y, zz};
(%o2)                 {aa, bb, c, x, y, zz}
(%i3) setdifference (S_1, S_2);
(%o3)                       {a, b, z}
(%i4) setdifference (S_2, S_1);
(%o4)                     {aa, bb, zz}
(%i5) setdifference (S_1, S_1);
(%o5)                          {}
(%i6) setdifference (S_1, {});
(%o6)                  {a, b, c, x, y, z}
(%i7) setdifference ({}, S_1);
(%o7)                          {}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="setequalp"></a>
<a name="Item_003a-setequalp"></a>
</p><dl>
<dt><u>Function:</u> <b>setequalp</b><i> (<var>a</var>, <var>b</var>)</i>
<a name="IDX1377"></a>
</dt>
<dd><p>Returns <code>true</code> if sets <var>a</var> and <var>b</var> have the same number of elements
and <code>is(<var>x</var> = <var>y</var>)</code> is <code>true</code>
for <code>x</code> in the elements of <var>a</var>
and <code>y</code> in the elements of <var>b</var>,
considered in the order determined by <code>listify</code>.
Otherwise, <code>setequalp</code> returns <code>false</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) setequalp ({1, 2, 3}, {1, 2, 3});
(%o1)                         true
(%i2) setequalp ({a, b, c}, {1, 2, 3});
(%o2)                         false
(%i3) setequalp ({x^2 - y^2}, {(x + y) * (x - y)});
(%o3)                         false
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>


</dd></dl>

<p><a name="setify"></a>
<a name="Item_003a-setify"></a>
</p><dl>
<dt><u>Function:</u> <b>setify</b><i> (<var>a</var>)</i>
<a name="IDX1378"></a>
</dt>
<dd><p>Constructs a set from the elements of the list <var>a</var>. Duplicate
elements of the list <var>a</var> are deleted and the elements
are sorted according to the predicate <code>orderlessp</code>.
</p>
<p><code>setify</code> complains if <var>a</var> is not a literal list.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) setify ([1, 2, 3, a, b, c]);
(%o1)                  {1, 2, 3, a, b, c}
(%i2) setify ([a, b, c, a, b, c]);
(%o2)                       {a, b, c}
(%i3) setify ([7, 13, 11, 1, 3, 9, 5]);
(%o3)                {1, 3, 5, 7, 9, 11, 13}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="setp"></a>
<a name="Item_003a-setp"></a>
</p><dl>
<dt><u>Function:</u> <b>setp</b><i> (<var>a</var>)</i>
<a name="IDX1379"></a>
</dt>
<dd><p>Returns <code>true</code> if and only if <var>a</var> is a Maxima set.
</p>
<p><code>setp</code> returns <code>true</code> for unsimplified sets (that is, sets with redundant members)
as well as simplified sets.
</p>
<p><code>setp</code> is equivalent to the Maxima function
<code>setp(a) := not atom(a) and op(a) = 'set</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) simp : false;
(%o1)                         false
(%i2) {a, a, a};
(%o2)                       {a, a, a}
(%i3) setp (%);
(%o3)                         true
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>


</dd></dl>

<p><a name="set_005fpartitions"></a>
<a name="Item_003a-set_005fpartitions"></a>
</p><dl>
<dt><u>Function:</u> <b>set_partitions</b><i> (<var>a</var>)</i>
<a name="IDX1380"></a>
</dt>
<dt><u>Function:</u> <b>set_partitions</b><i> (<var>a</var>, <var>n</var>)</i>
<a name="IDX1381"></a>
</dt>
<dd><p>Returns the set of all partitions of <var>a</var>, or a subset of that set.
</p>
<p><code>set_partitions(<var>a</var>, <var>n</var>)</code> returns a set of all
decompositions of <var>a</var> into <var>n</var> nonempty disjoint subsets.
</p>
<p><code>set_partitions(<var>a</var>)</code> returns the set of all partitions.
</p>
<p><code>stirling2</code> returns the cardinality of the set of partitions of a set.
</p>
<p>A set of sets <em>P</em> is a partition of a set <em>S</em> when
</p>
<ol>
<li>
each member of <em>P</em> is a nonempty set,
</li><li>
distinct members of <em>P</em> are disjoint,
</li><li>
the union of the members of <em>P</em> equals <em>S</em>.
</li></ol>

<p>Examples:
</p>
<p>The empty set is a partition of itself, the conditions 1 and 2 being vacuously true.
</p>
<pre class="example">(%i1) set_partitions ({});
(%o1)                         {{}}
</pre>
<p>The cardinality of the set of partitions of a set can be found using <code>stirling2</code>.
</p>
<pre class="example">(%i1) s: {0, 1, 2, 3, 4, 5}$
(%i2) p: set_partitions (s, 3)$ 
(%i3) cardinality(p) = stirling2 (6, 3);
(%o3)                        90 = 90
</pre>
<p>Each member of <code>p</code> should have <var>n</var> = 3 members; let's check.
</p>
<pre class="example">(%i1) s: {0, 1, 2, 3, 4, 5}$
(%i2) p: set_partitions (s, 3)$ 
(%i3) map (cardinality, p);
(%o3)                          {3}
</pre>
<p>Finally, for each member of <code>p</code>, the union of its members should 
equal <code>s</code>; again let's check.
</p>
<pre class="example">(%i1) s: {0, 1, 2, 3, 4, 5}$
(%i2) p: set_partitions (s, 3)$ 
(%i3) map (lambda ([x], apply (union, listify (x))), p);
(%o3)                 {{0, 1, 2, 3, 4, 5}}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="some"></a>
<a name="Item_003a-some"></a>
</p><dl>
<dt><u>Function:</u> <b>some</b><i> (<var>f</var>, <var>a</var>)</i>
<a name="IDX1382"></a>
</dt>
<dt><u>Function:</u> <b>some</b><i> (<var>f</var>, <var>L_1</var>, ..., <var>L_n</var>)</i>
<a name="IDX1383"></a>
</dt>
<dd><p>Returns <code>true</code> if the predicate <var>f</var> is <code>true</code> for one or more given arguments.
</p>
<p>Given one set as the second argument, 
<code>some(<var>f</var>, <var>s</var>)</code> returns <code>true</code>
if <code>is(<var>f</var>(<var>a_i</var>))</code> returns <code>true</code> for one or more <var>a_i</var> in <var>s</var>.
<code>some</code> may or may not evaluate <var>f</var> for all <var>a_i</var> in <var>s</var>.
Since sets are unordered,
<code>some</code> may evaluate <code><var>f</var>(<var>a_i</var>)</code> in any order.
</p>
<p>Given one or more lists as arguments,
<code>some(<var>f</var>, <var>L_1</var>, ..., <var>L_n</var>)</code> returns <code>true</code>
if <code>is(<var>f</var>(<var>x_1</var>, ..., <var>x_n</var>))</code> returns <code>true</code> 
for one or more <var>x_1</var>, ..., <var>x_n</var> in <var>L_1</var>, ..., <var>L_n</var>, respectively.
<code>some</code> may or may not evaluate 
<var>f</var> for some combinations <var>x_1</var>, ..., <var>x_n</var>.
<code>some</code> evaluates lists in the order of increasing index.
</p>
<p>Given an empty set <code>{}</code> or empty lists <code>[]</code> as arguments,
<code>some</code> returns <code>false</code>.
</p>
<p>When the global flag <code>maperror</code> is <code>true</code>, all lists 
<var>L_1</var>, ..., <var>L_n</var> must have equal lengths.
When <code>maperror</code> is <code>false</code>, list arguments are
effectively truncated to the length of the shortest list. 
</p>
<p>Return values of the predicate <var>f</var> which evaluate (via <code>is</code>)
to something other than <code>true</code> or <code>false</code>
are governed by the global flag <code>prederror</code>.
When <code>prederror</code> is <code>true</code>,
such values are treated as <code>false</code>.
When <code>prederror</code> is <code>false</code>,
such values are treated as <code>unknown</code>.
</p>
<p>Examples:
</p>
<p><code>some</code> applied to a single set.
The predicate is a function of one argument.
</p>
<pre class="example">(%i1) some (integerp, {1, 2, 3, 4, 5, 6});
(%o1)                         true
(%i2) some (atom, {1, 2, sin(3), 4, 5 + y, 6});
(%o2)                         true
</pre>
<p><code>some</code> applied to two lists.
The predicate is a function of two arguments.
</p>
<pre class="example">(%i1) some (&quot;=&quot;, [a, b, c], [a, b, c]);
(%o1)                         true
(%i2) some (&quot;#&quot;, [a, b, c], [a, b, c]);
(%o2)                         false
</pre>
<p>Return values of the predicate <var>f</var> which evaluate
to something other than <code>true</code> or <code>false</code>
are governed by the global flag <code>prederror</code>.
</p>
<pre class="example">(%i1) prederror : false;
(%o1)                         false
(%i2) map (lambda ([a, b], is (a &lt; b)), [x, y, z],
           [x^2, y^2, z^2]);
(%o2)              [unknown, unknown, unknown]
(%i3) some (&quot;&lt;&quot;, [x, y, z], [x^2, y^2, z^2]);
(%o3)                        unknown
(%i4) some (&quot;&lt;&quot;, [x, y, z], [x^2, y^2, z + 1]);
(%o4)                         true
(%i5) prederror : true;
(%o5)                         true
(%i6) some (&quot;&lt;&quot;, [x, y, z], [x^2, y^2, z^2]);
(%o6)                         false
(%i7) some (&quot;&lt;&quot;, [x, y, z], [x^2, y^2, z + 1]);
(%o7)                         true
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="stirling1"></a>
<a name="Item_003a-stirling1"></a>
</p><dl>
<dt><u>Function:</u> <b>stirling1</b><i> (<var>n</var>, <var>m</var>)</i>
<a name="IDX1384"></a>
</dt>
<dd><p>Represents the Stirling number of the first kind.
</p>
<p>When <var>n</var> and <var>m</var> are nonnegative 
integers, the magnitude of <code>stirling1 (<var>n</var>, <var>m</var>)</code> is the number of 
permutations of a set with <var>n</var> members that have <var>m</var> cycles.
For details, see Graham, Knuth and Patashnik <i>Concrete Mathematics</i>.
Maxima uses a recursion relation to define <code>stirling1 (<var>n</var>, <var>m</var>)</code> for
<var>m</var> less than 0; it is undefined for <var>n</var> less than 0 and for non-integer
arguments.
</p>
<p><code>stirling1</code> is a simplifying function.
Maxima knows the following identities.
</p>
<ol>
<li>
<em>stirling1(0, n) = kron_delta(0, n)</em> (Ref. [1])
</li><li>
<em>stirling1(n, n) = 1</em> (Ref. [1])
</li><li>
<em>stirling1(n, n - 1) = binomial(n, 2)</em> (Ref. [1])
</li><li>
<em>stirling1(n + 1, 0) = 0</em> (Ref. [1])
</li><li>
<em>stirling1(n + 1, 1) = n!</em> (Ref. [1])
</li><li>
<em>stirling1(n + 1, 2) = 2^n  - 1</em> (Ref. [1])
</li></ol>

<p>These identities are applied when the arguments are literal integers
or symbols declared as integers, and the first argument is nonnegative.
<code>stirling1</code> does not simplify for non-integer arguments.
</p>
<p>References:
</p>
<p>[1] Donald Knuth, <i>The Art of Computer Programming,</i>
third edition, Volume 1, Section 1.2.6, Equations 48, 49, and 50.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) declare (n, integer)$
(%i2) assume (n &gt;= 0)$
(%i3) stirling1 (n, n);
(%o3)                           1
</pre>
<p><code>stirling1</code> does not simplify for non-integer arguments.
</p>
<pre class="example">(%i1) stirling1 (sqrt(2), sqrt(2));
(%o1)              stirling1(sqrt(2), sqrt(2))
</pre>
<p>Maxima applies identities to <code>stirling1</code>.
</p>
<pre class="example">(%i1) declare (n, integer)$
(%i2) assume (n &gt;= 0)$
(%i3) stirling1 (n + 1, n);
                            n (n + 1)
(%o3)                       ---------
                                2
(%i4) stirling1 (n + 1, 1);
(%o4)                          n!
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Integers">Integers</a>
</p>
</div>


</dd></dl>

<p><a name="stirling2"></a>
<a name="Item_003a-stirling2"></a>
</p><dl>
<dt><u>Function:</u> <b>stirling2</b><i> (<var>n</var>, <var>m</var>)</i>
<a name="IDX1385"></a>
</dt>
<dd><p>Represents the Stirling number of the second kind.
</p>
<p>When <var>n</var> and <var>m</var> are nonnegative 
integers, <code>stirling2 (<var>n</var>, <var>m</var>)</code> is the number of ways a set with 
cardinality <var>n</var> can be partitioned into <var>m</var> disjoint subsets.
Maxima uses a recursion relation to define <code>stirling2 (<var>n</var>, <var>m</var>)</code> for
<var>m</var> less than 0; it is undefined for <var>n</var> less than 0 and for non-integer
arguments.
</p>
<p><code>stirling2</code> is a simplifying function.
Maxima knows the following identities.
</p>
<ol>
<li>
<em>stirling2(0, n) = kron_delta(0, n)</em> (Ref. [1])
</li><li>
<em>stirling2(n, n) = 1</em> (Ref. [1])
</li><li>
<em>stirling2(n, n - 1) = binomial(n, 2)</em> (Ref. [1])
</li><li>
<em>stirling2(n + 1, 1) = 1</em> (Ref. [1])
</li><li>
<em>stirling2(n + 1, 2) = 2^n  - 1</em> (Ref. [1])
</li><li>
<em>stirling2(n, 0) = kron_delta(n, 0)</em> (Ref. [2])
</li><li>
<em>stirling2(n, m) = 0</em> when <em>m &gt; n</em> (Ref. [2])
</li><li>
<em>stirling2(n, m) = sum((-1)^(m - k) binomial(m k) k^n,i,1,m) / m!</em>
when <em>m</em> and <em>n</em> are integers, and <em>n</em> is nonnegative. (Ref. [3])
</li></ol>

<p>These identities are applied when the arguments are literal integers
or symbols declared as integers, and the first argument is nonnegative.
<code>stirling2</code> does not simplify for non-integer arguments.
</p>
<p>References:
</p>
<p>[1] Donald Knuth. <i>The Art of Computer Programming</i>,
third edition, Volume 1, Section 1.2.6, Equations 48, 49, and 50.
</p>
<p>[2] Graham, Knuth, and Patashnik. <i>Concrete Mathematics</i>, Table 264.
</p>
<p>[3] Abramowitz and Stegun. <i>Handbook of Mathematical Functions</i>, Section 24.1.4.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) declare (n, integer)$
(%i2) assume (n &gt;= 0)$
(%i3) stirling2 (n, n);
(%o3)                           1
</pre>
<p><code>stirling2</code> does not simplify for non-integer arguments.
</p>
<pre class="example">(%i1) stirling2 (%pi, %pi);
(%o1)                  stirling2(%pi, %pi)
</pre>
<p>Maxima applies identities to <code>stirling2</code>.
</p>
<pre class="example">(%i1) declare (n, integer)$
(%i2) assume (n &gt;= 0)$
(%i3) stirling2 (n + 9, n + 8);
                         (n + 8) (n + 9)
(%o3)                    ---------------
                                2
(%i4) stirling2 (n + 1, 2);
                              n
(%o4)                        2  - 1
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Integers">Integers</a>
</p>
</div>


</dd></dl>

<p><a name="subset"></a>
<a name="Item_003a-subset"></a>
</p><dl>
<dt><u>Function:</u> <b>subset</b><i> (<var>a</var>, <var>f</var>)</i>
<a name="IDX1386"></a>
</dt>
<dd><p>Returns the subset of the set <var>a</var> that satisfies the predicate <var>f</var>. 
</p>
<p><code>subset</code> returns a set which comprises the elements of <var>a</var>
for which <var>f</var> returns anything other than <code>false</code>.
<code>subset</code> does not apply <code>is</code> to the return value of <var>f</var>.
</p>
<p><code>subset</code> complains if <var>a</var> is not a literal set.
</p>
<p>See also <code>partition_set</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) subset ({1, 2, x, x + y, z, x + y + z}, atom);
(%o1)                     {1, 2, x, z}
(%i2) subset ({1, 2, 7, 8, 9, 14}, evenp);
(%o2)                      {2, 8, 14}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="subsetp"></a>
<a name="Item_003a-subsetp"></a>
</p><dl>
<dt><u>Function:</u> <b>subsetp</b><i> (<var>a</var>, <var>b</var>)</i>
<a name="IDX1387"></a>
</dt>
<dd><p>Returns <code>true</code> if and only if the set <var>a</var> is a subset of <var>b</var>.
</p>
<p><code>subsetp</code> complains if either <var>a</var> or <var>b</var> is not a literal set.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) subsetp ({1, 2, 3}, {a, 1, b, 2, c, 3});
(%o1)                         true
(%i2) subsetp ({a, 1, b, 2, c, 3}, {1, 2, 3});
(%o2)                         false
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Predicate-functions">Predicate functions</a>
</p>
</div>


</dd></dl>

<p><a name="symmdifference"></a>
<a name="Item_003a-symmdifference"></a>
</p><dl>
<dt><u>Function:</u> <b>symmdifference</b><i> (<var>a_1</var>, ..., <var>a_n</var>)</i>
<a name="IDX1388"></a>
</dt>
<dd><p>Returns the symmetric difference of sets <code> <var>a_1</var>, ..., <var>a_n</var></code>.
Given two arguments, <code>symmdifference ( <var>a</var>, <var>b</var>)</code> is
the same as <code>union ( setdifference ( <var>a</var>, <var>b</var>), setdifference(<var>b</var>, <var>a</var>))</code>.
</p>
<p><code>symmdifference</code> complains if any argument is not a literal set.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) S_1 : {a, b, c};
(%o1)                       {a, b, c}
(%i2) S_2 : {1, b, c};
(%o2)                       {1, b, c}
(%i3) S_3 : {a, b, z};
(%o3)                       {a, b, z}
(%i4) symmdifference ();
(%o4)                          {}
(%i5) symmdifference (S_1);
(%o5)                       {a, b, c}
(%i6) symmdifference (S_1, S_2);
(%o6)                        {1, a}
(%i7) symmdifference (S_1, S_2, S_3);
(%o7)                        {1, b, z}
(%i8) symmdifference ({}, S_1, S_2, S_3);
(%o8)                        {1,b, z}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="tree_005freduce"></a>
<a name="Item_003a-tree_005freduce"></a>
</p><dl>
<dt><u>Function:</u> <b>tree_reduce</b><i> (<var>F</var>, <var>s</var>)</i>
<a name="IDX1389"></a>
</dt>
<dt><u>Function:</u> <b>tree_reduce</b><i> (<var>F</var>, <var>s</var>, <var>s_0</var>)</i>
<a name="IDX1390"></a>
</dt>
<dd><p>Extends the binary function <var>F</var> to an n-ary function by composition,
where <var>s</var> is a set or list.
</p>
<p><code>tree_reduce</code> is equivalent to the following:
Apply <var>F</var> to successive pairs of elements
to form a new list <code>[<var>F</var>(<var>s_1</var>, <var>s_2</var>), <var>F</var>(<var>s_3</var>, <var>s_4</var>), ...]</code>,
carrying the final element unchanged if there are an odd number of elements.
Then repeat until the list is reduced to a single element, which is the return value.
</p>
<p>When the optional argument <var>s_0</var> is present,
the result is equivalent <code>tree_reduce(<var>F</var>, cons(<var>s_0</var>, <var>s</var>)</code>.
</p>
<p>For addition of floating point numbers,
<code>tree_reduce</code> may return a sum that has a smaller rounding error
than either <code>rreduce</code> or <code>lreduce</code>.
</p>
<p>The elements of <var>s</var> and the partial results may be arranged in a minimum-depth binary tree,
thus the name &quot;tree_reduce&quot;.
</p>
<p>Examples:
</p>
<p><code>tree_reduce</code> applied to a list with an even number of elements.
</p>
<pre class="example">(%i1) tree_reduce (f, [a, b, c, d]);
(%o1)                  f(f(a, b), f(c, d))
</pre>
<p><code>tree_reduce</code> applied to a list with an odd number of elements.
</p>
<pre class="example">(%i1) tree_reduce (f, [a, b, c, d, e]);
(%o1)               f(f(f(a, b), f(c, d)), e)
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>

<p><a name="union"></a>
<a name="Item_003a-union"></a>
</p><dl>
<dt><u>Function:</u> <b>union</b><i> (<var>a_1</var>, ..., <var>a_n</var>)</i>
<a name="IDX1391"></a>
</dt>
<dd><p>Returns the union of the sets <var>a_1</var> through <var>a_n</var>. 
</p>
<p><code>union()</code> (with no arguments) returns the empty set.
</p>
<p><code>union</code> complains if any argument is not a literal set.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) S_1 : {a, b, c + d, %e};
(%o1)                   {%e, a, b, d + c}
(%i2) S_2 : {%pi, %i, %e, c + d};
(%o2)                 {%e, %i, %pi, d + c}
(%i3) S_3 : {17, 29, 1729, %pi, %i};
(%o3)                {17, 29, 1729, %i, %pi}
(%i4) union ();
(%o4)                          {}
(%i5) union (S_1);
(%o5)                   {%e, a, b, d + c}
(%i6) union (S_1, S_2);
(%o6)              {%e, %i, %pi, a, b, d + c}
(%i7) union (S_1, S_2, S_3);
(%o7)       {17, 29, 1729, %e, %i, %pi, a, b, d + c}
(%i8) union ({}, S_1, S_2, S_3);
(%o8)       {17, 29, 1729, %e, %i, %pi, a, b, d + c}
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
</p>
</div>


</dd></dl>

<p><a name="xreduce"></a>
<a name="Item_003a-xreduce"></a>
</p><dl>
<dt><u>Function:</u> <b>xreduce</b><i> (<var>F</var>, <var>s</var>)</i>
<a name="IDX1392"></a>
</dt>
<dt><u>Function:</u> <b>xreduce</b><i> (<var>F</var>, <var>s</var>, <var>s_0</var>)</i>
<a name="IDX1393"></a>
</dt>
<dd><p>Extends the function <var>F</var> to an n-ary function by composition,
or, if <var>F</var> is already n-ary, applies <var>F</var> to <var>s</var>.
When <var>F</var> is not n-ary, <code>xreduce</code> is the same as <code>lreduce</code>.
The argument <var>s</var> is a list.
</p>
<p>Functions known to be n-ary include
addition <code>+</code>, multiplication <code>*</code>, <code>and</code>, <code>or</code>, <code>max</code>,
<code>min</code>, and <code>append</code>.
Functions may also be declared n-ary by <code>declare(<var>F</var>, nary)</code>.
For these functions,
<code>xreduce</code> is expected to be faster than either <code>rreduce</code> or <code>lreduce</code>.
</p>
<p>When the optional argument <var>s_0</var> is present,
the result is equivalent to <code>xreduce(<var>s</var>, cons(<var>s_0</var>, <var>s</var>))</code>.
</p>
<p>Floating point addition is not exactly associative; be that as it may,
<code>xreduce</code> applies Maxima's n-ary addition when <var>s</var> contains floating point numbers.
</p>
<p>Examples:
</p>
<p><code>xreduce</code> applied to a function known to be n-ary.
<code>F</code> is called once, with all arguments.
</p>
<pre class="example">(%i1) declare (F, nary);
(%o1)                         done
(%i2) F ([L]) := L;
(%o2)                      F([L]) := L
(%i3) xreduce (F, [a, b, c, d, e]);
(%o3)         [[[[[(&quot;[&quot;, simp), a], b], c], d], e]
</pre>
<p><code>xreduce</code> applied to a function not known to be n-ary.
<code>G</code> is called several times, with two arguments each time.
</p>
<pre class="example">(%i1) G ([L]) := L;
(%o1)                      G([L]) := L
(%i2) xreduce (G, [a, b, c, d, e]);
(%o2)         [[[[[(&quot;[&quot;, simp), a], b], c], d], e]
(%i3) lreduce (G, [a, b, c, d, e]);
(%o3)                 [[[[a, b], c], d], e]
</pre>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Sets">Sets</a>
 &middot;
<a href="maxima_95.html#Category_003a-Lists">Lists</a>
</p>
</div>


</dd></dl>








<p><a name="Item_003a-Function-Definition"></a>
</p><hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC166" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima_39.html#SEC173" 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_79.html#SEC331" 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>April, 24 2010</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

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