summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/mathml/mmlprime.tex
blob: 811ba376b4e5c1280b209373f091ada840dbc695 (plain)
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
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
% language=uk

% author    : Hans Hagen
% copyright : PRAGMA ADE & ConTeXt Development Team
% license   : Creative Commons Attribution ShareAlike 4.0 International
% reference : pragma-ade.nl | contextgarden.net | texlive (related) distributions
% origin    : the ConTeXt distribution
%
% comment   : Because this manual is distributed with TeX distributions it comes with a rather
%             liberal license. We try to adapt these documents to upgrades in the (sub)systems
%             that they describe. Using parts of the content otherwise can therefore conflict
%             with existing functionality and we cannot be held responsible for that. Many of
%             the manuals contain characteristic graphics and personal notes or examples that
%             make no sense when used out-of-context.
%
% comment   : Some chapters might have been published in TugBoat, the NTG Maps, the ConTeXt
%             Group journal or otherwise. Thanks to the editors for corrections. Also thanks
%             to users for testing, feedback and corrections.

% \setupbackend[export=yes]

\usemodule[abr-02,mathml,math-coverage,asciimath]

% \enabletrackers[xml.entities]

% \showframe

\setupindenting
  [medium,next,yes]

\setupinteraction
  [state=start,
   color=,
   style=]

\placebookmarks
  [chapter,section]

% was: \doifelsemode {atpragma} { } { }

\doifelsefontpresent {LucidaBrightOT.otf} {
    \setupbodyfont[lucidaot,10pt]
    \definefontsynonym[NiceBold][Handwriting]
} {
    \setupbodyfont[pagella,11pt]
    \definefontsynonym[NiceBold][SerifBold]
}

\definefont[ChapterFont][NiceBold*default at 32pt]
\definefont[SectionFont][NiceBold*default sa 1.2]
\definefont[FormulaFont][NiceBold*default sa 1.0]

\setuplayout
  [topspace=15mm,
   backspace=15mm,
   header=10mm,
   headerdistance=5mm,
   footer=10mm,
   footerdistance=5mm,
   width=middle,
   height=middle]

\setuppagenumbering
  [alternative=doublesided]

\setuphead
  [chapter]
  [alternative=middle,
   number=no,
   style=ChapterFont,
   color=darkred,
   after={\blank[3*big]},
   header=high,
   footer=startofchapter]

\setuphead
  [section]
  [command=\SectionCommand,
   style=SectionFont,
   textcolor=darkred,
   after={\blank[big]}]

\setuphead
  [subsection]
  [command=\SubSectionCommand,
   style=SectionFont,
   textcolor=darkred,
   after={\blank[big]}]

\unexpanded\def\SectionCommand#1#2%
  {\darkblue<--\enspace\ifconditional\headshownumber\enspace#1\quad\fi#2\enspace-->}

\unexpanded\def\SubSectionCommand#1#2%
  {\darkblue<?\enspace\ifconditional\headshownumber#1\quad\fi#2\enspace ?>}

\setuplayout
  [style=\hw]

\setuppagenumbering
  [color=darkblue]

\setupheader
  [color=darkblue]

\setupfooter
  [color=darkblue]

\setuplinewidth
  [1pt]

\setuptabulate
  [rulecolor=darkblue]

\setuptables
  [rulecolor=darkblue]

\setupfootertexts
  [chapter]

\definetext
  [startofchapter]
  [footer][pagenumber]

\definestartstop
  [mmlelement]
  [style=\it]

\definestartstop
  [attvalue]
  [style=\it]

\definestartstop
  [entity]
  [style=\it,
   left=\textampersand,
   right=;]

\setuplist
  [chapter]
  [interaction=all,
   alternative=b,
   aligntitle=yes,
   textstyle=bold,
   numberstyle=bold,
   textcolor=darkblue,
   numbercolor=darkblue,
   after=\blank]

\setuplist
  [section]
  [interaction=all,
   alternative=b,
   maxwidth=.8\hsize,
   aligntitle=yes]

\definetabulate
  [directives]
  [| T l | T l | T l | l |]

\definetabulate
  [attributes]
  [| T l | T l | l | l |]

\definetabulate
  [mathmlattributes]
  [| B l w(2.5cm) T CT{darkred} | T l | c | p |]

\starttabulatehead[mathmlattributes]
    \FL
\stoptabulatehead

\starttabulatetail[mathmlattributes]
    \LL
\stoptabulatetail

\starttexdefinition unexpanded ExampleLine #1
    \noindentation % \dontleavehmode
    \type[color=darkblue]{#1}\quad\quad\asciimath{#1}
    \blank[big]
\stoptexdefinition


\setupformulas
  [way=bytext]

% isolated content

\startbuffer[derivates]
    \showXMLfile {derivate}{pc-d-001}
    \showXMLfile {derivate}{pc-d-002}
    \showXMLfile {derivate}{pc-d-003}
    \showXMLfile {derivate}{pc-d-004}
    \showXMLfile {derivate}{pc-d-005}
    \showXMLfile {derivate}{pc-d-006}
    \showXMLfile {derivate}{pc-d-007}
    \showXMLfile {derivate}{pc-d-008}
    \showXMLfile {derivate}{pc-d-009}
    \showXMLfile {derivate}{pc-d-010}
    \showXMLfile {derivate}{pc-d-011}
    \showXMLfile {derivate}{pc-d-043}
    %showXMLfile {derivate}{pc-d-051}
\stopbuffer

\startbuffer[integrals]
    \showXMLfile {integral}{pc-i-022}
    \showXMLfile {integral}{pc-i-061}
    \showXMLfile {integral}{pc-i-380}
\stopbuffer

\startbuffer[series]
    \showXMLfile {serie}{pc-s-001}
    \showXMLfile {serie}{pc-s-002}
    \showXMLfile {serie}{pc-s-003}
    \showXMLfile {serie}{wh-s-001}
    \showXMLfile {serie}{wh-s-002}
\stopbuffer

\startbuffer[logs]
    \showXMLfile {log}{wh-l-001}
    \showXMLfile {log}{wh-l-002}
    \showXMLfile {log}{wh-l-003}
    \showXMLfile {log}{wh-l-004}
\stopbuffer

\startbuffer[goniometrics]
    \showXMLfile {gonio}{wh-g-001}
    \showXMLfile {gonio}{wh-g-002}
    \showXMLfile {gonio}{wh-g-003}
    \showXMLfile {gonio}{wh-g-004}
    \showXMLfile {gonio}{wh-g-005}
    \showXMLfile {gonio}{wh-g-006}
    \showXMLfile {gonio}{wh-g-007}
    \showXMLfile {gonio}{wh-g-008}
    \showXMLfile {gonio}{wh-g-009}
    \showXMLfile {gonio}{wh-g-010}
    \showXMLfile {gonio}{wh-g-011}
    \showXMLfile {gonio}{wh-g-012}
    \showXMLfile {gonio}{wh-g-013}
    \showXMLfile {gonio}{wh-g-014}
    \showXMLfile {gonio}{wh-g-015}
    \showXMLfile {gonio}{wh-g-016}
\stopbuffer

\startbuffer[statistics]
    \showXMLfile {statistic}{wh-o-001}
    \showXMLfile {statistic}{wh-o-002}
    \showXMLfile {statistic}{wh-o-003}
\stopbuffer

\startbuffer[matrices]
    \showXMLfile {matrix}{wh-m-001}
    \showXMLfile {matrix}{wh-m-002}
\stopbuffer

% buffers voor de presentational MathML attributes

\startbuffer[mi-mn]
    \startmathmlattributes
    \NC mi, mn \NC class, id, style \NC -- \NC \NC\NR
    \NC        \NC dir              \NC -- \NC \NC\NR
    \NC        \NC href             \NC -- \NC \NC\NR
    \NC        \NC mathbackground   \NC -- \NC \NC\NR
    \NC        \NC mathcolor        \NC -- \NC \NC\NR
    \NC        \NC mathsize         \NC -- \NC \NC\NR
    \NC        \NC mathvariant      \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mo]
    \startmathmlattributes
    \NC mo \NC accent           \NC -- \NC   \NC\NR
    \NC    \NC class, id, style \NC -- \NC   \NC\NR
    \NC    \NC dir              \NC -- \NC   \NC\NR
    \NC    \NC fence            \NC -- \NC   \NC\NR
    \NC    \NC form             \NC -- \NC   \NC\NR
    \NC    \NC href             \NC -- \NC   \NC\NR
    \NC    \NC largeop          \NC -- \NC   \NC\NR
    \NC    \NC lspace           \NC -- \NC   \NC\NR
    \NC    \NC mathbackground   \NC -- \NC   \NC\NR
    \NC    \NC mathcolor        \NC -- \NC   \NC\NR
    \NC    \NC mathsize         \NC -- \NC   \NC\NR
    \NC    \NC mathvariant      \NC -- \NC   \NC\NR
    \NC    \NC maxsize          \NC +  \NC If stretchy is true, this attribute specifies the maximum size of the operator. Allowed values are: \quote{infinity} or an arbitrary length. \NC\NR
    \NC    \NC minsize          \NC -- \NC   \NC\NR
    \NC    \NC movablelimits    \NC -- \NC   \NC\NR
    \NC    \NC rspace           \NC -- \NC   \NC\NR
    \NC    \NC separator        \NC -- \NC   \NC\NR
    \NC    \NC stretchy         \NC -- \NC   \NC\NR
    \NC    \NC symmetric        \NC -- \NC   \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mrow]
    \startmathmlattributes
    \NC mrow \NC class, id, style \NC -- \NC \NC\NR
    \NC      \NC dir              \NC -- \NC \NC\NR
    \NC      \NC href             \NC -- \NC \NC\NR
    \NC      \NC mathbackground   \NC -- \NC \NC\NR
    \NC      \NC mathcolor        \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[msub]
    \startmathmlattributes
    \NC msub \NC class, id, style \NC -- \NC \NC\NR
    \NC      \NC href             \NC -- \NC \NC\NR
    \NC      \NC mathbackground   \NC -- \NC \NC\NR
    \NC      \NC mathcolor        \NC -- \NC \NC\NR
    \NC      \NC subscriptshift   \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[msup]
    \startmathmlattributes
    \NC msup \NC class, id, style \NC -- \NC \NC\NR
    \NC      \NC href             \NC -- \NC \NC\NR
    \NC      \NC mathbackground   \NC -- \NC \NC\NR
    \NC      \NC mathcolor        \NC -- \NC \NC\NR
    \NC      \NC superscriptshift \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[msubsup]
    \startmathmlattributes
    \NC msubsup \NC class, id, style \NC -- \NC \NC\NR
    \NC         \NC href             \NC -- \NC \NC\NR
    \NC         \NC mathbackground   \NC -- \NC \NC\NR
    \NC         \NC mathcolor        \NC -- \NC \NC\NR
    \NC         \NC subscriptshift   \NC -- \NC \NC\NR
    \NC         \NC superscriptshift \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mfrac]
    \startmathmlattributes
    \NC mfrac \NC bevelled         \NC +  \NC Specifies the way the fraction is displayed. If true, the fraction line is bevelled, which means that numerator and denominator are displayed side by side and separated by a slash (/). \NC\NR
    \NC       \NC class, id, style \NC -- \NC \NC\NR
    \NC       \NC denomalign       \NC -- \NC \NC\NR
    \NC       \NC href             \NC -- \NC \NC\NR
    \NC       \NC linethickness    \NC +  \NC The thickness of the horizontal fraction line. The default value is medium, but thin, thick, and other values can be set. \NC\NR
    \NC       \NC mathbackground   \NC -- \NC \NC\NR
    \NC       \NC mathcolor        \NC -- \NC \NC\NR
    \NC       \NC numalign         \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mfenced]
    \startmathmlattributes
    \NC mfenced \NC class, id, style \NC -- \NC \NC\NR
    \NC         \NC close            \NC +  \NC A string for the closing delimiter. The default value is \quote{)} and any white space is trimmed. \NC\NR
    \NC         \NC href             \NC -- \NC \NC\NR
    \NC         \NC mathbackground   \NC -- \NC \NC\NR
    \NC         \NC mathcolor        \NC -- \NC \NC\NR
    \NC         \NC open             \NC +  \NC A string for the opening delimiter. The default value is \quote{(} and any white space is trimmed. \NC\NR
    \NC         \NC separators       \NC +  \NC A sequence of zero or more characters to be used for different separators, optionally divided by white space, which is ignored. The default value is \quote{,}. \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[msqrt-mroot]
    \startmathmlattributes
    \NC msqrt, mroot \NC class, id, style \NC -- \NC \NC\NR
    \NC              \NC href             \NC -- \NC \NC\NR
    \NC              \NC mathbackground   \NC -- \NC \NC\NR
    \NC              \NC mathcolor        \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mtext]
    \startmathmlattributes
    \NC mtext \NC class, id, style \NC -- \NC \NC\NR
    \NC       \NC dir              \NC -- \NC \NC\NR
    \NC       \NC href             \NC -- \NC \NC\NR
    \NC       \NC mathbackground   \NC -- \NC \NC\NR
    \NC       \NC mathcolor        \NC -- \NC \NC\NR
    \NC       \NC mathsize         \NC -- \NC \NC\NR
    \NC       \NC mathvariant      \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mover]
    \startmathmlattributes
    \NC mover \NC accent           \NC -- \NC \NC\NR
    \NC       \NC align            \NC -- \NC \NC\NR
    \NC       \NC class, id, style \NC -- \NC \NC\NR
    \NC       \NC href             \NC -- \NC \NC\NR
    \NC       \NC mathbackground   \NC -- \NC \NC\NR
    \NC       \NC mathcolor        \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[munder]
    \startmathmlattributes
    \NC munder \NC accentunder      \NC -- \NC \NC\NR
    \NC        \NC align            \NC -- \NC \NC\NR
    \NC        \NC class, id, style \NC -- \NC \NC\NR
    \NC        \NC href             \NC -- \NC \NC\NR
    \NC        \NC mathbackground   \NC -- \NC \NC\NR
    \NC        \NC mathcolor        \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[munderover]
    \startmathmlattributes
    \NC munderover \NC accent           \NC -- \NC \NC\NR
    \NC            \NC accentunder      \NC -- \NC \NC\NR
    \NC            \NC align            \NC -- \NC \NC\NR
    \NC            \NC class, id, style \NC -- \NC \NC\NR
    \NC            \NC href             \NC -- \NC \NC\NR
    \NC            \NC mathbackground   \NC -- \NC \NC\NR
    \NC            \NC mathcolor        \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[ms]
    \startmathmlattributes
    \NC ms \NC class, id, style \NC -- \NC \NC\NR
    \NC    \NC dir              \NC -- \NC \NC\NR
    \NC    \NC lquote           \NC +  \NC The opening quote character (depends on dir) to enclose the content. The default value is \type{"}. \NC\NR
    \NC    \NC href             \NC -- \NC \NC\NR
    \NC    \NC mathbackground   \NC -- \NC \NC\NR
    \NC    \NC mathcolor        \NC -- \NC \NC\NR
    \NC    \NC mathsize         \NC -- \NC \NC\NR
    \NC    \NC mathvariant      \NC -- \NC \NC\NR
    \NC    \NC rquote           \NC +  \NC The closing quote mark (depends on dir) to enclose the content. The default value is \type{"}. \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[menclose]
    \startmathmlattributes
    \NC menclose \NC class, id, style \NC -- \NC \NC\NR
    \NC          \NC href             \NC -- \NC \NC\NR
    \NC          \NC mathbackground   \NC -- \NC \NC\NR
    \NC          \NC mathcolor        \NC -- \NC \NC\NR
    \NC          \NC notation         \NC +  \NC A list of notations, separated by white space, to apply to the child elements. The symbols are each drawn as if the others are not present, and therefore may overlap. Supported values are:
                                    longdiv, actuarial, radiacal, rule ({\em private}), box downdiagonalstrike, roundedbox updiagonalstrike, circle verticalstrike horizontalstrike, right bottom horizontalstrike, etc. \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[merror]
    \startmathmlattributes
    \NC merror \NC class, id, style \NC -- \NC \NC\NR
    \NC        \NC href             \NC -- \NC \NC\NR
    \NC        \NC mathbackground   \NC -- \NC \NC\NR
    \NC        \NC mathcolor        \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mmultiscripts]
    \startmathmlattributes
    \NC mmultiscripts \NC class, id, style \NC -- \NC \NC\NR
    \NC               \NC href             \NC -- \NC \NC\NR
    \NC               \NC mathbackground   \NC -- \NC \NC\NR
    \NC               \NC mathcolor        \NC -- \NC \NC\NR
    \NC               \NC subscriptshift   \NC -- \NC \NC\NR
    \NC               \NC superscriptshift \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mspace]
    \startmathmlattributes
    \NC mspace \NC class, id, style \NC -- \NC \NC\NR
    \NC        \NC depth            \NC -- \NC \NC\NR
    \NC        \NC height           \NC -- \NC \NC\NR
    \NC        \NC linebreak        \NC -- \NC \NC\NR
    \NC        \NC mathbackground   \NC -- \NC \NC\NR
    \NC        \NC spacing          \NC -- \NC The desired width of the space. \NC\NR  % AFO: bestaat attribuut echt?
    \NC        \NC width            \NC -- \NC The desired width of the space. \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mphantom]
    \startmathmlattributes
    \NC mphantom \NC class, id, style \NC -- \NC \NC\NR
    \NC          \NC mathbackground   \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mpadded]
    \startmathmlattributes
    \NC mpadded \NC class, id, style \NC -- \NC \NC\NR
    \NC         \NC depth            \NC -- \NC \NC\NR
    \NC         \NC height           \NC -- \NC \NC\NR
    \NC         \NC href             \NC -- \NC \NC\NR
    \NC         \NC lspace           \NC -- \NC \NC\NR
    \NC         \NC mathbackground   \NC -- \NC \NC\NR
    \NC         \NC mathcolor        \NC -- \NC \NC\NR
    \NC         \NC voffset          \NC -- \NC \NC\NR
    \NC         \NC width            \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mtable]
    \startmathmlattributes
    \NC mtable \NC align             \NC -- \NC \NC\NR
    \NC        \NC alignmentscope    \NC -- \NC \NC\NR
    \NC        \NC class, id, style  \NC -- \NC \NC\NR
    \NC        \NC columnalign       \NC +  \NC Specifies the horizontal alignment of the cells. Multiple values separated by space are allowed and apply to the corresponding columns (e.g. \type{columnalign="left right center"}). Possible values are: left, center (default) and right. \NC\NR
    \NC        \NC columnlines       \NC -- \NC \NC\NR
    \NC        \NC columnspacing     \NC +  \NC Specifies the space between table columns. \NC\NR
    \NC        \NC columnwidth       \NC -- \NC \NC\NR
    \NC        \NC displaystyle      \NC -- \NC \NC\NR
    \NC        \NC equalcolumns      \NC -- \NC \NC\NR
    \NC        \NC equalrows         \NC -- \NC \NC\NR
    \NC        \NC frame             \NC -- \NC \NC\NR
    \NC        \NC framespacing      \NC -- \NC \NC\NR
    \NC        \NC groupalign        \NC -- \NC \NC\NR
    \NC        \NC href              \NC -- \NC \NC\NR
    \NC        \NC mathbackground    \NC +  \NC The background color. \NC\NR
    \NC        \NC mathcolor         \NC +  \NC The text color. \NC\NR
    \NC        \NC minlabelspacing   \NC -- \NC \NC\NR
    \NC        \NC rowalign          \NC -- \NC \NC\NR
    \NC        \NC rowlines          \NC -- \NC \NC\NR
    \NC        \NC rowspacing        \NC +  \NC Specifies the space between table rows. \NC\NR
    \NC        \NC side              \NC -- \NC \NC\NR
    \NC        \NC width             \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mtr-mlabeledtr]
    \startmathmlattributes
    \NC mtr, labeledtr \NC class, id, style \NC -- \NC \NC\NR
    \NC                \NC columnalign      \NC +  \NC Overrides the horizontal alignment of cells specified by <mtable> for this row. \NC\NR
    \NC                \NC groupalign       \NC -- \NC \NC\NR
    \NC                \NC href             \NC -- \NC \NC\NR
    \NC                \NC mathbackground   \NC +  \NC The background color. \NC\NR
    \NC                \NC mathcolor        \NC +  \NC The text color. \NC\NR
    \NC                \NC rowalign         \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mtd]
    \startmathmlattributes
    \NC mtd \NC class, id, style \NC -- \NC \NC\NR
    \NC     \NC columnalign      \NC -- \NC \NC\NR
    \NC     \NC columnspan       \NC -- \NC \NC\NR
    \NC     \NC frame            \NC -- \NC Specifies whether the cell gets a frame. \NC\NR % AFO: wordt niet genoemd in Mozilla overview
    \NC     \NC groupalign       \NC -- \NC \NC\NR
    \NC     \NC href             \NC -- \NC \NC\NR
    \NC     \NC mathbackground   \NC -- \NC \NC\NR
    \NC     \NC mathcolor        \NC -- \NC \NC\NR
    \NC     \NC rowalign         \NC -- \NC \NC\NR
    \NC     \NC rowspan          \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[malignmark]
    \startmathmlattributes
    \NC malignmark \NC class, id, style \NC -- \NC \NC\NR
    \NC            \NC edge             \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mglyph]
    \startmathmlattributes
    \NC mglyph \NC alt              \NC  + \NC This attribute defines the alternative text describing the image. \NC\NR
    \NC        \NC class, id, style \NC -- \NC \NC\NR
    \NC        \NC height           \NC -- \NC \NC\NR
    \NC        \NC href             \NC -- \NC \NC\NR
    \NC        \NC mathbackground   \NC -- \NC \NC\NR
    \NC        \NC src              \NC -- \NC \NC\NR
    \NC        \NC valign           \NC -- \NC \NC\NR
    \NC        \NC width            \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

\startbuffer[mstyle]
    \startmathmlattributes
    \NC mstyle \NC dir                  \NC -- \NC \NC\NR
    \NC        \NC decimalpoint         \NC -- \NC \NC\NR
    \NC        \NC displaystyle         \NC -- \NC \NC\NR
    \NC        \NC infixlinebreakstyle  \NC -- \NC \NC\NR
    \NC        \NC scriptlevel          \NC +  \NC Controls mostly the font-size. The higher the scriptlevel, the smaller the font size. This attribute accepts a non-negative integer, as well as a \quote{+} or a \quote{--} sign, which increments or decrements the current value. \NC\NR
    \NC        \NC scriptminsize        \NC -- \NC \NC\NR
    \NC        \NC scriptsizemultiplier \NC -- \NC \NC\NR
    \stopmathmlattributes
\stopbuffer

% some helpers

\startxmlsetups xml:mmlprime
    \xmlsetsetup {\xmldocument} {document} {xml:mmlprime:document}
    \xmlsetsetup {\xmldocument} {textref}  {xml:mmlprime:textref}
\stopxmlsetups

\xmlregistersetup{xml:mmlprime}

\startxmlsetups xml:mmlprime:document
    \blank \start
    \xmlflush{#1}
    \stop \blank
\stopxmlsetups

\startxmlsetups xml:mmlprime:textref
    \in {\xmlflush{#1}} [\xmlatt{#1}{label}]
\stopxmlsetups

% redefine to use lua and mkiv xml instead of slower mkii

\startluacode
    local gsub = string.gsub
    local mapping = {
        [";"] = "{{\\darkblue\\string;}}",
        ["&"] = "{{\\ttsl\\darkblue\\string&}}", -- otherwise "et"
        ["/"] = "{{\\darkblue\\string/}}",
        ["<"] = "{{\\darkblue\\string<}}",
        [">"] = "{{\\darkblue\\string>}}",
    }
    function document.filterxmltitlestuff(name)
        local data = io.loaddata(name) or ""
        data = gsub(data,"<math[^>]*>","<math>")
        data = gsub(data,"[%s ]+"," ")
        data = gsub(data,"(.)",mapping)
        context(data)
    end
\stopluacode

\starttexdefinition unexpanded showXMLfileA #1#2
    \ignorespaces
    \ctxlua{document.filterxmltitlestuff("#2.xml")}
    \removeunwantedspaces
    \space
    \ignorespaces
\stoptexdefinition

\startluacode
    function document.filenumber(str)
        context(string.match(str,"([1-9][0-9]*)$"))
    end
\stopluacode

\starttexdefinition unexpanded showXMLfileB #1#2
    \bgroup
        \setuplabeltext[formula=#1\space]
        \setnumber[formula][\ctxlua{document.filenumber("#2")}]
        \decrementnumber[formula]
        \placeformula
            \startformula
                \processxmlfile{#2.xml}
            \stopformula
   \egroup
   \typefile{#2.xml}
   \page[bigpreference]
\stoptexdefinition

\startsetups showexamples

    \setupformulas
      [left=,
       right=,
       location=left,
       numberstyle=FormulaFont,
       numbercolor=darkblue]

    \resetnumber[formula]

    \let\showXMLfile\showXMLfileB

\stopsetups

\startsetups TitlePageBackground
    \setbox\scratchbox=\vbox to \paperheight {
        \hsize\paperwidth
        \definedfont[NiceBold*default at 7pt]
        \setupinterlinespace
        \let\showXMLfile\showXMLfileA
        \baselineskip=1\baselineskip plus 1pt
        \getbuffer[derivates]
        \getbuffer[integrals]
        \getbuffer[series]
        \getbuffer[logs]
        \getbuffer[goniometrics]
        \getbuffer[statistics]
        \getbuffer[matrices]
    }
    \setbox\scratchbox=\vsplit\scratchbox to \paperheight
    \vbox to \paperheight {
        \unvbox\scratchbox
        \vskip-.2ex
    }
\stopsetups

\defineoverlay
  [titlepage]
  [\directsetup{TitlePageBackground}]

\settaggedmetadata
  [title={MathML},
   author={Hans Hagen},
   version={January 2001 / June 2008 / June 2011},
   copyright={PRAGMA ADE, Hasselt, NL},
   url={www.pragma-ade.com / www.pragma-ade.nl}]

\starttext

\setupbackgrounds
  [page]
  [background={foreground,titlepage}]

\startelement[ignore]

    \startstandardmakeup[footerstate=none,doublesided=no,page=]
        \setupalign[left]
        \definefont[BigFont][RegularBold at 108pt]
        \definefont[MedFont][RegularBold at  48pt]
        \vfill
        \BigFont \darkred MathML     \par
        \vskip6pt
        \MedFont \darkred HANS HAGEN \par
    \stopstandardmakeup

\stopelement

\setupbackgrounds
  [page]
  [background=]

\startelement[ignore]

    \startstandardmakeup[footerstate=none,doublesided=no,page=]
        \startpacked
        Hans Hagen \par
        Hassel NL \par
        \goto{www.pragma-ade.com}[url(http://www.pragma-ade.com)] \par
        January  2001 /
        June     2008 /
        June     2011 /
        February 2015\par
        \stoppacked
        \vfill
      % More changes and additions can be expected when there is a definitive
      % version of the \MATHML~3 specification and more correct testsuite. One
      % thing we need to look into is the nesting model dealing with ()
      % discussed in the spec.
        \blank
        \start
        \starttabulate
        \NC \color[darkblue]{copyright} \EQ PRAGMA ADE, Hasselt, NL \NC \NR
        \NC \color[darkblue]{version}   \EQ \currentdate \NC \NR
        \NC \color[darkblue]{renderer}  \EQ \doifmodeelse{mkiv}{version 1 / mkiv}{\doifsetupselse{mmc:apply:start}{version 2}{version 3} / mkii} \NC \NR
        \stoptabulate
        \stop
    \stopstandardmakeup

\stopelement

\startfrontmatter

\starttitle[title={Table of Contents}]

\startmixedcolumns[n=3,separator=rule,rulecolor=darkblue,rulethickness=1pt,blank={line,fixed},balance=no]
    \placelist[chapter,section]
\stopmixedcolumns

\stoptitle

\startchapter[title={introduction}]

It is a well known fact that \TEX\ can do a pretty good job on typesetting math.
This is one reason why many scientific articles, papers and books are typeset
using \TEX. However, in these days of triumphing angle brackets, coding in \TEX\
looks more and more out of place.

From the point of view of an author, coding in \TEX\ is quite natural, given that
some time is spent on reading the manuals. This is because not only the natural
flow of the definition suits the way mathematicians think, but also because the
author has quite some control over the way his thoughts end up on paper. It will
be no surprise that switching to a more restricted way of coding, which also
demands more keystrokes, is not beforehand considered to be better.

There are however circumstances that one wants to share formulas (or
formula||like specifications) between several applications, one of which is a
typesetting engine. In that case, a bit more work now, later saves you some
headaches due to keeping the different source documents in sync.

The moment coding math in \XML\ is discussed, those in favour stress that coding
can be eased by using appropriate editors. Here we encounter a dilemma. For
optimal usage, one should code in terms of content, that is, the principles that
are expressed in a formula. Editors are not that strong in this area, and if they
would be, editing would be not that much different from traditionally editing
formulas: just keying in ideas using code that at first sight looks obscure. A
more graphical oriented editor can help authors to compose formulas, but the
underlaying coding will mainly be in terms of placing glyphs and boxes, and as a
result the code will hardly be usable in other applications.

So either we code in terms of concepts, which permits sharing code among
applications, and poses strong limitations on the influence of authors on the
visual appearance. Or we use an interactive editor to fine tune the appearance of
a formula and take for granted that reuse will be minimal or suboptimal.

In the following chapters we will discuss the mathematical language \MATHML\ in
the perspective of typography. As a typesetting vehicle, we have used \CONTEXT.
However, the principles introduced here and the examples that we provide are
independent of \CONTEXT. For a more formal exploration we recommend the \MATHML\
specification.

This document is dedicated to all those \CONTEXT\ users who like typesetting
math. I'm sure that my father, who was a math teacher, would have liked
proofreading this document. His absence was compensated by Tobias Burnus, Wang
Lei, Ton Otten, and later members of the \CONTEXT\ mailing list who carefully
read the text, corrected the errors in my math, tested the functionality, and
made suggestions. Any remaining errors are mine.

When we started supporting \MATHML\ we were under the impression that it would be
accepted and take of fast, but we were wrong. It toke much more than a decade for
instance to see browsers support rendering. Being involved in typesetting
educational content from \XML\ files, we could use this subsystem ourselves, and
this was useful in the sense that we ran into lots of contradicting and
suboptimal \MATHML\ code. However, the most interesting application has always
been in the math4all project, where we went from \TEX\ math, via content \MATHML\
and open math to presentational \MATHML. Nowadays web usage drives the coding and
limitations in other programs (and rendering) are sometimes compensated by coding
and our renderer then has to be able to recover nicely. Thanks to the enormous
productivity of the main math4all author Frits Spijkers and the careful checking
by my collegue Ton Otten, we could always keep op well. Development and support
of the \CONTEXT\ typesetting system is mostly done without any commercial
benefits and the amount of free time that we spend on it and especially its more
obscure properties like \MATHML\ is compensated by flexible and tolerant users
like them.

One problem is that our own usage of \MATHML\ changes over time. Some of our
projects demand the use of this standard but at the same time the used sources
need to satisfy other needs, for instance rendering on the web. For some 15 years
now the changing demands and quality have made us oscillate between (often
suboptimal) solutions that deal with the suboptimal code that comes from
compromises. For instance the mentioned project is now using a mixture of
\MATHML\ and so called \ASCII math because that is the only way the enormous
amount of math code can be rendered on the web. And even there we need to bend
the rules, for instance to compensate for missing features or cultural
differences. Eventually I will rewrite the rendering from scratch but I need time
and a very good reason for that.

This version of the manual is produced by \CONTEXT\ \MKIV\ and is also used as
testcase. The version rendered at \PRAGMA\ uses the Lucida Bright fonts. These
can be bought at \goto {www.tug.org} [url(http://{www.tug.org})] for a reasonable
low price and are really worth the money.

\startlines
Hans Hagen
PRAGMA ADE
Hasselt NL
2001 \emdash\ \currentdate[year]
\stoplines

\stopchapter

\stopfrontmatter

\startbodymatter

\startchapter[title={What is \MATHML}]

\startsection[title={backgrounds}]

\MATHML\ showed up in the evolving vacuum between structural \SGML\ markup and
presentational \HTML. Both \SGML\ and \HTML\ can be recognized by angle brackets.
The disadvantage of \SGML\ was that it was so open ended, that general tools
could hardly be developed. \HTML\ on the other hand was easy to use and became
extremely popular and users as well as software vendors quickly spoiled the
original ideas and created a mess. \SGML\ never became really popular, but thanks
to \HTML\ people became accustomed to that kind of notation. So, when \XML\ came
around as a more restricted cousin of \SGML, the world was kind of ready for it.
It cannot be denied that by some clever marketing many of today's users think
that they use something new and modern, while we are actually dealing with
something from the early days of computing. A main benefit of \XML\ is that it
brought the ideas behind \SGML\ (and medium neutral coding in general) to the
users and at the same time made a major cleanup of \HTML\ possible.

About the same time, \MATHML\ was defined, both to bring math to the \WWW, and to
provide a way of coding math that will stimulate sharing the same code between
different applications. At the end of 2000, the \MATHML\ version~2 draft became a
recommendation. In the process of rewriting the interpreter for \CONTEXT\ \MKIV\
mid 2008 a draft of \MATHML\ version~3 has been used.

Now, imagine that we want to present a document on the internet using a format
like \HTML, either for viewing or for being spoken. Converting text and graphics
is, given proper source coding, seldom a problem, but converting formulas into
some angle bracket representation is more tricky. A way out of this is \MATHML's
presentational markup.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> a </mi>
    <mo> + </mo>
    <mi> b </mi>
    <mo> = </mo>
    <mi> c </mi>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer

This simple formula, when coded in \TEX, looks like:

\starttyping
$$ a + b = c $$
\stoptyping

In presentational \MATHML\ we get:

\typebuffer

In presentational \MATHML, we use mostly begintags (\type {<mi>}) and end tags
(\type {</mi>}). The \mmlelement {mrow} element is the basic building block of a
formula. The \mmlelement {mi} element specifies a math identifier and \mmlelement
{mo} is used for operators. In the process of typesetting, both are subjected to
interpretation in order to get the best visualization.

Converting \TEX\ code directly or indirectly, using printable output or even
in||memory produced math lists, has been one of the driving forces behind
presentational \MATHML\ and other math related \DTD's like \EUROMATH. One may
wonder if there are sound and valid reasons for going the opposite way. You can
imagine that a converter from \TEX\ to \MATHML\ produces \mmlelement {menclose},
\mmlelement {mspace}, \mmlelement {mstyle} and other elements that can have many
spacing related attributes, but I wonder if any author is willing to think in
those quantities. Visual editors of course are good candidates for producing
presentational \MATHML.

But wouldn't it be more efficient if we could express ideas and concepts in such
a way that they could be handled by a broad range of applications, including a
typesetting engine? This is why, in addition to presentational \MATHML, there is
also content \MATHML. The previous formula, when coded in such a way, looks like:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <plus/>
      <ci> a </ci>
      <ci> b </ci>
    </apply>
    <ci> c </ci>
  </apply>
</math>
\stopbuffer

\typebuffer

This way of defining a formula resembles the so called polish (or stackwise)
notation. Opposite to presentational markup, here a typesetting engine has to
find out in what order and what way the content has to be presented. This may
seem a disadvantage, but in practice implementing content markup is not that
complicated. The big advantage is that, once we know how to typeset a concept,
\TEX\ can do a good job, while in presentational markup much hard coded spacing
can spoil everything. One can of course ignore specific elements, but it is more
safe to start from less and enhance, than to leave away something with unknown
quantities.

Instead of using hard coded operators as in presentational \MATHML, content
markup uses empty elements like \type {<plus/>}. Many operators and functions are
predefined but one can also define his own; in \MATHML~3 this is further extended
by adopting \OPENMATH\ as variant.

Of course the main question to be answered now is to what extent the author can
influence the appearance of a formula defined in content markup. Content markup
has the advantage that the results can be more consistent, but taking away all
control is counterproductive. The \MATHML\ level~2 draft mentions that this level
covers most of the pre university math. If so, that is a proper starting point,
but especially educational math often has to be typeset in such ways that it
serves its purpose. Also, (re|)|using the formulas in other applications
(simulators and alike) is useful in an educational setting, so content markup is
quite suitable.

How do we combine the advantages of content markup with the wish of an author to
control the visual output and at the same time get an as high as possible typeset
result. There are several ways to accomplish this. One is to include in the
document source both the content markup and the \TEX\ specific code.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <semantics>
    <apply> <eq/>
      <apply> <plus/>
        <ci> a </ci>
        <ci> b </ci>
      </apply>
    </apply>
    <ci> c </ci>
    <annotation encoding="TeX">a+b=c</annotation>
  </semantics>
</math>
\stopbuffer

\typebuffer

The \mmlelement {annotation} element is one of the few that is permitted inside
the \mmlelement {math} element. In this example, we embed pure \TEX\ code, which,
when enabled is typeset in math mode. It will be clear that for a simple formula
like this one, such redundant coding is not needed, but one can imagine more
complicated formulas. Because we want to limit the amount of work, we prefer just
content markup. \blank {\it Remark: Some characters, fillers or whatever may not
show up. This is due to the fact that the relevant tables for \CONTEXT\ \MKIV\
are defined stepwise. In due time most relevant symbols will be accessible.}

\stopsection

\startsection[title={two methods}]

The best way to learn \MATHML\ is to key in formulas, so that is what we did as
soon as we started adding \MATHML\ support to \CONTEXT. In some areas, \MATHML\
provides much detail (many functions are represented by elements) while in other
areas one has to fall back on the more generic function element or a full
description. Compare the following definitions:

\startbuffer[a]
<document>
  <math xmlns="http://www.w3c.org/mathml" version="2.0">
    <apply> <sin/> <ci> x </ci> </apply>
  </math>
  <math xmlns="http://www.w3c.org/mathml" version="2.0">
    <mrow> <mi> sin </mi> <mi> x </mi> </mrow>
  </math>
</document>
\stopbuffer

\typebuffer[a]

We prefer the first definition because it is more structured and gives more
control over the result. There is only one \quote {unknown} quantity, $x$, and
from the encapsulating element \mmlelement {ci} we know that it is an identifier.

\processxmlbuffer[a]

In the content example, from the \mmlelement {apply} \mmlelement {sin} we can
deduce that the following argument is an operand, either an \mmlelement {apply},
or a \mmlelement {ci} or \mmlelement {cn}. In the presentational alternative, the
following elements can be braces, a math identifier, a row, a sequence of
identifiers and operators, etc. There, the look and feel is hard coded.

\startbuffer[b]
<?context-mathml-directive function reduction no ?>
\stopbuffer

\typebuffer[b]

This directive, either issued in the \XML\ file, or set in the style file,
changes the appearance of the function, but only in content markup. It is because
of this feature, that we favour content markup.

\processxmlbuffer[b,a]

Does this mean that we can cover everything with content markup? The answer to
this is still unclear. Consider the following definition.

\processxmlfile {pc-i-380.xml}

Here we combine several cases in one formula by using $\pm$ and $\mp$ symbols.
Because we only have \mmlelement {plus} and \mmlelement {minus} elements, we have
to revert to the generic function element \mmlelement {fn}. We show the complete
definition of this formula.

\typefile {pc-i-380.xml}

The \MATHML\ parser and typesetting engine have to know how to handle these
special cases, because the visualization depends on the function (or operator).
Here both composed signs are treated like the plus and minus signs, but in other
cases an embraced argument may be needed.

\stopsection

\stopchapter

\startchapter[title={Presentational markup}]

\startsection[title=Introduction]

If a document contains presentational \MATHML, there is a good chance that the
code is output by an editor. Here we will discuss the presentation elements that
make sense for users when they want to manually code presentational \MATHML. In
this chapter we show the default rendering, later we will discuss options.

Although much is permitted, we advise to keep the code as simple as possible,
because then \TEX\ can do a rather good job on interpreting and typesetting it.
Just let \TEX\ take care of the spacing.

\stopsection

\startsection[title={mi, mn, mo}]

Presentational markup comes down to pasting boxes together in math specific ways.
The basic building blocks are these three character elements.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> x </mi> <mo> = </mo> <mn> 5 </mn>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\starttabulate[||||]
\HL
\NC \mmlelement {mi} \NC identifier \NC normally typeset in an italic font \NC \NR
\NC \mmlelement {mn} \NC number     \NC normally typeset in a normal font  \NC \NR
\NC \mmlelement {mo} \NC operator   \NC surrounded by specific spacing     \NC \NR
\HL
\stoptabulate

Because numbers are taken from an upright font, special numbers are taken care of
automatically. Here are some from the \MATHML\ specification:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mn> 2          </mn> <mtext>&nbsp;&nbsp;</mtext>
    <mn> 0.123      </mn> <mtext>&nbsp;&nbsp;</mtext>
    <mn> 0,000,000  </mn> <mtext>&nbsp;&nbsp;</mtext>
    <mn> 2.1e10     </mn> <mtext>&nbsp;&nbsp;</mtext>
    <mn> 0xFFeF     </mn> <mtext>&nbsp;&nbsp;</mtext>
    <mn> MCMLXIX    </mn> <mtext>&nbsp;&nbsp;</mtext>
    <mn> twenty one </mn> <mtext>&nbsp;&nbsp;</mtext>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Special characters can be accessed by their \UNICODE\ point or by a corresponding
entity. For some reason there is quite some duplication in entities, but we don't
bother too much about it because after all \UNICODE\ math (which has its own
peculiarities) is the way to go. The specification has this somewhat strange
formula definition:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mn> 2 </mn>
    <mo> + </mo>
    <mrow>
      <mn> 3</mn>
      <mo> &InvisibleTimes; </mo>
      <mi> &ImaginaryI; </mi>
    </mrow>
  </mrow>
  <mfrac>
    <mn> 1 </mn>
    <mn> 2 </mn>
  </mfrac>
  <mi> &pi; </mi>
  <mi> &ExponentialE; </mi>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

And:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfrac>
    <mo> &DifferentialD; </mo>
    <mrow>
      <mo> &DifferentialD; </mo>
      <mi> x </mi>
    </mrow>
  </mfrac>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Visualizing the \mmlelement {mo} element involved some heuristics. For instance
the size of fences depends on what they fence. In the following case you see how
we can influence this. For practical pusposes we only support size~1.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mo> ( </mo> <mi> x </mi>  <mo> ) </mo>
  </mrow>
  <mtext> or </mtext>
  <mrow>
    <mo maxsize="1"> ( </mo>  <mi> x </mi>  <mo> ) </mo>
  </mrow>
  <mtext> or </mtext>
  <mrow>
    <mo maxsize="1"     > ( </mo>
        <mfrac> <mn> 1 </mn> <mn> 2 </mn> </mfrac>
    <mo stretchy="false"> ) </mo>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[mi-mn]

\getbuffer[mo]

\stopsection

\startsection[title={mrow}]

The previous example demonstrated the use of \mmlelement {mrow}, the element that
is used to communicate the larger building blocks. Although this element from the
perspective of typesetting is not always needed, by using it, the structure of
the formula in the document source is more clear. There is some messy magic going
on when we try to fake fenced expressions.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow> <mi> x </mi> <mo> &geq; </mo> <mn> 2 </mn> </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> y </mi> <mo> &gt; </mo> <mn> 4 </mn>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mo> &lt; </mo> <mi> x </mi> <mo> &gt; </mo>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> a </mi> <mo> &lt; </mo> <mi> b </mi> <mo> &lt; </mo> <mi> c </mi>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Spacing between a sign and the following token is taken care of automatically by
\TEX:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mo> - </mo>
    <mn> 1 </mn>
    <mo> - </mo>
    <mn> 1 </mn>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[mrow]

\stopsection

\startsection[title={msup, msub, msubsup}]

Where in content markup super and subscript are absent and derived from the
context, in presentational markup they are quite present.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <msup>
    <msub> <mi> x </mi> <mn> 1 </mn> </msub>
    <mn> 2 </mn>
  </msup>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <msubsup>
    <mi> x </mi>
    <mn> 1 </mn>
    <mn> 2 </mn>
  </msubsup>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Watch the difference between both definitions and appearances. You can influence
the default behaviour with processing instructions.

\getbuffer[msub]

\getbuffer[msup]

\getbuffer[msubsup]

\stopsection

\startsection[title={mfrac}]

Addition, subtraction and multiplication is hard coded using the \mmlelement {mo}
element with $+$, $-$, and $\times$ (or nothing). You can use $/$ for division,
but for more complicated formulas you have to fall back on fraction building.
This is why \MATHML\ provides the \mmlelement {mfrac}.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfrac>
    <mrow> <mi> x </mi> <mo> + </mo> <mn> 1 </mn> </mrow>
    <mrow> <mi> y </mi> <mo> + </mo> <mn> 1 </mn> </mrow>
  </mfrac>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

You can change the width of the rule, but this is generally a bad idea. For
special purposes you can set the line thickness to zero.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfrac linethickness="0">
    <mrow> <mi> x </mi> <mo> &geq; </mo> <mn> 2 </mn> </mrow>
    <mrow> <mi> y </mi> <mo> &leq; </mo> <mn> 4 </mn> </mrow>
  </mfrac>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

A different kind of rendering is also possible, as shown in the following
example.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfrac bevelled="true">
    <mfrac>
      <mi> x </mi> <mn> 2 </mn>
      <mi> y </mi> <mn> 4 </mn>
    </mfrac>
    <mfrac>
      <mi> x </mi> <mn> 2 </mn>
      <mi> y </mi> <mn> 4 </mn>
    </mfrac>
  </mfrac>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[mfrac]

\stopsection

\startsection[title={mfenced}]

Braces are used to visually group sub||expressions. In presentational \MATHML\
you can either hard code braces, or use the \mmlelement {mfenced} element to
generate delimiters automatically. In \CONTEXT, as much as possible, the
operators and identifiers are interpreted, and when recognized treated according
to their nature.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfenced> <mi> a </mi> <mi> b </mi> <mn> 1 </mn> </mfenced>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The fencing symbols adapt their size to the content. Their dimensions also depend
on the way math fonts are defined. The standard \TEX\ fonts will give the same
height of braces around $x$ and $y$, but in other fonts the $y$ may invoke
slightly larger ones.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfenced open="[" close=")" separators=",">
    <mn> 0 </mn> <mn> 1 </mn>
  </mfenced>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The separators adapt their size to the fenced content too, just like the fences.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfenced open="[" close="]" separators="|">
    <mfrac> <mn> 1 </mn> <mi> x </mi> </mfrac>
    <mfrac> <mn> 1 </mn> <mi> y </mi> </mfrac>
    <mfrac> <mn> 1 </mn> <mi> z </mi> </mfrac>
  </mfenced>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfenced>
    <mrow> <mn> 1 </mn> <mo> + </mo> <mi> x </mi> </mrow>
  </mfenced>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfenced open="{" close="" separators="|+-">
    <mn> 1 </mn> <mn> 2 </mn> <mn> 3 </mn> <mn> 4 </mn>
  </mfenced>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfenced open="a" close="e" separators="bcd">
    <mn> 1 </mn> <mn> 2 </mn> <mn> 3 </mn> <mn> 4 </mn>
  </mfenced>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[mfenced]

\stopsection

\startsection[title={msqrt, mroot}]

The shape and size of roots, integrals, sums and products can depend on the size
of the content.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <msqrt>
    <mi> b </mi>
  </msqrt>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mroot>
    <mi> b </mi>
    <mn> 2 </mn>
  </mroot>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mroot>
    <mfrac> <mn> 1 </mn> <mi> b </mi> </mfrac>
    <mn> 2 </mn>
  </mroot>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mroot>
    <mfrac>
      <mn> 1 </mn>
      <mrow> <mi> a </mi> <mo> + </mo> <mi> b </mi> </mrow>
    </mfrac>
    <mn> 3 </mn>
  </mroot>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[msqrt-mroot]

\stopsection

\startsection[title={mtext}]

If you put text in a \mmlelement {mi} element, it will come out rather ugly. This
is due to the fact that identifiers are (at least in \TEX) not subjected to the
kerning that is normally used in text. Therefore, when you want to add some text
to a formula, you should use the \mmlelement {mtext} element.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfrac>
    <mi> Some Text </mi>
    <mtext> Some Text </mtext>
  </mfrac>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

As with all elements, leading and trailing spaces are ignored. If you really want
a space in front or at the end, you should use one of the space tokens other than
the ascii spacing tokens. You can also use entities like \type {&nbsp;}.

\getbuffer[mtext]

\stopsection

\startsection[title={mover, munder, munderover}]

Not all formulas are math and spacing and font rules may differ per discipline.
The following formula reflects a chemical reaction.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mrow>
      <mn> 2 </mn>
      <msub> <mtext> H </mtext> <mn> 2 </mn> </msub>
    </mrow>
    <mo> + </mo>
    <msub> <mtext> O </mtext> <mn> 2 </mn> </msub>
    <munder>
      <mo> &RightArrow; </mo>
      <mtext> explosion </mtext>
    </munder>
    <mrow>
      <mn> 2 </mn>
      <msub> <mtext> H </mtext> <mn> 2 </mn> </msub>
      <mtext> O </mtext>
    </mrow>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The \mmlelement {munder}, \mmlelement {mover} and \mmlelement {munderover}
elements can be used to put symbols and text or formulas on top of each other.
When applicable, the symbols will stretch themselves to span the natural size of
the text or formula.

The following examples demonstrate how the relevant components of this threesome
are defined.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> x </mi>
    <munder>
      <mo> &RightArrow; </mo>
      <mtext> maps to </mtext>
    </munder>
    <mi> y </mi>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> x </mi>
    <munder>
      <mtext> maps to </mtext>
      <mo> &RightArrow; </mo>
    </munder>
    <mi> y </mi>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> x </mi>
    <mover>
      <mtext> maps to </mtext>
      <mo> &RightArrow; </mo>
    </mover>
    <mi> y </mi>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> x </mi>
    <mover>
      <mo> &RightArrow; </mo>
      <mtext> maps to </mtext>
    </mover>
    <mi> y </mi>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <munderover>
      <mi> &int; </mi>
      <mn> 1 </mn>
      <mi> &infin; </mi>
    </munderover>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
    <mrow>
        <mover> <mi> x </mi> <mo> &#x2C6; </mo> </mover> <mo>+</mo>
        <mover> <mi> x </mi> <mo> &#x5E;  </mo> </mover> <mo>+</mo>
        <mover> <mi> x </mi> <mo> &Hat;   </mo> </mover>
    </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[munder]

\getbuffer[mover]

\getbuffer[munderover]

\stopsection

\startsection[title={ms}]

This is a bit weird element. It behaves like \mmlelement {mtext} but puts quotes
around the text.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfrac>
    <ms> Some Text </ms>
    <mtext> Some Text </mtext>
  </mfrac>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

You can specify the left and right boundary characters, either directly or
(preferably) using entities like \type {&quot;}.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <ms lquote="+" rquote="+"> A Famous Quotation </ms>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[ms]

\stopsection

\startsection[title={menclose}]

This element is implemented but it is such a weird element that it's probably
seldom used.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="longdiv"><mn>123</mn></menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="actuarial"><mn>123</mn></menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="radical"><mn>123</mn></menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

A bit more complex example (taken from the specification) demonstrates where
those somewhat strange rendering options are good for:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mtable columnspacing="0pt" rowspacing="0pt">
    <mtr>
      <mtd></mtd>
      <mtd columnalign="right"><mn>10</mn></mtd>
    </mtr>
    <mtr>
      <mtd columnalign="right"><mn>131</mn></mtd>
      <mtd columnalign="right">
        <menclose notation="longdiv"><mn>1413</mn></menclose>
      </mtd>
    </mtr>
    <mtr>
      <mtd></mtd>
      <mtd columnalign="right">
        <mrow>
          <munder>
            <mn>131</mn>
            <mo>&UnderBar;</mo>
          </munder>
          <mphantom><mn>3</mn></mphantom>
        </mrow>
      </mtd>
    </mtr>
    <mtr>
      <mtd></mtd>
      <mtd columnalign="right"><mn>103</mn></mtd>
    </mtr>
  </mtable>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

In \MATHML~3 a few more notations showed up and to some extend we support them.
We assume that the previously mentioned variants are always applied to the
content first.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="box downdiagonalstrike">
    <mtext>whatever</mtext>
  </menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="roundedbox updiagonalstrike">
    <mtext>whatever</mtext>
  </menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="circle verticalstrike horizontalstrike">
    <mtext>whatever</mtext>
  </menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="left top verticalstrike">
    <mtext>whatever</mtext>
  </menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="right bottom horizontalstrike">
    <mtext>whatever</mtext>
  </menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="radical right bottom horizontalstrike">
    <mtext>whatever</mtext>
  </menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="right bottom horizontalstrike radical">
    <mtext>whatever</mtext>
  </menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The graphics are drawn at runtime by \METAPOST. Currently we don't combine them
into one which would be more efficient in terms of output (not so much in
runtime). You can define additional variants; as an example we show one of the
solutions:

\startbuffer
\startuseMPgraphic{mml:enclose:box}
  draw OverlayBox
    withpen pencircle scaled (ExHeight/10) ;
\stopuseMPgraphic

\defineoverlay [mml:enclose:box] [\useMPgraphic{mml:enclose:box}]
\stopbuffer

\getbuffer \typebuffer

You can roll out your own:

\startbuffer
\startuseMPgraphic{mml:enclose:mybox}
  draw OverlayBox enlarged (ExHeight/5)
    withpen pencircle scaled (ExHeight/10) ;
\stopuseMPgraphic

\defineoverlay [mml:enclose:mybox] [\useMPgraphic{mml:enclose:mybox}]
\stopbuffer

\getbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <menclose notation="mybox">
    <mtext>whatever</mtext>
  </menclose>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[menclose]

\stopsection

\startsection[title={merror}]

There is not much chance that this element will end up in a math textbook, unless
the typeset output of programs is part of the story.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <merror>
    <mtext> Are you kidding? &ThickSpace; </mtext>
    <mfrac>
      <mrow> <mn> 1 </mn> <mo> + </mo> <mi> x </mi> </mrow>
      <mn> 0 </mn>
    </mfrac>
  </merror>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[merror]

\stopsection

\startsection[title={mmultiscripts, mprescripts}]

This element is one of the less obvious ones. The next two examples are taken
from the specification. The \mmlelement {multiscripts} element takes an odd
number of arguments. The second and successive child elements alternate between
sub- and superscript. The empty element \mmlelement {none} |<|a dedicated element
\mmlelement {mnone} would have been a better choice|>| serves as a placeholder.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mmultiscripts>
    <mi> R </mi>
    <mi> i </mi>
    <none/>
    <none/>
    <mi> j </mi>
    <mi> k </mi>
    <none/>
    <mi> l </mi>
    <none/>
  </mmultiscripts>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The \mmlelement {mmultiscripts} element can also be used to attach prescripts to
a symbol. The next example demonstrates this. The empty \mmlelement {prescripts}
element signals the start of the prescripts section.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mmultiscripts>
    <mi> Qb </mi>
    <mn> 4 </mn>
    <none/>
    <mprescripts/>
    <mn> 427 </mn>
    <none/>
  </mmultiscripts>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[mmultiscripts]

\stopsection

\startsection[title={mspace}]

Currently not all functionality of the \mmlelement {mspace} element is
implemented. Over time we will see what support is needed and makes sense,
especially since this command can spoil things. We only support the units that
make sense, so units in terms of pixels |<|a rather persistent oversight in
drafts|>| are kindly ignored.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <?context-mathml-directive mspace option test ?>
  <mrow>
    <mtext> use  </mtext> <mspace width="1em" />
    <mtext> me   </mtext> <mspace width="1ex" />
    <mtext> with </mtext> <mspace width="10pt"/>
    <mtext> care </mtext>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

As you can see here, spaces inside a \type {mtext} matter too! The next example
is more tight.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <?context-mathml-directive mspace option test ?>
  <mrow>
    <mtext>use</mtext>  <mspace width="1em" />
    <mtext>me</mtext>   <mspace width="1ex" />
    <mtext>with</mtext> <mspace width="10pt"/>
    <mtext>care</mtext>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

You can also pass a sample text:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mfrac>
     <mi> 44 </mi>
     <mfrac>
       <mrow>
         <mn> 11 </mn> <mn> 22 </mn> <mn> 33 </mn>
       </mrow>
       <mrow>
         <mn> 11 </mn> <mspace spacing="22"/> <mn> 33 </mn>
       </mrow>
     </mfrac>
  </mfrac>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[mspace]

\stopsection

\startsection[title={mphantom}]

A phantom element hides its content but still takes its space. A phantom element
can contain other elements.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mtext>    who is afraid of </mtext>    <mspace width=".5em" />
    <mphantom> phantom          </mphantom> <mspace width=".5em" />
    <mtext>    elements         </mtext>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[mphantom]

\stopsection

\startsection[title={mpadded}]

As with a few other elements, we first have to see some practical usage for this,
before we could implement the functionality needed.

\getbuffer[mpadded]

\stopsection

\startsection[title={mtable, mtr, mtd, mlabeledtr}]

As soon as you want to represent a matrix or other more complicated composed
constructs, you end up with spacing problems. This is when tables come into view.
Because presentational elements have no deep knowledge about their content,
tables made with presentational \MATHML\ will in most cases look worse than those
that result from content markup.

We have implemented tables on top of the normal \XML\ (\HTML) based table support
in \CONTEXT, also known as natural tables. Depending on the needs, support for
the \mmlelement {mtable} element will be extended.

The \mmlelement {mtable} element takes a lot of attributes. When no attributes
are given, we assume that a matrix is wanted, and typeset the content
accordingly.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mo> ( </mo>
    <mtable>
      <mtr>
        <mtd> <msub> <mi> x </mi> <mn> 1,1 </mn> </msub> </mtd>
        <mtd> <mn> 1 </mn> </mtd>
        <mtd> <mn> 0 </mn> </mtd>
      </mtr>
      <mtr>
        <mtd> <mn> 0 </mn> </mtd>
        <mtd> <msub> <mi> x </mi> <mn> 2,2 </mn> </msub> </mtd>
        <mtd> <mn> 1 </mn> </mtd>
      </mtr>
      <mtr>
        <mtd> <mn> 0 </mn> </mtd>
        <mtd> <mn> 1 </mn> </mtd>
        <mtd> <msub> <mi> x </mi> <mn> 3,3 </mn> </msub> </mtd>
      </mtr>
    </mtable>
    <mo> ) </mo>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mtable columnalign="left center right">
    <mtr>
      <mtd frame="solid"> <mn> 100 </mn> </mtd>
      <mtd              > <mn> 100 </mn> </mtd>
      <mtd              > <mn> 100 </mn> </mtd>
    </mtr>
    <mtr>
      <mtd              > <mn> 10  </mn> </mtd>
      <mtd frame="solid"> <mn> 10  </mn> </mtd>
      <mtd              > <mn> 10  </mn> </mtd>
    </mtr>
    <mtr>
      <mtd              > <mn> 1   </mn> </mtd>
      <mtd              > <mn> 1   </mn> </mtd>
      <mtd frame="solid"> <mn> 1   </mn> </mtd>
    </mtr>
  </mtable>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

A special case is the labeled row \mmlelement {mlabeledtr}. This one is meant for
numbering equations. However, in a properly formatted document there is probably
some encapsulating structure that takes care of this. Therefore we discard the
first child element. We show an example taken from the specification.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mtable>
    <mlabeledtr>
      <mtd>crap</mtd>
      <mtd>
        <mrow>
          <mi>E</mi>
          <mo>=</mo>
          <mrow>
            <mi>m</mi>
            <mi>&it;</mi>
            <msup>
              <mi>c</mi>
              <mn>2</mn>
            </msup>
          </mrow>
        </mrow>
      </mtd>
    </mlabeledtr>
  </mtable>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Although the underlying table mechanism can provide all the support needed (and
even more), not all attributes are yet implemented. We will make a useful
selection.

\starttabulate[|l|l|]
\HL
\NC columnalign   \NC keyword: left center (middle) right \NC \NR
\NC columnspacing \NC a meaningful dimension              \NC \NR
\NC rowspacing    \NC a meaningful dimension              \NC \NR
\NC frame         \NC keyword: none (off) solid (on)      \NC \NR
\NC color         \NC a named color identifier            \NC \NR
\NC background    \NC a named color identifier            \NC \NR
\HL
\stoptabulate

We only support properly named colors as back- and foreground colors. The normal
\CONTEXT\ color mapping mechanism can be used to remap colors. This permits
(read: forces) a consistent usage of colors. If you use named backgrounds
\unknown\ the sky is the limit.

\getbuffer[mtable]

\getbuffer[mtd]

\getbuffer[mtr-mlabeledtr]

\stopsection

\startsection[title={mcolumn}]

This element is new in \MATHML~3 and is kind of special in the sense that the
content is analyzed. It would have made more sense just to provide some proper
structure instead since it's intended use is rather well defined.

Because it is not much fun to implement such a messy element we only support it
partially and add what comes on our way. Here are a few examples (more or less
taken from the reference).

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mcolumn>
    <mn>12</mn>
    <mrow> <mo>&times;</mo> <mn>12</mn> </mrow>
    <mline spacing="000"/>
    <mn>24</mn>
    <mrow> <mn>12</mn> <mspace spacing="0"/> </mrow>
    <mline spacing="000"/>
    <mn>144</mn>
  </mcolumn>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mcolumn>
    <mn>123</mn>
    <mrow> <mn>456</mn> <mo>+</mo> </mrow>
    <mline spacing="000+"/>
    <mn>579</mn>
  </mcolumn>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mcolumn>
    <mn>1,23</mn>
    <mrow> <mn>4,56</mn> <mo>+</mo> </mrow>
    <mline spacing="0,00+"/>
    <mn>5,79</mn>
  </mcolumn>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mcolumn>
    <mstyle mathsize="71%">
        <menclose notation="bottom"> <mn>10</mn> </menclose>
    </mstyle>
    <mn>52</mn>
    <mrow> <mo>&minus;</mo> <mn>7</mn> </mrow>
    <mline spacing="45"/>
    <mn>45</mn>
  </mcolumn>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Similar effects can be accomplished with the \mmlelement {mtable}
element.

\stopsection

\startsection[title={malignmark, maligngroup}]

This element is used in tables and is not yet implemented, first because I still
have to unravel its exact usage, but second, because it is about the ugliest
piece of \MATHML\ markup you will encounter.

% AFO: http://www.w3.org/TR/2007/WD-MathML3-20071005/chapter3.html#presm.malign

\getbuffer[malignmark]

\stopsection

\startsection[title={mglyph}]

This element is for those who want to violate the ideas of general markup by
popping in his or her own glyphs. Of course one should use entities, even if they
have to be defined.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <mrow>
    <mi> <mglyph fontfamily="Serif" index="65" alt="The Letter A"/></mi>
    <mo> + </mo>
    <mi> <mglyph fontfamily="Serif" index="66" alt="The Letter B"/></mi>
    <mo> = </mo>
    <mi> <mglyph fontfamily="Serif" index="67" alt="The Letter C"/></mi>
  </mrow>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\getbuffer[mglyph]

\stopsection

\startsection[title={mstyle}]

This element is implemented but not yet discussed since we want more control over
its misuse.

\getbuffer[mstyle]

\stopsection

\startsection[title={afterword}]

You may have noticed that we prefer content \MATHML\ over presentational \MATHML.
So, unless you're already tired of any math coded in angle brackets, we invite
you to read the next chapter too.

\stopsection

\stopchapter

\startchapter[title={Content markup}]

\startsection[title={introduction}]

In this chapter we will discuss the \MATHML\ elements from the point of view of
typesetting. We will not pay attention to other rendering techniques, like speech
generation. Some elements take attributes and those often make more sense for
other applications than for a typesetting engine like \TEX, which has a strong
math engine that knows how to handle math.

One of the most prominent changes in \MATHML~3 is support for an \OPENMATH\ like
coding. Here the \mmlelement {csymbol} takes the place of the empty element as
first argument of an \mmlelement {apply}. There are more symbols in \OPENMATH\
then we supported in the interpreter, but in due time (depending on demand) we
will add more. At the time of writing this the draft was really a draft which
made it hard to grasp all the implications for rendering so we probably need to
overhaul the code sometime in the future.

Another change is the usage of \mmlelement {apply} that has been delegated to
\mmlelement {bind}. One may wonder why this hadn't happen before. For the moment
we treat the \mmlelement {bind} as if it were an \mmlelement {apply}.

\stopsection

\startsection[title={apply}]

If you are dealing with rather ordinary math, you will only need a subset of
content \MATHML. For this reason we will start with the most common elements.
When you key in \XML\ directly, you will encounter the \mmlelement {apply}
element quite often, even in a relatively short formula like the following.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
    <apply> <minus/>
        <cn> 1 </cn>
    </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

In most cases the \mmlelement {apply} element is followed by a specification
disguised as an empty element.

Later we will see more complex examples but here we already show the different
ways of encoding. First we show the traditional \MATHML~2 method:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
    <apply> <forall/>
        <bvar> <ci>x</ci> </bvar>
        <apply> <geq/>
            <ci>x</ci>
            <cn>4</cn>
        </apply>
    </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

This is now called \quote {pragmatic} \MATHML. Using symbols and \mmlelement
{bind} this becomes \quote {strict} \MATHML:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="3.0">
    <bind> <csymbol cd="quant1">forall</csymbol>
        <bvar> <ci>x</ci> </bvar>
        <apply> <csymbol cd="relation1">geq</csymbol>
            <ci>x</ci>
            <cn>4</cn>
        </apply>
    </bind>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={ci, cn, sep}]

These elements are used to specify identifiers and numbers. Both elements can
be made more explicit by using attributes.

\startattributes
\HL
\NC type \NC set      \NC use a representation appropriate for sets \NC \NR
\NC      \NC vector   \NC mark this element as vector               \NC \NR
\NC      \NC function \NC consider this element to be a function    \NC \NR
\NC      \NC fn       \NC idem \NC \NR
\HL
\stopattributes

When \attvalue {set} is specified, a blackboard symbol is used when available.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <in/>
    <ci> x </ci>
    <ci type="set"> N </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The \attvalue {function} specification makes sense when the \mmlelement {ci}
element is used in for instance a differential equation.

\startattributes
\HL
\NC type \NC integer           \NC a whole number with an optional base \NC \NR
\NC      \NC logical           \NC a boolean constant \NC \NR
\NC      \NC rational          \NC a real number \NC \NR
\NC      \NC complex-cartesian \NC a complex number in $x+iy$ notation \NC \NR
\NC      \NC complex           \NC idem \NC \NR
\NC      \NC complex-polar     \NC a complex number in polar notation \unknown \NC \NR
\HL
\stopattributes

You're lucky when your document uses decimal notation, otherwise you will end up
with long specs if you want to be clear in what numbers are used.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <plus/>
      <cn type="integer" base="16"> 1A2C </cn>
      <cn type="integer" base="16"> 0101 </cn>
    </apply>
    <cn type="integer" base="16"> 1B2D </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Complex numbers have two components. These are separated by the \mmlelement {sep}
element. In the following example we see that instead of using a \mmlelement {ci}
with set specifier, the empty element \mmlelement {complexes} can be used. We
will see some more of those later.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <in/>
    <cn type="complex"> 2 <sep/> 5 </cn>
    <complexes/>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={eq, neq, gt, lt, geq, leq}]

Expressions, and especially those with \mmlelement {eq} are typical for math.
Because such expressions can be quite large, there are provisions for proper
alignment.

\starttabulate[||c||c|] % we want inline math
\HL
\NC lt  \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><lt/> <ci>a</ci><ci>b</ci></apply></math>} \NC
    leq \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><leq/><ci>a</ci><ci>b</ci></apply></math>} \NC \NR
\NC eq  \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><eq/> <ci>a</ci><ci>b</ci></apply></math>} \NC
    neq \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><neq/><ci>a</ci><ci>b</ci></apply></math>} \NC \NR
\NC gt  \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><gt/> <ci>a</ci><ci>b</ci></apply></math>} \NC
    geq \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><geq/><ci>a</ci><ci>b</ci></apply></math>} \NC \NR
\HL
\stoptabulate

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <leq/>
    <ci> a </ci>
    <ci> b </ci>
    <ci> c </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={equivalent, approx, implies}]

Equivalence, approximations, and implications are handled like \mmlelement {eq}
and alike and have their own symbols.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <equivalent/>
    <apply> <plus/> <ci> a </ci> <ci> b </ci> </apply>
    <apply> <plus/> <ci> b </ci> <ci> a </ci> </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

This document is typeset with \LUATEX\ built upon \TEX\ version $3.14159$, and
given that \TEX\ is written by a mathematician, it will be no surprise that:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <approx/>
    <cn> 3.14159 </cn>
    <pi/>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <implies/>
    <apply> <eq/>
      <apply> <plus/>
        <ci> x </ci>
        <cn> 4 </cn>
      </apply>
      <cn> 9 </cn>
    </apply>
    <apply> <eq/>
      <ci> x </ci>
      <cn> 5 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={minus, plus}]

Addition and subtraction are main building blocks of math so you will meet them
often.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <minus/>
    <cn> 37 </cn>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

In most cases there will be more than one argument to take care of, but
especially \mmlelement {minus} will be used with one argument too. Although \typ
{<cn> -37 </cn>} is valid, using \mmlelement {minus} is sometimes more clear.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <minus/>
    <cn> 37 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

You should pay attention to combinations of \mmlelement {plus} and \mmlelement
{minus}. Opposite to presentational \MATHML, in content markup you don't think
and code sequential.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <plus/>
    <apply> <minus/>
      <ci> x </ci>
    </apply>
    <cn> 37 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

In \MATHML~3 we can also be more vebose:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="3.0">
    <apply> <csymbol cd="arith1">plus</csymbol>
        <ci>a</ci>
        <ci>x</ci>
    </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={times}]

Multiplication is another top ten element. Although \type {3p} as content of the
\mmlelement {ci} element would have rendered the next example as well, you really
should split off the number and mark it as \mmlelement {cn}. When this is done
consistently, we can comfortably change the font of numbers independent of the
font used for displaying identifiers.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <times/>
    <cn> 3 </cn>
    <ci> p </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

In a following chapter we will see how we can add multiplication signs between
variables and constants.

\stopsection

\startsection[title={divide}]

When typeset, a division is characterized by a horizontal rule. Some elements,
like the differential element \mmlelement {diff}, generate their own division.

\processxmlfile{pc-s-001.xml}

This example also demonstrates how to mix \mmlelement {plus} and \mmlelement
{minus}.

\typefile{pc-s-001.xml}

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
    <apply><divide/>
        <apply><minus/>
            <apply><minus/><ci>b</ci></apply>
            <apply><minus/><ci>b</ci></apply>
            <apply><root/> <ci>a</ci></apply>
        </apply>
        <apply><minus/>
            <apply><minus/><ci>b</ci><ci>b</ci></apply>
            <apply><minus/><ci>b</ci></apply>
            <apply><root/> <ci>a</ci></apply>
        </apply>
    </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={power}]

In presentational \MATHML\ you think in super- and subscripts, but in content
\MATHML\ these elements are not available. There you need to think in terms of
\mmlelement {power}.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <plus/>
    <apply> <power/>
      <ci> x </ci>
      <cn> 2 </cn>
    </apply>
    <apply> <power/>
      <apply> <sin/>
        <ci> x </ci>
      </apply>
      <cn> 2 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The \mmlelement {power} element is clever enough to determine where the
superscript should go. In the case of the sinus function, by default it will go
after the function identifier.

\stopsection

\startsection[title={root, degree}]

If you study math related \DTD's |<|these are the formal descriptions for \SGML\
or \XML\ element collections|>| you will notice that there are not that many
elements that demand a special kind of typography: differential equations,
limits, integrals and roots are the most distinctive ones.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <root/>
      <degree> 3 </degree>
      <ci> 64 </ci>
    </apply>
    <cn> 4 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Contrary to \mmlelement {power}, the \mmlelement {root} element uses a
specialized child element to denote the degree. The positive consequence of this
is that there cannot be a misunderstanding about what role the child element
plays, while in for instance \mmlelement {power} you need to know that the second
child element denotes the degree.

\stopsection

\startsection[title={sin, cos, tan, cot, scs, sec, \unknown}]

All members of the family of goniometric functions are available as empty
element. When needed, their argument is surrounded by braces. They all behave the
same.

\starttabulate[|||||]
\HL
\NC sin \NC arcsin \NC sinh \NC arcsinh \NC \NR
\NC cos \NC arccos \NC cosh \NC arccosh \NC \NR
\NC tan \NC arctan \NC tanh \NC arctanh \NC \NR
\NC cot \NC arccot \NC coth \NC arccoth \NC \NR
\NC csc \NC arccsc \NC csch \NC arccsch \NC \NR
\NC sec \NC arcsec \NC sech \NC arcsech \NC \NR
\HL
\stoptabulate

These functions are normally typeset in a non italic (often roman) font shape.

\processxmlfile{wh-g-001.xml}

By default the typesetting engine will minimize the number of braces that
surrounds the argument of a function.

\typefile{wh-g-001.xml}

You can specify $\pi$ as an entity \type {&pi;} or as empty element \mmlelement
{pi}. In many cases it is up to your taste which one you use. There are many
symbols that are only available as entity, so in some respect there is no real
reason to treat $\pi$ different.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <cos/>
      <pi/>
    </apply>
    <apply> <minus/>
      <cn> 1 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={log, ln, exp}]

The \mmlelement {log} and \mmlelement {ln} are typeset similar to the previously
discussed goniometric functions. The \mmlelement {exp} element is a special case
of \mmlelement {power}. The constant $e$ can be specified with \mmlelement
{exponentiale}.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <approx/>
    <apply> <ln/>
      <apply> <plus/>
        <exponentiale/>
        <cn> 2 </cn>
      </apply>
    </apply>
    <cn> 1.55 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <exp/>
      <cn> 2 </cn>
    </apply>
    <cn> 7.3890560989307 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={quotient, rem}]

The result of a division can be a rational number, so $\frac{5}{4}$ is equivalent
to $1.25$ and $1.25 \times 4$ gives~$5$. An integer division will give~$1$ with a
remainder~$2$. Many computer languages provide a \type {div} and \type {mod}
function, and since \MATHML\ is also meant for computation, it provides similar
concepts, represented by the elements \mmlelement {quotient} and \mmlelement
{rem}. The representation of \mmlelement {quotient} is rather undefined, but the
next one is among the recommended alternatives.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <quotient/>
    <ci> a </ci>
    <ci> b </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={factorial}]

Showing the representation of a factorial is rather dull, so we will use a few
more elements as well as a processing instruction to illustrate the usage of
\mmlelement {factorial}.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <?context-mathml-directive times symbol yes ?>
  <apply> <eq/>
    <apply> <factorial/>
      <ci> n </ci>
    </apply>
    <apply> <times/>
      <ci> n </ci>
      <apply> <minus/> <ci> n </ci> <cn> 1 </cn> </apply>
      <apply> <minus/> <ci> n </ci> <cn> 2 </cn> </apply>
      <csymbol definitionUrl="cdots"/>
      <cn> 1 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The processing instruction is responsible for the placement of the $\times$
symbols.

\stopsection

\startsection[title={min, max, gcd, lcm}]

These functions can handle more than two arguments. When typeset, these are
separated by commas.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <ci> z </ci>
    <apply> <min/>
      <apply> <plus/>   <ci> x </ci> <ci> y </ci> </apply>
      <apply> <times/>  <cn> 2 </cn> <ci> x </ci> </apply>
      <apply> <divide/> <cn> 1 </cn> <ci> y </ci> </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={and, or, xor, not}]

Logical expressions can be defined using these elements. The operations are
represented by symbols and braces are applied when needed.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <and/>
      <cn type="integer" base="2"> 1001 </cn>
      <cn type="integer" base="2"> 0101 </cn>
    </apply>
    <cn type="integer" base="2"> 0001 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={set, bvar}]

The appearance of a \mmlelement {set} depends on the presence of the child
element \mmlelement {bvar}. In its simplest form, a set is represented as a list.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <neq/>
    <set>
      <cn> 1 </cn>
      <cn> 4 </cn>
      <cn> 8 </cn>
    </set>
    <emptyset/>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

A set can be distinguished from a vector by its curly braces. The simplest case
is just a comma separated list. The next example demonstrates the declarative
case. Without doubt, there will be other alternatives.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <set>
    <bvar><ci> x </ci></bvar>
    <condition>
      <apply> <lt/>
        <cn> 2 </cn>
        <ci> x </ci>
        <cn> 8 </cn>
      </apply>
    </condition>
  </set>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={list}]

This element is used in different contexts. When used as a top level element, a
list is typeset as follows.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <list>
    <cn> 1 </cn>
    <cn> 1 </cn>
    <cn> 3 </cn>
  </list>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

When used in a context like \mmlelement {partialdiff}, the list specification
becomes a subscript.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <partialdiff/>
    <list>
      <cn> 1 </cn>
      <cn> 1 </cn>
      <cn> 3 </cn>
    </list>
    <ci type="fn"> f </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The function specification in this formula (which is taken from the specs) can
also be specified as \typ {<fn> <ci> f </ci> </fn>} (which is more clear).

\stopsection

\startsection[title={union, intersect, \unknown}]

There is a large number of set operators, each represented by a distinctive
symbol.

\starttabulate[||c||c|] % we want in line math
\HL
\NC union       \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><union/>      <ci>U</ci><ci>V</ci></apply></math>} \NC
                \NC \NC \NR
\NC intersect   \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><intersect/>  <ci>U</ci><ci>V</ci></apply></math>} \NC
                \NC \NC \NR
\NC in          \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><in/>         <ci>U</ci><ci>V</ci></apply></math>} \NC
    notin       \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><notin/>      <ci>U</ci><ci>V</ci></apply></math>} \NC \NR
\NC subset      \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><subset/>     <ci>U</ci><ci>V</ci></apply></math>} \NC
    notsubset   \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><notsubset/>  <ci>U</ci><ci>V</ci></apply></math>} \NC \NR
\NC prsubset    \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><prsubset/>   <ci>U</ci><ci>V</ci></apply></math>} \NC
    notprsubset \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><notprsubset/><ci>U</ci><ci>V</ci></apply></math>} \NC \NR
\NC setdiff     \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><apply><setdiff/>    <ci>U</ci><ci>V</ci></apply></math>} \NC
                \NC \NC \NR
\HL
\stoptabulate

These operators are applied as follows:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <union/>
    <ci> U </ci>
    <ci> V </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={conjugate, arg, real, imaginary}]

The visual representation of \mmlelement {conjugate} is a horizontal bar with a
width matching the width of the expression.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <conjugate/>
    <apply> <plus/>
      <ci> x </ci>
      <apply> <times/>
        <cn> &ImaginaryI; </cn>
        <ci> y </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The \mmlelement {arg}, \mmlelement {real} and \mmlelement {imaginary} elements
trigger the following appearance.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <arg/>
    <apply> <plus/>
      <ci> x </ci>
      <apply> <times/>
        <cn> &ImaginaryI; </cn>
        <ci> y </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <real/>
    <apply> <plus/>
      <ci> x </ci>
      <apply> <times/>
        <cn> &ImaginaryI; </cn>
        <ci> y </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <imaginaryi/>
    <apply> <plus/>
      <ci> x </ci>
      <apply> <times/>
        <cn> &ImaginaryI; </cn>
        <ci> y </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

\stopsection

\startsection[title={abs, floor, ceiling}]

There are a couple of functions that turn numbers into positive or rounded ones.
In computer languages names are used, but in math we use special boundary
characters.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <abs/> <cn> -5 </cn> </apply>
    <cn> 5 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <floor/> <cn> 5.5 </cn> </apply>
    <cn> 5 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <ceiling/> <cn> 5.5 </cn> </apply>
    <cn> 6 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={interval}]

An interval is visualized as: \xmldata {<math xmlns="http://www.w3c.org/mathml"
version="2.0"> <interval> <cn> 1 </cn> <cn> 10 </cn> </interval> </math>}. The
\mmlelement {interval} element is a container element and has a begin and endtag.
You can specify the closure as attribute:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <interval closure="open-closed">
    <ci> a </ci>
    <ci> b </ci>
  </interval>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The following closures are supported:

\starttabulate[|||]
\HL
\NC open        \NC \xmldata {<math xmlns="http://www.w3c.org/mathml" version="2.0"> <interval closure="open"> <ci>
                    a </ci> <ci> b </ci> </interval> </math>} \NC \NR
\NC closed      \NC \xmldata {<math xmlns="http://www.w3c.org/mathml" version="2.0"> <interval closure="closed"> <ci>
                    a </ci> <ci> b </ci> </interval> </math>} \NC \NR
\NC open-closed \NC \xmldata {<math xmlns="http://www.w3c.org/mathml" version="2.0"> <interval closure="open-closed"> <ci>
                    a </ci> <ci> b </ci> </interval> </math>} \NC \NR
\NC closed-open \NC \xmldata {<math xmlns="http://www.w3c.org/mathml" version="2.0"> <interval closure="closed-open"> <ci>
                    a </ci> <ci> b </ci> </interval> </math>} \NC \NR
\HL
\stoptabulate

In strict \MATHML\ we use symbols instead of attributes to define the openess:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="3.0">
    <apply> <csymbol cd="interval1">interval_oo</csymbol>
        <ci>a</ci>
        <ci>x</ci>
    </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="3.0">
    <apply> <csymbol cd="interval1">interval_cc</csymbol>
        <ci>a</ci>
        <ci>x</ci>
    </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={inverse}]

This operator is applied to a function. The following example demonstrates that
this is one of the few cases (if not the only one) where the first element
following an \mmlelement {apply} begintag is an \mmlelement {apply} itself.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply>
    <apply> <inverse/> <sin/> </apply>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={reln}]

This element is a left||over from the first \MATHML\ specification and its usage
is no longer advocated. Its current functionality matches the functionality of
\mmlelement {apply}.

\stopsection

\startsection[title={cartesianproduct, vectorproduct, scalarproduct, outerproduct}]

The context of the formula will often provide information of what kind of
multiplication is meant, but using different symbols to represent the kind of
product certainly helps.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <cartesianproduct/>
    <ci> a </ci>
    <ci> b </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

We have:

\starttabulate[|||]
\HL
\NC cartesian \NC \xmldata {<math xmlns="http://www.w3c.org/mathml" version="2.0"> <apply> <cartesianproduct/> <ci>
                  a </ci> <ci> b </ci> </apply> </math>} \NC \NR
\NC vector    \NC \xmldata {<math xmlns="http://www.w3c.org/mathml" version="2.0"> <apply> <vectorproduct/> <ci>
                  a </ci> <ci> b </ci> </apply> </math>} \NC \NR
\NC scalar    \NC \xmldata {<math xmlns="http://www.w3c.org/mathml" version="2.0"> <apply> <scalarproduct/> <ci>
                  a </ci> <ci> b </ci> </apply> </math>} \NC \NR
\NC outer     \NC \xmldata {<math xmlns="http://www.w3c.org/mathml" version="2.0"> <apply> <outerproduct/> <ci>
                  a </ci> <ci> b </ci> </apply> </math>} \NC \NR
\HL
\stoptabulate

\stopsection

\startsection[title={sum, product, limit, lowlimit, uplimit, bvar}]

Sums, products and limits have a distinctive look, especially when they have
upper and lower limits attached. Unfortunately there is no way to specify the
$x_i$ in content \MATHML. In the next chapter we will see how we can handle that.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <sum/>
    <bvar> <ci> i </ci> </bvar>
    <lowlimit> <cn> 1 </cn> </lowlimit>
    <uplimit> <ci> n </ci> </uplimit>
    <apply> <divide/>
      <cn> 1 </cn>
      <ci> x </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

When we omit the limits, the \mmlelement {bvar} is still typeset.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <product/>
    <bvar>
      <ci> i </ci>
    </bvar>
    <apply> <divide/>
      <cn> 1 </cn>
      <ci> x </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

You can specify the condition under which the function is applied.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <product/>
    <bvar>
      <ci> x </ci>
    </bvar>
    <condition>
      <apply> <in/>
        <ci> x </ci>
        <ci type="set"> R </ci>
      </apply>
    </condition>
    <apply> <ci type="fn"> f </ci>
      <ci> x </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <limit/>
    <bvar>
      <ci> x </ci>
    </bvar>
    <lowlimit>
      <cn> 0 </cn>
    </lowlimit>
    <apply> <sin/>
      <ci> x </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={int, diff, partialdiff, bvar, degree}]

These elements reach a high level of abstraction. The best way to learn how to
use them is to carefully study some examples.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <diff/>
    <bvar> <ci> a </ci> </bvar>
    <apply> <int/>
      <lowlimit> <ci> p </ci> </lowlimit>
      <uplimit>  <ci> q </ci> </uplimit>
      <bvar> <ci> x </ci> </bvar>
      <apply>
        <fn> <ci> f </ci> </fn>
        <ci> x </ci>
        <ci> a </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The \mmlelement {bvar} element is essential, since it is used to automatically
generate some of the components that make up the visual appearance of the
formula. If you look at the formal specification of these elements, you will
notice that the appearance may depend on your definition. How the formula shows
up, depends not only on the \mmlelement {bvar} element, but also on the optional
\mmlelement {degree} element within.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <diff/>
    <ci> f </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <diff/>
    <bvar>
      <ci> x </ci>
      <degree> <cn> 2 </cn> </degree>
    </bvar>
    <apply> <fn> <ci> f </ci> </fn>
      <ci> x </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <partialdiff/>
    <bvar>
      <degree> <cn> 2 </cn> </degree>
      <ci> x </ci>
    </bvar>
    <bvar> <ci> y </ci> </bvar>
    <bvar> <ci> x </ci> </bvar>
    <degree> <cn> 4 </cn> </degree>
    <ci type="fn"> f </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <partialdiff/>
    <bvar>
      <ci> x </ci> <degree> <ci> m </ci> </degree>
    </bvar>
    <bvar>
      <ci> y </ci> <degree> <ci> n </ci> </degree>
    </bvar>
    <degree> <ci> k </ci> </degree>
    <apply> <ci type="fn"> f </ci>
      <ci> x </ci>
      <ci> y </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <partialdiff/>
    <bvar>
      <ci> x </ci> <degree> <ci> m </ci> </degree>
    </bvar>
    <bvar>
      <ci> y </ci> <degree> <ci> n </ci> </degree>
    </bvar>
    <apply> <ci type="fn"> f </ci>
      <ci> x </ci>
      <ci> y </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

When a degree is not specified, it is deduced from the context, but since this is
not 100\% robust, you can best be complete in your specification.

These examples are taken from the \MATHML\ specification. In the example document
that comes with this manual you can find a couple more.

\stopsection

\startsection[title={fn}]

There are a lot of predefined functions and operators. If you want to introduce a
new one, the \mmlelement {fn} element can be used. In the following example we
have turned the $\pm$ and $\mp$ symbols into (coupled) operators.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <times/>
      <apply> <fn> <ci> &plusminus; </ci> </fn>
        <ci> x </ci>
        <cn> 1 </cn>
      </apply>
      <apply> <fn> <ci> &minusplus; </ci> </fn>
        <ci> x </ci>
        <cn> 1 </cn>
      </apply>
    </apply>
    <apply> <minus/>
      <apply> <power/>
        <ci> x </ci>
        <cn> 2 </cn>
      </apply>
      <cn> 1 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The typeset result depends on the presence of a handler, which in this case
happens to be true.

\stopsection

\startsection[title={matrix, matrixrow}]

A matrix is one of the building blocks of linear algebra and therefore both
presentational and content \MATHML\ have dedicated elements for defining it.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <matrix>
    <matrixrow> <cn> 23 </cn> <cn> 87 </cn> <ci>  c </ci> </matrixrow>
    <matrixrow> <cn> 41 </cn> <ci>  b </ci> <cn> 33 </cn> </matrixrow>
    <matrixrow> <ci>  a </ci> <cn> 65 </cn> <cn> 16 </cn> </matrixrow>
  </matrix>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={vector}]

We make a difference between a vector specification and a vector variable. A
specification is presented as a list:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <vector>
    <ci> x </ci>
    <ci> y </ci>
  </vector>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

When the \mmlelement {vector} element has one child element, we use a right arrow
to identify the variable as vector.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <vectorproduct/>
    <vector> <ci> A </ci> </vector>
    <vector> <ci> B </ci> </vector>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={grad, curl, ident, divergence}]

These elements expand into named functions, but we can imagine that in the future
a more appropriate visualization will be provided as an option.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <neq/>
    <apply> <grad/>       <ci> A </ci> </apply>
    <apply> <curl/>       <ci> B </ci> </apply>
    <apply> <ident/>      <ci> C </ci> </apply>
    <apply> <divergence/> <ci> D </ci> </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={lambda, bvar}]

The lambda specification of a function needs a \mmlelement {bvar} element. The
visualization can be influenced with processing instructions as described in a
later chapter.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <lambda>
    <bvar> <ci> x </ci> </bvar>
    <apply> <sin/>
      <apply> <minus/>
        <ci> x </ci>
        <apply> <divide/>
          <ci> x </ci>
          <cn> 2 </cn>
        </apply>
      </apply>
    </apply>
  </lambda>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={piecewise, piece, otherwise}]

There are not so many elements that deal with combinations of formulas or
conditions. The \mmlelement {piecewise} is the only real selector available. The
following example defines how the state of~$n$ depends on the state of~$x$.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <ci> n </ci>
    <piecewise>
      <piece>
        <apply> <minus/>
          <cn> 1 </cn>
        </apply>
        <apply> <lt/>
          <ci> x </ci>
          <cn> 0 </cn>
        </apply>
      </piece>
      <piece>
        <cn> 1 </cn>
        <apply> <gt/>
          <ci> x </ci>
          <cn> 0 </cn>
        </apply>
      </piece>
      <otherwise>
        <cn> 0 </cn>
      </otherwise>
    </piecewise>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

We could have used a third \mmlelement {piece} instead of (optional) \mmlelement
{otherwise}.

\stopsection

\startsection[title={forall, exists, condition}]

Conditions are often used in combination with elements like \mmlelement {forall}.
There are several ways to convert and combine them in formulas and environments,
so you may expect more alternatives in the future.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <forall/>
    <bvar> <ci> x </ci> </bvar>
    <condition>
      <apply> <lt/>
        <ci> x </ci>
        <cn> 9 </cn>
      </apply>
    </condition>
    <apply> <lt/>
      <ci> x </ci>
      <cn> 10 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The next example is taken from the specifications with a few small changes.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <forall/>
    <bvar> <ci> x </ci> </bvar>
    <condition>
      <apply> <in/>
        <ci> x </ci>
        <ci type="set"> N </ci>
      </apply>
    </condition>
    <apply> <exists/>
      <bvar> <ci> p </ci> </bvar>
      <bvar> <ci> q </ci> </bvar>
      <condition>
        <apply> <and/>
          <apply> <in/>
            <ci> p </ci>
            <ci type="set"> P </ci>
          </apply>
          <apply> <in/>
            <ci> q </ci>
            <ci type="set"> P </ci>
          </apply>
          <apply> <eq/>
            <apply> <plus/> <ci> p </ci> <ci> q </ci> </apply>
            <apply> <times/> <cn> 2 </cn> <ci> x </ci> </apply>
          </apply>
        </apply>
      </condition>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={factorof, tendsto}]

The \mmlelement {factorof} element is applied to its two child elements and
contrary to most functions, the symbol is placed between the elements instead of
in front.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <factorof/>
    <ci> a </ci>
    <ci> b </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The same is true for the \mmlelement {tendsto} element.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <tendsto/>
    <ci> a </ci>
    <ci> b </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={compose}]

This is a nasty element since it has to take care of braces in special ways and
therefore has to analyse its child elements.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <compose/>
    <ci type="fn"> f </ci>
    <ci type="fn"> g </ci>
    <ci type="fn"> h </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply>
    <apply> <compose/>
      <fn> <ci> f </ci> </fn>
      <fn> <ci> g </ci> </fn>
    </apply>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={laplacian}]

A laplacian function is typeset using a $\nabla$ (nabla) symbol.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <laplacian/>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={mean, sdev, variance, median, mode}]

When statistics shows up in math text books, the \mmlelement {sum} element is
likely to show up, probably in combination with the for statistics meaningful
symbolic representation of variables. The mean value of a series of observations
is defined as:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <mean/>
      <ci> x </ci>
    </apply>
    <apply> <divide/>
      <apply> <sum/>
        <ci> x </ci>
      </apply>
      <ci> n </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

or more beautiful:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <mean/>
      <ci> x </ci>
    </apply>
    <apply> <times/>
      <apply> <divide/>
        <cn> 1 </cn>
        <ci> n </ci>
      </apply>
      <apply> <sum/>
        <ci> x </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Of course this definition is not that perfect, but we will present a better
alternative in the chapter on combined markup. The definition of the standard
deviation is more complicated:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <approx/>
    <apply> <sdev/>
      <ci> x </ci>
    </apply>
    <apply> <root/>
      <apply> <divide/>
        <apply> <sum/>
          <apply> <power/>
            <apply> <minus/>
              <ci> x </ci>
              <apply> <mean/>
                <ci> x </ci>
              </apply>
            </apply>
            <cn> 2 </cn>
          </apply>
        </apply>
        <apply> <minus/>
          <ci> n </ci>
          <cn> 1 </cn>
        </apply>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The next example demonstrates the usage of the \mmlelement {variance} in its own
definition.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <variance/>
      <ci> x </ci>
    </apply>
    <apply> <approx/>
      <apply> <mean/>
        <apply> <power/>
          <apply> <minus/>
            <ci> x </ci>
            <apply> <mean/>
              <ci> x </ci>
            </apply>
          </apply>
          <cn> 2 </cn>
        </apply>
      </apply>
      <apply> <times/>
        <apply> <divide/>
          <cn> 1 </cn>
          <apply> <minus/>
            <ci> n </ci>
            <cn> 1 </cn>
          </apply>
        </apply>
        <apply> <sum/>
          <apply> <power/>
            <apply> <minus/>
              <ci> x </ci>
              <apply> <mean/>
                <ci> x </ci>
              </apply>
            </apply>
            <cn> 2 </cn>
          </apply>
        </apply>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

The \mmlelement {median} and \mmlelement {mode} of a series of observations have
no special symbols and are presented as is.

\stopsection

\startsection[title={moment, momentabout, degree}]

Because \MATHML\ is used for a wide range of applications, there can be
information in a definition that does not end up in print but is only used in
some cases. This is illustrated in the next example.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <moment/>
    <degree>
      <cn> 3 </cn>
    </degree>
    <momentabout>
      <ci> p </ci>
    </momentabout>
    <ci> X </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={determinant, transpose}]

These two (and the following) are used to manipulate matrices, either or not in a
symbolic way. A simple determinant or transpose looks like:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <determinant/>
    <ci type="matrix"> A </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <transpose/>
    <ci type="matrix"> A </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

When the \mmlelement {determinant} element is applied to a full blown matrix, the
braces are omitted and replaced by the vertical bars.

\processxmlfile{wh-m-002.xml} \typefile{wh-m-002.xml}

\stopsection

\startsection[title={selector}]

The \mmlelement {selector} element can be used to index a matrix cell or
variable. This element honors the braces.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <selector/>
    <matrix>
      <matrixrow> <cn> 1 </cn> <cn> 2 </cn> </matrixrow>
      <matrixrow> <cn> 3 </cn> <cn> 4 </cn> </matrixrow>
    </matrix>
    <cn> 1 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

A more common usage of the selector is the following:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <selector/>
    <ci> x </ci>
    <ci> i </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

It is possible to pass a comma separated list of indices:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <selector/>
    <ci> x </ci> <cn> 1,2 </cn>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

If you want to have a more verbose index, you can use the \mmlelement {csymbol}
element, flagged with text encoding.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <selector/>
    <ci> x </ci>
    <csymbol encoding="text"> max </csymbol>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={card}]

A cardinality is visualized using vertical bars.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <card/>
      <ci> A </ci>
    </apply>
    <ci> 5 </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={domain, codomain, image}]

The next couple of examples are taken from the \MATHML\ specification and
demonstrate the usage of the not that spectacular domain related elements.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <domain/>
      <fn> <ci> f </ci> </fn>
    </apply>
    <reals/>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

These are typically situations where the \mmlelement {fn} element may show up.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <codomain/>
      <fn> <ci> f </ci> </fn>
    </apply>
    <rationals/>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

This example from the \MATHML\ specification demonstrates a typical usage of the
\mmlelement {image} element. As with the previous two, it is applied to a
function, in this case the predefined \mmlelement {sin}.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <image/>
      <sin/>
    </apply>
    <interval>
      <cn> -1 </cn>
      <cn>  1 </cn>
    </interval>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={domainofapplication}]

This is another seldom used element. Actually, this element is a further
specification of the outer level applied function.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <int/>
    <domainofapplication>
      <ci> C </ci>
    </domainofapplication>
    <ci> f </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={semantics, annotation, annotation-xml}]

We will never know what Albert Einstein would have thought about \MATHML. But we
do know for sure that coding one of his famous findings in \XML\ takes much more
tokens that it takes in \TEX.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <semantics>
    <apply> <eq/>
      <ci> e </ci>
      <apply> <times/>
        <ci> m </ci>
        <apply> <power/>
          <ci> c </ci>
          <cn> 2 </cn>
        </apply>
      </apply>
    </apply>
    <annotation encoding="tex">
      e = m c^2
    </annotation>
  </semantics>
</math>
\stopbuffer

Within a \mmlelement {semantics} element there can be many \mmlelement
{annotation} elements. When using \CONTEXT, the elements that can be identified
as being encoded in \TEX\ will be treated as such. Currently, the related
\mmlelement {annotation-xml} element is ignored.

\processxmlbuffer \typebuffer

Another variant that we support is called \quote {calcmath} which is an efficient
way to enter school math. The syntax resembles the one used in advanced
calculators.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <semantics>
    <annotation encoding="calcmath">
      x = sqrt(sin(x) + cos(c))
    </annotation>
  </semantics>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={integers, reals, ...}]

Sets of numbers are characterized with special (often blackboard) symbols. These
symbols are not always available.

\starttabulate[|||] % we want in line math
\HL
\NC integers       \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><integers/>      </math>} \NC \NR
\NC reals          \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><reals/>         </math>} \NC \NR
\NC rationals      \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><rationals/>     </math>} \NC \NR
\NC naturalnumbers \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><naturalnumbers/></math>} \NC \NR
\NC complexes      \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><complexes/>     </math>} \NC \NR
\NC primes         \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><primes/>        </math>} \NC \NR
\HL
\stoptabulate

\stopsection

\startsection[title={pi, imaginaryi, exponentiale}]

Being a greek character, $\pi$ is a distinctive character. In most math documents
the imaginary~$i$ and exponential~$e$ are typeset as any math identifier.

\starttabulate[|||] % we want in line math
\HL
\NC pi           \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><pi/>          </math>} \NC \NR
\NC imaginaryi   \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><imaginaryi/>  </math>} \NC \NR
\NC exponentiale \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><exponentiale/></math>} \NC \NR
\HL
\stoptabulate

\stopsection

\startsection[title={eulergamma, infinity, emptyset}]

There are a couple of more special tokens. As with the other ones, they can be
changed by reassigning the corresponding entities.

\starttabulate[|||] % we want in line math
\HL
\NC eulergamma \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><eulergamma/></math>} \NC \NR
\NC infinity   \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><infinity/>  </math>} \NC \NR
\NC emptyset   \NC \xmldata{<math xmlns="http://www.w3c.org/mathml" version="2.0"><emptyset/>  </math>} \NC \NR
\HL
\stoptabulate

\stopsection

\startsection[title={notanumber}]

Because \MATHML\ is used for more purposes than typesetting, there are a couple
of elements that do not make much sense in print. One of these is \mmlelement
{notanumber}, which is issued by programs as error code or string.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <divide/>
      <ci> x </ci>
      <cn> 0 </cn>
    </apply>
    <notanumber/>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={true, false}]

When assigning to a boolean variable, or in boolean expressions one can use~$0$
or~$1$ to identify the states, but if you want to be more verbose, you can use
these elements.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <equivalent/>
    <cn type="integer" base="2"> 1 </cn>
    <true/>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={declare}]

Reusing definitions would be a nice feature, but for the moment the formal
specification of this element does not give us the freedom to use it the way we
want.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <declare>
    <ci> A </ci>
    <vector>
      <ci> a </ci>
      <ci> b </ci>
      <ci> c </ci>
    </vector>
  </declare>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={csymbol}]

This element will be implemented as soon as we have an application for it.

\stopsection

\stopchapter

\startchapter[title={Mixed markup}]

\startsection[title={introduction}]

The advantage of presentational markup is that you can build complicated formulas
using super- and subscripts and other elements. The drawback is that the look and
feel is rather fixed and cannot easily be adapted to the purpose that the
document serves. Take for instance the difference between

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <log/>
    <logbase> <cn> 2 </cn> </logbase>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

and

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <?context-mathml-directive log location left ?>
  <apply> <log/>
    <logbase> <cn> 2 </cn> </logbase>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

Both formulas were defined in content \MATHML, so no explicit super- and
subscripts were used. In the next chapter we will see how to achieve such
different appearances.

There are situations where content \MATHML\ is not rich enough to achieve the
desired output. This omission in content \MATHML\ forces us to fall back on
presentational markup.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <ci> <msub> <mi> P </mi> <mi> 1 </mi> </msub> </ci>
    <ci> <msub> <mi> P </mi> <mi> 2 </mi> </msub> </ci>
    <apply> <approx/>
      <cn> 1.01 </cn>
      <cn> 1 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

Here we used presentational elements inside a content \mmlelement {ci} element.
We could have omitted the outer \mmlelement {ci} element, but since the content
\MATHML\ parser may base its decisions on the content elements it finds, it is
best to keep the outer element there.

\typebuffer

The lack of an index element can be quite prominent. For instance, when in an
expose about rendering we want to explore the mapping from coordinates in user
space to those in device space, we use the following formula.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <vector>
      <ci> <msub> <mi> D </mi> <mi> x </mi> </msub> </ci>
      <ci> <msub> <mi> D </mi> <mi> y </mi> </msub> </ci>
      <cn> 1 </cn>
    </vector>
    <apply> <times/>
      <vector>
        <ci> <msub> <mi> U </mi> <mi> x </mi> </msub> </ci>
        <ci> <msub> <mi> U </mi> <mi> y </mi> </msub> </ci>
        <cn> 1 </cn>
      </vector>
      <matrix>
        <matrixrow>
          <ci> <msub> <mi> s </mi> <mi> x </mi> </msub> </ci>
          <ci> <msub> <mi> r </mi> <mi> x </mi> </msub> </ci>
          <cn> 0 </cn>
        </matrixrow>
        <matrixrow>
          <ci> <msub> <mi> r </mi> <mi> y </mi> </msub> </ci>
          <ci> <msub> <mi> s </mi> <mi> y </mi> </msub> </ci>
          <cn> 0 </cn>
        </matrixrow>
        <matrixrow>
          <ci> <msub> <mi> t </mi> <mi> x </mi> </msub> </ci>
          <ci> <msub> <mi> t </mi> <mi> y </mi> </msub> </ci>
          <cn> 1 </cn>
        </matrixrow>
      </matrix>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Again, the \mmlelement {msub} element provides a way out, as in the next
examples, which are adapted versions of formulas we used when demonstrating the
statistics related elements.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <mean/>
      <ci> x </ci>
    </apply>
    <apply> <times/>
      <apply> <divide/>
        <cn> 1 </cn>
        <ci> n </ci>
      </apply>
      <apply> <sum/>
        <bvar> <ci> i </ci> </bvar>
        <ci> x </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <mean/>
      <ci> x </ci>
    </apply>
    <apply> <times/>
      <apply> <divide/>
        <cn> 1 </cn>
        <ci> n </ci>
      </apply>
      <apply> <sum/>
        <bvar> <ci> i </ci> </bvar>
        <lowlimit> <cn> 1 </cn> </lowlimit>
        <uplimit> <cn> n </cn> </uplimit>
        <ci> x </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <mean/>
      <ci> x </ci>
    </apply>
    <apply> <times/>
      <apply> <divide/>
        <cn> 1 </cn>
        <ci> n </ci>
      </apply>
      <apply> <sum/>
        <bvar> <ci> i </ci> </bvar>
        <lowlimit> <cn> 1 </cn> </lowlimit>
        <uplimit> <cn> n </cn> </uplimit>
        <ci> <msub> <mi> x </mi> <mi> i </mi> </msub> </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

You can also use a selector for indexing, so in practice we can avoid the mixed
mode:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <vector>
      <apply> <selector/> <ci> D </ci> <ci> x </ci> </apply>
      <apply> <selector/> <ci> D </ci> <ci> y </ci> </apply>
      <cn> 1 </cn>
    </vector>
    <apply> <times/>
      <vector>
        <apply> <selector/> <ci> U </ci> <ci> x </ci> </apply>
        <apply> <selector/> <ci> U </ci> <ci> y </ci> </apply>
        <cn> 1 </cn>
      </vector>
      <matrix>
        <matrixrow>
          <apply> <selector/> <ci> s </ci> <ci> x </ci> </apply>
          <apply> <selector/> <ci> r </ci> <ci> x </ci> </apply>
          <cn> 0 </cn>
        </matrixrow>
        <matrixrow>
          <apply> <selector/> <ci> s </ci> <ci> y </ci> </apply>
          <apply> <selector/> <ci> r </ci> <ci> y </ci> </apply>
          <cn> 0 </cn>
        </matrixrow>
        <matrixrow>
          <apply> <selector/> <ci> t </ci> <ci> x </ci> </apply>
          <apply> <selector/> <ci> t </ci> <ci> y </ci> </apply>
          <cn> 1 </cn>
        </matrixrow>
      </matrix>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\stopchapter

\startchapter[title={Directives}]

Some elements can be tuned by changing their attributes. Especially when formulas
are defined by a team of people or when they are taken from a repository, there
is a good chance that inconsistencies will show up.

In \CONTEXT, you can influence the appearance by setting the typesetting
parameters of (classes of) elements. You can do this either by adding processing
instructions, or by using the \CONTEXT\ command \type {\setupMMLappearance}.
Although the first method is more in the spirit of \XML, the second method is
more efficient and consistent. As a processing instruction, a directive looks
like:

\starttyping
<?context-mathml-directive element key value ?>
\stoptyping

This is equivalent to the \CONTEXT\ command:

\starttyping
\setupMMLappearance [element] [key=value]
\stoptyping

Some settings concern a group of elements, in which case a group classification
(like \type {sign}) is used.

\startsection[title={scripts}]

By default, nested super- and subscripts are kind of isolated from each other. If
you want a combined script, there is the \mmlelement {msubsup}. You can however
force combinations with a directive.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <msup>
    <msub> <mi> x </mi> <mn> 1 </mn> </msub>
    <mn> 2 </mn>
  </msup>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<?context-mathml-directive scripts alternative b ?>

<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <msup>
    <msub> <mi> x </mi> <mn> 1 </mn> </msub>
    <mn> 2 </mn>
  </msup>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={sign}]

The core element of \MATHML\ is \mmlelement {apply}. Even simple formulas will
often have more than one (nested) \mmlelement {apply}. The most robust way to
handle nested formulas is to use braces around each sub formula. No matter how
robust this is, when presented in print we want to use as less braces as
possible. The next example shows addition as well as subtraction.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <plus/>
    <cn> 7 </cn>
    <cn> 5 </cn>
    <apply> <minus/>
      <cn> 3 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

In principle subtraction is adding negated numbers, so it would have been natural
to have just an addition (\mmlelement {plus}) and negation operator. However,
\MATHML\ provides both a \mmlelement {plus} and \mmlelement {minus} operator,
where the latter can be used as a negation. So in fact we have:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <?context-mathml-directive sign reduction no ?>
  <apply> <plus/>
    <cn> 7 </cn>
    <cn> 5 </cn>
    <apply> <minus/>
      <cn> 3 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

Now imagine that a teacher wants to stress this negation in the way presented
here, using parentheses. Since all the examples shown here are typeset directly
from the \MATHML\ source, you may expect a solution, so here it is:

\typebuffer

By default signs are reduced, but one can disable that at the document and|/|or
formula level using a processing instruction at the top of the formula. There are
of course circumstances where the parentheses cannot be left out.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <plus/>
    <ci> a </ci>
    <apply> <plus/> <ci> b </ci> <ci> c </ci> </apply>
    <ci> d </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <minus/>
    <ci> a </ci>
    <apply> <minus/> <ci> b </ci> <ci> c </ci> </apply>
    <ci> d </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <plus/>
    <ci> a </ci>
    <apply> <minus/> <ci> b </ci> <ci> c </ci> </apply>
    <ci> d </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <minus/>
    <ci> a </ci>
    <apply> <plus/> <ci> b </ci> <ci> c </ci> </apply>
    <ci> d </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

Another place where parentheses are not needed is the following:

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <minus/>
    <apply> <exp/>
      <cn> 3 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\typebuffer

This means that the interpreter of this kind of \MATHML\ has to analyze child
elements in order to choose the right way to typeset the formula. The output will
look like:

\processxmlbuffer

By default, as less braces as possible are used. As demonstrated, a special case
is when \mmlelement {plus} and \mmlelement {minus} have one sub element to deal
with. If you really want many braces there, you can turn off sign reduction.

\startdirectives
\HL
\NC sign \NC reduction \NC yes \NC use as less braces as possible \NC \NR
\NC      \NC           \NC no  \NC always use braces \NC \NR
\HL
\stopdirectives

We will demonstrate these alternatives with an example.

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <plus/>
    <ci> a </ci>
    <apply> <sin/>
      <ci> b </ci>
    </apply>
    <apply> <power/>
      <ci> c </ci>
      <cn> 5 </cn>
    </apply>
    <apply> <power/>
      <apply> <sin/>
        <ci> d </ci>
      </apply>
      <cn> 2 </cn>
    </apply>
    <ci> e </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer[a]

We need quite some code to encode this formula.

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive power reduction no ?>
\stopbuffer

With power reduction turned off, we get:

\processxmlbuffer[b,a]

As directive we used:

\typebuffer[b]

The following example illustrates that we should be careful in coding such
formulas; here the \mmlelement {power} is applied to the argument of \mmlelement
{sin}.

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <plus/>
    <ci> a </ci>
    <apply> <sin/>
      <ci> b </ci>
    </apply>
    <apply> <power/>
      <ci> c </ci>
      <cn> 5 </cn>
    </apply>
    <apply> <sin/>
      <apply> <power/>
        <ci> d </ci>
        <cn> 2 </cn>
      </apply>
    </apply>
    <ci> e </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer \typebuffer

\stopsection

\startsection[title={divide}]

Divisions can be very space consuming but there is a way out: using a forward
slash symbol. You can set the level at which this will take place. By default,
fractions are typeset in the traditional way.

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <divide/>
    <cn> 1 </cn>
    <apply> <plus/>
      <cn> 1 </cn>
      <apply> <divide/>
        <cn> 1 </cn>
        <ci> x </ci>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\startbuffer[b]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <divide/>
    <cn> 1 </cn>
    <apply> <plus/>
      <cn> 1 </cn>
      <apply> <divide/>
        <cn> 1 </cn>
        <apply> <plus/>
          <cn> 1 </cn>
          <apply> <divide/>
            <cn> 1 </cn>
            <ci> x </ci>
          </apply>
        </apply>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\processxmlbuffer[a] \typebuffer[a]
\processxmlbuffer[b] \typebuffer[b]

\startbuffer[c]
<?context-mathml-directive divide level 1 ?>
\stopbuffer

\processxmlbuffer[c,a] \processxmlbuffer[c,b] \typebuffer[c]

\startbuffer[c]
<?context-mathml-directive divide level 2 ?>
\stopbuffer

\processxmlbuffer[c,a] \processxmlbuffer[c,b] \typebuffer[c]

\stopsection

\startsection[title={relation}]

You should keep in mind that (at least level 2) content \MATHML\ is not that rich
in terms of presenting your ideas in a visually attractive way. On the other
hand, because the content is highly structured, some intelligence can be applied
when typesetting them. By default, a relation is not vertically aligned but
typeset horizontally.

If an application just needs raw formulas, definitions like the following are all
right.

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <apply> <plus/>
      <ci> a </ci>
      <ci> b </ci>
      <ci> c </ci>
    </apply>
    <apply> <plus/>
      <ci> d </ci>
      <ci> e </ci>
    </apply>
    <apply> <plus/>
      <ci> f </ci>
      <ci> g </ci>
      <ci> h </ci>
      <ci> i </ci>
    </apply>
    <cn> 123 </cn>
  </apply>
</math>
\stopbuffer

\typebuffer[a]

The typeset result will bring no surprises:

\processxmlbuffer[a]

But, do we want to show a formula that way? And what happens with much longer
formulas? You can influence the appearance with processing instructions.

\startdirectives
\HL
\NC relation \NC align \NC no    \NC don't align relations \NC \NR
\NC          \NC       \NC left  \NC align all relations left \NC \NR
\NC          \NC       \NC right \NC align all relations right \NC \NR
\NC          \NC       \NC first \NC place the leftmost relation left \NC \NR
\NC          \NC       \NC last  \NC place the rightmost relation right \NC \NR
\HL
\stopdirectives

The next couple of formulas demonstrate in what way the previously defined
formula is influenced by the processing instructions.

\startbuffer[b]
<?context-mathml-directive relation align left ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive relation align right ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive relation align first ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive relation align last ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={base}]

When in a document several number systems are used, it can make sense to mention
the base of the number. There are several ways to identify the base.

\startdirectives
\HL
\NC base \NC symbol \NC numbers    \NC a (decimal) number \NC \NR
\NC      \NC        \NC characters \NC one character      \NC \NR
\NC      \NC        \NC text       \NC a mnemonic         \NC \NR
\NC      \NC        \NC no         \NC no symbol          \NC \NR
\HL
\stopdirectives

By default, when specified, a base is identified as number.

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <cn type="integer" base="8"> 1427 </cn>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive base symbol numbers ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive base symbol characters ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive base symbol text ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={function}]

There is a whole bunch of functions available as empty element, like \mmlelement
{sin} and \mmlelement {log}. When a function is applied to a function, braces
make not much sense and placement is therefore disabled.

\startdirectives
\HL
\NC function \NC reduction \NC yes \NC chain functions without braces \NC \NR
\NC          \NC           \NC no  \NC put braces around nested functions \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <sin/> <ci> x </ci> </apply>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive function reduction yes ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive function reduction no ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={limits}]

When limits are placed on top of the limitation symbol, this generally looks
better than when they are placed alongside. You can also influence limit
placement per element. This feature is available for \mmlelement{int},
\mmlelement {sum}, \mmlelement {product} and \mmlelement {limit}.

\startdirectives
\HL
\NC limit \NC location \NC top   \NC place limits on top of the symbols \NC \NR
\NC       \NC          \NC right \NC attached limits as super/subscripts \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <int/>
    <bvar> <ci> x </ci> </bvar>
    <lowlimit> <cn> 0 </cn> </lowlimit>
    <uplimit> <cn> 1 </cn> </uplimit>
  </apply>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive int location top ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive int location right ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={declare}]

Currently declarations are not supposed to end up in print. By default we typeset
a message, but you can as well completely hide declarations.

\startdirectives
\HL
\NC declare \NC state \NC start \NC show declarations \NC \NR
\NC         \NC       \NC stop  \NC ignore (hide) declarations \NC \NR
\HL
\stopdirectives

\stopsection

\startsection[title={lambda}]

There is more than one way to visualize a lambda function. As with some other
settings, changing the appearance can best take place at the document level.

\startdirectives
\HL
\NC lambda \NC alternative \NC b \NC show lambda as arrow \NC \NR
\NC        \NC             \NC a \NC show lambda as set \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <lambda>
    <bvar> <ci> x </ci> </bvar>
    <apply> <log/>
      <ci> x </ci>
    </apply>
  </lambda>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive lambda alternative a ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive lambda alternative b ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={power}]

Taking the power of a function looks clumsy when braces are put around the
function. Therefore, by default, the power is applied to the function symbol
instead of the whole function.

\startdirectives
\HL
\NC power \NC reduction \NC yes \NC attach symbol to function symbol \NC \NR
\NC       \NC           \NC no  \NC attach symbol to function argument \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <power/>
    <apply> <ln/>
      <ci> x </ci>
    </apply>
    <cn> 3 </cn>
  </apply>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive power reduction yes ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive power reduction no ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={diff}]

Covering all kind of differential formulas is not trivial. Currently we support
two locations for the operand (function). By default the operand is placed above
the division line.

\startdirectives
\HL
\NC diff \NC location \NC top   \NC put the operand in the fraction \NC \NR
\NC      \NC          \NC right \NC put the operand after the fraction \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <diff/>
    <bvar>
      <ci> x </ci>
      <degree> <cn> 2 </cn> </degree>
    </bvar>
    <apply> <fn> <ci> f </ci> </fn>
      <apply> <plus/>
        <apply> <times/>
          <cn> 2 </cn>
          <ci> x </ci>
        </apply>
        <cn> 1 </cn>
      </apply>
    </apply>
  </apply>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive diff location top ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive diff location right ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={vector}]

Depending on the complication of a vector or on the available space, you may wish
to typeset a vector horizontally or vertically. By default a vector is typeset
horizontally.

\startdirectives
\HL
\NC vector \NC direction \NC horizontal \NC put vector elements alongside \NC \NR
\NC        \NC           \NC vertical   \NC stack vector elements \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <eq/>
    <vector>
      <ci> x </ci>
      <ci> y </ci>
      <ci> z </ci>
    </vector>
    <vector>
      <cn> 1 </cn>
      <cn> 0 </cn>
      <cn> 1 </cn>
    </vector>
  </apply>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive vector direction horizontal ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive vector direction vertical ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={times}]

Depending on the audience, a multiplication sign is implicit (absent) or
represented by a regular times symbol or a dot.

\startdirectives
\HL
\NC times \NC symbol \NC no  \NC don't add a symbol \NC \NR
\NC       \NC        \NC yes \NC separate operands by a times ($\times$) \NC \NR
\NC       \NC        \NC dot \NC separate operands by a dot ($\cdot$)\NC \NR
\NC auto  \NC symbol \NC no  \NC don't check for succesive numbers \NC \NR
\NC       \NC        \NC yes \NC separate succesive numbers by a times ($\times$) \NC \NR
\NC       \NC        \NC dot \NC separate succesive numbers by a dot ($\cdot$)\NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <plus/>
    <ci> x </ci>
    <apply> <times/>
      <cn> 2 </cn>
      <ci> x </ci>
    </apply>
  </apply>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive times symbol no ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive times symbol yes ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive times symbol dot ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={log}]

The location of a logbase depends on tradition and|/|or preference, which is why
we offer a few alternatives: as pre superscript (in the right top corner before
the symbol) or as post subscript (in the lower left corner after the symbol).

\startdirectives
\HL
\NC log \NC location \NC right \NC place logbase at the right top \NC \NR
\NC     \NC          \NC left  \NC place logbase at the lower left \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <log/>
    <logbase>
      <ci> 3 </ci>
    </logbase>
    <apply> <plus/>
      <ci> x </ci>
      <cn> 1 </cn>
    </apply>
  </apply>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive log location right ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive log location left ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={polar}]

For polar notation we provide several renderings:

\startdirectives
\HL
\NC polar \NC alternative \NC a \NC explicit polar notation       \NC \NR
\NC       \NC             \NC b \NC exponential power notation    \NC \NR
\NC       \NC             \NC c \NC exponential function notation \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <cn type="polar"> 2 <sep/> <pi/> </cn>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive polar alternative a ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive polar alternative b ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive polar alternative c ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\startsection[title={e-notation}]

Depending on the context, you may want to typeset the number \type {1.23e4} not
as this sequence, but using a multiplier construct. As with the \mmlelement
{times}, we support both multiplication symbols.

\startdirectives
\HL
\NC enotation \NC symbol \NC no  \NC no interpretation              \NC \NR
\NC           \NC        \NC yes \NC split exponent, using $\times$ \NC \NR
\NC           \NC        \NC dot \NC split exponent, using $\cdot$  \NC \NR
\HL
\stopdirectives

\startbuffer[a]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <cn type="e-notation">10<sep/>23</cn>
</math>
\stopbuffer

\typebuffer[a]

\startbuffer[b]
<?context-mathml-directive enotation symbol no ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive enotation symbol yes ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\startbuffer[b]
<?context-mathml-directive enotation symbol dot ?>
\stopbuffer

\processxmlbuffer[b,a] \typebuffer[b]

\stopsection

\stopchapter

\startchapter[title={Typesetting modes}]

Math can be typeset inline or display. In order not to widen up the text of a
paragraph too much, inline math is typeset more cramped. Since \MATHML\ does
provide just a general purpose \mmlelement {math} element we have to provide the
information needed using other elements. Consider the following text.

\startbuffer
<document>
To what extent is math supposed to reflect the truth and nothing but
the truth? Consider the simple expression
    <math xmlns="http://www.w3c.org/mathml" version="2.0">
        <apply> <eq/>
            <cn> 10 </cn>
            <apply> <plus/>
                <cn> 3 </cn>
                <cn> 7 </cn>
            </apply>
        </apply>
    </math>. Many readers will consider this the truth, but then,
can we assume that the decimal notation is used?

<formula>
  <math xmlns="http://www.w3c.org/mathml" version="2.0">
    <apply> <eq/>
      <cn> 10 </cn>
      <apply> <plus/>
        <cn> 3 </cn>
        <ci> x </ci>
      </apply>
    </apply>
  </math>
</formula>

In many elementary math books, you can find expressions like the
previous. Because in our daily life we use the decimal numbering system,
we can safely assume that
    <math xmlns="http://www.w3c.org/mathml" version="2.0">
        <apply> <eq/>
            <ci> x </ci>
            <cn> 7 </cn>
        </apply>
    </math>. But, without explicitly mentioning this boundary condition,
more solutions are correct.

<formula label="octal" sublabel="a">
  <math xmlns="http://www.w3c.org/mathml" version="2.0">
    <apply> <eq/>
      <cn> 10 </cn>
      <apply> <plus/>
        <cn> 3 </cn>
        <cn> 5 </cn>
      </apply>
    </apply>
  </math>
</formula>

In <textref label="octal">formula</textref> we see an at first sight
wrong formula. But, if we tell you that octal numbers are used, your
opinion may change instantly. A rather clean way out of this confusion
is to extend the notation of numbers by explicitly mentioning the base.

<subformula label="octal base" sublabel="b">
  <math xmlns="http://www.w3c.org/mathml" version="2.0">
    <apply> <eq/>
      <cn type="integer" base="8"> 10 </cn>
      <apply> <plus/>
        <cn type="integer" base="8"> 3 </cn>
        <cn type="integer" base="8"> 5 </cn>
      </apply>
    </apply>
  </math>
</subformula>

Of course, when a whole document is in octal notation, a proper
introduction is better than annotated numbers as used in <textref
label="octal base">formula</textref>.
</document>
\stopbuffer

\blank \startnarrower \processxmlbuffer \stopnarrower \blank

In terms of \XML\ this can look like:

\typebuffer

Math that is part of the text flow is automatically handled as inline math. If
needed you can encapsulate the code in an \mmlelement {imath} environment.
Display math is recognized as such when it is a separate paragraph, but since
this is more a \TEX\ feature than an \XML\ one, you should encapsulate display
math either in a \mmlelement {dmath} element or in a \mmlelement {formula} or
\mmlelement {subformula} element.

For a while you can use attribute \type {mode} with values \type {display} or
\type {inline}. Recent \MATHML\ specifications provide the \type {display}
attribute with values \type {block} or \type {inline}. We support both.

\stopchapter

\startchapter[title={Getting started}]

A comfortable way to get accustomed to \MATHML\ is to make small documents of the
following form:

\starttyping
\usemodule[mathml]

\starttext

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <cos/>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

\stoptext
\stoptyping

As you see, we can mix \MATHML\ with normal \TEX\ code. A document like this is
processed in the normal way using the \type {context} command. If you also want
to see the original code, you can say:

\starttyping
\usemodule[mathml]

\starttext

\startbuffer
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <cos/>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\processxmlbuffer

\typebuffer

\stoptext
\stoptyping

Like \TEX\ and \METAPOST\ code, buffers can contain \MATHML\ code. The advantage
of this method is that we only have to key in the data once. It also permits you
to experiment with processing instructions.

\starttyping
\startbuffer[mml]
<math xmlns="http://www.w3c.org/mathml" version="2.0">
  <apply> <log/>
    <logbase> <cn> 3.5 </cn> </logbase>
    <ci> x </ci>
  </apply>
</math>
\stopbuffer

\startbuffer[pi]
 <?context-mathml-directive log location right ?>
\stopbuffer

\processxmlbuffer[pi,mml]

\startbuffer[pi]
 <?context-mathml-directive log location left ?>
\stopbuffer

\processxmlbuffer[pi,mml]
\stoptyping

If you like coding your documents in \TEX\ but want to experiment with \MATHML,
combining both languages in the way demonstrated here may be an option. When you
provide enough structure in your \TEX\ code, converting a document to \XML\ is
then not that hard to do. Where coding directly in \XML\ is kind of annoying,
coding \MATHML\ is less cumbersome, because you can structure your formulas
pretty well, especially since the fragments are small so that proper indentation
is possible.

\stopchapter

\startchapter[title={Bidi}]

Support for bidirectional math is not entirely trivial as it demands a font that
supports it. When they were released, the stix fonts were not that useable and
Khaled Hosny turned them into the xits fonts that are now quite complete and
useable in an \OPENTYPE\ and \UNICODE\ environment. He also added support for
right to left math.

Normally you will only use that in a right to left typeset document, in which
case you have a setup like this:

\starttyping
\setuptobodyfont
  [xitsbidi]

\setupalign
  [r2l]

\setupmathematics
  [align=r2l]

\starttext

Some text.

\startformula \sqrt{ف^2\over 4ب} \stopformula

Some more text

\stoptext
\stoptyping

As \MATHML\ has no global settings you need to control it specifically. At some
point we might decide to provide some global flags but that depends on how the
general bidi layout machinery evolves. Here we just stick to an example:

\startbuffer[test]
<math xmlns="http://www.w3.org/1998/Math/MathML" dir="rtl">
    <msqrt>
        <mfrac>
            <msup><mi>ف</mi><mn>2</mn></sup>
            <mrow><mn>4</mn><mi>ب</mi></mrow>
        </mfrac>
    </msqrt>
</math>
\stopbuffer

\typebuffer[test]

\start
    \switchtobodyfont[xitsbidi]
    \xmlprocessbuffer{main}{test}{}
    \par
\stop

The order of input is still rather left to right which makes sense as we're sort
of structuring the math input.

\stopchapter

\startchapter[title={OpenMath}]

Because \OPENMATH\ is now a subset of \MATHML\ we can to some extend also support
this coding. We do a straightforward remapping to content \MATHML\ so any
rendering that is supported there is also supported in the equivalent \OPENMATH\
code.

\startbuffer
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
  <OMA> <OMS cd="relation1" name="eq"/>
    <OMV name="y"/>
    <OMA> <OMS cd="arith1" name="minus"/>
      <OMA> <OMV name="f"/>
        <OMV name="x"/>
      </OMA>
      <OMA> <OMV name="f"/>
        <OMA> <OMS cd="arith1" name="minus"/>
          <OMV name="x"/>
          <OMI>1</OMI>
        </OMA>
      </OMA>
    </OMA>
  </OMA>
</OMOBJ>
\stopbuffer

\processxmlbuffer \typebuffer

Because in practice we may use a mixture of math encodings this can come in handy
because it saves conversion of the \XML\ source.

\stopchapter

\startchapter[title={CalcMath}]

We support two types of annotation markup: \TEX\ (\type {tex}) and what we call
\quote {calculator math} (\type {calcmath}). The second type is also available
directly. Inline calcmath is coded using the \mmlelement{icm} element.

\startbuffer
<document>
  This is an inline formula <icm>sin(x^2+1/x)</icm> just to demonstrate
  the idea of calculator math.
</document>
\stopbuffer

\blank \noindentation \processxmlbuffer \typebuffer

If one edits the \XML\ file directly this can type quite some coding. For more
complex formulas one can revert to content \MATHML, or when interactivity is
needed to \OPENMATH.

The argument that one should use a dedicated editor for math instead is not that
convincing for authors who have to key on lots of small snippets of math. And one
can always transform this code in its more bloated variant. The calcmath
converter is dedicated to Frits Spijkers, author of Dutch math schoolbooks and
fluent in all those math encodings methods we force upon him. The code resembles
that used in the calculators at schools and we used it in projects with computer
aided feedback where students had to key in math. When there is demand for this
input method we will provide more details.

\stopchapter

\startchapter[title={AsciiMath}]

A few years back we included some basic support for \ASCIIMATH\ as a proof of
concept not knowing that one day we were forced to fully support it in a project.
In one of our projects \CONTEXT\ is the backend for generating math books for
high school math. Input is \XML\ and math is coded in presentational \MATHML. We
should say \quotation {was coded}, because in the Spring of 2014 another party in
the project (the one responsible for the web part) converted the \MATHML\ into
\ASCIIMATH\ on behalve of their web authoring tool.

Where we would have chosen to use the \MATHML\ annotation attribute, they had
chosen to flatten the structured \MATHML\ into less structured \ASCIIMATH. And
there was no way back. We're talking of tens of thousands of files here.
\footnote {Around the same time Google decided to drop native \MATHML\ support
from Chrome so one might wonder why \MATHML\ was developed in the first place.}

On the web \ASCIIMATH\ is mostly interpreted by MathJax's \JAVASCRIPT\ in
combination with \CSS. Since we didn't want to depend on a \JAVASCRIPT\
conversion in \CONTEXT\ we started to completely rewrite our \ASCIIMATH\ module.
We also needed a bit more control in order to meet specific demands of the
publisher, like formatting numbers, support for characters not in the normal
repertoire, checking and tracing, and the speed of rendering had not to be
affected.

If you invoke the \ASCIIMATH\ module with \typ {\usemodule [asciimath]} the
command \type {\asciimath{...}} is available for testing purposes. Within the
curly brackets you can type an \ASCIIMATH\ expression.

Normally an \ASCIIMATH\ expression in \XML|/|\HTML\ is enclosed by back-quotes:

\startbuffer
`x^2`
\stopbuffer

\typebuffer

But we rather stick to the \XML\ like coding:

\startbuffer
<am>x^2</am>
\stopbuffer

\typebuffer

This is equivalent to the \TEX\ command:

\asciimath{x^2}

The interpretation of such a formula is no problem. But let's give a few examples
where \ASCIIMATH\ lacks structure or needs a (sometimes bizar) interpretation to
obtain adequate rendering:

\noindentation Behaviour of superscripts and subscripts depends on operator that
preceeds a number or variable:

\starttabulate
\FL
\NC \type{`sin^-1(x)`}          \NC \asciimath{sin^-1(x)}             \NC \NR
\NC \type{`sin^+1(x)`}          \NC \asciimath{sin^+1(x)}             \NC \NR
\LL
\stoptabulate

\noindentation A script can be either one character or a number made from more
characters:

\starttabulate
\FL
\NC \type{`int_a^b f(x)`}       \NC \asciimath{int_a^b f(x)}          \NC \NR
\NC \type{`int_aa^bb f(x)`}     \NC \asciimath{int_aa^bb f(x)}        \NC \NR
\NC \type{`int_1000^2000 f(x)`} \NC \asciimath{int_1000^2000 f(x)}    \NC \NR
\LL
\stoptabulate

\noindentation Behaviour of operator depends on character, where some characters
have special meaning:

\starttabulate
\FL
\NC \type{`d/dx`}               \NC \asciimath{d/dx}                  \NC \NR
\NC \type{`q/qx`}               \NC \asciimath{q/qx}                  \NC \NR
\LL
\stoptabulate

\noindentation Behaviour of the curly brackets is somewhat peculiar because at
times they are not used for grouping anymore:

\starttabulate
\FL
\NC \type{`{a/b}/{d/c}`}        \NC \asciimath{{a/b}/{d/c}}           \NC \NR
\NC \type{`{a/b}//{d/c}`}       \NC \asciimath{{a/b}//{d/c}}          \NC \NR
\LL
\stoptabulate

\noindentation Behaviour depends on sequence of scripts (solved in \CONTEXT):

\starttabulate
\FL
\NC \type{`int_0^1 f(x)dx`}     \NC \asciimath{int_0^1 f(x)dx}        \NC \NR
\NC \type{`int^1_0 f(x)dx`}     \NC \asciimath{int^1 text(_)0 f(x)dx} \NC \NR
\LL
\stoptabulate

During the development of the \ASCIIMATH\ support we used the MathJax interpretor
as a reference since that is available on the web. At the time of writing
documentation was limited so some trial and error was involved in writing the
parser. As usual we started from examples. Below we give a number of those
examples so you can familiarize yourself with \ASCIIMATH. Note that you can use
\TEX||like math coding and even use the backslash, but be warned for unexpected
behaviour. In a webpage backticks are used to indicate \ASCIIMATH.

\startlines
\ExampleLine{sqrt-3ax}
\ExampleLine{sqrt(-3ax)}
\ExampleLine{root(3)(ax)}
\ExampleLine{x^2+y_1+z_12^3}
\ExampleLine{sin^-1(x)}
\ExampleLine{d/dx f(x)=lim_(h->0) (f(x+h)-f(x))/h}
\ExampleLine{f(x)=sum_(n=0)^oo(f^((n))(a))/(n!)(x-a)^n}
\ExampleLine{int_0^1 f(x)dx}
\ExampleLine{int^1_0 f(x)dx}
\ExampleLine{a//b}
\ExampleLine{a//\alpha}
\ExampleLine{(a/b)/(d/c)}
\ExampleLine{((a*b))/(d/c)}
\ExampleLine{(a/b)/(c/d)={:(ad)/(bd):}/{:(bc)/(bd):}=(ad)/(bc)=(ad)/(bc)}
\ExampleLine{a/b//c/d=(ad)/(bd)//(bc)/(bd)=ad//bc=(ad)/(bc)}
\ExampleLine{[[a,b],[c,d]]((n),(k))}
\ExampleLine{1/x={(1,text{if } x!=0),(text(undefined), text(if ) x=0):}}
\ExampleLine{<<a,b>> text{ and } [ (x,y),(u,v) ] }
\ExampleLine{(a,b] = {x in RR | a < x <= b}}
\ExampleLine{langle larr ; 0,4]}
\ExampleLine{〈← ; 0,4]}
\ExampleLine{[0 , rarr rangle}
\ExampleLine{[0 , →〉}
\ExampleLine{5/|CD|=8/5}
\ExampleLine{|MD|/|CD|=|AD|/|MD|}
\ExampleLine{x lt 4 vv x gt 1}
\ExampleLine{x \lt 4 vv x \gt 1}
\ExampleLine{x &lt; 4 vv x &gt; 1}     % Hans: werkt niet goed; wel op http://www.wjagray.co.uk/maths/ASCIIMathTutorial.html
\ExampleLine{lim_(x→∞)1/x=0}
\ExampleLine{text(D)_(f)}
\ExampleLine{p _|_ q}
\ExampleLine{g·g· stackrel (text(n times) ) (...·g)}
\ExampleLine{stackrel(+)(\rightarrow)}
\ExampleLine{stackrel(+)(rightarrow)}  % Hans: werkt niet goed; wel op http://www.wjagray.co.uk/maths/ASCIIMathTutorial.html
\ExampleLine{((a_(11),cdots,a_(1n)),(vdots,ddots,vdots),(a_(m1),cdots,a_(mn)))}
\stoplines

Unfortunately \ASCIIMATH\ can be unpredictable which is a side effect of the fact that a
high degree of tolerance is built in. We strongly advice to use spaces to make your
results predictable.

\startlines
\ExampleLine{o ox x = xo}
\ExampleLine{a ax x = xa}
\ExampleLine{ooxx=xo}
\ExampleLine{aaxx=xa}
\stoplines

One of the properties is that \TEX\ commands are supported, that is,. with a few
exceptions: \type {P} and \type {S} don't produce $\P$ and $\S$. Also, don't
confuse these symbols with the entities supported by \MATHML: in \ASCIIMATH\
\type{circ} is circle and not a circumflex. Also, \type {&lt;}, \type {&gt;} are
converted into \asciimath {&lt;} and \asciimath {&gt;} while \type {&amp;}
becomes \asciimath{&amp;}. As usual with input formats that start out simple, in
the end they become so complex that one can wonder why to use them. It is the
usual problem of using one system for everything.

The following examples are similar to the once shown elsewhere in this document.

\startsubsubject[title=derivatives]

\ExampleLine{(da)/(dx) = 0}
\ExampleLine{dx/dx = 0}
\ExampleLine{(d(au))/(dx) = a (du)/(dx)}
\ExampleLine{(d(u+v+w))/(dx) = (du)/(dx) + (dv)/(dx) + (dw)/(dx)}
\ExampleLine{(d(uv))/(dx) = u (du)/(dx) + v (dv)/(dx)}
\ExampleLine{(d(uvw))/(dx) = vw(du)/(dx) + uw(dv)/(dx) + uv(dw)/(dx)}
\ExampleLine{(d(u/v))/(dx) = (v(du)/(dx) - u(dv)/(dx) ) / (v^2) = 1/v (du)/(dx) - u/v^2 (dv)/(dx)}
\ExampleLine{(d(u^n))/(dx) = n(u)^(n-1) (dv)/(dx)}
\ExampleLine{(d sqrt(u))/(dx) = 1/(2 sqrt(u)) (du)/(dx) }
\ExampleLine{(d(1/u))/(dx) = - 1/u^2 (du)/(dx)}
\ExampleLine{(d(1/(u^n)))/(dx) = - n/u^(n+1) (du)/(dx)}
\ExampleLine{(d log (u + sqrt(u^2+1)))/(dx) = 1/(sqrt(u^2 + 1)) (du)/(dx) }

\stopsubsubject

\startsubsubject[title=integral]

\ExampleLine{int (1 / (x sqrt(a^2 +- x^2) ) ) dx = - 1/a log (a + sqrt(a^2 +- x^2)) / x}
\ExampleLine{int (1 / ( a + bx^2) ) = 1 / (2 sqrt(-ab)) log (a + x sqrt(-ab) ) / (a - x sqrt(-ab) ) vv 1 / sqrt(-ab) tanh^(-1) (x sqrt (-ab)) / a}
\ExampleLine{int ( 1 / (cos(ax) (1 +- sin(ax)) ) ) dx = ( 1 / (2a( 1 +- sin(ax) )) ) + 1 / (2a) log tan(pi/4 + (ax)/2)}

\stopsubsubject

\startsubsubject[title=series]

\ExampleLine{1 - 1/3 + 1/5 - 1/7 + cdots = pi/4}
\ExampleLine{1 + 1/2^2 + 1/3^2 + 1/4^2 + cdots = pi^2/6}
\ExampleLine{1 - 1/2^2 + 1/3^2 - 1/4^2 + cdots = pi^2/12}
\ExampleLine{AA x in RR | e^x = 1 + x + x^2/(2!) + x^3/(3!) + cdots + x^n/(n!)}
\ExampleLine{AA x in RR | e^(text(-)x) = 1 - x + x^2/(2!) - x^3/(3!) + cdots + (text(-)1^n)x^n/(n!)}

\stopsubsubject

\startsubsubject[title=logs]

\ExampleLine{AA a > 0 ^^ b > 0 | {:log_g:} a + {:log_g:} b}
\ExampleLine{AA a > 0 ^^ b > 0 | {:log_g:} a/b = {:log_g:} a - {:log_g:} b}
\ExampleLine{AA b in RR ^^ a > 0 | {:log_g:} a^b = b {:log_g:} a}
\ExampleLine{AA a > 0 | {:log_g:} a = ({:log_p:} a) / ({:log_p:} g)}

\stopsubsubject

\startsubsubject[title=goniometrics]

\ExampleLine{sin(x+y) = sinx cosy + cosx siny}
\ExampleLine{sin(x-y) = sinx cosy - cosx siny}
\ExampleLine{sin(x+y) = cosx cosy - sinx siny}
\ExampleLine{sin(x-y) = cosx cosy + sinx siny}
\ExampleLine{tan(x+y) = (tanx + tany) / (1 - tanx tany)}
\ExampleLine{tan(x-y) = (tanx - tany) / (1 + tanx tany)}
\ExampleLine{sinp + sinq = 2 sin (p+q)/2 cos (p-q)/2}
\ExampleLine{sinp - sinq = 2 cos (p+q)/2 sin (p-q)/2}
\ExampleLine{cosp + cosq = 2 cos (p+q)/2 cos (p-q)/2}
\ExampleLine{2 cos alpha cos beta = cos(alpha + beta) + cos(alpha - beta)}
\ExampleLine{-2 sin alpha cos beta = sin(alpha + beta) - sin(alpha - beta)}
\ExampleLine{AA ∆ ABC | a / (sin alpha) + b / (sin beta) + c / (sin gamma)}
\ExampleLine{AA ∆ ABC | {:(a^2 = b^2 + c^2 - 2bc cos alpha),(b^2 = a^2 + c^2 - 2ac cos beta),(c^2 = a^2 + b^2 - 2ab cos gamma):}}

\stopsubsubject

\startsubsubject[title=statistics]

\ExampleLine{bar x = 1/n sum x_i}
\ExampleLine{sigma (x) ~~ sqrt ((x_i - (bar x)^2) / (n-1) )}
\ExampleLine{sigma (x)^2 ~~ bar ((x_i - bar x)^2) = 1/(n-1) sum (x_i - bar x)^2}

\stopsubsubject

\startsubsubject[title=matrices]

\ExampleLine{|{:(sin alpha,cos alpha),(sin beta,cos beta):}| = sin (alpha - beta)}
\ExampleLine{|I| = | {: (1,0),(0,1):}| = 1}

\stopsubsubject

\stopchapter

\startchapter[title={A few examples}]

\setups[showexamples]

\startsection[title={derivatives}]  \getbuffer[derivates]    \stopsection
\startsection[title={integrals}]    \getbuffer[integrals]    \stopsection
\startsection[title={series}]       \getbuffer[series]       \stopsection
\startsection[title={logs}]         \getbuffer[logs]         \stopsection
\startsection[title={goniometrics}] \getbuffer[goniometrics] \stopsection
\startsection[title={statistics}]   \getbuffer[statistics]   \stopsection
\startsection[title={matrices}]     \getbuffer[matrices]     \stopsection

\stopchapter

\startchapter[title={Unicode Math}]

\startsection[title={entities}]

Support for \MATHML\ showed up in \CONTEXT\ by the end of second millenium. The
first more or less complete version of this manual dates from the end of 1999. At
that time \UNICODE\ math was no fact yet and entities were the way to get special
symbols done. Mapping the names of symbols onto something that could be rendered
was up to the \XML\ processors and typesetting engine.

Nowadays we can use \UNICODE\ directly although it has the drawback that not all
editing applications show the corresponding shapes. It is for this reason that
entities will have their use for a while. In the next table we see the official
ones. The table is actually larger, but we only show the shapes that have a math
property in the \CONTEXT\ character database. The full list is supported and can
be found in the following documents:

\starttyping
http://www.w3.org/2003/entities/2007/w3centities-f.ent
http://www.w3.org/2003/entities/2007/htmlmathml-f.ent
\stoptyping

\blank \showmathentities

\stopsection

\startsection[title={properties}]

\noindentation A different way to look at this is \UNICODE\ itself. Here's the
list of characters that have a math related property in \CONTEXT.

\blank \showmathcharacters

\stopsection

\startsection[title={alphabets}]

Traditionally (in \TEX) one enters \ASCII\ characters to represent identifiers
and use a font switch to get for instance a bold rendering. In \UNICODE\ it is
more natural to use code points that represent the meaning. So, instead if
enterinf

So instead of keying in byte \type {U+0058} for a bold \type {x} one will use an
\UTF\ sequence representing \type {U+1D431}. Because there are not than many
editors that show all those \UNICODE\ characters it still makes sense to use
regular latin and greek alphabets combined with directives that tell what real
alphabet is used. For \CONTEXT\ it does not matter what approach is chosen: both
work ok and internally characters are mapped onto the right slot. When a font
does not provide a shape a fallback is chosen. Technically one can construct a
complete math font by combining all kind of fonts, but this is normally not
needed.

Here we show the combinations of styles and alternatives. Not all combinations
are present in \UNICODE. Actually, as \UNICODE\ math is rather agnostic of
cultural determined math rendering, at some point \CONTEXT\ could provide more.
\footnote {An example is the German handwriting style Suetterlin that is still
used for vectors.} Also, modern \OPENTYPE\ fonts can have alternatives, for
instance variants of script, blackboard or fraktur. This is not related to
\UNICODE\ and it makes no sense to encode that in \MATHML, but a setup of the
rendering.

\blank \showmathalphabets

\stopsection

\startsection[title={scripts}]

Glyphs (traditionally) come in three sizes. The script and scriptscript sizes can
be downscaled from text size but most math fonts have additional glyphs tuned for
smaller sizes. The next table shows some of this.

\blank \showmathscripts

\stopsection

\startsection[title={bold}]

There are two ways to look at bold math. First there are bold alphabets and bold
symbols and these have some meaning. Then there is what we can best call boldened
math that is used in section titles and such. The normal bold then becomes heavy.
The next table shows (for the font used here) what bold shapes are available.

\blank \showmathbold

\stopsection

\stopchapter

\stopbodymatter

\stoptext