summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex
blob: ad9e06287cd980824e9d7a8773af3d4da33627ba (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
%% $Id: pstricks-add-doc.tex 887 2018-12-29 13:17:59Z herbert $
%
\documentclass[11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small,
    headinclude=false,footinclude=false,oneside]{pst-doc}
\listfiles
\usepackage{biblatex}
\addbibresource{pstricks-add-doc.bib}
\makeatletter
%\RequirePackage{ltxcmds}[2010/01/28]
%\@ifpackagelater{ltxcmds}{2010/03/09}{}{%
%  \def\ltx@pkgextension{sty}%
%}
\makeatother

\usepackage{siunitx}
\sisetup{add-decimal-zero,
	round-mode=places,
	round-precision=2,
	output-decimal-marker={,},
	detect-all}



%\input{data/pstricks-add-doc.data}

\usepackage[utf8]{inputenc}
%\usepackage{pstricks-add}
%\let\pstricksaddFV\fileversion
\usepackage{pst-eucl,pst-fun,pst-func,multirow}
\usepackage{pifont,pst-func}
\let\belowcaptionskip\abovecaptionskip
%
\def\textat{\char064}%
\newdimen\fullWidth
\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{2em}{2.3em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{10em}{5em}}
\makeatother
\lstset{explpreset={pos=l,width=-99pt,overhang=0pt,hsep=\columnsep,vsep=\bigskipamount,rframe={}},
    escapechar=§}

\def\bgImage{\includegraphics{data/olympic}}

\iffalse
\psset{unit=1.5}
\begin{pspicture}(-3,-3.25)(3,3)
\psChart[userColor={red!30,green!30,blue!40,gray,cyan!50,
    magenta!60,cyan},chartSep=30pt,shadow=true,shadowsize=5pt]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2}
\psset{nodesepA=5pt,nodesepB=-10pt}
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)}
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)}
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)}
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)}
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)}
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)}
\bfseries%
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills}
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food}
\end{pspicture}}
\fi


\begin{document}
\title{\texttt{pstricks-add}\\additionals Macros for \texttt{pstricks}\\
    \small v.\pstricksaddFV}
%\docauthor{Herbert Vo\ss}
\author{Dominique Rodriguez\\Michael Sharpe\\Herbert Voß}
\date{\today}

\maketitle

\fullWidth=\linewidth
\advance\fullWidth by \marginparsep
\advance\fullWidth by \marginparwidth


\begin{abstract}
This version of \verb+pstricks-add+ needs \verb+pstricks.tex+
version >1.04 from June 2004, otherwise the additional macros may
not work as expected. The ellipsis material and the option
\verb+asolid+ (renamed to \verb+eofill+) are
\index{fillstyle!eofill@\texttt{eofill}} now part of the new
\verb+pstricks.tex+ package, available on CTAN. \LPack{pstricks-add} will for ever be
an experimental and dynamical package, try it at your own risk.

\begin{itemize}
\item It is important to load \LPack{pstricks-add} as the \textbf{last} PSTricks related package, otherwise
a lot of the macros won't work in the expected way.
\item \LPack{pstricks-add} uses the extended version of the keyval package. So be sure that
you have installed \LPack{pst-xkey} which is part of the
\LPack{xkeyval}-package, and that all packages that use the old
keyval interface are loaded \textbf{before} the
\LPack{xkeyval}.
\item the option \Lkeyword{tickstyle} from \LPack{pst-plot} is no longer supported; use \Lkeyword{ticksize} instead.
\item the option \Lkeyword{xyLabel} is no longer supported; use the option \Lkeyword{labelFontSize} instead.
\item if \LPack{pstricks-add} is loaded together with the package  \LPack{pst-func} then  \Lkeyword{InsideArrow}
    of the \Lcs{psbezier} macro doesn't work!
\end{itemize}

\vfill
\noindent
Thanks to:  
%Hendri Adriaens;
Stefano Baroni;
Martin Chicoine;
Gerry Coombes;
Ulrich Dirr;
Christophe Fourey;
Hubert G\"a\ss lein;
J\"urgen Gilg;
Denis Girou;
Pablo Gonzáles;
Peter Hutnick;
Christophe Jorssen;
Uwe Kern;
Friedrich Lenk;
Manuel Luque;
Jens-Uwe Morawski;
Tobias N\"ahring;
Rolf Niepraschk;
Alan Ristow;
Christine R\"omer;
Arnaud Schmittbuhl;
John Smith;
Timothy Van Zandt
\end{abstract}

\clearpage
\tableofcontents


\clearpage

\section{\nxLcs{psGetSlope} and \nxLcs{psGetDistance}}
%--------------------------------------------------------------------------------------

\begin{BDef}
\Lcs{psGetSlope}\coord1\coord2\Lcs{\Larga{macro}}\\
\Lcs{psGetDistance}\coord1\coord2\Lcs{\Larga{macro}}
\end{BDef}

\begin{LTXexample}[width=4cm]
\psGetSlope(-2,1)(3,1)\SlopeVal \SlopeVal \quad
\psGetDistance(-2,1)(3,1)\DVal \DVal\\
\psGetSlope(-2,1)(-3,-1)\SlopeVal \SlopeVal\quad
\psGetDistance(-2,1)(-3,-1)\DVal \DVal\\
\psGetSlope(-2,0)(3,-1)\SlopeVal \SlopeVal\quad
\psGetDistance(-2,0)(3,-1)\DVal \DVal\\
\psGetSlope(-2111,-12)(3,1)\SlopeVal \SlopeVal\quad
%\psGetDistance(-2111,-12)(3,1)\DVal ==> Overflow!
\end{LTXexample}



\clearpage

%--------------------------------------------------------------------------------------
\section{"`Handmade"' lines :-)}
%--------------------------------------------------------------------------------------

\begin{BDef}
\Lcs{pslineByHand}\OptArgs\coord1\coord2\coord3 \ldots
\end{BDef}

\begin{LTXexample}[width=0.4\linewidth]
\begin{pspicture}(4,6)
\psset{unit=2cm}
  \pslineByHand[linecolor=red](0,0)(0,2)(2,2)(2,0)(0,0)(2,2)(1,3)(0,2)(2,0)
\end{pspicture}
\end{LTXexample}

\iffalse
  \pslineByHand( 1.20, 1.50)( 1.20, 1.51)( 1.20, 1.53)( 1.20, 1.54)( 1.19, 1.55)( 1.19, 1.56)
    ( 1.19, 1.57)( 1.18, 1.59)( 1.18, 1.60)( 1.17, 1.61)( 1.16, 1.62)( 1.15, 1.63)( 1.15, 1.64)
    ( 1.14, 1.65)( 1.13, 1.65)( 1.12, 1.66)( 1.11, 1.67)( 1.10, 1.68)( 1.09, 1.68)( 1.07, 1.69)
    ( 1.06, 1.69)( 1.05, 1.69)( 1.04, 1.70)( 1.03, 1.70)( 1.01, 1.70)( 1.00, 1.70)( 0.99, 1.70)
    ( 0.97, 1.70)( 0.96, 1.70)( 0.95, 1.69)( 0.94, 1.69)( 0.93, 1.69)( 0.91, 1.68)( 0.90, 1.68)
    ( 0.89, 1.67)( 0.88, 1.66)( 0.87, 1.65)( 0.86, 1.65)( 0.85, 1.64)( 0.85, 1.63)( 0.84, 1.62)
    ( 0.83, 1.61)( 0.82, 1.60)( 0.82, 1.59)( 0.81, 1.57)( 0.81, 1.56)( 0.81, 1.55)( 0.80, 1.54)
    ( 0.80, 1.53)( 0.80, 1.51)( 0.80, 1.50)( 0.80, 1.49)( 0.80, 1.47)( 0.80, 1.46)( 0.81, 1.45)
    ( 0.81, 1.44)( 0.81, 1.43)( 0.82, 1.41)( 0.82, 1.40)( 0.83, 1.39)( 0.84, 1.38)( 0.85, 1.37)
    ( 0.85, 1.36)( 0.86, 1.35)( 0.87, 1.35)( 0.88, 1.34)( 0.89, 1.33)( 0.90, 1.32)( 0.91, 1.32)
    ( 0.93, 1.31)( 0.94, 1.31)( 0.95, 1.31)( 0.96, 1.30)( 0.97, 1.30)( 0.99, 1.30)( 1.00, 1.30)
    ( 1.01, 1.30)( 1.03, 1.30)( 1.04, 1.30)( 1.05, 1.31)( 1.06, 1.31)( 1.07, 1.31)( 1.09, 1.32)
    ( 1.10, 1.32)( 1.11, 1.33)( 1.12, 1.34)( 1.13, 1.35)( 1.14, 1.35)( 1.15, 1.36)( 1.15, 1.37)
    ( 1.16, 1.38)( 1.17, 1.39)( 1.18, 1.40)( 1.18, 1.41)( 1.19, 1.43)( 1.19, 1.44)( 1.19, 1.45)
    ( 1.20, 1.46)( 1.20, 1.47)( 1.20, 1.49)( 1.20, 1.50)
\fi

\begin{LTXexample}[pos=t]
\begin{pspicture}(\linewidth,3)
\multido{\rA=0.00+0.25}{12}{\pslineByHand[linecolor=blue](0,\rA)(\linewidth,\rA)}
\end{pspicture}
\end{LTXexample}

The amplitude and the width can be changed by the optional arguments \Lkeyword{varsteptol} and
\Lkeyword{VarStepEpsilon}. Both are preset to \verb+VarStepEpsilon=2,varsteptol=0.8+.


\begin{LTXexample}[pos=t]
\begin{pspicture}(\linewidth,3)
\multido{\rA=0.00+0.25}{12}{%
  \pslineByHand[linecolor=blue,VarStepEpsilon=4,varsteptol=2](0,\rA)(\linewidth,\rA)}
\end{pspicture}
\end{LTXexample}

\clearpage

%--------------------------------------------------------------------------------------
\section{\nxLcs{rmultiput}: a multiple \nxLcs{rput}}
%--------------------------------------------------------------------------------------
\verb+PSTricks+ already has a \Lcs{multirput}, which puts a box n
times with a difference of $dx$ and $dy$ relative to each other.
It is not possible to put it with a different distance from one
point to the next. This is possible with \Lcs{rmultiput}:

\begin{BDef}
\LcsStar{rmultiput}\OptArgs\Largb{any material}\coord1\coord2\ldots\Largr{\coord{n}}
\end{BDef}

\begin{LTXexample}[width=6.2cm]
\psset{unit=0.75}
\begin{pspicture}(-4,-4)(4,4)
\rmultiput[rot=45]{\red\psscalebox{3}{\ding{250}}}%
    (-2,-4)(-2,-3)(-3,-3)(-2,-1)(0,0)(1,2)(1.5,3)(3,3)
\rmultiput[rot=90,ref=lC]{\blue\psscalebox{2}{\ding{253}}}%
    (-2,2.5)(-2,2.5)(-3,2.5)(-2,1)(1,-2)(1.5,-3)(3,-3)
\psgrid[subgriddiv=0,gridcolor=lightgray]
\end{pspicture}
\end{LTXexample}

\clearpage


%--------------------------------------------------------------------------------------
\section{\nxLcs{psVector}: Drawing relative vector lines}
%--------------------------------------------------------------------------------------

The new macros \Lcs{psStartPoint} and \Lcs{psVector} allow to draw a series of
vectors which start point refers to the endpoint of the last drawn vector. The 
coordinates of the endpoint are \emph{always} interpreted relative to the last
the vector. The first vector refers to the coordinates set by \Lcs{psStartPoint}.
With the boolean argument one can draw the horizontal angle of the vector.

\begin{BDef}
\Lcs{psVector}\OptArgs\OptArg*{\texttt{<startpoint>}}\coord1\coord2\ldots\Largr{\coord{n}}\\
\Lcs{psStartPoint}\OptArg{node basename}\Largr{$x$,$y$}
\end{BDef}

If the optional argument in angle braces is given then it will be the start point
for the current vector and the next ones, until a new start point is defined or a
new optional argument is used. 

The style of the angle arc is saved in \Lkeyval{psMarkAngleStyle} and the style
for the horizontal line in \Lkeyval{psMarkAngleLineStyle} and preset to

\begin{lstlisting}
\newpsstyle{psMarkAngleStyle}{arrows=->,arrowsize=4pt}
\newpsstyle{psMarkAngleLineStyle}{linestyle=dotted}
\end{lstlisting}


 \begin{pspicture}[showgrid](10,10)
 \psVector<1,1>(3;30)(4;60)\nbput{$V_2$}
 \psVector[linecolor=red](3;10)\nbput{$V_3$}
 \psVector[linestyle=dashed](4;110)\nbput{$V_4$}
 \psStartPoint(1,1)\psset{markAngle}
 \psVector[linestyle=dashed](4;110)\ncput*{$V_1$}
 \psVector[linecolor=red](3;10)\ncput*{$V_2$}
 \psVector(4;60)(3;30)\ncput*{$V_4$}
 \end{pspicture}

\begin{lstlisting}
 \begin{pspicture}[showgrid](10,10)
 \psVector<1,1>(3;30)(4;60)\nbput{$V_2$}
 \psVector[linecolor=red](3;10)\nbput{$V_3$}
 \psVector[linestyle=dashed](4;110)\nbput{$V_4$}
 \psset{markAngle}
 \psVector[linestyle=dashed]<1,1>(4;110)\ncput*{$V_1$}
 \psVector[linecolor=red](3;10)\ncput*{$V_2$}
 \psVector(4;60)(3;30)\ncput*{$V_4$}
 \end{pspicture}
\end{lstlisting}

All end points of the vectors are saved in node names with the preset name \verb=Vector#=,
where \# is the consecutive  number of the nodes. \verb=Vector0= ist the starting point of
the first \Lcs{psVector}. With the macro \Lcs{psStartPoint} one can set the starting point and
with optional argument the name of the nodes. \verb=Vector3= is the default node name of
the endpoint of the third vector or the name of the starting point of the forth vector.


\begin{pspicture}[showgrid,linewidth=1pt](10,10.4)
 \psStartPoint[A](1,1)% nodes have the base name A
 \psVector(3;30)(4;60)\psVector[linecolor=red](3;10)
 \psVector[linestyle=dashed](4;110)\nbput{$V_3$}
 \psline{->}(A0)(A4)
 \psStartPoint[B](1,1)\psset{markAngle}% nodes have the base name B
 \psVector[linestyle=dashed](4;110)\naput{$V_1$}
 \psVector[linecolor=red](3;10)\ncput*{$V_2$}
 \psVector(4;60)(3;30)
 \psline[arrows=-D>,arrowscale=2,linewidth=1.5pt,linecolor=red](B2)(A2)
 \psline[arrows=-D>,arrowscale=2,linewidth=1.5pt,linecolor=blue](A3)(B3)
 \multido{\iA=0+1}{5}{\uput[0](A\iA){A\iA}\uput[180](B\iA){B\iA}}
\end{pspicture}

\begin{lstlisting}
\begin{pspicture}[showgrid,linewidth=1pt](10,10.4)
 \psStartPoint[A](1,1)% nodes have the base name A
 \psVector(3;30)(4;60)\psVector[linecolor=red](3;10)
 \psVector[linestyle=dashed](4;110)\nbput{$V_3$}
 \psline{->}(A0)(A4)
 \psStartPoint[B](1,1)\psset{markAngle}% nodes have the base name B
 \psVector[linestyle=dashed](4;110)\naput{$V_1$}
 \psVector[linecolor=red](3;10)\ncput*{$V_2$}
 \psVector(4;60)(3;30)
 \psline[arrows=-D>,arrowscale=2,linewidth=1.5pt,linecolor=red](B2)(A2)
 \psline[arrows=-D>,arrowscale=2,linewidth=1.5pt,linecolor=blue](A3)(B3)
 \multido{\iA=0+1}{5}{\uput[0](A\iA){A\iA}\uput[180](B\iA){B\iA}}
 \end{pspicture}
\end{lstlisting}

\clearpage


%--------------------------------------------------------------------------------------
\section{\nxLcs{psCircleTangents}: Calculating tangent lines of circles}
%--------------------------------------------------------------------------------------

The macro calculates the points on a circle where tangent lines from another
point or another circle are drawn.

\begin{BDef}
\Lcs{psCircleTangents}\Largr{$x1,y1$}\Largr{$x2,y2$}\Largb{Radius}\\
\Lcs{psCircleTangents}\Largr{$x1,y1$}\Largb{Radius}\Largr{$x2,y2$}\Largb{Radius}
\end{BDef}

In the first case the coordinates of a point and the center and the radius
of a circle must be given. The names of the calculates node names are \verb=CircleT1=
and \verb=CircleT2=.

\bigskip
\begin{pspicture}[showgrid](0,3)(10,10)
\psdot(2,4)\pscircle(7,7){2}
\psCircleTangents(2,4)(7,7){2}
\pcline[nodesep=-1cm,linecolor=blue](2,4)(CircleT1)
\pcline[nodesep=-1cm,linecolor=blue](2,4)(CircleT2)
\psdots(CircleT1)(CircleT2)
\uput[-80](CircleT1){T1}\uput[115](CircleT2){T2}
\end{pspicture}


\begin{lstlisting}
\begin{pspicture}[showgrid](0,3)(10,10)
\psdot(2,4)\pscircle(7,7){2}
\psCircleTangents(2,4)(7,7){2}
\pcline[nodesep=-1cm,linecolor=blue](2,4)(CircleT1)
\pcline[nodesep=-1cm,linecolor=blue](2,4)(CircleT2)
\psdots(CircleT1)(CircleT2)
\uput[-80](CircleT1){T1}\uput[115](CircleT2){T2}
\end{pspicture}
\end{lstlisting}

\bigskip
When using the other variant of the macro two circles must be given. The macro then defines
ten nodes, named \verb=CircleTC1= and \verb=CircleTC2= for the two intersection points,
 \verb=CircleTO1=, \verb=CircleTO2=, \verb=CircleTO3=, and \verb=CircleTO4= for the four
 nodes of the outer tangent lines and 
  \verb=CircleTI1=, \verb=CircleTI2=, \verb=CircleTI3=, and \verb=CircleTI4= for the
  four nodes of the inner tangent lines.

\bigskip
\begin{pspicture}[showgrid](-2,-2)(10,10)
\pscircle(1,1){1}\pscircle(7,7){3}
\psCircleTangents(1,1){1}(7,7){3}
\pcline[nodesep=-1cm,linecolor=blue](CircleTO1)(CircleTO2)
\pcline[nodesep=-1cm,linecolor=blue](CircleTO3)(CircleTO4)
\pcline[nodesep=-1cm,linecolor=red](CircleTI1)(CircleTI2)
\pcline[nodesep=-1cm,linecolor=red](CircleTI3)(CircleTI4)
\psdots(CircleTC1)(CircleTC2)%
  (CircleTO1)(CircleTO2)(CircleTO3)(CircleTO4)%
  (CircleTI1)(CircleTI2)(CircleTI3)(CircleTI4)%
\uput[0](CircleTC1){TC1}\uput[0](CircleTC2){TC2}
\uput[-80](CircleTI1){TI1}\uput[115](CircleTI2){TI2}
\uput[150](CircleTI3){TI3}\uput[-45](CircleTI4){TI4}
\uput[-80](CircleTO1){TO1}\uput[150](CircleTO2){TO2}
\uput[150](CircleTO3){TO3}\uput[-45](CircleTO4){TO4}
\end{pspicture}

\bigskip
\begin{lstlisting}
\begin{pspicture}[showgrid](-2,-2)(10,10)
\pscircle(1,1){1}\pscircle(7,7){3}
\psCircleTangents(1,1){1}(7,7){3}
\pcline[nodesep=-1cm,linecolor=blue](CircleTO1)(CircleTO2)
\pcline[nodesep=-1cm,linecolor=blue](CircleTO3)(CircleTO4)
\pcline[nodesep=-1cm,linecolor=red](CircleTI1)(CircleTI2)
\pcline[nodesep=-1cm,linecolor=red](CircleTI3)(CircleTI4)
\psdots(CircleTC1)\psdots(CircleTC2)%
  (CircleTO1)(CircleTO2)(CircleTO3)(CircleTO4)%
  (CircleTI1)(CircleTI2)(CircleTI3)(CircleTI4)%
\uput[0](CircleTC1){TC1}\uput[0](CircleTC2){TC2}
\uput[-80](CircleTI1){TI1}\uput[115](CircleTI2){TI2}
\uput[150](CircleTI3){TI3}\uput[-45](CircleTI4){TI4}
\uput[-80](CircleTO1){TO1}\uput[150](CircleTO2){TO2}
\uput[150](CircleTO3){TO3}\uput[-45](CircleTO4){TO4}
\end{pspicture}
\end{lstlisting}


\clearpage

%--------------------------------------------------------------------------------------
\section{\nxLcs{psEllipseTangents}: Calculating tangent lines of an ellipse}
%--------------------------------------------------------------------------------------

The macro calculates the two points on an ellipse where tangent lines from an outside  point
 are drawn.

\begin{BDef}
\Lcs{psEllipseTangents}\Largr{$x_0,y_0$}\Largr{$a,b$}\Largr{$x_p,y_p$}\\
\end{BDef}

The first two pairs of coordinates are the same as the ones for the default ellipse.
The names of the calculates node names are \verb=EllipseT1=
and \verb=EllipseT2=.

\bigskip
\begin{pspicture}[showgrid](0,3)(10,10)
\psdot(2,4)\psellipse(7,7)(3,1.5)
\psEllipseTangents(7,7)(3,1.5)(2,4)
\pcline[nodesep=-1cm,linecolor=blue](2,4)(EllipseT1)
\pcline[nodesep=-1cm,linecolor=blue](2,4)(EllipseT2)
\psdots(EllipseT1)(EllipseT2)
\uput[-80](EllipseT1){T1}\uput[115](EllipseT2){T2}
\end{pspicture}


\begin{lstlisting}
\begin{pspicture}[showgrid](0,3)(10,10)
\psdot(2,4)\psellipse(7,7)(3,1.5)
\psEllipseTangents(7,7)(3,1.5)(2,4)
\pcline[nodesep=-1cm,linecolor=blue](2,4)(EllipseT1)
\pcline[nodesep=-1cm,linecolor=blue](2,4)(EllipseT2)
\psdots(EllipseT1)(EllipseT2)
\uput[-80](EllipseT1){T1}\uput[115](EllipseT2){T2}
\end{pspicture}
\end{lstlisting}


\clearpage

%--------------------------------------------------------------------------------------
\section{\nxLcs{psrotate}: Rotating objects}
%--------------------------------------------------------------------------------------
\Lcs{rput} also has an optional argument for rotating objects, but
it always depends on the \Lcs{rput} coordinates. With
\Lcs{psrotate} the rotating center can be placed anywhere. The
rotation is done with \verb+\pscustom+, all optional arguments are
only valid if they are part of the \verb+\pscustom+ macro.

\begin{BDef}
\Lcs{psrotate}\OptArgs\Largr{$x,y$}\Largb{rot angle}\Largb{object}
\end{BDef}

\begin{LTXexample}[width=0.4\linewidth]
\psset{unit=0.75}
\begin{pspicture}(-0.5,-3.5)(8.5,4.5)
  \psaxes{->}(0,0)(-0.5,-3)(8.5,4.5)
  \psdots[linecolor=red,dotscale=1.5](2,1)
  \psarc[linecolor=red,linewidth=0.4pt,showpoints=true]
        {->}(2,1){3}{0}{60}
  \pspolygon[linecolor=green,linewidth=1pt](2,1)(5,1.1)(6,-1)(2,-2)
  \psrotate(2,1){60}{%
    \pspolygon[linecolor=blue,linewidth=1pt](2,1)(5,1.1)(6,-1)(2,-2)}
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}[width=6cm]
\begin{pspicture}(-1,-1)(3,6)
\def\canne{%  Idea by Manuel Luque
  \psgrid[subgriddiv=0](-1,0)(1,5)
  \pscustom[linewidth=2mm]{\psline(0,4)\psarcn(0.3,4){0.3}{180}{360}}%
  \pscircle*(0.6,4){0.1}\pstriangle*(0,0)(0.2,-0.3)}
\def\Object{}
  \canne
  \psrotate(0.3,4){45}{\psset{linecolor=red!50}\canne}
  \psrotate(0.3,4){90}{\psset{linecolor=blue!50}\canne}
  \psrotate(0.3,4){360}{\psset{linecolor=cyan!50}\canne}
  \psdot[linecolor=red](0.3,4)
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}[pos=t]
\begin{pspicture}(0,-6)(15,5)
\def\majorette{\psline[linewidth=0.5mm](0,2)%  Idea by Manuel Luque
               \pscircle[fillstyle=solid]{0.1}
               \pscircle[fillstyle=solid](0,2){0.1}}
  \psaxes[linewidth=0.5pt]{->}(0,0)(0,-5)(15,5)
  \pstVerb{/V0 10 def /Alpha 45 def}% vitesse initiale, angle de lancement
  \multido{\nT=0.0+0.05,\iA=0+40}{41}{%
    \pstVerb{/nT \nT\space def}%
    \rput(!V0 Alpha cos mul nT mul -9.81 2 div nT dup mul mul V0 Alpha sin mul nT mul add){%
       \psrotate(0,1){\iA}{\majorette\psdot[linecolor=red](0,1)\psdot[linecolor=green](0,2)}}}
  \parametricplot[linecolor=red]{0}{2}{% trajectoire du milieu
     V0 Alpha cos mul t mul -9.81 2 div t dup mul mul V0 Alpha sin mul t mul add 1 add}
  \parametricplot[linecolor=green,plotpoints=360]{0}{2}{% d'une extremite
     V0 Alpha cos mul t mul 800 t mul sin sub % x(t)
     -9.81 2 div t dup mul mul V0 Alpha sin mul t mul add 1 add 800 t mul cos add }%y(t)
\end{pspicture}
\end{LTXexample}


\clearpage

%--------------------------------------------------------------------------------------
\section{\nxLcs{psComment}: comments to a graphic}
%--------------------------------------------------------------------------------------

\begin{BDef}
\LcsStar{psComment}\OptArgs\OptArg*{\Largb{arrows}}\coord0\coord1\Largb{Text}\OptArg{line macro}\OptArg{put macro}
\end{BDef}

By default the macro uses the \Lcs{ncline} macro to draw a line from the first to the
second point, it can be changed with the first additional optional argument. The label is
put by default with \Lcs{rput}, which can be changed with the last optional argument.
If this is used, then the line macro has also be defined, eg \verb+\psComment(A)(B){text}[\ncarc][\ncput}+
At least, leave the argument empty.


\begin{LTXexample}[pos=t,wide]
\SpecialCoor\newpsstyle{weiss}{fillstyle=solid,fillcolor=white}
\footnotesize\psset{unit=0.5cm,dimen=middle}
\begin{pspicture}(-12,-4)(6,10)
\psframe*[linecolor=black!20](-5,-3)(5,7) \psframe*[linecolor=black!40](-5,3)(5,6)
\pscircle(-8.19,5.51){0.2}
\psframe[fillcolor=white,fillstyle=solid](-5.8,3.6)(4.3,5.8)
\psframe(-8.98,3.14)(-5.8,6.32)
\multido{\rA=-4.1+1.3}{5}{\rput(\rA,-2.4){\psframe[style=weiss](1.1,6)
  \psline(0,0)(1.1,0.5)(0,1)(1.1,1.6)(0,2.2)(1.1,2.7)(0,3.2)(1.1,3.2)}}
\pspolygon*(-4.1,3.7)(-4.1,3)(-3,3)(-3.01,3.7)(-3.54,4.19)
\pspolygon*(1.09,3.7)(1.1,3)(2.2,3)(2.18,3.7)(1.65,4.24)
\pspolygon*(-2.78,3.7)(-2.8,3)(-1.7,3)(-1.71,3.7)(-2.27,4.04)
\pspolygon*(-1.51,3.7)(-1.5,3)(-0.4,3)(-0.41,3.7)(-1.02,4.17)
\pspolygon*(-0.21,3.7)(-0.2,3)(0.9,3)(0.89,3.7)(0.3,4.04)
\psline(-5,3.83)(-4.15,3.86)(-3.5,4.3)(-2.85,3.81)(-2.22,4.21)(-1.6,3.86)(-0.99,4.33)
       (-0.28,3.83)(0.35,4.19)(0.97,3.83)(1.65,4.39)(2.2,4.01)(3.57,4.89)(2.41,5.8)
  \psline(-5,5.8)(-5.78,5.8)  \psline(-5.78,5.47)(2.85,5.47)
  \psline(-5.8,3.52)(-5,3.5)  \psline(3.57,4.89)(-5.8,4.89)
  \psComment*[ref=r]{->}(-8.14,1.19)(-4.31,3.27){Mantelstift}
  \psComment*[ref=r]{->}(-8.17,-0.56)(-4.37,1.59){Kernstift}[\ncarc]
  \psComment*[ref=r]{->}(-7.91,-2.24)(-4.44,-0.23){Feder}[\ncarc]
  \psComment[npos=-0.1]{->}(-3.48,8.72)(-1.33,5.46){Nur f\"ur Profil}
\end{pspicture}
\end{LTXexample}

\clearpage
%--------------------------------------------------------------------------------------
\section{\nxLcs{psChart}: a pie chart}
%--------------------------------------------------------------------------------------

\begin{BDef}
\Lcs{psChart}\OptArgs\Largb{comma separated value list}\Largb{comma separated value list}\Largb{radius}
\end{BDef}

The special optional arguments for the \Lcs{psChart} macro are as follows:

\noindent
\begin{tabularx}{\linewidth}{@{}>{\ttfamily}lX>{\ttfamily}l@{}}
\textrm{\emph{name}} & \textrm{\emph{description}} & \textrm{\emph{default}}\\\hline
\Lkeyword{chartSep}  & distance from the pie chart center to an outraged pie piece & 10pt\\
\Lkeyword{chartColor} & gray or colored pie (values are: \texttt{gray} or \texttt{color})& gray\\
\Lkeyword{userColor} & a comma separated list of user defined colors for the pie & \{\}\\
\Lkeyword{chartNodeI}& the position of the inner node, relative to the radius & 0.75\\
\Lkeyword{chartNodeO}& the position of the outer node, relative to the radius & 1.5
\end{tabularx}

\bigskip
The first mandatory argument is the list of the values and may not be empty. The second
one is a list of outraged pieces, numbered consecutively from 1 to up the total number
of values. The list of user defined colors must be enclosed in braces!

The macro \Lcs{psChart} defines for every value three nodes at the half angle and
in distances from 0.75, 1, and 1.25 times of the radius from the origin. The nodes
are named as \verb+psChartI?+, \verb+psChart?+, and \verb+psChartO?+, where ? is the number of
the pie. The letter I leads to the inner node and the letter O to the outer node.
The distance can be changed with the optional arguments \Lkeyword{chartNodeI} and
\Lkeyword{chartNodeO} in the usual way with \verb+\psset{chartNodeI=...,chartNodeO=...}+.

The other one is the node on the circle line.
The origin is by default \texttt{(0,0)}. Moving the pie to another position can be done as
usual with the \Lcs{rput}-macro. The used colors are named internally as \Lkeyword{chartFillColor?}
and can be used by the user for coloring lines or text.

\begin{LTXexample}[width=6cm]
\begin{pspicture}(-3,-3)(3,3)
\psChart{ 23, 29, 3, 26, 28, 14 }{}{2}
\multido{\iA=1+1}{6}{%
  \psdot(psChart\iA)\psdot(psChartI\iA)\psdot(psChartO\iA)%
  \psline[linestyle=dashed,linecolor=white](psChart\iA)
  \psline[linestyle=dashed](psChart\iA)(psChartO\iA)}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=6cm]
\begin{pspicture}(-3,-3)(3,3)
\psChart[chartColor=color]{45,90}{1}{2}
\ncline[linecolor=-chartFillColor1,
  nodesepB=-20pt]{psChartO1}{psChart1}
\rput[l](psChartO1){%
  \textcolor{chartFillColor1}{pie no 1}}
\ncline[linecolor=-chartFillColor2,
  nodesepB=-20pt]{psChartO2}{psChart2}
\rput[lt](psChartO2){%
  \textcolor{chartFillColor2}{pie no 2}}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=7.5cm]
\psframebox[fillcolor=black!20,
  fillstyle=solid]{%
\begin{pspicture}(-3.5,-3.5)(4.25,3.5)
\psChart[chartColor=color]%
  {23, 29, 3, 26, 28, 14, 17, 4, 9}{}{2}
\multido{\iA=1+1}{9}{%
  \ncline[linecolor=-chartFillColor\iA,
    nodesepB=-10pt]{psChartO\iA}{psChart\iA}
  \rput[l](psChartO\iA){%
    \textcolor{chartFillColor\iA}{pie no \iA}}}
\end{pspicture}}
\end{LTXexample}

\begin{LTXexample}[width=6cm]
\begin{pspicture}(-3,-3)(3,3)
\psChart[userColor={red!30,green!30,
    blue!40,gray,magenta!60,cyan}]%
      { 23, 29, 3, 26, 28, 14 }{1,4}{2}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=6cm]
\begin{pspicture}(-3,-2.5)(3,2.5)
\psChart{ 23, 29, 3, 26, 28, 14 }{}{2}
\multido{\iA=1+1}{6}{\rput*(psChartI\iA){\iA}}
\end{pspicture}
\end{LTXexample}






%\begin{LTXexample}[pos=t]
\psset{unit=1.5}
\begin{pspicture}(-3,-3)(3,3)
\psChart[userColor={red!30,green!30,blue!40,gray,cyan!50,
    magenta!60,cyan},chartSep=30pt,shadow=true,shadowsize=5pt]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2}
\psset{nodesepA=5pt,nodesepB=-10pt}
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)}
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)}
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)}
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)}
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)}
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)}
\bfseries%
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills}
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food}
\end{pspicture}
%\end{LTXexample}
\psset{unit=1cm}

\begin{lstlisting}
\psset{unit=1.5}
\begin{pspicture}(-3,-3)(3,3)
\psChart[userColor={red!30,green!30,blue!40,gray,cyan!50,
    magenta!60,cyan},chartSep=30pt,shadow=true,shadowsize=5pt]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2}
\psset{nodesepA=5pt,nodesepB=-10pt}
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)}
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)}
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)}
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)}
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)}
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)}
\bfseries%
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills}
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food}
\end{pspicture}
\end{lstlisting}


The linecolor of the pies is by default identical to the fillcolor. If you want another line color
for all pies then use the optional argument \Lkeyword{uselinecolor}. In this case the current
setting of \Lkeyword{linecolor} is taken into account:


%\begin{LTXexample}[pos=t]
\psset{unit=1.5}
\begin{pspicture}(-3,-3)(3,3)
\psChart[chartSep=30pt,shadow=true,shadowsize=5pt,
         uselinecolor,linecolor=black!20]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2}
\psset{nodesepA=5pt,nodesepB=-10pt}
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)}
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)}
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)}
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)}
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)}
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)}
\bfseries\color{white}%
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills}
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food}
\end{pspicture}
%\end{LTXexample}
\psset{unit=1cm}

\begin{lstlisting}
\psset{unit=1.5}
\begin{pspicture}(-3,-3)(3,3)
\psChart[chartSep=30pt,shadow=true,shadowsize=5pt,
         uselinecolor,linecolor=black!20]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2}
\psset{nodesepA=5pt,nodesepB=-10pt}
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)}
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)}
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)}
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)}
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)}
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)}
\bfseries\color{white}%
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills}
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food}
\end{pspicture}
\end{lstlisting}

\clearpage
%--------------------------------------------------------------------------------------
\section{\nxLcs{psHomothetie}: central dilatation}
%--------------------------------------------------------------------------------------

\begin{BDef}
\Lcs{psHomothetie}\OptArgs\Largr{center}\Largb{factor}\Largb{object}
\end{BDef}

\begin{LTXexample}[width=9cm]
\begin{pspicture}[showgrid=true](-5,-4)(4,8)
\psBill% needs package pst-fun
\psHomothetie[linecolor=blue](4,-3){2}{\psBill}
\psdots[dotsize=3pt,linecolor=red](4,-3)
\psplot[linestyle=dashed,linecolor=red]{-5}{4}%
  [ /m -3 -0.85 sub 4 0.6 sub div def ]
  { m x mul m 4 mul sub 3 sub }%
\psHomothetie[linecolor=green](4,-3){-0.2}{\psBill}
\end{pspicture}
\end{LTXexample}

%\pstVerb{ /m -3 -0.85 sub 4 0.6 sub div def }


\clearpage

%--------------------------------------------------------------------------------------
\section{\nxLcs{psbrace}}
%--------------------------------------------------------------------------------------
\begin{BDef}
\LcsStar{psbrace}\OptArgs\Largr{A}\Largr{B}\Largb{text}
\end{BDef}

Additional to all other available options from \LPack{pstricks} or the other
related packages,  there are two new option, named  \Lkeyword{braceWidth} and
\Lkeyword{bracePos}. All important ones are shown in the following graphics
and table.

\begin{center}
\begin{pspicture}[showgrid=true](10,5)
  \psbrace[braceWidth=1cm,braceWidthInner=1cm,
    braceWidthOuter=1cm,bracePos=0.6,fillcolor=white,
    nodesepA=10mm,nodesepB=10mm](0,5)(10,5){\fbox{Label}}
\pcline{<->}(3,3)(3,4)\ncput*{\footnotesize\ttfamily braceWidth}
\pcline{<->}(3,4)(3,5)\ncput*{\footnotesize\ttfamily braceWidthInner}
\pcline{<->}(3,2)(3,3)\ncput*{\footnotesize\ttfamily braceWidthOuter}
\pcline{<->}(6,1)(6,2)\ncput{\footnotesize\ttfamily nodesepB}
\pcline{<->}(6,1)(7,1)\ncput*{\footnotesize\ttfamily A}
\pcline{<->}(0,0.5)(6,0.5)\ncput*{\footnotesize\ttfamily bracePos}
\psdot[dotscale=2](0,5)\uput[0](0,5){\textbf{A}}
\psdot[dotscale=2](10,5)\uput[180](10,5){\textbf{B}}
\end{pspicture}
\end{center}

A positive value for \Lkeyword{nodesepA} and \Lkeyword{nodesepB} shifts the label to the upper right
and a negative value to the lower left. This does not depends on
the value for the rotating of the label!

\begin{center}
\begin{tabular}{@{}l|l@{}}
name & meaning\\\hline
\Lkeyword{braceWidth} & default is \Lcs{pslinewidth}\\
\Lkeyword{braceWidthInner} & default is \verb+10\pslinewidth+\\
\Lkeyword{braceWidthOuter} & default is \verb+10\pslinewidth+\\
\Lkeyword{bracePos} & relative position (default is $0.5$)\\
\Lkeyword{nodesepA} & x-separation (default is $0pt$)\\
\Lkeyword{nodesepB} & y-separation (default is $0pt$)\\
\Lkeyword{rot} & additional rotating for the text (default is $0$)\\
\Lkeyword{ref} & reference point for the text (default is c)\\
\Lkeyword{fillcolor} & default is black
\end{tabular}
\end{center}

By default the text is written perpendicular to the brace line and
can be changed with the \LPack{pstricks} option \Lkeyword{rot}=\ldots\ The
text parameter can take any object and may also be empty. The
reference point can be any value of the combination of \Lkeyval{l}
(left) or \Lkeyval{r} (right) and \Lkeyval{b} (bottom) or \Lkeyval{B}
(Baseline) or \Lkeyval{C} (center) or \Lkeyval{t} (top), where the
default is \Lkeyval{c}, the center of the object.



\begin{LTXexample}[width=4.5cm]
\begin{pspicture}(4,4)
\psgrid[subgriddiv=0,griddots=10]
\pnode(0,0){A}
\pnode(4,4){B}
\psbrace[linecolor=red,ref=lC](A)(B){Text I}
\psbrace*[linecolor=blue,ref=lC](3,4)(0,1){Text II}
\psbrace[fillcolor=white](3,0)(3,4){III}
\end{pspicture}
\end{LTXexample}

\bigskip
The option \Lcs{specialCoor} is enabled, so that all types of coordinates
are possible, (nodename), ($x,y$), ($nodeA|nodeB$), \ldots
The star version fills the inner of the \Index{brace} with the current linecolor.
With the fillcolor \verb+white+ or any other background color the brace can
be "`unfilled"'.

\begin{LTXexample}
\begin{pspicture}(8,2.5)
\psbrace(0,0)(0,2){\fbox{Text}}%
\psbrace[nodesepA=10pt](2,0)(2,2){\fbox{Text}}
\psbrace[ref=lC](4,0)(4,2){\fbox{Text}}
\psbrace[ref=lt,rot=90,nodesepB=-15pt](6,0)(6,2){\fbox{Text}}
\psbrace[ref=lt,rot=90,nodesepA=-5pt,nodesepB=15pt](8,2)(8,0){\fbox{Text}}
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}
\def\someMath{$\int\limits_1^{\infty}\frac{1}{x^2}\,dx=1$}
\begin{pspicture}(8,2.5)
\psbrace[ref=lC](0,0)(0,2){\someMath}%
\psbrace[rot=90](2,0)(2,2){\someMath}
\psbrace[ref=lC](4,0)(4,2){\someMath}
\psbrace[ref=lt,rot=90,nodesepB=-30pt](6,0)(6,2){\someMath}
\psbrace[ref=lt,rot=90,nodesepB=30pt](8,2)(8,0){\someMath}
\end{pspicture}
\end{LTXexample}

%$

\begin{LTXexample}
\begin{pspicture}(\linewidth,5)
\psbrace(0,0.5)(\linewidth,0.5){\fbox{Text}}%
\psbrace[bracePos=0.25,nodesepB=10pt,rot=90](0,2)(\linewidth,2){\fbox{Text}}
\psbrace[ref=lC,nodesepA=-3.5cm,nodesepB=15pt,rot=90](0,4)(\linewidth,4){%
   \fbox{some very, very long wonderful Text}}
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}[width=8cm]
\psset{unit=0.8}
\begin{pspicture}(10,11)
\psgrid[subgriddiv=0,griddots=10]
\pnode(0,0){A}
\pnode(4,6){B}
\psbrace[ref=lC](A)(B){One}
\psbrace[rot=180,nodesepA=-5pt,ref=rb](B)(A){Two}
\psbrace[linecolor=blue,bracePos=0.25,ref=lB](8,1)(1,7){Three}
\psbrace[braceWidth=-1mm,rot=180,ref=rB](8,1)(1,7){Four}
\psbrace*[linearc=0.5,fillstyle=none,linewidth=1pt,braceWidth=1.5pt,
  bracePos=0.25,ref=lC](8,1)(8,9){A}
\psbrace(4,9)(6,9){}
\psbrace(6,9)(6,7){}
\psbrace(6,7)(4,7){}
\psbrace(4,7)(4,9){}
\psset{linecolor=red}
\psbrace*[ref=lb](7,10)(3,10){I}
\psbrace*[ref=lb,bracePos=0.75](3,10)(3,6){II}
\psbrace*[ref=lb](3,6)(7,6){III}
\psbrace*[ref=lb](7,6)(7,10){IV}
\end{pspicture}
\end{LTXexample}

%$

\begin{LTXexample}[width=5cm]
\[
\begin{pmatrix}
    \Rnode[vref=2ex]{A}{~1} \\
    & \ddots \\
    && \Rnode[href=2]{B}{1} \\
    &&& \Rnode[vref=2ex]{C}{0} \\
    &&&& \ddots \\
    &&&&& \Rnode[href=2]{D}{0}~ \\
\end{pmatrix}
\]
\psbrace[rot=-90,nodesepB=-0.5,nodesepA=-0.2](B)(A){\small n times}
\psbrace[rot=-90,nodesepB=-0.5,nodesepA=-0.2](D)(C){\small n times}
\end{LTXexample}


\clearpage
It is also possible to put a vertical brace around a
default paragraph. This works by setting two invisible nodes at
the beginning and the end of the paragraph. Indentation is
possible with a minipage.

\small
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.

\noindent\rnode{A}{}

\vspace*{-1ex}
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.

\vspace*{-2ex}\noindent\rnode{B}{}\psbrace*[linecolor=red](A)(B){}

Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.

\medskip\hfill\begin{minipage}{0.95\linewidth}
\noindent\rnode{A}{}

\vspace*{-1ex}
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.

\vspace*{-2ex}
\noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){}
\end{minipage}

\normalsize

\begin{lstlisting}
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.

\noindent\rnode{A}{}

\vspace*{-1ex}
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.

\vspace*{-2ex}\noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){}

Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.

\medskip\hfill\begin{minipage}{0.95\linewidth}
\noindent\rnode{A}{}

\vspace*{-1ex}
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.
Some nonsense text, which is nothing more than nonsense.

\vspace*{-2ex}\noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){}
\end{minipage}
\end{lstlisting}

\clearpage

%--------------------------------------------------------------------------------------
\section{Contour plots}
%--------------------------------------------------------------------------------------
Contour plots are 2D-images but representing 3D data. The color is the representation of
the z coordinate.
It is only possible to plot data files which must have the following
structure:
\begin{verbatim}
/contourdata [[
x y z
x y z
][
x y z
...
][
... 
] def
\end{verbatim} 
it is an PostScript array of array. The Perl script \url{http://tug.org/pstricks/pst-plot/3D/MakeData.pl} 
allows to plot a file of the 3D-data of a mathematical function $z=f(x,y)$ and the Perl script
\url{http://tug.org/pstricks/pst-plot/3D/PrepareData.pl} prepares the data file
into the above structure for using it with the example file. 

\begin{LTXexample}[pos=t]
\psset{unit=1.75cm}
\begin{pspicture}[showgrid](-3,-3)(3,3)
\pstContour[colored]{data/contourN.data}
\end{pspicture}
\end{LTXexample}

\emph{Important} is the option \verb|-dNOSAFER| for the \texttt{ps2pdf} run, otherwise Ghostscript
didn't allow the run of external data files. Important optional arguments are
\Lkeyword{colored}, \Lkeyword{colorOffset}, and \Lkeyword{colSteps}.

%--------------------------------------------------------------------------------------
\section{Random dots}
%--------------------------------------------------------------------------------------
The syntax of the new macro \Lcs{psRandom} is:

\begin{BDef}
\Lcs{psRandom}\OptArgs\Largb{}\\
\Lcs{psRandom}\OptArgs\OptArg*{\Largr{$x_{Min},y_{Min}$}}\OptArg*{\Largr{$x_{Max},y_{Max}$}}\Largb{clip path} %$ \\
\Lcs{psRandomPointArea}\OptArgs\Largb{No dots}\Largb{function}\\
%\psRandom[<option>](<xMax,yMax>){<clip path>}
%\psRandom[<option>](<xMin,yMin>)(<xMax,yMax>){<clip path>}
\end{BDef}


\subsection{Simple random dots}


If there is no area for the dots defined, then \verb+(0,0)(1,1)+ in the current
scale setting is used for placing the dots. If there is only one \Largr{$x_{Max},y_{Max}$} %$
defined, then \verb+(0,0)+ is used for the other point.
This area should be greater than the clipping
path to be sure that the dots are placed over the full area. The clipping path can
be everything. If no clipping path is given, then the frame \verb+(0,0)(1,1)+
in user coordinates is used.  The new options are:

\begin{center}
\begin{tabular}{@{}l|l|l@{}}
name & default\\\hline
\Lkeyword{randomPoints} &   \verb|1000| & number of random dots\tabularnewline
\Lkeyword{randInit} &   \verb|rrand| & initial value for the generator\tabularnewline
\Lkeyword{color} & \false & random color\tabularnewline
\end{tabular}
\end{center}


\begin{LTXexample}[width=0.3\linewidth]
\psset{unit=5cm}
\begin{pspicture}(1,1)
  \psRandom[dotsize=1pt,fillstyle=solid](1,1){\pscircle(0.5,0.5){0.5}}
\end{pspicture}
\begin{pspicture}(1,1)
  \psRandom[randInit=42,dotsize=2pt,randomPoints=5000,color,%
      fillstyle=solid](1,1){\pscircle(0.5,0.5){0.5}}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=0.4\linewidth]
\psset{unit=5cm}
\begin{pspicture}(1,1)
  \psRandom[randomPoints=200,dotsize=8pt,dotstyle=+]{}
\end{pspicture}
\begin{pspicture}(1.5,1)
  \psRandom[dotsize=5pt,color](0,0)(1.5,0.8){\psellipse(0.75,0.4)(0.75,0.4)}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}
\psset{unit=2.5cm}
\begin{pspicture}(0,-1)(3,1)
  \psRandom[dotsize=4pt,dotstyle=o,linecolor=blue,fillcolor=red,%
     fillstyle=solid,randomPoints=1000]%
      (0,-1)(3,1){\psplot{0}{3.14}{ x 114 mul sin }}
\end{pspicture}
\end{LTXexample}

\psset{unit=1cm}


\subsection{Simple random dots devided by a function}

The predefined colors are blue (lower part) and red (upper part).
\begin{LTXexample}[pos=t]
\psset{unit=6cm}
\begin{pspicture}(-0.2,-0.1)(1.1,1.2)
\psaxes[linewidth=1.25pt,Dx=0.2,Dy=0.2,
  labelFontSize=\scriptstyle,ticksize=0 1,subticks=2,
  subticksize=1,tickwidth=1pt,tickcolor=black!30,subtickcolor=black!20](0,0)(1,1)%
\psRandomPointArea[radius=1.5pt,countDots,algebraic,
  fillcolorA=black,fillcolorB=green]{30}{sqrt(1-x^2)}%
\psplot[plotpoints=200]{0}{1}{1 x dup mul sub sqrt}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t]
\psset{unit=6cm}
\begin{pspicture}(-0.2,-0.1)(1.1,1.2)
\psaxes[linewidth=1.25pt,Dx=0.2,Dy=0.2,
  labelFontSize=\scriptstyle,ticksize=0 1,subticks=2,
  subticksize=1,tickwidth=1pt,tickcolor=black!30,subtickcolor=black!20](0,0)(1,1)%
\psRandomPointArea[algebraic]{300}{-4*(x^2-x)}%
\psplot[plotpoints=200,algebraic]{0}{1}{-4*(x^2-x)}
\end{pspicture}
\end{LTXexample}





\clearpage
 %--------------------------------------------------------------------------------------
\section{\nxLcs{psDice}}
 %--------------------------------------------------------------------------------------
\Lcs{psdice} creates the view of a dice. The number on the dice is the only parameter.
The optional parameters, like the color can be used as usual. The macro is a box of
dimension zero and is placed
at the current point. Use  the \Lcs{rput} macro to place it anywhere. The optional
argument \Lkeyword{unit} can be used to scale the dice. the default size of
the dice $1\mathrm{cm}\times1\mathrm{cm}$.

\begin{center}
\begin{pspicture}(-1,-1)(8,9)
\multido{\iA=1+1}{6}{%
  \rput(\iA,7.5){\Huge\psdice[unit=0.75,linecolor=red!80]{\iA}}
  \rput(! -0.5 7 \iA\space sub){\Huge\psdice[unit=0.75,linecolor=blue!70]{\iA}}%
  \multido{\iB=1+1}{6}{%
    \rput(! \iA\space 7 \iB\space sub){%
      \rnode[c]{p\iA\iB}{\makebox[1em][l]{\strut\psPrintValue[fontscale=12]{\iA\space \iB\space add}}}%
}}}
\ncbox[linearc=0.35,nodesep=0.2,linestyle=dotted]{p11}{p66}
\ncbox[linearc=0.35,nodesep=0.2,linestyle=dashed]{p15}{p51}
\rput{90}(-1.5,3.5){1. dice}
\rput{0}(3.5,8.5){2. dice}
\psline[linewidth=1.5pt](0.25,0.5)(0.25,8)
\psline[linewidth=1.5pt](-1,6.75)(6.5,6.75)
\end{pspicture}
\end{center}

\begin{lstlisting}
\begin{pspicture}(-1,-1)(8,8)
\multido{\iA=1+1}{6}{%
  \rput(\iA,7.5){\Huge\psdice[unit=0.75,linecolor=red!80]{\iA}}
  \rput(! -0.5 7 \iA\space sub){\Huge\psdice[unit=0.75,linecolor=blue!70]{\iA}}%
  \multido{\iB=1+1}{6}{%
    \rput(! \iA\space 7 \iB\space sub){%
      \rnode[c]{p\iA\iB}{\makebox[1em][l]{\strut\psPrintValue[fontscale=12]{\iA\space \iB\space add}}}%
}}}
\ncbox[linearc=0.35,nodesep=0.2,linestyle=dotted]{p11}{p66}
\ncbox[linearc=0.35,nodesep=0.2,linestyle=dashed]{p15}{p51}
\rput{90}(-1.5,3.5){1. dice}
\rput{0}(3.5,8.5){2. dice}
\psline[linewidth=1.5pt](0.25,0.5)(0.25,8)
\psline[linewidth=1.5pt](-1,6.75)(6.5,6.75)
\end{pspicture}
\end{lstlisting}


\clearpage
\section{Olympic Rings}
The colors for the Rings are defined as \LColor{OlympicBlue}, \LColor{OlympicRed}, \LColor{OlympicGreen},
and \LColor{OlympicYellow} and can be overwritten by the user. The only valid optional argument
is \Lkeyword{psscale} for scaling.

\begin{BDef}
\Lcs{psOlympicRings}\OptArgs\coord1
\end{BDef}

\resetOptions
\psset{unit=1cm,doubleline=false,linearc=0,psscale=1}

\includegraphics{data/olympic}

\begin{lstlisting}
\begin{pspicture}(-4.5,-3)(4.5,1.5)
\psOlympicRings(0,0)
\psOlympicRings[psscale=0.2](1.5,-1.5)
\psOlympicRings[psscale=0.2](-1.5,-1.5)
\psOlympicRings[psscale=0.2](0,0.5)
\end{pspicture}
\end{lstlisting}



\clearpage
%--------------------------------------------------------------------------------------
\section{\nxLcs{psFormatInt}}
%--------------------------------------------------------------------------------------
There exist some packages and a lot of code to format an integer like $1\,000\,000$
or $1,234,567$ (in Europe $1.234.567$). But all packages expect a real number as
argument and cannot handle macros as an argument. For this case \LPack{pstricks-add}
has a macro \Lcs{psFormatInt} which can handle both:

\begin{LTXexample}[width=3cm]
\psFormatInt{1234567}\\
\psFormatInt[intSeparator={,}]{1234567}\\
\psFormatInt[intSeparator=.]{1234567}\\
\psFormatInt[intSeparator=$\cdot$]{1234567}\\
\def\temp{965432}
\psFormatInt{\temp}
\end{LTXexample}

With the option \Lkeyword{intSeparator} the symbol can be changed to any any non-number character.


\clearpage


%--------------------------------------------------------------------------------------
\section{\nxLcs{psRelLine}}
%--------------------------------------------------------------------------------------
With this macro it is possible to plot lines relative to a given one. Parameter are
the angle and the length factor:

\begin{BDef}
\Lcs{psRelLine}\Largr{P0}\Largr{P1}\Largb{length factor}\Largb{<end node name>}\\
\Lcs{psRelLine}\OptArg{\Largb{arrows}}\Largr{P0}\Largr{P1}\Largb{length factor}\Largb{end node name}\\
\Lcs{psRelLine}\OptArgs\Largr{P0}\Largr{P1}\Largb{length factor}\Largb{end node name}\\
\Lcs{psRelLine}\OptArgs\OptArg{\Largb{arrows}}\Largr{P0}\Largr{P1}\Largb{length factor}\Largb{end node name}
\end{BDef}

The length factor relates to the distance $\overline{P_0P_1}$ and
the end node name must be a valid nodename and shouldn't contain
any of the special PostScript characters. There are two valid
options which are described in the foregoing section for
\Lcs{psRelNode}.

The following two figures show the same, the first one with a scaling different to $1:1$,
this is the reason why the end points are on an ellipse and not on a circle like in the
second figure.

\begin{LTXexample}[width=5cm]
\psset{yunit=2,xunit=1}
\begin{pspicture}(-2,-2)(3,2)
\psgrid[subgriddiv=2,subgriddots=10,gridcolor=lightgray]
\pnode(-1,0){A}\pnode(3,2){B}
\psline[linecolor=red](A)(B)
\psRelLine[linecolor=blue,angle=30](-1,0)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=blue,angle=-30](A)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=magenta,angle=90](-1,0)(3,2){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=magenta,angle=-90](A)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=5cm]
\begin{pspicture}(-2,-2)(3,2)
\psgrid[subgriddiv=2,subgriddots=10,gridcolor=lightgray]
\pnode(-1,0){A}\pnode(3,2){B}
\psline[linecolor=red](A)(B)
\psarc[linestyle=dashed](A){2.23}{-90}{135}
\psRelLine[linecolor=blue,angle=30](-1,0)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=blue,angle=-30](A)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=magenta,angle=90](-1,0)(3,2){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=magenta,angle=-90](A)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\end{pspicture}
\end{LTXexample}

\medskip
The following figure has also a different scaling, but has set the
option \Lkeyword{trueAngle}, all angles refer to "what you see".

\begin{LTXexample}[width=6.5cm]
\psset{yunit=2,xunit=1}
\begin{pspicture}(-3,-1)(3,2)\psgrid[subgridcolor=lightgray]
\pnode(-1,0){A}\pnode(3,2){B}
\psline[linecolor=red](A)(B)
\psarc(A){2.83}{-45}{135}
\psRelLine[linecolor=blue,angle=30,trueAngle](A)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=blue,angle=-30,trueAngle](A)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=magenta,angle=90,trueAngle](A)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\psRelLine[linecolor=magenta,angle=-90,trueAngle](A)(B){0.5}{EndNode}
\qdisk(EndNode){2pt}
\end{pspicture}
\end{LTXexample}

\medskip
Two examples using \verb+\multido+ to show the behaviour of the
options \verb+trueAngle+ and \verb+angle+.

\medskip
\begin{LTXexample}[width=8cm]
\psset{yunit=4,xunit=2}
\begin{pspicture}(-1,0)(3,2)\psgrid[subgridcolor=lightgray]
\pnode(-1,0){A}\pnode(1,1){B}
\psline[linecolor=red](A)(3,2)
\multido{\iA=0+10}{36}{%
  \psRelLine[linecolor=blue,angle=\iA](B)(A){-0.5}{EndNode}
  \qdisk(EndNode){2pt}
}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=8cm]
\psset{yunit=4,xunit=2}
\begin{pspicture}(-1,0)(3,2)\psgrid[subgridcolor=lightgray]
\pnode(-1,0){A}\pnode(1,1){B}
\psline[linecolor=red](A)(3,2)
\multido{\iA=0+10}{36}{%
  \psRelLine[linecolor=magenta,angle=\iA,trueAngle]{->}(B)(A){-0.5}{EndNode}
}
\end{pspicture}
\end{LTXexample}

\begin{center}
\bgroup
\psset{xunit=0.75\linewidth,yunit=0.75\linewidth,trueAngle}%
\begin{pspicture}(1,0.6)%\psgrid
  \pnode(.3,.35){Vk} \pnode(.375,.35){D} \pnode(0,.4){DST1} \pnode(1,.18){DST2}
  \pnode(0,.1){A1}   \pnode(1,.31){A1}
  { \psset{linewidth=.02,linestyle=dashed,linecolor=gray}%
    \pcline(DST1)(DST2) % <- Druckseitentangente
    \pcline(A2)(A1) % <- Anstr\"omrichtung
    \lput*{:U}{\small Anstr\"omrichtung $v_{\infty}$} }%
  \psIntersectionPoint(A1)(A2)(DST1)(DST2){Hk}
  \pscurve(Hk)(.4,.38)(Vk)(.36,.33)(.5,.32)(Hk)
  \psParallelLine[linecolor=red!75!green,arrows=->,arrowscale=2](Vk)(Hk)(D){.1}{FtE}
  \psRelLine[linecolor=red!75!green,arrows=->,arrowscale=2,angle=90](D)(FtE){4}{Fn}% why "4"?
  \psParallelLine[linestyle=dashed](D)(FtE)(Fn){.1}{Fnr1}
  \psRelLine[linestyle=dashed,angle=90](FtE)(D){-4}{Fnr2} % why "-4"?
  \psline[linewidth=1.5pt,arrows=->,arrowscale=2](D)(Fnr2)
  \psIntersectionPoint(D)([nodesep=2]D)(Fnr1)([offset=-4]Fnr1){Fh}
  \psIntersectionPoint(D)([offset=2]D)(Fnr1)([nodesep=4]Fnr1){Fv}
  \psline[linecolor=blue,arrows=->,arrowscale=2](D)(Fh)
  \psline[linecolor=blue,arrows=->,arrowscale=2](D)(Fv)
  \psline[linestyle=dotted](Fh)(Fnr1)  \psline[linestyle=dotted](Fv)(Fnr1)
  \uput{.1}[0](Fh){\blue $F_{H}$}   \uput{.1}[180](Fv){\blue $F_{V}$}
  \uput{.1}[-45](Fnr1){$F_{R}$}     \uput{.1}[90](Fn){\color{red!75!green}$F_{N}$}
  \uput{.25}[-90](FtE){\color{red!75!green}$F_{T}$}
\end{pspicture}
\egroup
\end{center}
\begin{lstlisting}
\psset{xunit=0.75\linewidth,yunit=0.75\linewidth,trueAngle}%
\end{center}
\begin{pspicture}(1,0.6)%\psgrid
  \pnode(.3,.35){Vk} \pnode(.375,.35){D} \pnode(0,.4){DST1} \pnode(1,.18){DST2}
  \pnode(0,.1){A1}   \pnode(1,.31){A1}
  { \psset{linewidth=.02,linestyle=dashed,linecolor=gray}%
    \pcline(DST1)(DST2) % <- Druckseitentangente
    \pcline(A2)(A1) % <- Anstr"omrichtung
    \lput*{:U}{\small Anstr"omrichtung $v_{\infty}$} }%
  \psIntersectionPoint(A1)(A2)(DST1)(DST2){Hk}
  \pscurve(Hk)(.4,.38)(Vk)(.36,.33)(.5,.32)(Hk)
  \psParallelLine[linecolor=red!75!green,arrows=->,arrowscale=2](Vk)(Hk)(D){.1}{FtE}
  \psRelLine[linecolor=red!75!green,arrows=->,arrowscale=2,angle=90](D)(FtE){4}{Fn}% why "4"?
  \psParallelLine[linestyle=dashed](D)(FtE)(Fn){.1}{Fnr1}
  \psRelLine[linestyle=dashed,angle=90](FtE)(D){-4}{Fnr2} % why "-4"?
  \psline[linewidth=1.5pt,arrows=->,arrowscale=2](D)(Fnr2)
  \psIntersectionPoint(D)([nodesep=2]D)(Fnr1)([offset=-4]Fnr1){Fh}
  \psIntersectionPoint(D)([offset=2]D)(Fnr1)([nodesep=4]Fnr1){Fv}
  \psline[linecolor=blue,arrows=->,arrowscale=2](D)(Fh)
  \psline[linecolor=blue,arrows=->,arrowscale=2](D)(Fv)
  \psline[linestyle=dotted](Fh)(Fnr1)  \psline[linestyle=dotted](Fv)(Fnr1)
  \uput{.1}[0](Fh){\blue $F_{H}$}   \uput{.1}[180](Fv){\blue $F_{V}$}
  \uput{.1}[-45](Fnr1){$F_{R}$}     \uput{.1}[90](Fn){\color{red!75!green}$F_{N}$}
  \uput{.25}[-90](FtE){\color{red!75!green}$F_{T}$}
\end{pspicture}
\end{lstlisting}


%--------------------------------------------------------------------------------------
\section{\nxLcs{psParallelLine}}
%--------------------------------------------------------------------------------------
With this macro it is possible to plot lines relative to a given one, which is parallel.
There is no special parameter here.

\begin{lstlisting}[style=syntax]
\psParallelLine(<P0>)(<P1>)(<P2>){<length>}{<end node name>}
\psParallelLine{<arrows>}(<P0>)(<P1>)(<P2>){<length>}{<end node name>}
\psParallelLine[<options>](<P0>)(<P1>)(<P2>){<length>}{<end node name>}
\psParallelLine[<options>]{<arrows>}(<P0>)(<P1>)(<P2>){<length>}{<end node name>}
\end{lstlisting}

The line starts at $P_2$, is parallel to $\overline{P_0P_1}$ and
the length of this parallel line depends on the length factor. The
end node name must be a valid nodename and shouldn't contain any
of the special PostScript characters.

\begin{LTXexample}
\begin{pspicture*}(-5,-4)(5,3.5)
  \psgrid[subgriddiv=0,griddots=5]
  \pnode(2,-2){FF}\qdisk(FF){1.5pt}
  \pnode(-5,5){A}\pnode(0,0){O}
  \multido{\nCountA=-2.4+0.4}{9}{%
    \psParallelLine[linecolor=red](O)(A)(0,\nCountA){9}{P1}
    \psline[linecolor=red](0,\nCountA)(FF)
    \psRelLine[linecolor=red](0,\nCountA)(FF){9}{P2}
  }
  \psline[linecolor=blue](A)(FF)
  \psRelLine[linecolor=blue](A)(FF){5}{END1}
  \psline[linewidth=2pt,arrows=->](2,0)(FF)
\end{pspicture*}
\end{LTXexample}

the following example was created by Patrice Mégret.

\psset{unit=1cm}
\newcommand\pmsc[1]{\ensuremath{\underline{#1}}}
\newcommand\pmIc{\pmsc{I}}
\newcommand\pmUc{\pmsc{U}}
\newcommand\pmEc{\pmsc{E}}
\begin{pspicture}[showgrid=true](-5,-2)(3,8)
\psStartPoint[I](0,0)
\psVector[linewidth=1.5pt,linecolor=red](1.5;235)\ncput*{$\pmIc_2$}%I_2
\psStartPoint[U](0,0)
\psVector[linewidth=1.5pt](2;90)\ncput*{$\pmUc_2$}%U_2
\psParallelLine[linewidth=1.5pt,arrows=->](0,0)(I1)(U1){-0.3}{NUa}\nbput{\tiny $-R_2\pmIc_2$}%-R_2.I_2
\psRelLine[linewidth=1.5pt,arrows=->,angle=90](NUa)(U1){-5}{NUb}\nbput{\tiny $-j\omega L_{\sigma2}\pmIc_2$}  %$
\pcline[linewidth=3.5pt,arrows=->](0,0)(NUb)\naput{$\pmEc_2$}%E_2
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NUb)(0,0){1.428}{NUc}\nbput[npos=0.8]{$\pmEc_1$}%E_1 (m=0.7)
\psRelLine[linewidth=1.5pt,arrows=->,angle=-85,linecolor=orange](0,0)(NUc){0.2}{NIm1}\nbput{\tiny $\pmIc_{m1}$}%I_m1
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=orange](0,0)(I1)(NIm1){-0.7}{NI1}\nbput{\tiny $-m\pmIc_2$}%m.I_2
\pcline[linewidth=1.5pt,arrows=->,linecolor=orange](0,0)(NI1)\naput{\tiny $\pmIc_{1}$}%I_1
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NI1)(NUc){0.2}{NUd}\nbput{\tiny $R_1\pmIc_1$}%R_1 I_1
\psRelLine[linewidth=1.5pt,arrows=->,angle=90,linecolor=blue](NUd)(NUc){-5}{NUe}\nbput{\tiny $j\omega L_{\sigma1}\pmIc_1$}%-j\omega I_2
\pcline[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NUe)\naput{$\pmUc_{1}$}%I_1
\end{pspicture}

%$


\begin{lstlisting}[basicstyle=\footnotesize\ttfamily]
\newcommand\pmsc[1]{\ensuremath{\underline{#1}}}
\newcommand\pmIc{\pmsc{I}}
\newcommand\pmUc{\pmsc{U}}
\newcommand\pmEc{\pmsc{E}}
\begin{pspicture}[showgrid=true](-5,-2)(3,8)
\psStartPoint[I](0,0)
\psVector[linewidth=1.5pt,linecolor=red](1.5;235)\ncput*{$\pmIc_2$}%I_2
\psStartPoint[U](0,0)
\psVector[linewidth=1.5pt](2;90)\ncput*{$\pmUc_2$}%U_2
\psParallelLine[linewidth=1.5pt,arrows=->](0,0)(I1)(U1){-0.3}{NUa}\nbput{\tiny $-R_2\pmIc_2$}
\psRelLine[linewidth=1.5pt,arrows=->,angle=90](NUa)(U1){-5}{NUb}%
	\nbput{\tiny $-j\omega L_{\sigma2}\pmIc_2$}%-j\omega I_2
\pcline[linewidth=3.5pt,arrows=->](0,0)(NUb)\naput{$\pmEc_2$}%E_2
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NUb)(0,0){1.428}{NUc}%
        \nbput[npos=0.8]{$\pmEc_1$}%E_1 (m=0.7)
\psRelLine[linewidth=1.5pt,arrows=->,angle=-85,linecolor=orange](0,0)(NUc){0.2}{NIm1}
	\nbput{\tiny $\pmIc_{m1}$}%I_m1
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=orange](0,0)(I1)(NIm1){-0.7}{NI1}
	\nbput{\tiny $-m\pmIc_2$}%m.I_2
\pcline[linewidth=1.5pt,arrows=->,linecolor=orange](0,0)(NI1)\naput{\tiny $\pmIc_{1}$}%I_1
\psParallelLine[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NI1)(NUc){0.2}{NUd}
	\nbput{\tiny $R_1\pmIc_1$}%R_1 I_1
\psRelLine[linewidth=1.5pt,arrows=->,angle=90,linecolor=blue](NUd)(NUc){-5}{NUe}
	\nbput{\tiny $j\omega L_{\sigma1}\pmIc_1$}%-j\omega I_2
\pcline[linewidth=1.5pt,arrows=->,linecolor=blue](0,0)(NUe)\naput{$\pmUc_{1}$}%I_1
\end{pspicture}
\end{lstlisting}

%$

\clearpage

%--------------------------------------------------------------------------------------
\section{\nxLcs{psIntersectionPoint}}
%--------------------------------------------------------------------------------------
This macro calculates the intersection point of two lines, given by the four coordinates.
There is no special parameter here.
\begin{lstlisting}[style=syntax]
\psIntersectionPoint(<P0>)(<P1>)(<P2>)(<P3>){<node name>}
\end{lstlisting}

\begin{LTXexample}[width=5.5cm]
\psset{unit=0.5cm}
\begin{pspicture}(-5,-4)(5,5)
  \psaxes[labelFontSize=\scriptstyle,
    dx=2,Dx=2,dy=2,Dy=2]{->}(0,0)(-5,-4)(5,5)
  \psline[linecolor=red,linewidth=2pt](-5,-1)(5,5)
  \psline[linecolor=blue,linewidth=2pt](-5,3)(5,-4)
  \qdisk(-5,-1){2pt}\uput[-90](-5,-1){A}
  \qdisk(5,5){2pt}\uput[-90](5,5){B}
  \qdisk(-5,3){2pt}\uput[-90](-5,3){C}
  \qdisk(5,-4){2pt}\uput[-90](5,-4){D}
  \psIntersectionPoint(-5,-1)(5,5)(-5,3)(5,-4){IP}
  \qdisk(IP){3pt}\uput{0.3}[90](IP){IP}
  \psline[linestyle=dashed](IP|0,0)(IP)(0,0|IP)
\end{pspicture}
\end{LTXexample}

\clearpage

%--------------------------------------------------------------------------------------
\section[\nxLcs{psCancel}]{\nxLcs{psCancel}\footnotemark}
%--------------------------------------------------------------------------------------
\footnotetext{Thanks to by Stefano Baroni} This macro works like
the \Lcs{cancel} macro from the package of the same name but it
allows as argument any contents, not only letters but also a
complex graphic.

\begin{BDef}
\LcsStar{psCancel}\OptArgs\Largb{contents}%
\end{BDef}

All optional arguments for lines and boxes are valid and can be
used in the usual way. The star option fills the underlying box
rectangle with the linecolor. This can be transparent if
\Lkeyword{opacity} is set to a value less than 1. This can be used
in presentation to strike out words, equations, and graphic
objects. Lines can also be transparent when the option
\Lkeyword{strokeopacity} is used.

\begingroup
\psCancel{A} \psCancel[linecolor=red]{Tikz :-)} \quad
\psCancel[linecolor=blue,doubleline=true]{%
  \readdata{\data}{data/demo1.data}
  \psset{shift=*,xAxisLabel=x-Axis,yAxisLabel=y-Axis,llx=-13mm,lly=-7mm,
      xAxisLabelPos={c,-1},yAxisLabelPos={-7,c}}
  \pstScalePoints(1,0.00000001){}{}
  \begin{psgraph}[axesstyle=frame,xticksize=0 7.5,yticksize=0 25,subticksize=1,
     ylabelFactor=\cdot 10^8,Dx=5,Dy=1,xsubticks=2](0,0)(25,7.5){5.5cm}{5cm}
  \listplot[linecolor=red, linewidth=2pt, showpoints=true]{\data}
  \end{psgraph}} \qquad% end of Cancel
\psCancel[linewidth=3pt,linecolor=red,
    strokeopacity=0.5]{\tabular[b]{c}first line\\second line\endtabular}\quad
\psCancel*[linecolor=red!50,opacity=0.5]{\tabular[b]{c}first line\\second line\endtabular}


\psCancel*[linecolor=blue!30,opacity=0.5]{%
  \readdata{\data}{data/demo1.data}
  \psset{shift=*,xAxisLabel=x-Axis,yAxisLabel=y-Axis,llx=-15mm,lly=-7mm,urx=1mm,
      xAxisLabelPos={c,-1},yAxisLabelPos={-7,c}}
  \pstScalePoints(1,0.00000001){}{}
  \begin{psgraph}[axesstyle=frame,xticksize=0 7.5,yticksize=0 25,subticksize=1,
     ylabelFactor=\cdot 10^8,Dx=5,Dy=1,xsubticks=2](0,0)(25,7.5){5.5cm}{5cm}
  \listplot[linecolor=red, linewidth=2pt, showpoints=true]{\data}
  \end{psgraph}} \quad% end of Cancel
\psCancel[linewidth=4pt,strokeopacity=0.5]{\parbox{8cm}{\[
  \binom{x_R}{y_R} = \underbrace{r\vphantom{\binom{A}{B}}}_{\text{Scaling}}\cdot
    \underbrace{\begin{pmatrix}
        \sin\gamma & -\cos\gamma \\
      \cos \gamma & \sin \gamma \\
      \end{pmatrix}}_{\text{Rotation}} \binom{x_K}{y_K} +
  \underbrace{\binom{t_x}{t_y}}_{\text{Translation}} \]} }% end of psCancel
\endgroup

\bigskip
\begin{lstlisting}
\psCancel{A} \psCancel[linecolor=red]{Tikz :-)} \quad
\psCancel[linecolor=blue,doubleline=true]{%
  \readdata{\data}{data/demo1.data}
  \psset{shift=*,xAxisLabel=x-Axis,yAxisLabel=y-Axis,llx=-13mm,lly=-7mm,
      xAxisLabelPos={c,-1},yAxisLabelPos={-7,c}}
  \pstScalePoints(1,0.00000001){}{}
  \begin{psgraph}[axesstyle=frame,xticksize=0 7.5,yticksize=0 25,subticksize=1,
     ylabelFactor=\cdot 10^8,Dx=5,Dy=1,xsubticks=2](0,0)(25,7.5){5.5cm}{5cm}
  \listplot[linecolor=red, linewidth=2pt, showpoints=true]{\data}
  \end{psgraph}} \qquad% end of Cancel
\psCancel[linewidth=3pt,linecolor=red,
    strokeopacity=0.5]{\tabular[b]{c}first line\\second line\endtabular}\quad
\psCancel*[linecolor=red!50,opacity=0.5]{\tabular[b]{c}first line\\second line\endtabular}
\quad
\psCancel*[linecolor=blue!30,opacity=0.5]{%
  \readdata{\data}{data/demo1.data}
  \psset{shift=*,xAxisLabel=x-Axis,yAxisLabel=y-Axis,llx=-15mm,lly=-7mm,urx=1mm,
      xAxisLabelPos={c,-1},yAxisLabelPos={-7,c}}
  \pstScalePoints(1,0.00000001){}{}
  \begin{psgraph}[axesstyle=frame,xticksize=0 7.5,yticksize=0 25,subticksize=1,
     ylabelFactor=\cdot 10^8,Dx=5,Dy=1,xsubticks=2](0,0)(25,7.5){5.5cm}{5cm}
  \listplot[linecolor=red, linewidth=2pt, showpoints=true]{\data}
  \end{psgraph}} \quad% end of Cancel
\psCancel[linewidth=4pt,strokeopacity=0.5]{\parbox{8cm}{\[
  \binom{x_R}{y_R} = \underbrace{r\vphantom{\binom{A}{B}}}_{\text{Scaling}}\cdot
    \underbrace{\begin{pmatrix}
        \sin\gamma & -\cos\gamma \\
      \cos \gamma & \sin \gamma \\
      \end{pmatrix}}_{\text{Rotation}} \binom{x_K}{y_K} +
  \underbrace{\binom{t_x}{t_y}}_{\text{Translation}} \]} }% end of psCancel
\end{lstlisting}

The optional argument \Lkeyword{cancelType} allows to define the lines for the non star version.
Possible values are \Lkeyval{x} for a cross, \Lkeyval{s} for a slash, and \Lkeyval{b}
for a backslash. It is also possible to use the long words for the \Lkeyval{slash} and the \Lkeyval{backslash}.
An empty value is always assumed as a \Lkeyval{x}. The uppercase keys maybe used in presentations where it make sense 
to have thesame box size before ander after something is cancelled by lines.

\begin{LTXexample}[pos=t,wide]
\psset{linewidth=3pt,strokeopacity=0.4}
\psCancel{\tabular[b]{c}first line\\second line\endtabular}   \quad
\psCancel[cancelType=x]{\tabular[b]{c}first line\\second line\endtabular}\quad
\psCancel[cancelType=s]{\tabular[b]{c}first line\\second line\endtabular}\quad
\psCancel[cancelType=b]{\tabular[b]{c}first line\\second line\endtabular}\\
\psCancel[cancelType=X]{\tabular[b]{@{}c@{}}first line\\second line\endtabular}\quad
\psCancel[cancelType=S]{\tabular[b]{@{}c@{}}first line\\second line\endtabular}\quad
\psCancel[cancelType=B]{\tabular[b]{@{}c@{}}first line\\second line\endtabular}
\end{LTXexample}

\clearpage
%--------------------------------------------------------------------------------------
\section{\nxLcs{psStep}}
%--------------------------------------------------------------------------------------
\Lcs{psStep} calculates a step function for the upper or lower
sum or the max/min of the \Index{Riemann} integral definition of a given
function. The available option is

\Lkeyset{StepType=lower}|\Lkeyval{upper}|\Lkeyval{Riemann}|\Lkeyval{infimum}|\Lkeyval{supremum} or alternative
\Lkeyset{StepType=l}|\Lkeyval{u}|\Lkeyval{R}|\Lkeyval{i}|\Lkeyval{s}

with \Lkeyword{lower} as the default setting. The syntax of the function is

\begin{BDef}
\Lcs{psStep}\OptArgs\Largr{$x1,x2$}\Largb{n}\Largb{function}
\end{BDef}

%$





(x1,x2) is the given interval for the step wise calculated
function, n is the number of the rectangles and \Larg{function} is
the mathematical function in postfix or algebraic notation (with
\Lkeyword{algebraic}).

\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(-0.5,-0.5)(10,3)
 \psaxes[labelFontSize=\scriptstyle]{->}(10,3)
 \psplot[plotpoints=100,linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)}
 \psStep[linecolor=magenta,StepType=upper,fillstyle=hlines](0,9){9}{x sqrt}
 \psStep[linecolor=blue,fillstyle=vlines](0,9){9}{x sqrt }
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{plotpoints=200}
\begin{pspicture}(-0.5,-2.25)(10,3)
  \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)
 \psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}
 \psStep[algebraic,linecolor=magenta,StepType=upper](0,9){20}{sqrt(x)*sin(x)}
 \psStep[linecolor=blue,linestyle=dashed](0,9){20}{x sqrt x RadtoDeg sin mul}
\end{pspicture}
\end{LTXexample}




\begin{LTXexample}[pos=t,preset=\centering]
\psset{yunit=1.25cm,plotpoints=200}
\begin{pspicture}(-0.5,-1.5)(10,1.5)
 \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5)
 \psStep[algebraic,StepType=Riemann,fillstyle=solid,fillcolor=black!10](0,10){50}%
    {sqrt(x)*cos(x)*sin(x)}
 \psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)}
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}[pos=t,preset=\centering]
\psset{yunit=1.25cm,plotpoints=200}
\begin{pspicture}(-0.5,-1.5)(10,1.5)
 \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5)
 \psStep[algebraic,StepType=infimum,fillstyle=solid,fillcolor=black!10](0,10){50}%
    {sqrt(x)*cos(x)*sin(x)}
 \psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{yunit=1.25cm,plotpoints=200}
\begin{pspicture}(-0.5,-1.5)(10,1.5)
 \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5)
 \psStep[algebraic,StepType=supremum,fillstyle=solid,fillcolor=black!10](0,10){50}%
    {sqrt(x)*cos(x)*sin(x)}
 \psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{unit=1.5cm,plotpoints=200}
\begin{pspicture}[plotpoints=200](-0.5,-3)(10,2.5)
  \psStep[algebraic,fillstyle=solid,fillcolor=yellow](0.001,9.5){40}{2*sqrt(x)*cos(ln(x))*sin(x)}
  \psStep[algebraic,StepType=Riemann,fillstyle=solid,fillcolor=blue](0.001,9.5){40}{2*sqrt(x)*cos(ln(x))*sin(x)}
  \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.75)(10,2.5)
  \psplot[algebraic,linecolor=white]{0.001}{9.75}{2*sqrt(x)*cos(ln(x))*sin(x)}
  \uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$}
\end{pspicture}
\end{LTXexample}


There is also an optional argument \Lkeyword{noVerticalLines} which suppresses all
vertical lines of the step function in the output.

\iffalse



\definecolor{BeigeTS}{rgb}{0.98,0.95,0.87}
\definecolor{CornBlauTS}{rgb}{0.39,0.59,0.93}
\definecolor{SandBraun}{rgb}{0.96,0.64,0.38}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{yunit=1.25cm,arrowinset=0.02,arrowlength=2,linewidth=0.5pt,saveNodeCoors,NodeCoorPrefix=n,PrintCoord}
\def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)}
\begin{pspicture}[plotpoints=500,algebraic,fontscale=5,markZeros,dotscale=0.7](-0.5,-3)(10,2.5)
\psStep[fillstyle=solid,fillcolor=BeigeTS,opacity=0.7,linewidth=0.3pt,linecolor=SandBraun!50](0.001,9.5){40}{\funkf}
\psStep[StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,linecolor=CornBlauTS,linewidth=0.3pt]%
(0.001,9.5){40}{\funkf}
\psaxes[labelFontSize=\scriptstyle,ticksize=-0.1 0]{->}(0,0)(0,-2.75)(10,2.5)
\psplot[linecolor=BeigeTS!60,linewidth=0.8pt]{0.001}{9.75}{\funkf}
\psplotTangent[linecolor=blue, Derive={Derive(1,\funkf)}]{1.29}{1.5}{\funkf}
\uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$}
\psZero[xShift=-0.2,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={1},Newton](0.5,1){\funkf}{0}{N1}
\psZero[xShift=-0.05,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={2}](2,4){\funkf}{0}{N2}
\psZero[xShift=-0.45,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={3}](4,6){\funkf}{0}{N3}
\psZero[xShift=-0.45,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={4}](6,7){\funkf}{0}{N4}
\psZero[xShift=-0.45,yShift=0.15,linecolor=blue!50!black!90,ydecimals=0,postString={5}](9,11){\funkf}{0}{N5}
\psZero[xShift=-1.15,yShift=0,linecolor=blue!50!black!90,PtName={M},postString={m=1}](0.5,2){Derive(1,\funkf)-1+\funkf}{\funkf}{M}
\pcline{->}(0.5,-1)(M)
\nbput[nrot=:U,labelsep=0.01]{\scriptsize Steigung ist hier \psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round=true,fontscale=7]{nMx,{Derive(1,\funkf)}}}
%\psdot[linecolor=green,strokeopacity=0.8](*{nMx} {\funkf})
\uput[90](*{nMx} {\funkf}){$m=$\psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round=true,fontscale=8]{nMx,{Derive(1,\funkf)}}}
\end{pspicture}
\end{LTXexample}





\begin{pspicture}(-0.5,-1.5)(10.2,1.5)
 \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10.2,1.5)
 \psplot[linewidth=.6pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)}
 \psStep[algebraic,StepType=infimum,fillstyle=solid,opacity=0.3,fillcolor=green!50!black!30,linecolor=green,linewidth=0.1pt,strokeopacity=0.8](0,10){50}%
    {sqrt(x)*cos(x)*sin(x)}
\end{pspicture}


\psset{yunit=1.25cm,plotpoints=500}
\begin{pspicture}(-0.5,-1.5)(10,1.5)
 \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5)
 \psStep[algebraic,StepType=supremum,fillstyle=solid,opacity=0.3,fillcolor=green!50!black!30,linecolor=green,linewidth=0.1pt](0,10){50}%
    {sqrt(x)*cos(x)*sin(x)}
 \psplot[linewidth=.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)}
\end{pspicture}



\begin{pspicture}(-0.5,-0.5)(10,3)
 \psaxes[labelFontSize=\scriptstyle]{->}(10,3)
 \psplot[plotpoints=500,linewidth=.5pt,algebraic]{0}{10}{sqrt(x)}
 \psStep[linecolor=green,StepType=upper,fillstyle=solid,opacity=0.3,fillcolor=green!50!black!60,linewidth=0.3pt](0,9){9}{x sqrt}
 \psStep[linecolor=BeigeTS,StepType=lower,fillstyle=hlines,hatchcolor=BeigeTS,hatchwidth=0.3pt,hatchsep=1.2pt,linewidth=0.3pt](0,9){9}{x sqrt }
\end{pspicture}



\psset{plotpoints=500}
\begin{pspicture}(-0.5,-2.25)(10,3)
  \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)
 \psplot[linewidth=0.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}
 \psStep[algebraic,linecolor=SandBraun,linewidth=0.4pt,StepType=upper](0,9){20}{sqrt(x)*sin(x)}
 \psStep[linecolor=CornBlauTS,linewidth=0.4pt,linestyle=dashed,dash=1.6pt 1.6pt](0,9){20}{x sqrt x RadtoDeg sin mul}
\end{pspicture}



\psset{yunit=1.25cm,plotpoints=500}
\begin{pspicture}(-0.5,-1.5)(10,1.5)
 \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-1.5)(10,1.5)
 \psStep[algebraic,StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,linecolor=CornBlauTS,linewidth=0.2pt](0,10){50}%
    {sqrt(x)*cos(x)*sin(x)}
 \psplot[linewidth=.5pt,algebraic]{0}{10}{sqrt(x)*cos(x)*sin(x)}
\end{pspicture}

\fi




With setting the optional argument \Lkeyword{saveSumValue} 
it is possible to calculate the area under the rectangles. The value is calculated on PostScript level and then
later saved in a macro \Lcs{pstAreaA},
for the next call of \Lcs{psStep} in the macro \Lcs{pstAreaB} and so on. The values are calculated
on PostScript level, the reason why two \LaTeX\ runs are needed. for every \Lcs{psStep} there will
be an external file \verb|\jobname-area#.tex| which has the definition of the macros \nxLcs{pstArea?}.
In this documentation the following \Lcs{psStep} is the 10th call of this function, the reason
why we have to choose \Lcs{pstAreaJ} and so on:

\clearpage

%\begin{LTXexample}[pos=t,preset=\centering]
\psset{plotpoints=200}%
\begin{pspicture}(-0.5,-2.25)(10,3)
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)%
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}%
\psset{linewidth=0.5pt}%
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){20}{sqrt(x)*sin(x)}%
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \pstAreaJ}}%
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){20}{sqrt(x)*sin(x)}%
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaK}}%
\end{pspicture}
%\end{LTXexample}

\begin{lstlisting}
\psset{plotpoints=200}%
\begin{pspicture}(-0.5,-2.25)(10,3)
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)%
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}%
\psset{linewidth=0.5pt}%
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){20}{sqrt(x)*sin(x)}%
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \pstAreaJ}}%
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){20}{sqrt(x)*sin(x)}%
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaK}}%
\end{pspicture}
\end{lstlisting}


%\begin{LTXexample}[pos=t,preset=\centering]
\psset{plotpoints=200}%
\begin{pspicture}(-0.5,-2.25)(10,3)
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)%
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}%
\psset{linewidth=0.1pt}%
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){100}{sqrt(x)*sin(x)}%
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \pstAreaL}}%
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){100}{sqrt(x)*sin(x)}%
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaM}}%
\end{pspicture}
%\end{LTXexample}

\begin{lstlisting}
\psset{plotpoints=200}%
\begin{pspicture}(-0.5,-2.25)(10,3)
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)%
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}%
\psset{linewidth=0.1pt}%
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){100}{sqrt(x)*sin(x)}%
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \pstAreaL}}%
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){100}{sqrt(x)*sin(x)}%
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaM}}%
\end{pspicture}
\end{lstlisting}
%--------------------------------------------------------------------------------------


The values for the Riemann sum can also be calculatet on \LaTeX\ level, but it needs
the package xparse and fp from the new \LaTeX3 kernel. It is not available for running \TeX.

\begin{BDef}
\Lcs{psRiemannSum}\Largr{$x_0,x_1$}\Largb{n}\Largb{f(\#1)}
\end{BDef}

The variable name in the last argument must be \#1!
After using the above macro the following four macros are defined:

\begin{BDef}
\Lcs{psLeftSumValue}\\
\Lcs{psRightSumValue}\\
\Lcs{psMiddleSumValue}\\
\Lcs{psDiffSumValue}
\end{BDef}

They all sum up the Riemann sum for the rectangle of width $dx$ and the height of the left, right
or middle value of the function $f(x)$. \Lcs{psDiffSumValue} sums up the absolute value of rextangles
in difference to the other three macros which takes a negative area into account.

%\begin{LTXexample}[pos=t,preset=\centering]
\psset{plotpoints=200}%
\begin{pspicture}(-0.5,-2.25)(10,3)
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)%
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}%
\psset{linewidth=0.1pt}%
\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)}
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){18}{sqrt(x)*sin(x)}%
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \psRightSumValue}}%
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){18}{sqrt(x)*sin(x)}%
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \psLeftSumValue}}%
\end{pspicture}
%\end{LTXexample}

\begin{lstlisting}
\psset{plotpoints=200}%
\begin{pspicture}(-0.5,-2.25)(10,3)
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)%
\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}%
\psset{linewidth=0.1pt}%
\psRiemannSum(0,9){18}
\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){18}{sqrt(x)*sin(x)}%
\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \psRightSumValue}}%
\psStep[algebraic,linecolor=blue,saveSumValue](0,9){18}{sqrt(x)*sin(x)}%
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \psLeftSumValue}}%
\end{pspicture}
\end{lstlisting}


With package \texttt{siunitx} it is possible to round the values:

\begin{lstlisting}
\usepackage{siunitx}
\sisetup{add-decimal-zero,
	round-mode=places,
	round-precision=2,
	output-decimal-marker={,},
	detect-all}
[...]
\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)}%
\num{\psLeftSumValue}\\
\num{\psRightSumValue}\\
\num{\psMiddleSumValue}\\
\num{\psDiffSumValue}
\end{lstlisting}

\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)}%
\num{\psLeftSumValue}\\
\num{\psRightSumValue}\\
\num{\psMiddleSumValue}\\
\num{\psDiffSumValue}


\clearpage






\section{Tangent lines}
There are two macros for plotting a tangent line or the tangent normal line.
The first one is \Lcs{psTangentLine} which expects three pairs of coordinates,
a $x$ and a $dx$ value. The second one is \Lcs{psplotTangent} which expects 
a function for the curve. \xLkeyword{Tnormal}

\subsection{\nxLcs{psTangentLine} and option \nxLkeyword{Tnormal}}

\begin{BDef}
\Lcs{psTangentLine}\OptArgs\coord1\coord2\coord3\Largb{x}\Largb{dx}
\end{BDef}

\begin{LTXexample}[width=0.45\linewidth,wide]
\psset{unit=2cm}
\begin{pspicture}[showgrid=true](1,-1)(4,1)
  \pscurve[showpoints=true]
    (2.1,-0.2)(2.5,0.2)(3.2,0.235)(3.8,-0.2)
  \psTangentLine[Tnormal,arrows=->,
    linecolor=red](2.5,0.2)(3.2,0.235)%
      (3.8,-0.2){3}{0.1}
  \psTangentLine[arrows=<->,
    linecolor=blue](2.5,0.2)(3.2,0.235)%
      (3.8,-0.2){3}{0.5}
\end{pspicture}
\end{LTXexample}

In special cases one has to use \Lkeyword{curvature}\verb+=1 1 1+ for the macro \Lcs{pscurve}
to get the same equation for the curve as \Lcs{psplotTangentLine} does.

\begin{LTXexample}[pos=t,preset=\centering]
\psset{unit=2cm}
\begin{pspicture}[showgrid=true](2,-1)(6,2)
\pscurve[showpoints=true,
  curvature=1 1 1](2.1,-0.2)(2.5,0.2)(3.2,0.235)(5.8,2)
\pscurve[showpoints=true,linecolor=green,
  curvature=1 1 1](2.5,0.2)(3.2,0.235)(5.8,2)
\psTangentLine[Tnormal,arrows=->,linecolor=red](2.5,0.2)(3.2,0.235)(5.8,2){4.6}{0.6}
\psTangentLine[arrows=<->,linecolor=blue](2.5,0.2)(3.2,0.235)(5.8,2){4.5}{0.6}
\end{pspicture}
\end{LTXexample}


The end points are saved as nodes \verb=OCurve=, \verb=ETangent=, and \verb=ENormal=. They can
be used in the default ways for nodes:

\begin{LTXexample}[pos=t,preset=\centering,wide]
\psset{yunit=4cm,xunit=2cm,arrowscale=2}
\begin{pspicture}(0.1,-0.3)(4,1)
\pscurve[showpoints=true](2.1,-0.2)(2.5,0.2)(3.2,0.4)(3.8,-0.2)
\psTangentLine[Tnormal,arrows=->,linecolor=red](2.5,0.2)(3.2,0.4)(3.8,-0.2){3.5}{0.5}
\psTangentLine[arrows=->,linecolor=blue](2.5,0.2)(3.2,0.4)(3.8,-0.2){3.5}{0.5}
\pcline[linestyle=dashed]{->}(OCurve)(ETangent|OCurve)\naput{$v_x$}
\pcline[linestyle=dashed]{->}(ETangent|OCurve)(ETangent)\naput{$v_y$}% double coordinate (x,y|x,y)
\end{pspicture}
\end{LTXexample}





\subsection{\nxLcs{psplotTangent} and option \nxLkeyword{Tnormal}}
%--------------------------------------------------------------------------------------
There is an additional option, named \Lkeyword{Derive} for an
alternative function (see following example) to calculate the
slope of the tangent. This will be in general the first
derivative, but can also be any other function. If this option is
different to to the default value \Lkeyset{Derive=default}, then this
function is taken to calculate the slope. For the other cases,
\LPack{pstricks-add} builds a secant with -0.00005<x<0.00005,
calculates the slope and takes this for the tangent. This may be
problematic in some cases of special functions or $x$ values, then
it may be appropriate to use the Derive option.

\begin{BDef}
\LcsStar{psplotTangent}\OptArgs\Largb{x}\Largb{dx}\Largb{function}
\end{BDef}



The macro expects three parameters:

\begin{description}
\item[$x$]: the $x$ value of the function for which the tangent should be calculated
\item[$dx$]: the $dx$ to both sides of the $x$ value
\item[$f(x)$]: the function in infix (with option \Lkeyword{algebraic}) or the default
postfix (PostScript) notation
\end{description}

The following examples show the use of the algebraic option together with the Derive option.
Remember that using the \Lkeyword{algebraic} option implies that the angles have to be in the
radian unit!

\begin{center}
\bgroup
\def\F{x RadtoDeg dup dup cos exch 2 mul cos add exch 3 mul cos add}
\def\Fp{x RadtoDeg dup dup sin exch 2 mul sin 2 mul add exch 3 mul sin 3 mul add neg}
\psset{plotpoints=1001}
\begin{pspicture}(-7.5,-2.5)(7.5,4)%X\psgrid
  \psaxes{->}(0,0)(-7.5,-2)(7.5,3.5)
  \psplot[linewidth=3\pslinewidth]{-7}{7}{\F}
  \psset{linecolor=red, arrows=<->, arrowscale=2}
  \multido{\n=-7+1}{8}{\psplotTangent{\n}{1}{\F}}
  \psset{linecolor=magenta, arrows=<->, arrowscale=2}%
  \multido{\n=0+1}{8}{\psplotTangent[linecolor=blue, Derive=\Fp]{\n}{1}{\F}}
\end{pspicture}
\egroup
\end{center}


\begin{lstlisting}
\def\F{x RadtoDeg dup dup cos exch 2 mul cos add exch 3 mul cos add}
\def\Fp{x RadtoDeg dup dup sin exch 2 mul sin 2 mul add exch 3 mul sin 3 mul add neg}
\psset{plotpoints=1001}
\begin{pspicture}(-7.5,-2.5)(7.5,4)%X\psgrid
  \psaxes{->}(0,0)(-7.5,-2)(7.5,3.5)
  \psplot[linewidth=3\pslinewidth]{-7}{7}{\F}
  \psset{linecolor=red, arrows=<->, arrowscale=2}
  \multido{\n=-7+1}{8}{\psplotTangent{\n}{1}{\F}}
  \psset{linecolor=magenta, arrows=<->, arrowscale=2}%
  \multido{\n=0+1}{8}{\psplotTangent[linecolor=blue, §\ON§Derive=\Fp§\OFF§]{\n}{1}{\F}}
\end{pspicture}
\end{lstlisting}

The star version plots only the tangent line in the positive $x$-direction:

\begin{center}
\bgroup
\def\Falg{cos(x)+cos(2*x)+cos(3*x)}   \def\Fpalg{-sin(x)-2*sin(2*x)-3*sin(3*x)}
\begin{pspicture}(-7.5,-2.5)(7.5,4)%\psgrid
  \psaxes{->}(0,0)(-7.5,-2)(7.5,3.5)
  \psplot[linewidth=1.5pt,algebraic,plotpoints=500]{-7.5}{7.5}{\Falg}
  \multido{\n=-7+1}{8}{\psplotTangent*[linecolor=red,arrows=->,arrowscale=2,algebraic]{\n}{1}{\Falg}}
  \multido{\n=0+1}{8}{\psplotTangent*[linecolor=magenta,%
     arrows=->,arrowscale=2,algebraic,Derive={\Fpalg}]{\n}{1}{\Falg}}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\def\Falg{cos(x)+cos(2*x)+cos(3*x)}   \def\Fpalg{-sin(x)-2*sin(2*x)-3*sin(3*x)}
\begin{pspicture}(-7.5,-2.5)(7.5,4)%\psgrid
  \psaxes{->}(0,0)(-7.5,-2)(7.5,3.5)
  \psplot[linewidth=1.5pt,algebraic,plotpoints=500]{-7.5}{7.5}{\Falg}
  \multido{\n=-7+1}{8}{\psplotTangent*[linecolor=red,arrows=->,arrowscale=2,algebraic]{\n}{1}{\Falg}}
  \multido{\n=0+1}{8}{\psplotTangent*[linecolor=magenta,%
     arrows=->,arrowscale=2,algebraic,Derive={\Fpalg}]{\n}{1}{\Falg}}
\end{pspicture}
\end{lstlisting}

The next example shows the use of the \Lkeyword{Derive} option to draw
the perpendicular line to the tangent.

\begin{LTXexample}[width=8cm,wide]
\begin{pspicture}(-0.5,-0.5)(7.25,7.25)
  \def\Func{10 x div}
  \psaxes[arrowscale=1.5]{->}(7,7)
  \psplot[linewidth=2pt,algebraic]{1.5}{5}{10/x}
  \psplotTangent[linewidth=.5\pslinewidth,linecolor=red,algebraic]{3}{2}{10/x}
  \psplotTangent[linewidth=.5\pslinewidth,linecolor=blue,algebraic,Derive=(x*x)/10]{3}{2}{10/x}
  \psline[linestyle=dashed](!0 /x 3 def \Func)(!3 /x 3 def \Func)(3,0)
\end{pspicture}
\end{LTXexample}

By setting the optional argument \Lkeyword{Tnormal} one can plot the
normal of the tangent line. It always starts at the given point.

\begin{LTXexample}[width=8cm,wide]
\begin{pspicture}(-0.5,-0.5)(7.25,7.25)
  \def\Func{10 x div}
  \psaxes[arrowscale=1.5]{->}(7,7)
  \psplot[linewidth=2pt]{1.5}{5}{\Func}
  \psplotTangent[linewidth=1.5\pslinewidth,linecolor=red]{3}{2}{\Func}
  \psplotTangent[linewidth=1.5\pslinewidth,linecolor=blue,Tnormal]{3}{2}{\Func}
  \psline[linestyle=dashed](!0 /x 3 def \Func)(!3 /x 3 def \Func)(3,0)
\end{pspicture}
\end{LTXexample}


Let's work with the classical \Index{cardioid}: $r=2(1+\cos(\theta))$ and
$\displaystyle \frac{d r}{d\theta}=-2\sin(\theta)$. The \Lkeyword{Derive}
option always expects the $\frac{d r}{d\theta}$ value and uses
internally the equation for the derivative of implicitly defined
functions:

\[
\frac{dy}{dx}=\frac{r^\prime\cdot\sin\theta + x}{r^\prime\cdot\cos\theta - y}
\]
where $x=r\cdot\cos\theta$ and $y=r\cdot\sin\theta$


\begin{LTXexample}[width=6cm,wide]
\begin{pspicture}(-1,-3)(5,3)%\psgrid[subgridcolor=lightgray]
  \psaxes{->}(0,0)(-1,-3)(5,3)
  \psplot[polarplot,linewidth=3\pslinewidth,linecolor=blue,%
     plotpoints=500]{0}{360}{1 x cos add 2 mul}
\end{pspicture}
\end{LTXexample}

\psset{algebraic=false}
\begin{LTXexample}[width=6cm,wide]
\begin{pspicture}(-1,-3)(5,3)%\psgrid[subgridcolor=lightgray]
  \psaxes{->}(0,0)(-1,-3)(5,3)
  \psplot[polarplot,linewidth=3\pslinewidth,linecolor=blue,plotpoints=500]{0}{360}{1 x cos add 2 mul}
  \multido{\n=0+36}{10}{%
     \psplotTangent[polarplot,linecolor=red,arrows=<->]{\n}{1.5}{1 x cos add 2 mul} }
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=6cm,wide]
\begin{pspicture}(-1,-3)(5,3)%\psgrid[subgridcolor=lightgray]
  \psaxes{->}(0,0)(-1,-3)(5,3)
  \psplot[polarplot,linewidth=3\pslinewidth,linecolor=blue,algebraic,plotpoints=500]{0}{6.289}{2*(1+cos(x))}
  \multido{\r=0.000+0.314}{21}{%
     \psplotTangent[polarplot,Derive=-2*sin(x),algebraic,linecolor=red,arrows=<->]{\r}{1.5}{2*(1+cos(x))} }
\end{pspicture}
\end{LTXexample}


Let's work with a \Index{Lissajou curve}:
 $\displaystyle\left\{\begin{array}{l}x=3.5\cos(2t)\\y=3.5\sin(6t)\end{array}\right.$
whose derivative is :
 $\displaystyle\left\{\begin{array}{l}x=-7\sin(2t)\\y=21\cos(6t)\end{array}\right.$

The parameter must be the letter $t$ instead of $x$ and when using
the \Lkeyword{algebraic} option you must separate the two equations by
a \Lnotation{|} (see example).

\begin{LTXexample}[pos=t,wide]
\def\Lissa{t dup 2 RadtoDeg mul cos 3.5 mul exch 6 mul RadtoDeg sin 3.5 mul}%
\psset{yunit=0.6}
\begin{pspicture}(-4,-4)(4,6)
  \parametricplot[plotpoints=500,linewidth=3\pslinewidth]{0}{3.141592}{\Lissa}
  \multido{\r=0.000+0.314}{11}{%
    \psplotTangent[linecolor=red,arrows=<->]{\r}{1.5}{\Lissa} }
  \multido{\r=0.157+0.314}{11}{%
    \psplotTangent[linecolor=blue,arrows=<->]{\r}{1.5}{\Lissa} }
\end{pspicture}\hfill%
\def\LissaAlg{3.5*cos(2*t)|3.5*sin(6*t)}  \def\LissaAlgDer{-7*sin(2*t)|21*cos(6*t)}%
\begin{pspicture}(-4,-4)(4,6)
  \parametricplot[algebraic,plotpoints=500,linewidth=3\pslinewidth]{0}{3.141592}{\LissaAlg}
  \multido{\r=0.000+0.314}{11}{%
    \psplotTangent[algebraic,linecolor=red,arrows=<->]{\r}{1.5}{\LissaAlg}}
  \multido{\r=0.157+0.314}{11}{%
    \psplotTangent[algebraic,linecolor=blue,arrows=<->,
       Derive=\LissaAlgDer]{\r}{1.5}{\LissaAlg} }
\end{pspicture}
\end{LTXexample}

\iffalse
\begin{LTXexample}[pos=t,wide]
\psset{yunit=2cm,xunit=1.2cm,plotpoints=500,arrowinset=0.02,arrowlength=2,algebraic}
\def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)}
\begin{pspicture}[showgrid](-1,-3)(10,3.2)
\psaxes[labelFontSize=\scriptstyle,subticks=5,ticksize=-0.1 0,labelsep=0.07]{->}(0,0)(0,-2.75)(10,2.5)
\psplot{0.001}{9.75}{\funkf}
\psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)},
  showpoints,nodesep=0]{0.35}{1.5}{\funkf}
\psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)},Tnormal,
  nodesepA=-3,nodesepB=0,strokeopacity=0.4]{0.35}{1.5}{\funkf}
\psdot[linecolor=cyan](ENormal)
\psdot[linecolor=cyan](ENormalE)
\psdot[linecolor=red](OCurve)
\psdot[linecolor=green](ETangent)
\psdot[linecolor=green](ETangentE)
\end{pspicture}
\end{LTXexample}
\fi

\clearpage
\section{Successive derivatives of a function}

The new PostScript function \Lps{Derive} has been added for
plotting successive derivatives of a function. It must be used
with the \Lkeyword{algebraic} option. This function has two arguments:

\begin{enumerate}
\item a positive integer which defines the order of the derivative; obviously $0$ means the
  function itself!
\item a function of variable $x$ which can be any function using common operators,
\end{enumerate}

Do not think that the derivative is approximated, the internal PostScript engine will
compute the real derivative using a formal derivative engine.

The following diagram contains the plot of the polynomial:

\[ f(x)=\sum_{i=0}^{14}\frac{(-1)^{i}x^{2i}}{i!}=1-\frac{x^2}{2}+\frac{x^4}{4!}-\frac{x^6}{6!}+\frac{x^8}{8!}-
          \frac{x^{10}}{10!}+\frac{x^{12}}{12!}-\frac{x^{14}}{14!}\]

and of its first 15 derivatives. It is the sequence definition of
the cosine.


\begin{LTXexample}[pos=t,wide,preset=\centering]
\psset{unit=2}
\def\getColor#1{\ifcase#1 Tan\or RedOrange\or magenta\or yellow\or green\or Orange\or blue\or
  DarkOrchid\or BrickRed\or Rhodamine\or OliveGreen\or Goldenrod\or Mahogany\or
  OrangeRed\or CarnationPink\or RoyalPurple\or Lavender\fi}
\begin{pspicture}[showgrid=true](0,-1.2)(7,1.5)
  \psclip{\psframe[linestyle=none](0,-1.1)(7,1.1)}
  \multido{\in=0+1}{16}{%
     \psplot[linewidth=1pt,algebraic,linecolor=\getColor{\in}]{0}{7}
      {Derive(\in,1-x^2/2+x^4/24-x^6/720+x^8/40320-x^10/3628800+x^12/479001600-x^14/87178291200)}}
  \endpsclip
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[shift=-2.5,showgrid=true,linewidth=1pt](0,-2)(3,3)
  \psplot[algebraic]{.001}{3}{x*ln(x)}  % f(x)
  \psplot[algebraic,linecolor=red]{.05}{3}{Derive(1,x*ln(x))} % f'(x)=1+ln(x)
\end{pspicture}
\end{LTXexample}


\clearpage
\section{Variable step for plotting a curve}
\subsection{Theory}

As you know with the \Lcs{psplot} macro, the curve is plotted
using a piece-wise linear curve. The step is given by the
parameter \Lkeyword{plotpoints}. For each step between $x_i$ and
$x_{i+1}$, the area defined between the curve and its
approximation (a segment) is majored by this formula :

\begin{minipage}[m]{.5\linewidth}
\[|\varepsilon|\le\frac{M_2(f)(x_{i+1}-x_i)^3}{12}\]

$M_2(f)$ is a majorant of the second derivative of $f$ in the interval $[x_i;x_{i+1}]$.
\end{minipage}
{\psset{unit=1cm, showpoints=false}
\begin{pspicture}[shift=-2,showgrid=true](0,-1)(6,3)
  \pscurve(0,0)(1,1)(3,2.2)(5,2)(6,1)\psline(1,1)(5,2)
  \psline(.5,0)(5.5,0)\psline(1,0)(1,1)\psline(5,0)(5,2)
  \rput[t](1,-.1){$x_n$}\rput[t](5,-.1){$x_{n+1}$}
  \psclip{\pscustom{\psecurve(0,0)(1,1)(3,2.2)(5,2)(6,1)\psline(5,2)}}
    \psframe[fillstyle=solid, fillcolor=gray](0,0)(5,5)
  \endpsclip
  \rput*(3,1.8){$\varepsilon$}
\end{pspicture}}



The parameter \Lkeyword{VarStep} (\false\ by default) activates
the variable step algorithm. It is set to a tolerance defined by
the parameter \Lkeyword{VarStepEpsilon} (\Lkeyval{default} by default,
accept real value). If this parameter is not set by the user, then
it is automatically computed using the default first step given by
the parameter \Lkeyword{plotpoints}. Then, for each step, $f''(x_n)$
and $f''(x_{n+1})$ are computed and the smaller is used as
$M_2(f)$, and then the step is approximated. This means that the
step is constant for second order polynomials.

\subsection{The cosine}

Different value for the tolerance from $0.01$ to $0.000\,1$, a factor $10$ between
each of them. In black, there is the classic \Lcs{psplot} behavior, and in
magenta the default variable step behavior.

\begin{center}
\bgroup
\psset{algebraic, VarStep=true, unit=2, showpoints=true, linecolor=red}
\begin{pspicture}(-0,-1)(3.14,2)\psgrid
  \psplot[VarStepEpsilon=.01]{0}{3.14}{cos(x)}
  \psplot[VarStepEpsilon=.001]{0}{3.14}{cos(x)+.15}
  \psplot[VarStepEpsilon=.0001]{0}{3.14}{cos(x)+.3}
  \psplot[linecolor=magenta]{0}{3.14}{cos(x)+.45}
  \psplot[VarStep=false, linewidth=2\pslinewidth, linecolor=black]{-0}{3.14}{cos(x)+.6}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{algebraic, VarStep=true, unit=2, showpoints=true, linecolor=red}
\begin{pspicture}[showgrid=true](-0,-1)(3.14,2)
  \psplot[VarStepEpsilon=.01]{0}{3.14}{cos(x)}
  \psplot[VarStepEpsilon=.001]{0}{3.14}{cos(x)+.15}
  \psplot[VarStepEpsilon=.0001]{0}{3.14}{cos(x)+.3}
  \psplot[linecolor=magenta]{0}{3.14}{cos(x)+.45}
  \psplot[VarStep=false,linewidth=1pt,linecolor=black]{-0}{3.14}{cos(x)+.6}
\end{pspicture}
\end{lstlisting}


\subsection{The Napierian Logarithm}

A really classic example which gives a bad beginning, the tolerance is set to $0.001$.

\begin{center}
\bgroup
\psset{algebraic, VarStep=true, linecolor=red, showpoints=true}
\begin{pspicture}[showgrid=true](0,-5)(16,4)
  \psplot[VarStep=false, linecolor=black]{.01}{16}{ln(x)+1}
  \psplot[linecolor=magenta]{.51}{16}{ln(x-1/2)+1/2}
  \psplot[VarStepEpsilon=.001]{1.01}{16}{ln(x-1)}
  \psplot[VarStepEpsilon=.01]{1.51}{16}{ln(x-1.5)-100/200}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{algebraic, VarStep=true, linecolor=red, showpoints=true}
\begin{pspicture}[showgrid=true](0,-5)(16,4)
  \psplot[VarStep=false, linecolor=black]{.01}{16}{ln(x)+1}
  \psplot[linecolor=magenta]{.51}{16}{ln(x-1/2)+1/2}
  \psplot[VarStepEpsilon=.001]{1.01}{16}{ln(x-1)}
  \psplot[VarStepEpsilon=.01]{1.51}{16}{ln(x-1.5)-100/200}
\end{pspicture}
\end{lstlisting}


\clearpage
\subsection{Sine of the inverse of $x$}
Impossible to draw, but let's try!

\begin{center}
\bgroup
\psset{xunit=64,algebraic,VarStep,linecolor=red,showpoints=true,linewidth=1pt}
\begin{pspicture}[showgrid=true](0,-1)(.5,1)
  \psplot[VarStepEpsilon=.0001]{.01}{.25}{sin(1/x)}
\end{pspicture}\\
\begin{pspicture}[showgrid=true](0,-1)(.5,1)
  \psplot[VarStepEpsilon=.00001]{.01}{.25}{sin(1/x)}
\end{pspicture}\\
\begin{pspicture}[showgrid=true](0,-1)(.5,1)
  \psplot[VarStepEpsilon=.000001]{.01}{.25}{sin(1/x)}
\end{pspicture}\\
\begin{pspicture}[showgrid=true](0,-1)(.5,1)
  \psplot[VarStep=false, linecolor=black]{.01}{.25}{sin(1/x)}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{xunit=64,algebraic,VarStep,linecolor=red,showpoints=true,linewidth=1pt}
\begin{pspicture}[showgrid=true](0,-1)(.5,1)
  \psplot[VarStepEpsilon=.0001]{.01}{.25}{sin(1/x)}
\end{pspicture}\\
\begin{pspicture}[showgrid=true](0,-1)(.5,1)
  \psplot[VarStepEpsilon=.00001]{.01}{.25}{sin(1/x)}
\end{pspicture}\\
\begin{pspicture}[showgrid=true](0,-1)(.5,1)
  \psplot[VarStepEpsilon=.000001]{.01}{.25}{sin(1/x)}
\end{pspicture}\\
\begin{pspicture}[showgrid=true](0,-1)(.5,1)
  \psplot[VarStep=false, linecolor=black]{.01}{.25}{sin(1/x)}
\end{pspicture}
\end{lstlisting}





\clearpage
\subsection{A really complicated function}

Just appreciate the difference between the normal behavior and the plotting with the
\Lkeyword{varStep} option. The function is:

\[f(x)=x-\frac{x^2}{10}+\ln(x)+\cos(2x)+\sin(x^2)-1\]

\begin{center}
\bgroup
\psset{xunit=3, algebraic, VarStep, showpoints=true}
\begin{pspicture}[showgrid=true](0,-2)(5,6)
  \psplot[VarStepEpsilon=.0005, linecolor=red]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)}
  \psplot[linecolor=magenta]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)+.5}
  \psplot[VarStep=false]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)-1}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{xunit=3, algebraic, VarStep, showpoints=true}
\begin{pspicture}[showgrid=true](0,-2)(5,6)
  \psplot[VarStepEpsilon=.0005, linecolor=red]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)}
  \psplot[linecolor=magenta]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)+.5}
  \psplot[VarStep=false]{.1}{5}{x-x^2/10+ln(x)+cos(2*x)+sin(x^2)-1}
\end{pspicture}
\end{lstlisting}


\clearpage
\subsection{A hyperbola}

\begin{center}
\bgroup
\psset{algebraic, showpoints=true, unit=0.75}
\begin{pspicture}(-5,-4)(9,6)
  \psplot[linecolor=black]{-5}{1.8}{(x-1)/(x-2)}
  \psplot[VarStep=true, VarStepEpsilon=.001, linecolor=red]{2.2}{9}{(x-1)/(x-2)}
  \psaxes{->}(0,0)(-5,-4)(9,6)
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{algebraic, showpoints=true, unit=0.75}
\begin{pspicture}(-5,-4)(9,6)
  \psplot[linecolor=black]{-5}{1.8}{(x-1)/(x-2)}
  \psplot[VarStep=true, VarStepEpsilon=.001, linecolor=red]{2.2}{9}{(x-1)/(x-2)}
  \psaxes{->}(0,0)(-5,-4)(9,6)
\end{pspicture}
\end{lstlisting}



\clearpage
\subsection{Using \nxLcs{psparametricplot}}

\begin{BDef}
\Lcs{parametricplot}\OptArgs\Largb{t0}\Largb{t1}\OptArg{PS commands}\Largb{x(t) y(t)}
\end{BDef}

\begin{center}
\bgroup
\psset{unit=2.5}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\parametricplot[algebraic,linecolor=red,VarStep=true, showpoints=true,
                VarStepEpsilon=.0001]
                {-3.14}{3.14}{cos(3*t)|sin(2*t)}
\end{pspicture}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\parametricplot[algebraic,linecolor=blue,VarStep=true, showpoints=false,
                VarStepEpsilon=.0001]
                {-3.14}{3.14}{cos(3*t)|sin(2*t)}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{unit=3}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\parametricplot[algebraic,linecolor=red,VarStep=true, showpoints=true,
                VarStepEpsilon=.0001]
                {-3.14}{3.14}{cos(3*t)|sin(2*t)}
\end{pspicture}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\parametricplot[algebraic,linecolor=blue,VarStep=true, showpoints=false,
                VarStepEpsilon=.0001]
                {-3.14}{3.14}{cos(3*t)|sin(2*t)}
\end{pspicture}
\end{lstlisting}


\begin{center}
\bgroup
\psset{unit=2.5}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\parametricplot[algebraic,linecolor=red,VarStep=true, showpoints=true,
                VarStepEpsilon=.0001]
                {0}{47.115}{cos(5*t)|sin(3*t)}
\end{pspicture}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\parametricplot[algebraic,linecolor=blue,VarStep=true, showpoints=false,
                VarStepEpsilon=.0001]
                {0}{47.115}{cos(5*t)|sin(3*t)}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{unit=2.5}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\parametricplot[algebraic,linecolor=red,VarStep=true, showpoints=true,
                VarStepEpsilon=.0001]
                {0}{47.115}{cos(5*t)|sin(3*t)}
\end{pspicture}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\parametricplot[algebraic,linecolor=blue,VarStep=true, showpoints=false,
                VarStepEpsilon=.0001]
                {0}{47.115}{cos(5*t)|sin(3*t)}
\end{pspicture}
\end{lstlisting}


\begin{center}
\bgroup
\psset{xunit=.5}
\begin{pspicture}[showgrid=true](0,0)(12.566,2)
\parametricplot[algebraic,linecolor=red,VarStep, showpoints=true,
        VarStepEpsilon=.01]{0}{12.566}{t+cos(-t-Pi/2)|1+sin(-t-Pi/2)}
\end{pspicture}
%
\begin{pspicture}[showgrid=true](0,0)(12.566,2)
\parametricplot[algebraic,linecolor=blue,VarStep, showpoints=false,
        VarStepEpsilon=.001]{0}{12.566}{t+cos(-t-Pi/2)|1+sin(-t-Pi/2)}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{xunit=.5}
\begin{pspicture}[showgrid=true](0,0)(12.566,2)
\parametricplot[algebraic,linecolor=red,VarStep, showpoints=true,
        VarStepEpsilon=.01]{0}{12.566}{t+cos(-t-Pi/2)|1+sin(-t-Pi/2)}
\end{pspicture}
%
\begin{pspicture}[showgrid=true](0,0)(12.566,2)
\parametricplot[algebraic,linecolor=blue,VarStep, showpoints=false,
        VarStepEpsilon=.001]{0}{12.566}{t+cos(-t-Pi/2)|1+sin(-t-Pi/2)}
\end{pspicture}
\end{lstlisting}


\section{New math functions and their derivatives}

\subsection{The inverse sine and its derivative}

\begin{center}
\bgroup
\psset{unit=1.5}
\begin{pspicture}[showgrid=true](-1,-2)(1,2)
  \psplot[linecolor=blue,algebraic]{-1}{1}{asin(x)}
\end{pspicture}
\hspace{1em}
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true}
\begin{pspicture}[showgrid=true](-1,-2)(1,2)
  \psplot[linecolor=blue]{-.999}{.999}{asin(x)}
\end{pspicture}
\hspace{1em}
\begin{pspicture}[showgrid=true](-1,0)(1,4)
  \psplot[linecolor=blue]{-.97}{.97}{Derive(1,asin(x))}
\end{pspicture}
\hspace{1em}
\psset{algebraic, VarStep, VarStepEpsilon=.0001, showpoints=true}
\begin{pspicture}[showgrid=true](-1,0)(1,4)
  \psplot[linecolor=blue]{-.97}{.97}{Derive(1,asin(x))}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{unit=1.5}
\begin{pspicture}[showgrid=true](-1,-2)(1,2)
  \psplot[linecolor=blue,algebraic]{-1}{1}{asin(x)}
\end{pspicture}
\hspace{1em}
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true}
\begin{pspicture}[showgrid=true](-1,-2)(1,2)
  \psplot[linecolor=blue]{-.999}{.999}{asin(x)}
\end{pspicture}
\hspace{1em}
\begin{pspicture}[showgrid=true](-1,0)(1,4)
  \psplot[linecolor=red]{-.97}{.97}{Derive(1,asin(x))}
\end{pspicture}
\hspace{1em}
\psset{algebraic, VarStep, VarStepEpsilon=.0001, showpoints=true}
\begin{pspicture}[showgrid=true](-1,0)(1,4)
  \psplot[linecolor=red]{-.97}{.97}{Derive(1,asin(x))}
\end{pspicture}
\end{lstlisting}


\subsection{The inverse cosine and its derivative}

\begin{center}
\bgroup
\psset{unit=1.5}
\begin{pspicture}[showgrid=true](-1,0)(1,3)
  \psplot[linecolor=blue,algebraic]{-1}{1}{acos(x)}
\end{pspicture}
\hspace{1em}
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true}
\begin{pspicture}[showgrid=true](-1,0)(1,3)
  \psplot[linecolor=blue]{-.999}{.999}{acos(x)}
\end{pspicture}
\hspace{1em}
\begin{pspicture}[showgrid=true](-1,-4)(1,-1)
  \psplot[linecolor=blue]{-.97}{.97}{Derive(1,acos(x))}
\end{pspicture}
\hspace{1em}
\psset{algebraic, VarStep, VarStepEpsilon=.0001, showpoints=true}
\begin{pspicture}[showgrid=true](-1,-4)(1,-1)
  \psplot[linecolor=blue]{-.97}{.97}{Derive(1,acos(x))}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{unit=1.5}
\begin{pspicture}[showgrid=true](-1,0)(1,3)
  \psplot[linecolor=blue,algebraic]{-1}{1}{acos(x)}
\end{pspicture}
\hspace{1em}
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true}
\begin{pspicture}[showgrid=true](-1,0)(1,3)
  \psplot[linecolor=blue]{-.999}{.999}{acos(x)}
\end{pspicture}
\hspace{1em}
\begin{pspicture}[showgrid=true](-1,-4)(1,-1)
  \psplot[linecolor=red]{-.97}{.97}{Derive(1,acos(x))}
\end{pspicture}
\hspace{1em}
\psset{algebraic, VarStep, VarStepEpsilon=.0001, showpoints=true}
\begin{pspicture}[showgrid=true](-1,-4)(1,-1)
  \psplot[linecolor=red]{-.97}{.97}{Derive(1,acos(x))}
\end{pspicture}
\end{lstlisting}



\subsection{The inverse tangent and its derivative}

\begin{center}
\bgroup
\begin{pspicture}[showgrid=true](-4,-2)(4,2)
\psset{algebraic}
  \psplot[linecolor=blue,linewidth=1pt]{-4}{4}{atg(x)}
  \psplot[linecolor=red,VarStep, VarStepEpsilon=.0001, showpoints=true]{-4}{4}{Derive(1,atg(x))}
\end{pspicture}
\hspace{1em}
\begin{pspicture}[showgrid=true](-4,-2)(4,2)
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=blue]{-4}{4}{atg(x)}
  \psplot[linecolor=red]{-4}{4}{Derive(1,atg(x))}
\end{pspicture}
\egroup
\end{center}







\begin{lstlisting}
\begin{pspicture}[showgrid=true](-4,-2)(4,2)
\psset{algebraic}
  \psplot[linecolor=blue,linewidth=1pt]{-4}{4}{atg(x)}
  \psplot[linecolor=red,VarStep, VarStepEpsilon=.0001, showpoints=true]{-4}{4}{Derive(1,atg(x))}
\end{pspicture}
\hspace{1em}
\begin{pspicture}[showgrid=true](-4,-2)(4,2)
\psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=blue]{-4}{4}{atg(x)}
  \psplot[linecolor=red]{-4}{4}{Derive(1,atg(x))}
\end{pspicture}
\end{lstlisting}

\subsection{Hyperbolic functions}

\begin{center}
\bgroup
\begin{pspicture}(-3,-4)(3,4)
\psset{algebraic}
  \psplot[linecolor=red,linewidth=1pt]{-2}{2}{sh(x)}
  \psplot[linecolor=blue,linewidth=1pt]{-2}{2}{ch(x)}
  \psplot[linecolor=green,linewidth=1pt]{-3}{3}{th(x)}
  \psaxes{->}(0,0)(-3,-4)(3,4)
\end{pspicture}
\hspace{1em}
\begin{pspicture}(-3,-4)(3,4)
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=red,linewidth=1pt]{-2}{2}{sh(x)}
  \psplot[linecolor=blue,linewidth=1pt]{-2}{2}{ch(x)}
  \psplot[linecolor=green,linewidth=1pt]{-3}{3}{th(x)}
  \psaxes{->}(0,0)(-3,-4)(3,4)
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\begin{pspicture}(-3,-4)(3,4)
\psset{algebraic}
  \psplot[linecolor=red,linewidth=1pt]{-2}{2}{sh(x)}
  \psplot[linecolor=blue,linewidth=1pt]{-2}{2}{ch(x)}
  \psplot[linecolor=green,linewidth=1pt]{-3}{3}{th(x)}
  \psaxes{->}(0,0)(-3,-4)(3,4)
\end{pspicture}
\hspace{1em}
\begin{pspicture}(-3,-4)(3,4)
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=red,linewidth=1pt]{-2}{2}{sh(x)}
  \psplot[linecolor=blue,linewidth=1pt]{-2}{2}{ch(x)}
  \psplot[linecolor=green,linewidth=1pt]{-3}{3}{th(x)}
  \psaxes{->}(0,0)(-3,-4)(3,4)
\end{pspicture}
\end{lstlisting}



\begin{center}
\bgroup
\begin{pspicture}(-3,-4)(3,4)
\psset{algebraic}
  \psplot[linecolor=red,linewidth=1pt]{-2}{2}{Derive(1,sh(x))}
  \psplot[linecolor=blue,linewidth=1pt]{-2}{2}{Derive(1,ch(x))}
  \psplot[linecolor=green,linewidth=1pt]{-3}{3}{Derive(1,th(x))}
  \psaxes{->}(0,0)(-3,-4)(3,4)
\end{pspicture}
\hspace{1em}
\begin{pspicture}(-3,-4)(3,4)
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=red,linewidth=1pt]{-2}{2}{Derive(1,sh(x))}
  \psplot[linecolor=blue,linewidth=1pt]{-2}{2}{Derive(1,ch(x))}
  \psplot[linecolor=green,linewidth=1pt]{-3}{3}{Derive(1,th(x))}
  \psaxes{->}(0,0)(-3,-4)(3,4)
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\begin{pspicture}(-3,-4)(3,4)
\psset{algebraic,linewidth=1pt}
  \psplot[linecolor=red,linewidth=1pt]{-2}{2}{Derive(1,sh(x))}
  \psplot[linecolor=blue,linewidth=1pt]{-2}{2}{Derive(1,ch(x))}
  \psplot[linecolor=green,linewidth=1pt]{-3}{3}{Derive(1,th(x))}
  \psaxes{->}(0,0)(-3,-4)(3,4)
\end{pspicture}
\hspace{1em}
\begin{pspicture}(-3,-4)(3,4)
\psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=red,linewidth=1pt]{-2}{2}{Derive(1,sh(x))}
  \psplot[linecolor=blue,linewidth=1pt]{-2}{2}{Derive(1,ch(x))}
  \psplot[linecolor=green,linewidth=1pt]{-3}{3}{Derive(1,th(x))}
  \psaxes{->}(0,0)(-3,-4)(3,4)
\end{pspicture}
\end{lstlisting}



\begin{center}
\bgroup
\begin{pspicture}(-7,-3)(7,3)
\psset{algebraic}
  \psplot[linecolor=red,linewidth=1pt]{-7}{7}{Argsh(x)}
  \psplot[linecolor=blue,linewidth=1pt]{1}{7}{Argch(x)}
  \psplot[linecolor=green,linewidth=1pt]{-.99}{.99}{Argth(x)}
  \psaxes{->}(0,0)(-7,-3)(7,3)
\end{pspicture}\\[\baselineskip]
\begin{pspicture}(-7,-3)(7,3)
  \psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=red,linewidth=1pt]{-7}{7}{Argsh(x)}
  \psplot[linecolor=blue,linewidth=1pt]{1.001}{7}{Argch(x)}
  \psplot[linecolor=green,linewidth=1pt]{-.99}{.99}{Argth(x)}
  \psaxes{->}(0,0)(-7,-3)(7,3)
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\begin{pspicture}(-7,-3)(7,3)
\psset{algebraic}
  \psplot[linecolor=red,linewidth=1pt]{-7}{7}{Argsh(x)}
  \psplot[linecolor=blue,linewidth=1pt]{1}{7}{Argch(x)}
  \psplot[linecolor=green,linewidth=1pt]{-.99}{.99}{Argth(x)}
  \psaxes{->}(0,0)(-7,-3)(7,3)
\end{pspicture}\\[\baselineskip]
\begin{pspicture}(-7,-3)(7,3)
  \psset{algebraic, VarStep, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=red,linewidth=1pt]{-7}{7}{Argsh(x)}
  \psplot[linecolor=blue,linewidth=1pt]{1.001}{7}{Argch(x)}
  \psplot[linecolor=green,linewidth=1pt]{-.99}{.99}{Argth(x)}
  \psaxes{->}(0,0)(-7,-3)(7,3)
\end{pspicture}
\end{lstlisting}



\begin{center}
\bgroup
\begin{pspicture}(-7,-0.5)(7,6)
\psset{algebraic}
  \psplot[linecolor=red,linewidth=1pt]{-7}{7}{Derive(1,Argsh(x))}
  \psplot[linecolor=blue,linewidth=1pt]{1.014}{7}{Derive(1,Argch(x))}
  \psplot[linecolor=green,linewidth=1pt]{-.9}{.9}{Derive(1,Argth(x))}
  \psaxes{->}(0,0)(-7,0)(7,6)
\end{pspicture}\\[\baselineskip]
\begin{pspicture}(-7,-0.5)(7,6)
\psset{algebraic}
  \psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=red,linewidth=1pt]{-7}{7}{Derive(1,Argsh(x))}
  \psplot[linecolor=blue,linewidth=1pt]{1.014}{7}{Derive(1,Argch(x))}
  \psplot[linecolor=green,linewidth=1pt]{-.9}{.9}{Derive(1,Argth(x))}
  \psaxes{->}(0,0)(-7,0)(7,6)
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\begin{pspicture}(-7,-0.5)(7,6)
\psset{algebraic}
  \psplot[linecolor=red,linewidth=1pt]{-7}{7}{Derive(1,Argsh(x))}
  \psplot[linecolor=blue,linewidth=1pt]{1.014}{7}{Derive(1,Argch(x))}
  \psplot[linecolor=green,linewidth=1pt]{-.9}{.9}{Derive(1,Argth(x))}
  \psaxes{->}(0,0)(-7,0)(7,6)
\end{pspicture}\\[\baselineskip]
\begin{pspicture}(-7,-0.5)(7,6)
\psset{algebraic}
  \psset{algebraic, VarStep=true, VarStepEpsilon=.001, showpoints=true}
  \psplot[linecolor=red,linewidth=1pt]{-7}{7}{Derive(1,Argsh(x))}
  \psplot[linecolor=blue,linewidth=1pt]{1.014}{7}{Derive(1,Argch(x))}
  \psplot[linecolor=green,linewidth=1pt]{-.9}{.9}{Derive(1,Argth(x))}
  \psaxes{->}(0,0)(-7,0)(7,6)
\end{pspicture}
\end{lstlisting}


\clearpage
%--------------------------------------------------------------------------------------
\section[\nxLcs{psplotDiffEqn} -- solving diffential equations]%
  {\nxLcs{psplotDiffEqn} -- solving diffential equations}
%--------------------------------------------------------------------------------------


 A differential equation of first order is like

\begin{align} y^\prime=f(x,y,y^\prime) \end{align}


where $y$ is a function of $x$. We define some vectors $Y=[y, y',
\cdots , y^{(n-1)}]$ and $Y^\prime=[y^\prime, y^{\prime\prime},
\cdots , y^{n}]$, depending on the order $n$. The syntax of the
macro is

\begin{BDef}
\Lcs{psplotDiffEqn}\OptArgs\Largb{x0}\Largb{x1}\Largb{y0}\Largb{f(x,y,y',...)}
\end{BDef}

\begin{itemize}\setlength\itemsep{0pt}\setlength\parsep{0pt}\setlength\parskip{0pt}
\item \verb+options+: the \verb+\psplotDiffEqn+ specific options and all other of PSTricks, which
make sense;
\item $x_0$: the start value;
\item $x_1$: the end value of the definition interval;
\item $y_0$: the initial values for $y(x_0)\ y'(x_0)\ \ldots$;
\item $f(x,y,y',...)$: the differential equation, depending to the number of initial values, e.g.:
    \verb+{0 1}+ for $y_0$ are two initial values, so that we have a differential equation of
    second order $f(x,y,y')$ and the macro leaves $y\ y'$ on the stack.
\end{itemize}

The new options are:


\begin{itemize}\setlength\itemsep{0pt}\setlength\parsep{0pt}\setlength\parskip{0pt}
\item \Lkeyword{method}: integration method (\verb+euler+ for order 1 euler method, \verb+rk4+ for
  4\textsuperscript{th} order Runge-Kutta method);
\item \Lkeyword{whichabs}: select the abscissa for plotting the graph, by default it is
  $x$, but you can specify a number which represent a position in the vector $y$;
\item \Lkeyword{whichord}: same as precedent for the ordinate, by default $y(0)$;
\item \Lkeyword{plotfuncx}: describe a ps function for the abscissa, parameter
  \Lkeyword{whichabs} becomes useless;
\item \Lkeyword{plotfuncy}: idem for the ordinate;
\item \Lkeyword{buildvector}: boolean parameter for specifying the input-output of the
  $f$ description:
  \begin{description}
  \item[\texttt{true}] (default): $y$ is put on the stack element by element, $y'$
    must be given in the same way;
  \item[\texttt{false}]: $y$ is put on the stack as a vector, $y'$ must be returned
  in the same way;
  \end{description}

\item \Lkeyword{algebraic}: algebraic description for $f$, \Lkeyword{buildvector}
  parameter is useless when activating this option.
\end{itemize}



\clearpage
\subsection{Variable step for differential equations}

A new algorithm has been added for adjusting the step according to the variations of
the curve. The parameter \Lkeyword{method} has a new possible value : \Lkeyword{varrkiv} to
activate the \Index{Runge-Kutta} method with variable step, then the parameter
\Lkeyword{varsteptol} (real value; \verb+.01+ by default) can control the tolerance of
the algortihm.

\begin{center}
\bgroup
\def\Funct{neg}\def\FunctAlg{-y[0]}
\psset{xunit=1.5, yunit=8, showpoints=true}
\begin{pspicture}[showgrid=true](0,0)(10,1.2)
  \psplot[linewidth=6\pslinewidth, linecolor=green, showpoints=false]{0}{10}{Euler x neg exp}
  \psplotDiffEqn[linecolor=magenta, method=varrkiv, varsteptol=.1, plotpoints=2]{0}{10}{1}{\Funct}
  \rput(0,.0){\psplotDiffEqn[linecolor=blue, method=varrkiv, varsteptol=.01, plotpoints=2]{0}{10}{1}{\Funct}}
  \rput(0,.1){\psplotDiffEqn[linecolor=Orange, method=varrkiv, varsteptol=.001, plotpoints=2]{0}{10}{1}{\Funct}}
  \rput(0,.2){\psplotDiffEqn[linecolor=red, method=varrkiv, varsteptol=.0001, plotpoints=2]{0}{10}{1}{\Funct}}
  \psset{linewidth=4\pslinewidth,showpoints=false}
  \rput*(3.3,.9){\psline[linecolor=magenta](-.75cm,0)}
  \rput*[l](3.3,.9){\small RK ordre 4 : $\varepsilon<10^{-1}$}
  \rput*(3.3,.8){\psline[linecolor=blue](-.75cm,0)}
  \rput*[l](3.3,.8){\small RK ordre 4 : $\varepsilon<10^{-2}$}
  \rput*(3.3,.7){\psline[linecolor=Orange](-.75cm,0)}
  \rput*[l](3.3,.7){\small RK ordre 4 : $\varepsilon<10^{-3}$}
  \rput*(3.3,.6){\psline[linecolor=red](-.75cm,0)}
  \rput*[l](3.3,.6){\small RK ordre 4 : $\varepsilon<10^{-4}$}
  \rput*(3.3,.5){\psline[linecolor=green](-.75cm,0)}
  \rput*[l](3.3,.5){\small solution exacte}
\end{pspicture}
{\captionof{figure}{Equation $y'=-y$ with $y_0=1$.}\label{fig:minusexpvarstep}}
\egroup
\end{center}


\begin{lstlisting}[wide=true]
\def\Funct{neg}\def\FunctAlg{-y[0]}
\psset{xunit=1.5, yunit=8, showpoints=true}
\begin{pspicture}[showgrid=true](0,0)(10,1.2)
  \psplot[linewidth=6\pslinewidth, linecolor=green, showpoints=false]{0}{10}{Euler x neg exp}
  \psplotDiffEqn[linecolor=magenta, method=varrkiv, varsteptol=.1, plotpoints=2]{0}{10}{1}{\Funct}
  \rput(0,.0){\psplotDiffEqn[linecolor=blue, method=varrkiv, varsteptol=.01, plotpoints=2]{0}{10}{1}{\Funct}}
  \rput(0,.1){\psplotDiffEqn[linecolor=Orange, method=varrkiv, varsteptol=.001, plotpoints=2]{0}{10}{1}{\Funct}}
  \rput(0,.2){\psplotDiffEqn[linecolor=red, method=varrkiv, varsteptol=.0001, plotpoints=2]{0}{10}{1}{\Funct}}
  \psset{linewidth=4\pslinewidth,showpoints=false}
  \rput*(3.3,.9){\psline[linecolor=magenta](-.75cm,0)}
  \rput*[l](3.3,.9){\small RK ordre 4 : $\varepsilon<10^{-1}$}
  \rput*(3.3,.8){\psline[linecolor=blue](-.75cm,0)}
  \rput*[l](3.3,.8){\small RK ordre 4 : $\varepsilon<10^{-2}$}
  \rput*(3.3,.7){\psline[linecolor=Orange](-.75cm,0)}
  \rput*[l](3.3,.7){\small RK ordre 4 : $\varepsilon<10^{-3}$}
  \rput*(3.3,.6){\psline[linecolor=red](-.75cm,0)}
  \rput*[l](3.3,.6){\small RK ordre 4 : $\varepsilon<10^{-4}$}
  \rput*(3.3,.5){\psline[linecolor=green](-.75cm,0)}
  \rput*[l](3.3,.5){\small solution exacte}
\end{pspicture}
\end{lstlisting}



\begin{center}
\bgroup
\def\Funct{exch neg}
\psset{xunit=1.5, yunit=5, method=varrkiv, showpoints=true}%%
\def\quatrepi{12.5663706144}
\begin{pspicture}(0,-1)(10,1.3)
  \psaxes{->}(0,0)(0,-1)(10,1.3)
  \psplot[linewidth=4\pslinewidth, linecolor=green, algebraic]{0}{10}{cos(x)}
  \rput(0,.0){\psplotDiffEqn[linecolor=magenta, plotpoints=7, varsteptol=.1]{0}{10}{1 0}{\Funct}}
  \rput(0,.0){\psplotDiffEqn[linecolor=blue, plotpoints=201, varsteptol=.01]{0}{10}{1 0}{\Funct}}
  \rput(0,.1){\psplotDiffEqn[linewidth=2\pslinewidth, linecolor=red, varsteptol=.001]{0}{10}{1 0}{\Funct}}
  \rput(0,.2){\psplotDiffEqn[linecolor=black, varsteptol=.0001]{0}{10}{1 0}{\Funct}}
  \rput(0,.3){\psplotDiffEqn[linecolor=Orange, varsteptol=.00001]{0}{10}{1 0}{\Funct}}
  \psset{linewidth=4\pslinewidth,showpoints=false}
  \rput*(2.3,.9){\psline[linecolor=magenta](-.75cm,0)}
  \rput*[l](2.3,.9){\small $\varepsilon<10^{-1}$}
  \rput*(2.3,.8){\psline[linecolor=blue](-.75cm,0)}
  \rput*[l](2.3,.8){\small $\varepsilon<10^{-2}$}
  \rput*(2.3,.7){\psline[linecolor=red](-.75cm,0)}
  \rput*[l](2.3,.7){\small $\varepsilon<10^{-3}$}
  \rput*(2.3,.6){\psline[linecolor=black](-.75cm,0)}
  \rput*[l](2.3,.6){\small $\varepsilon<10^{-4}$}
  \rput*(2.3,.5){\psline[linecolor=Orange](-.75cm,0)}
  \rput*[l](2.3,.5){\small $\varepsilon<10^{-5}$}
  \rput*(2.3,.4){\psline[linecolor=green](-.75cm,0)}
  \rput*[l](2.3,.4){\small solution exacte}
\end{pspicture}
{\captionof{figure}{Equation $y''=-y$}\label{fig:trigfunc}}
\egroup
\end{center}

\begin{lstlisting}[wide=true]
\def\Funct{exch neg}
\psset{xunit=1.5, yunit=5, method=varrkiv, showpoints=true}%%
\def\quatrepi{12.5663706144}
\begin{pspicture}(0,-1)(10,1.3)
  \psaxes{->}(0,0)(0,-1)(10,1.3)
  \psplot[linewidth=4\pslinewidth, linecolor=green, algebraic]{0}{10}{cos(x)}
  \rput(0,.0){\psplotDiffEqn[linecolor=magenta, plotpoints=7, varsteptol=.1]{0}{10}{1 0}{\Funct}}
  \rput(0,.0){\psplotDiffEqn[linecolor=blue, plotpoints=201, varsteptol=.01]{0}{10}{1 0}{\Funct}}
  \rput(0,.1){\psplotDiffEqn[linewidth=2\pslinewidth, linecolor=red, varsteptol=.001]{0}{10}{1 0}{\Funct}}
  \rput(0,.2){\psplotDiffEqn[linecolor=black, varsteptol=.0001]{0}{10}{1 0}{\Funct}}
  \rput(0,.3){\psplotDiffEqn[linecolor=Orange, varsteptol=.00001]{0}{10}{1 0}{\Funct}}
  \psset{linewidth=4\pslinewidth,showpoints=false}
  \rput*(2.3,.9){\psline[linecolor=magenta](-.75cm,0)}
  \rput*[l](2.3,.9){\small $\varepsilon<10^{-1}$}
  \rput*(2.3,.8){\psline[linecolor=blue](-.75cm,0)}
  \rput*[l](2.3,.8){\small $\varepsilon<10^{-2}$}
  \rput*(2.3,.7){\psline[linecolor=red](-.75cm,0)}
  \rput*[l](2.3,.7){\small $\varepsilon<10^{-3}$}
  \rput*(2.3,.6){\psline[linecolor=black](-.75cm,0)}
  \rput*[l](2.3,.6){\small $\varepsilon<10^{-4}$}
  \rput*(2.3,.5){\psline[linecolor=Orange](-.75cm,0)}
  \rput*[l](2.3,.5){\small $\varepsilon<10^{-5}$}
  \rput*(2.3,.4){\psline[linecolor=green](-.75cm,0)}
  \rput*[l](2.3,.4){\small solution exacte}
\end{pspicture}
\end{lstlisting}




\begin{center}
\bgroup
\def\Funct{exch}
\psset{xunit=4, yunit=1, method=varrkiv, showpoints=true}%%
\def\quatrepi{12.5663706144}
\begin{pspicture}(0,-0.5)(3,11)
  \psaxes{->}(0,0)(3,11)
  \psplot[linewidth=4\pslinewidth, linecolor=green, algebraic]{0}{3}{ch(x)}
  \rput(0,.0){\psplotDiffEqn[linecolor=magenta, varsteptol=.1]{0}{3}{1 0}{\Funct}}
  \rput(0,.3){\psplotDiffEqn[linecolor=blue, varsteptol=.01]{0}{3}{1 0}{\Funct}}
  \rput(0,.6){\psplotDiffEqn[linecolor=red, varsteptol=.001]{0}{3}{1 0}{\Funct}}
  \rput(0,.9){\psplotDiffEqn[linecolor=black, varsteptol=.0001]{0}{3}{1 0}{\Funct}}
  \rput(0,1.2){\psplotDiffEqn[linecolor=Orange, varsteptol=.00001]{0}{3}{1 0}{\Funct}}
  \psset{linewidth=4\pslinewidth,showpoints=false}
  \rput*(2.3,.9){\psline[linecolor=magenta](-.75cm,0)}
  \rput*[l](2.3,.9){\small $\varepsilon<10^{-1}$}
  \rput*(2.3,.8){\psline[linecolor=blue](-.75cm,0)}
  \rput*[l](2.3,.8){\small $\varepsilon<10^{-2}$}
  \rput*(2.3,.7){\psline[linecolor=red](-.75cm,0)}
  \rput*[l](2.3,.7){\small $\varepsilon<10^{-3}$}
  \rput*(2.3,.6){\psline[linecolor=black](-.75cm,0)}
  \rput*[l](2.3,.6){\small $\varepsilon<10^{-4}$}
  \rput*(2.3,.5){\psline[linecolor=Orange](-.75cm,0)}
  \rput*[l](2.3,.5){\small $\varepsilon<10^{-5}$}
  \rput*(2.3,.4){\psline[linecolor=green](-.75cm,0)}
  \rput*[l](2.3,.4){\small solution exacte}
\end{pspicture}
\captionof{figure}{Equation $y''=y$}
\egroup
\end{center}

\begin{lstlisting}[wide=true]
\def\Funct{exch}
\psset{xunit=4, yunit=1, method=varrkiv, showpoints=true}%%
\def\quatrepi{12.5663706144}
\begin{pspicture}(0,-0.5)(3,11)
  \psaxes{->}(0,0)(3,11)
  \psplot[linewidth=4\pslinewidth, linecolor=green, algebraic]{0}{3}{ch(x)}
  \rput(0,.0){\psplotDiffEqn[linecolor=magenta, varsteptol=.1]{0}{3}{1 0}{\Funct}}
  \rput(0,.3){\psplotDiffEqn[linecolor=blue, varsteptol=.01]{0}{3}{1 0}{\Funct}}
  \rput(0,.6){\psplotDiffEqn[linecolor=red, varsteptol=.001]{0}{3}{1 0}{\Funct}}
  \rput(0,.9){\psplotDiffEqn[linecolor=black, varsteptol=.0001]{0}{3}{1 0}{\Funct}}
  \rput(0,1.2){\psplotDiffEqn[linecolor=Orange, varsteptol=.00001]{0}{3}{1 0}{\Funct}}
  \psset{linewidth=4\pslinewidth,showpoints=false}
  \rput*(2.3,.9){\psline[linecolor=magenta](-.75cm,0)}
  \rput*[l](2.3,.9){\small $\varepsilon<10^{-1}$}
  \rput*(2.3,.8){\psline[linecolor=blue](-.75cm,0)}
  \rput*[l](2.3,.8){\small $\varepsilon<10^{-2}$}
  \rput*(2.3,.7){\psline[linecolor=red](-.75cm,0)}
  \rput*[l](2.3,.7){\small $\varepsilon<10^{-3}$}
  \rput*(2.3,.6){\psline[linecolor=black](-.75cm,0)}
  \rput*[l](2.3,.6){\small $\varepsilon<10^{-4}$}
  \rput*(2.3,.5){\psline[linecolor=Orange](-.75cm,0)}
  \rput*[l](2.3,.5){\small $\varepsilon<10^{-5}$}
  \rput*(2.3,.4){\psline[linecolor=green](-.75cm,0)}
  \rput*[l](2.3,.4){\small solution exacte}
\end{pspicture}
\end{lstlisting}




\clearpage
\subsection{Equation of second order}

Here is the traditional simulation of two stars attracting each
other according to the classical gravitation law in
$\displaystyle\frac{1}{r^2}$. In 2-Dimensions, the system to be
solved is composed of four second order differential equations. In
order to be described, each of them gives two first order
equations, then we obtain a 8 sized vectorial equation. In the
following example the masses of the stars are 1 and 20.

\[
\left\{
\begin{array}[m]{l}
  x''_1=\displaystyle\frac{M_2}{r^2}\cos(\theta)\\
  y''_1=\displaystyle\frac{M_2}{r^2}\sin(\theta)\\
  x''_2=\displaystyle\frac{M_1}{r^2}\cos(\theta)\\
  y''_2=\displaystyle\frac{M_1}{r^2}\sin(\theta)\\
\end{array}
\right.
\mbox{ avec }
\left\{
\begin{array}[m]{l}
  r^2=(x_1-x_2)^2+(y_1-y_2)^2\\
  \cos(\theta)=\displaystyle\frac{(x_1-x_2)}{r}\\
  \sin(\theta)=\displaystyle\frac{(y_1-y_2)}{r}\\
\end{array}
\right.
\mbox{%
\begin{pspicture}[shift=-2](5,4)\psset{arrowscale=2}
  \psframe[linewidth=.75\pslinewidth](5,4)
  \pstGeonode[PosAngle={-90,90}](1,1){M_1}(4,3){M_2}
  \pstHomO[HomCoef=.33, PointSymbol=none]{M_1}{M_2}[F_1]
  \psline[arrows=->](M_1)(F_1)
  \pstHomO[HomCoef=.33, PointSymbol=none]{M_2}{M_1}[F_2]
  \psline[arrows=->, arrowscale=2](M_2)(F_2)
  \pstGeonode[PointSymbol=none, PointName=none](M_2|M_1){A}
  \psline[linewidth=.5\pslinewidth](M_1)(A)
  \pstMarkAngle{A}{M_1}{M_2}{$\theta$}
  \ncline[linewidth=.5\pslinewidth, offset=.5, arrows=<->]{M_1}{M_2}
  \ncput*{$r$}
\end{pspicture}}
\]

\begin{table}[!htbp]
  \centering\small
    \begin{tabular}{|l@{}>{\ttfamily}l@{}>{ \ttfamily \%\% }l|}
      \hline
      && x1 y1 x'1 y'1 x2 y2 x'2 y'2\\
      &/yp2 exch def /xp2 exch def /ay2 exch def /ax2 exch def&mise en variables\\
      &/yp1 exch def /xp1 exch def /ay1 exch def /ax1 exch def&mise en variables\\
      &/ro2 ax2 ax1 sub dup mul ay2 ay1 sub dup mul add def&calcul de r*r\\
      &xp1 yp1&\\
      &ax2 ax1 sub ro2 sqrt div ro2 div&calcul de x''1\\
      &ay2 ay1 sub ro2 sqrt div ro2 div&calcul de y''1\\
      &xp2 yp2&\\
      &3 index -20 mul&calcul de x''2=-20x''1\\
      &3 index -20 mul&calcul de y''2=-20y''1\\
      \hline
    \end{tabular}
    \caption{\PS source code for the gravitational interaction}\label{intgravcode}
\end{table}

\begin{table}[!htbp]
  \centering
    \small\newcommand{\POW}{\symbol{'136}}
    \begin{tabular}{|l@{}>{\ttfamily}l@{}>{ \ttfamily \%\% }l|}
      \hline
      &y[2]|&y'[0]\\
      &y[3]|&y'[1]\\
      &(y[4]-y[0])/((y[4]-y[0])\POW 2+(y[5]-y[1])\POW 2)\POW 1.5|&y'[2]=y''[0]\\
      &(y[5]-y[1])/((y[4]-y[0])\POW 2+(y[5]-y[1])\POW 2)\POW 1.5|&y'[3]=y''[1]\\
      &y[6]|&y'[4]\\
      &y[7]|&y'[5]\\
      &20*(y[0]-y[4])/((y[4]-y[0])\POW 2+(y[5]-y[1])\POW 2)\POW 1.5|&y'[6]=y''[4]\\
      &20*(y[1]-y[5])/((y[4]-y[0])\POW 2+(y[5]-y[1])\POW 2)\POW 1.5&y'[7]=y''[5]\\
      \hline
    \end{tabular}
    \caption{Algebraic description for the gravitational interaction}\label{intgravalgcode}
\end{table}

\newcommand\Grav{%
  /yp2 exch def /xp2 exch def /ay2 exch def /ax2 exch def
  /yp1 exch def /xp1 exch def /ay1 exch def /ax1 exch def
  /ro2 ax2 ax1 sub dup mul ay2 ay1 sub dup mul add def
  xp1 yp1
  ax2 ax1 sub ro2 sqrt div ro2 div
  ay2 ay1 sub ro2 sqrt div ro2 div
  xp2 yp2
  3 index -20 mul
  3 index -20 mul}
\newcommand\GravAlg{%
  y[2]|y[3]|%
  (y[4]-y[0])/((y[4]-y[0])^2+(y[5]-y[1])^2)^1.5|%
  (y[5]-y[1])/((y[4]-y[0])^2+(y[5]-y[1])^2)^1.5|%
  y[6]|y[7]|%
  20*(y[0]-y[4])/((y[4]-y[0])^2+(y[5]-y[1])^2)^1.5|%
  20*(y[1]-y[5])/((y[4]-y[0])^2+(y[5]-y[1])^2)^1.5}
%%  0  1   2   3  4  5   6   7
%% x1 y1 x'1 y'1 x2 y2 x'2 y'2


\begin{LTXexample}[width=5cm,wide]
\def\InitCond{ 1  1  .1  0 -1 -1  -2   0}
\begin{pspicture}[shift=-2,showgrid=true](-3,-1.75)(2,1.5)
  \psplotDiffEqn[whichabs=0, whichord=1, linecolor=blue, method=rk4, plotpoints=100]{0}{3.95}{\InitCond}{\Grav}
  \psset{showpoints=true,whichabs=4, whichord=5}
  \psplotDiffEqn[linecolor=black, method=varrkiv, varsteptol=.0001, plotpoints=200]{0}{3.9}{\InitCond}{\Grav}
\end{pspicture}
\end{LTXexample}
\vspace{-2ex}
{\captionof{figure}{Gravitational interaction: fixed landmark, trajectory of the stars}\label{fig:InterGravRepFix}}



\bigskip
\begin{LTXexample}[width=5cm,wide]
\def\InitCond{ 1  1  .1  0 -1 -1  -2   0}
\begin{pspicture}[shift=-1.5,showgrid=true](-4,-1.75)(1,1)
  \psplotDiffEqn[linecolor=red, plotpoints=200,method=varrkiv, varsteptol=.0001, showpoints=true,
      plotfuncx=y dup 4 get exch 0 get sub,
      plotfuncy=dup 5 get exch 1 get sub ]{0}{3.9}{\InitCond}{\Grav}
\end{pspicture}
\end{LTXexample}
\vspace{-2ex}
{\captionof{figure}{Gravitational interaction : landmark defined by one star}\label{fig:IGnewrep}}


\begin{center}
\bgroup
\def\InitCond{ 1  1  .1   0 -1 -1  -2   0}
\psset{xunit=2}
\begin{pspicture}[showgrid=true](0,0)(8,9)
  \psset{showpoints=true}
  \psplotDiffEqn[linecolor=red, method=varrkiv, plotpoints=2, varsteptol=.0001,
      plotfuncy=dup 6 get dup mul exch 7 get dup mul add sqrt]{0}{8}{\InitCond}{\Grav}
  \psplotDiffEqn[linecolor=blue, method=varrkiv, plotpoints=2, varsteptol=.0001,
      plotfuncy=dup 2 get dup mul exch 3 get dup mul add sqrt]{0}{8}{\InitCond}{\Grav}
\end{pspicture}
\captionof{figure}{Gravitational interaction : speeds of the
stars} \egroup
\end{center}

\begin{lstlisting}
\psset{xunit=2}
\begin{pspicture}[showgrid=true](0,0)(8,9)
  \psset{showpoints=true}
  \psplotDiffEqn[linecolor=red, method=varrkiv, plotpoints=2, varsteptol=.0001,
      plotfuncy=dup 6 get dup mul exch 7 get dup mul add sqrt]{0}{8}{\InitCond}{\Grav}
  \psplotDiffEqn[linecolor=blue, method=varrkiv, plotpoints=2, varsteptol=.0001,
      plotfuncy=dup 2 get dup mul exch 3 get dup mul add sqrt]{0}{8}{\InitCond}{\Grav}
\end{pspicture}
\end{lstlisting}

%--------------------------------------------------------------------------------------
\clearpage
\subsubsection{Simple equation of first order $y'=y$}
%--------------------------------------------------------------------------------------

For the initial value $y(0)=1$ we have the solution $y(x)=e^x$. $y$ is always
on the stack, so we have to do nothing. Using the \Lkeyword{algebraic} option, we write it
as \verb$y[0]$. The following example shows different solutions depending to the number of plotpoints
with $y_0=1$:


\begin{center}
\bgroup
\psset{xunit=4, yunit=.4}
\begin{pspicture}(3,19)\psgrid[subgriddiv=1]
  \psplot[linewidth=6\pslinewidth, linecolor=green]{0}{3}{Euler x exp}
  \psplotDiffEqn[linecolor=magenta,plotpoints=16,algebraic]{0}{3}{1}{y[0]}
  \psplotDiffEqn[linecolor=blue,plotpoints=151]{0}{3}{1}{}
  \psplotDiffEqn[linecolor=red,method=rk4,plotpoints=15]{0}{3}{1}{}
  \psplotDiffEqn[linecolor=Orange,method=rk4,plotpoints=4]{0}{3}{1}{}
  \psset{linewidth=4\pslinewidth}
  \rput*(0.35,19){\psline[linecolor=magenta](-.75cm,0)}
  \rput*[l](0.35,19){\small Euler order 1 $h=0{,}2$}
  \rput*(0.35,17){\psline[linecolor=blue](-.75cm,0)}
  \rput*[l](0.35,17){\small Euler order 1 $h=0{,}02$}
  \rput*(0.35,15){\psline[linecolor=Orange](-.75cm,0)}
  \rput*[l](0.35,15){\small RK ordre 4 $h=1$}
  \rput*(0.35,13){\psline[linecolor=red](-.75cm,0)}
  \rput*[l](0.35,13){\small RK ordre 4 $h=0{,}2$}
  \rput*(0.35,11){\psline[linecolor=green](-.75cm,0)}
  \rput*[l](0.35,11){\small solution exacte}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{xunit=4, yunit=.4}
\begin{pspicture}(3,19)\psgrid[subgriddiv=1]
  \psplot[linewidth=6\pslinewidth, linecolor=green]{0}{3}{Euler x exp}
  \psplotDiffEqn[linecolor=magenta,plotpoints=16,algebraic]{0}{3}{1}{y[0]}
  \psplotDiffEqn[linecolor=blue,plotpoints=151]{0}{3}{1}{}
  \psplotDiffEqn[linecolor=red,method=rk4,plotpoints=15]{0}{3}{1}{}
  \psplotDiffEqn[linecolor=Orange,method=rk4,plotpoints=4]{0}{3}{1}{}
  \psset{linewidth=4\pslinewidth}
  \rput*(0.35,19){\psline[linecolor=magenta](-.75cm,0)}
  \rput*[l](0.35,19){\small Euler order 1 $h=0{,}2$}
  \rput*(0.35,17){\psline[linecolor=blue](-.75cm,0)}
  \rput*[l](0.35,17){\small Euler order 1 $h=0{,}02$}
  \rput*(0.35,15){\psline[linecolor=Orange](-.75cm,0)}
  \rput*[l](0.35,15){\small RK ordre 4 $h=1$}
  \rput*(0.35,13){\psline[linecolor=red](-.75cm,0)}
  \rput*[l](0.35,13){\small RK ordre 4 $h=0{,}2$}
  \rput*(0.35,11){\psline[linecolor=green](-.75cm,0)}
  \rput*[l](0.35,11){\small solution exacte}
\end{pspicture}
\end{lstlisting}

%--------------------------------------------------------------------------------------
\clearpage
\subsubsection{$y'=\displaystyle\frac{2-ty}{4-t^2}$}% $
%--------------------------------------------------------------------------------------

For the initial value $y(0)=1$ the exact solution is
$y(x)=\displaystyle\frac{t+\sqrt{4-t^2}}{2}$. The function $f$
described in PostScript code is like (y is still on the stack):
\begin{lstlisting}[style=syntax]
x              %% y x
mul            %% x*y
2 exch sub     %% 2-x*y
4 x dup mul    %% 2-x*y 4 x^2
sub            %% 2-x*y 4-x^2
div            %% (2-x*y)/(4-x^2)
\end{lstlisting}
\noindent
The following example uses $y_0=1$.

\begin{lstlisting}[style=syntax]
\newcommand{\InitCond}{1}
\newcommand{\Func}{x mul 2 exch sub 4 x dup mul sub div}
\newcommand{\FuncAlg}{(2-x*y[0])/(4-x^2)}
\end{lstlisting}

\begin{center}
\bgroup
\psset{xunit=6.4, yunit=9.6, showpoints=false}
\begin{pspicture}(0,1)(2,1.5)  \psgrid[griddots=10](0,1)(2,1.5)
  { \psset{linewidth=4\pslinewidth,linecolor=lightgray}
  \psplot{0}{1.8}{x dup dup mul 4 exch sub sqrt add 2 div}
  \psplot{1.8}{2}{x dup dup mul 4 exch sub sqrt add 2 div} }
  \def\InitCond{1}
  \def\Func{x mul 2 exch sub 4 x dup mul sub div}
  \psplotDiffEqn[linecolor=magenta, plotpoints=20]{0}{1.9}{\InitCond}{\Func}
  \psplotDiffEqn[linecolor=blue, plotpoints=191]{0}{1.9}{\InitCond}{\Func}
  \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11,%
     algebraic]{0}{1.9}{\InitCond}{(2-x*y[0])/(4-x^2)}
  \psplotDiffEqn[linecolor=Orange, method=rk4, plotpoints=21,%
     algebraic]{0}{1.9}{\InitCond}{(2-x*y[0])/(4-x^2)}
  \psset{linewidth=4\pslinewidth}\small
  \rput*(0,1.4){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](0,1.4){Euler order 1 $h=0{,}1$}
  \rput*(0,1.35){\psline[linecolor=blue](-.75cm,0)}\rput*[l](0,1.35){Euler order 1 $h=0{,}01$}
  \rput*(0,1.3){\psline[linecolor=Orange](-.75cm,0)}\rput*[l](0,1.3){RK order 4 $h=0{,}19$}
  \rput*(0,1.25){\psline[linecolor=red](-.75cm,0)}\rput*[l](0,1.25){RK order 4 $h=0{,}095$}
  \rput*(0,1.2){\psline[linecolor=lightgray](-.75cm,0)}\rput*[l](0,1.2){exactly}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}[xrightmargin=-1cm,xleftmargin=-1cm]
\psset{xunit=6.4, yunit=9.6, showpoints=false}
\begin{pspicture}(0,1)(2,1.7)  \psgrid[subgriddiv=5]
  { \psset{linewidth=4\pslinewidth,linecolor=lightgray}
  \psplot{0}{1.8}{x dup dup mul 4 exch sub sqrt add 2 div}
  \psplot{1.8}{2}{x dup dup mul 4 exch sub sqrt add 2 div} }
  \def\InitCond{1}
  \def\Func{x mul 2 exch sub 4 x dup mul sub div}
  \psplotDiffEqn[linecolor=magenta, plotpoints=20]{0}{1.9}{\InitCond}{\Func}
  \psplotDiffEqn[linecolor=blue, plotpoints=191]{0}{1.9}{\InitCond}{\Func}
  \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11,%
     algebraic]{0}{1.9}{\InitCond}{(2-x*y[0])/(4-x^2)}
  \psplotDiffEqn[linecolor=Orange, method=rk4, plotpoints=21,%
     algebraic]{0}{1.9}{\InitCond}{(2-x*y[0])/(4-x^2)}
  \psset{linewidth=4\pslinewidth}
  \rput*(0.3,1.6){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](0.3,1.6){\small Euler order 1 $h=0{,}1$}
  \rput*(0.3,1.55){\psline[linecolor=blue](-.75cm,0)}\rput*[l](0.3,1.55){\small Euler order 1 $h=0{,}01$}
  \rput*(0.3,1.5){\psline[linecolor=Orange](-.75cm,0)}\rput*[l](0.3,1.5){\small RK order 4 $h=0{,}19$}
  \rput*(0.3,1.45){\psline[linecolor=red](-.75cm,0)}\rput*[l](0.3,1.45){\small RK order 4 $h=0{,}095$}
  \rput*(0.3,1.4){\psline[linecolor=lightgray](-.75cm,0)}\rput*[l](0.3,1.4){\small exactly}
\end{pspicture}
\end{lstlisting}


%--------------------------------------------------------------------------------------
\clearpage
\subsubsection{$y'=-2xy$}
%--------------------------------------------------------------------------------------

For $y(-1)=\frac{1}{e}$ we get $y(x)=e^{-x^2}$.

\begin{center}
\bgroup
\psset{unit=4}
\begin{pspicture}(-1,0)(3,1.1)\psgrid
  \psplot[linewidth=4\pslinewidth,linecolor=gray]{-1}{3}{Euler x dup mul neg exp}
  \psset{plotpoints=9}
  \psplotDiffEqn[linecolor=cyan]{-1}{3}{1 Euler div}{x -2 mul mul}
  \psplotDiffEqn[linecolor=yellow, method=rk4]{-1}{3}{1 Euler div}{x -2 mul mul}
  \psset{plotpoints=21}
  \psplotDiffEqn[linecolor=blue]{-1}{3}{1 Euler div}{x -2 mul mul}
  \psplotDiffEqn[linecolor=Orange, method=rk4]{-1}{3}{1 Euler div}{x -2 mul mul}
  \psset{linewidth=2\pslinewidth}
  \rput*(2,1){\psline[linecolor=Orange](-0.25,0)}
  \rput*[l](2,1){RK}
  \rput*(2,.9){\psline[linecolor=blue](-0.25,0)}
  \rput*[l](2,.9){\textsc{Euler}-1}
  \rput*(2,.8){\psline[linecolor=gray](-0.25,0)}
  \rput*[l](2,.8){solution}
\end{pspicture}
\egroup
\end{center}


\begin{lstlisting}
\psset{unit=4}
\begin{pspicture}(-1,0)(3,1.1)\psgrid
  \psplot[linewidth=4\pslinewidth,linecolor=gray]{-1}{3}{Euler x dup mul neg exp}
  \psset{plotpoints=9}
  \psplotDiffEqn[linecolor=cyan]{-1}{3}{1 Euler div}{x -2 mul mul}
  \psplotDiffEqn[linecolor=yellow, method=rk4]{-1}{3}{1 Euler div}{x -2 mul mul}
  \psset{plotpoints=21}
  \psplotDiffEqn[linecolor=blue]{-1}{3}{1 Euler div}{x -2 mul mul}
  \psplotDiffEqn[linecolor=Orange, method=rk4]{-1}{3}{1 Euler div}{x -2 mul mul}
  \psset{linewidth=2\pslinewidth}
  \rput*(2,1){\psline[linecolor=Orange](-0.25,0)}
  \rput*[l](2,1){RK}
  \rput*(2,.9){\psline[linecolor=blue](-0.25,0)}
  \rput*[l](2,.9){\textsc{Euler}-1}
  \rput*(2,.8){\psline[linecolor=gray](-0.25,0)}
  \rput*[l](2,.8){solution}
\end{pspicture}
\end{lstlisting}


%--------------------------------------------------------------------------------------
\clearpage
\subsubsection{Spiral of Cornu}
%--------------------------------------------------------------------------------------

The integrals of \Index{Fresnel}:
\begin{align} x & =\int^t_0\cos\frac{\pi t^2}{2}\mathrm{d}t \\
 y & =\int^t_0\sin\frac{\pi t^2}{2}\mathrm{d}t \\
\intertext{with}
 \dot{x} &= \cos\frac{\pi t^2}{2} \\
 \dot{y} & =\sin\frac{\pi t^2}{2}
 \end{align}

\begin{lstlisting}
\psset{unit=8}
\begin{pspicture}(1,1)\psgrid[subgriddiv=5]
  \psplotDiffEqn[whichabs=0,whichord=1,linecolor=red,method=rk4,algebraic,%
     plotpoints=500,showpoints=true]{0}{10}{0 0}{cos(Pi*x^2/2)|sin(Pi*x^2/2)}
\end{pspicture}
\end{lstlisting}


\begin{center}
\bgroup
\psset{unit=8}
\begin{pspicture}(1,1)\psgrid[subgriddiv=5]
  \psplotDiffEqn[whichabs=0,whichord=1,linecolor=red,method=rk4,algebraic,%
     plotpoints=500,showpoints=true]{0}{10}{0 0}{cos(Pi*x^2/2)|sin(Pi*x^2/2)}
\end{pspicture}
\egroup
\end{center}



%--------------------------------------------------------------------------------------
\clearpage
\subsubsection{Lotka-Volterra}
%--------------------------------------------------------------------------------------

The Lotka-Volterra model describes interactions between two species in an ecosystem, a 
predator and a prey. This represents our first multi-species model. Since we are considering 
two species, the model will involve two equations, one which describes how the prey 
population changes and the second which describes how the predator population changes.

For concreteness let us assume that the prey in our model are rabbits, and that the 
predators are foxes. If we let $R(t)$ and $F(t)$ represent the number of rabbits and 
foxes, respectively, that are alive at time t, then the Lotka-Volterra model is:
%
\begin{align}
\dot R &= a\cdot R - b\cdot R\cdot F\\
\dot F &= e\cdot b\cdot R\cdot F - c\cdot F
\end{align}
%
where the parameters are defined by:
\begin{description}
\item[a] is the natural growth rate of rabbits in the absence of predation,
\item[c] is the natural death rate of foxes in the absence of food (rabbits),
\item[b] is the death rate per encounter of rabbits due to predation,
\item[e] is the efficiency of turning predated rabbits into foxes.
\end{description}

The Stella model representing the \Index{Lotka-Volterra} model will be slightly more complex than the 
single species models we've dealt with before. The main difference is that our model will have 
two stocks (reservoirs), one for each species. Each species will have its own birth and death 
rates. In addition, the Lotka-Volterra model involves four parameters rather than two. All told, 
the Stella representation of the Lotka-Volterra model will use two stocks, four flows, four 
converters and many connectors.

\bgroup
\begin{center}
\def\InitCond{ 0 10 10}%% xa ya xl
\def\Faiglelapin{\Vaigle*(y[2]-y[0])/sqrt(y[1]^2+(y[2]-y[0])^2)|%
                 -\Vaigle*y[1]/sqrt(y[1]^2+(y[2]-y[0])^2)|%
                 -\Vlapin}
\def\Vlapin{1}  \def\Vaigle{1.6}
\psset{unit=.7,subgriddiv=0,gridcolor=lightgray,method=adams,algebraic,%
   plotpoints=20,showpoints=true}
\begin{pspicture}[showgrid=true](-3,-3)(10,10)
 \psplotDiffEqn[plotfuncy=pop 0,whichabs=2,linecolor=red]{0}{10}{\InitCond}{\Faiglelapin}
 \psplotDiffEqn[whichabs=0,whichord=1,linecolor=black,method=rk4]{0}{10}{\InitCond}{\Faiglelapin}
  \psplotDiffEqn[whichabs=0,whichord=1,linecolor=blue]{0}{10}{\InitCond}{\Faiglelapin}
\end{pspicture}
\end{center}

\begin{lstlisting}[label={fig:aiglelapin},xrightmargin=-1.5cm]
\def\InitCond{ 0 10 10}%% xa ya xl
\def\Faiglelapin{\Vaigle*(y[2]-y[0])/sqrt(y[1]^2+(y[2]-y[0])^2)|%
                 -\Vaigle*y[1]/sqrt(y[1]^2+(y[2]-y[0])^2)|%
                 -\Vlapin}
\def\Vlapin{1}  \def\Vaigle{1.6}
\psset{unit=.7,subgriddiv=0,gridcolor=lightgray,method=adams,algebraic,%
   plotpoints=20,showpoints=true}
\begin{pspicture}[showgrid=true](-3,-3)(10,10)
 \psplotDiffEqn[plotfuncy=pop 0,whichabs=2,linecolor=red]{0}{10}{\InitCond}{\Faiglelapin}
 \psplotDiffEqn[whichabs=0,whichord=1,linecolor=black,method=rk4]{0}{10}{\InitCond}{\Faiglelapin}
  \psplotDiffEqn[whichabs=0,whichord=1,linecolor=blue]{0}{10}{\InitCond}{\Faiglelapin}
\end{pspicture}
\end{lstlisting}


\begin{center}
\def\InitCond{ 0 10 10}%% xa ya xl
\def\Faiglelapin{\Vaigle*(y[2]-y[0])/sqrt(y[1]^2+(y[2]-y[0])^2)|%
                 -\Vaigle*y[1]/sqrt(y[1]^2+(y[2]-y[0])^2)|%
                 -\Vlapin}
\def\Vlapin{1}  \def\Vaigle{1.6}
\psset{unit=.7,subgriddiv=0,gridcolor=lightgray,method=adams,algebraic,%
   plotpoints=20,showpoints=true}
\begin{pspicture}[showgrid=true](0,-0.25)(10,14)
 \psplotDiffEqn[plotfuncy=dup 1 get dup mul exch dup 0 get exch 2 get sub dup
    mul add sqrt,linecolor=red,method=rk4]{0}{10}{\InitCond}{\Faiglelapin}
 \psplotDiffEqn[plotfuncy=dup 1 get dup mul exch dup 0 get exch 2 get sub dup
    mul add sqrt,linecolor=blue]{0}{10}{\InitCond}{\Faiglelapin}
 \psplotDiffEqn[plotfuncy=pop Func aload pop pop dup mul exch dup mul add sqrt,
    linecolor=yellow]{0}{10}{\InitCond}{\Faiglelapin}
\end{pspicture}
\end{center}
\egroup

\begin{lstlisting}[label={fig:aiglelapin2},xrightmargin=-1.5cm]
\def\InitCond{ 0 10 10}%% xa ya xl
\def\Faiglelapin{\Vaigle*(y[2]-y[0])/sqrt(y[1]^2+(y[2]-y[0])^2)|%
                 -\Vaigle*y[1]/sqrt(y[1]^2+(y[2]-y[0])^2)|%
                 -\Vlapin}
\def\Vlapin{1}  \def\Vaigle{1.6}
\psset{unit=.7,subgriddiv=0,gridcolor=lightgray,method=adams,algebraic,%
   plotpoints=20,showpoints=true}
\begin{pspicture}[showgrid=true](10,12)
 \psplotDiffEqn[plotfuncy=dup 1 get dup mul exch dup 0 get exch 2 get sub dup
    mul add sqrt,linecolor=red,method=rk4]{0}{10}{\InitCond}{\Faiglelapin}
 \psplotDiffEqn[plotfuncy=dup 1 get dup mul exch dup 0 get exch 2 get sub dup
    mul add sqrt,linecolor=blue]{0}{10}{\InitCond}{\Faiglelapin}
 \psplotDiffEqn[plotfuncy=pop Func aload pop pop dup mul exch dup mul add sqrt,
    linecolor=yellow]{0}{10}{\InitCond}{\Faiglelapin}
\end{pspicture}
\end{lstlisting}


%--------------------------------------------------------------------------------------
\subsubsection{$y''=y$}
%--------------------------------------------------------------------------------------

Beginning with the initial equation $\displaystyle y(x)=Ae^x+Be^{-x}$ we get the hyperbolic
trigonometrical functions.

\begin{center}
\bgroup
\def\Funct{exch}   \psset{xunit=5cm, yunit=0.75cm}
\begin{pspicture}(0,-0.25)(2,7)\psgrid[subgriddiv=1,griddots=10]
 \psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler x exp}  %%e^x
 \psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{1 1}{\Funct}
 \psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{1 1}{\Funct}
 \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{1 1}{\Funct}
 \psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler dup x exp  %%ch(x)
    exch x neg exp add 2 div}
 \psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{1 0}{\Funct}
 \psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{1 0}{\Funct}
 \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{1 0}{\Funct}
 \psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler dup x exp
     exch x neg exp sub 2 div}  %%sh(x)
 \psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{0 1}{\Funct}
 \psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{0 1}{\Funct}
 \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{0 1}{\Funct}
 \rput*(1.3,.9){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](1.3,.9){\small\textsc{Euler} order 1 $h=1$}
 \rput*(1.3,.8){\psline[linecolor=blue](-.75cm,0)}\rput*[l](1.3,.8){\small\textsc{Euler} order 1 $h=0{,}1$}
 \rput*(1.3,.7){\psline[linecolor=red](-.75cm,0)}\rput*[l](1.3,.7){\small RK order 4 $h=1$}
 \rput*(1.3,.6){\psline[linecolor=green](-.75cm,0)}\rput*[l](1.3,.6){\small exact solution}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}[label={fig:minusexp},xrightmargin=-1.5cm]
\def\Funct{exch}   \psset{xunit=5cm, yunit=0.75cm}
\begin{pspicture}(0,-0.25)(2,7)\psgrid[subgriddiv=1,griddots=10]
 \psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler x exp}  %%e^x
 \psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{1 1}{\Funct}
 \psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{1 1}{\Funct}
 \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{1 1}{\Funct}
 \psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler dup x exp  %%ch(x)
    exch x neg exp add 2 div}
 \psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{1 0}{\Funct}
 \psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{1 0}{\Funct}
 \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{1 0}{\Funct}
 \psplot[linewidth=4\pslinewidth, linecolor=green]{0}{2}{Euler dup x exp
     exch x neg exp sub 2 div}  %%sh(x)
 \psplotDiffEqn[linecolor=magenta, plotpoints=11]{0}{2}{0 1}{\Funct}
 \psplotDiffEqn[linecolor=blue, plotpoints=101]{0}{2}{0 1}{\Funct}
 \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=11]{0}{2}{0 1}{\Funct}
 \rput*(1.3,.9){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](1.3,.9){\small\textsc{Euler} order 1 $h=1$}
 \rput*(1.3,.8){\psline[linecolor=blue](-.75cm,0)}\rput*[l](1.3,.8){\small\textsc{Euler} order 1 $h=0{,}1$}
 \rput*(1.3,.7){\psline[linecolor=red](-.75cm,0)}\rput*[l](1.3,.7){\small RK order 4 $h=1$}
 \rput*(1.3,.6){\psline[linecolor=green](-.75cm,0)}\rput*[l](1.3,.6){\small exact solution}
\end{pspicture}
\end{lstlisting}

%--------------------------------------------------------------------------------------
\clearpage
\subsubsection{$y''=-y$}
%--------------------------------------------------------------------------------------
\begin{center}
\bgroup
\def\Funct{exch neg}
\psset{xunit=1, yunit=4}
\def\quatrepi{12.5663706144}%%4pi=12.5663706144
\begin{pspicture}(0,-1.25)(\quatrepi,1.25)\psgrid[subgriddiv=1,griddots=10]
 \psplot[linewidth=4\pslinewidth,linecolor=green]{0}{\quatrepi}{x RadtoDeg cos}%%cos(x)
 \psplotDiffEqn[linecolor=blue, plotpoints=201]{0}{3.1415926}{1 0}{\Funct}
 \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=31]{0}{\quatrepi}{1 0}{\Funct}
 \psplot[linewidth=4\pslinewidth,linecolor=green]{0}{\quatrepi}{x RadtoDeg sin}  %%sin(x)
 \psplotDiffEqn[linecolor=blue,plotpoints=201]{0}{3.1415926}{0 1}{\Funct}
 \psplotDiffEqn[linecolor=red,method=rk4, plotpoints=31]{0}{\quatrepi}{0 1}{\Funct}
 \rput*(3.3,.9){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](3.3,.9){\small Euler order 1 $h=1$}
 \rput*(3.3,.8){\psline[linecolor=blue](-.75cm,0)}\rput*[l](3.3,.8){\small Euler order 1 $h=0{,}1$}
 \rput*(3.3,.7){\psline[linecolor=red](-.75cm,0)}\rput*[l](3.3,.7){\small RK order 4 $h=1$}
 \rput*(3.3,.6){\psline[linecolor=green](-.75cm,0)}\rput*[l](3.3,.6){\small exact solution}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}[label={fig:minusexp2}]
\def\Funct{exch neg}
\psset{xunit=1, yunit=4}
\def\quatrepi{12.5663706144}%%4pi=12.5663706144
\begin{pspicture}(0,-1.25)(\quatrepi,1.25)\psgrid[subgriddiv=1,griddots=10]
 \psplot[linewidth=4\pslinewidth,linecolor=green]{0}{\quatrepi}{x RadtoDeg cos}%%cos(x)
 \psplotDiffEqn[linecolor=blue, plotpoints=201]{0}{3.1415926}{1 0}{\Funct}
 \psplotDiffEqn[linecolor=red, method=rk4, plotpoints=31]{0}{\quatrepi}{1 0}{\Funct}
 \psplot[linewidth=4\pslinewidth,linecolor=green]{0}{\quatrepi}{x RadtoDeg sin}  %%sin(x)
 \psplotDiffEqn[linecolor=blue,plotpoints=201]{0}{3.1415926}{0 1}{\Funct}
 \psplotDiffEqn[linecolor=red,method=rk4, plotpoints=31]{0}{\quatrepi}{0 1}{\Funct}
 \rput*(3.3,.9){\psline[linecolor=magenta](-.75cm,0)}\rput*[l](3.3,.9){\small Euler order 1 $h=1$}
 \rput*(3.3,.8){\psline[linecolor=blue](-.75cm,0)}\rput*[l](3.3,.8){\small Euler order 1 $h=0{,}1$}
 \rput*(3.3,.7){\psline[linecolor=red](-.75cm,0)}\rput*[l](3.3,.7){\small RK order 4 $h=1$}
 \rput*(3.3,.6){\psline[linecolor=green](-.75cm,0)}\rput*[l](3.3,.6){\small exact solution}
\end{pspicture}
\end{lstlisting}

%--------------------------------------------------------------------------------------
\clearpage
\subsubsection{The mechanical pendulum: $y''=-\frac{g}{l}\sin(y)$}% $
%--------------------------------------------------------------------------------------

For small \Index{oscillation}s $\sin(y)\simeq y$:

\[ y(x)=y_0\cos\left(\sqrt{\frac{g}{l}}x\right) \]

The function $f$ is written in PostScript code:

\begin{lstlisting}[style=syntax]
exch RadtoDeg sin -9.8 mul %% y' -gsin(y)
\end{lstlisting}



\begin{center}
\bgroup
\def\Func{y[1]|-9.8*sin(y[0])}
\psset{yunit=2,xunit=4,algebraic,linewidth=1.5pt}
\begin{pspicture}(0,-2.25)(3,2.25)
  \psaxes{->}(0,0)(0,-2)(3,2)
  \psplot[linewidth=3\pslinewidth, linecolor=Orange]{0}{3}{.1*cos(sqrt(9.8)*x)}
  \psset{method=rk4,plotpoints=50,linecolor=blue}
  \psplotDiffEqn{0}{3}{.1 0}{\Func}
  \psplot[linewidth=3\pslinewidth,linecolor=Orange]{0}{3}{.25*cos(sqrt(9.8)*x)}
  \psplotDiffEqn{0}{3}{.25 0}{\Func}
  \psplotDiffEqn{0}{3}{.5 0}{\Func}
  \psplotDiffEqn{0}{3}{1 0}{\Func}
  \psplotDiffEqn[plotpoints=100]{0}{3}{Pi 2 div 0}{\Func}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}[label=fig:second]
\def\Func{y[1]|-9.8*sin(y[0])}
\psset{yunit=2,xunit=4,algebraic,linewidth=1.5pt}
\begin{pspicture}(0,-2.25)(3,2.25)
  \psaxes{->}(0,0)(0,-2)(3,2)
  \psplot[linewidth=3\pslinewidth, linecolor=Orange]{0}{3}{.1*cos(sqrt(9.8)*x)}
  \psset{method=rk4,plotpoints=50,linecolor=blue}
  \psplotDiffEqn{0}{3}{.1 0}{\Func}
  \psplot[linewidth=3\pslinewidth,linecolor=Orange]{0}{3}{.25*cos(sqrt(9.8)*x)}
  \psplotDiffEqn{0}{3}{.25 0}{\Func}
  \psplotDiffEqn{0}{3}{.5 0}{\Func}
  \psplotDiffEqn{0}{3}{1 0}{\Func}
  \psplotDiffEqn[plotpoints=100]{0}{3}{Pi 2 div 0}{\Func}
\end{pspicture}
\end{lstlisting}

%--------------------------------------------------------------------------------------
\clearpage
\subsubsection{$y''=-\frac{y'}{4}-2y$}% $
%--------------------------------------------------------------------------------------

For $y_0=5$ and $y'_0=0$ the solution is:

\[
5e^{-\frac{x}{8}}\left(\cos\left(\omega x\right)+\frac{\sin(\omega x)}{8\omega}\right)
\mbox{ avec } \omega=\frac{\sqrt{127}}{8}
\]

\begin{center}
\bgroup
\psset{xunit=.6,yunit=0.8,plotpoints=500}
\begin{pspicture}(0,-4.25)(26,5.25)
  \psaxes{->}(0,0)(0,-4)(26,5)
  \psplot[plotpoints=200,linewidth=4\pslinewidth,linecolor=gray]{0}{26}{%
     Euler x -8 div exp x 127 sqrt 8 div mul RadtoDeg dup cos 5 mul exch sin 127 sqrt div 5 mul add mul}
  \psplotDiffEqn[linecolor=red,linewidth=5\pslinewidth]{0}{26}{5 0}
     {dup 3 1 roll -4 div exch 2 mul sub}
  \psplotDiffEqn[linecolor=black,algebraic]{0}{26}{5 0} {y[1]|-y[1]/4-2*y[0]}
  \psset{method=rk4, plotpoints=50}
  \psplotDiffEqn[linecolor=blue,linewidth=5\pslinewidth]{0}{26}{5 0}{%
      dup 3 1 roll -4 div exch 2 mul sub}
  \psplotDiffEqn[linecolor=black,algebraic]{0}{26}{5 0}{y[1]|-y[1]/4-2*y[0]}
\end{pspicture}
\egroup
\end{center}

\begin{lstlisting}
\psset{xunit=.6,yunit=0.8,plotpoints=500}
\begin{pspicture}(0,-4.25)(26,5.25)
  \psaxes{->}(0,0)(0,-4)(26,5)
  \psplot[plotpoints=200,linewidth=4\pslinewidth,linecolor=gray]{0}{26}{%
     Euler x -8 div exp x 127 sqrt 8 div mul RadtoDeg dup cos 5 mul exch sin 127 sqrt div 5 mul add mul}
  \psplotDiffEqn[linecolor=red,linewidth=5\pslinewidth]{0}{26}{5 0}
     {dup 3 1 roll -4 div exch 2 mul sub}
  \psplotDiffEqn[linecolor=black,algebraic]{0}{26}{5 0} {y[1]|-y[1]/4-2*y[0]}
  \psset{method=rk4, plotpoints=50}
  \psplotDiffEqn[linecolor=blue,linewidth=5\pslinewidth]{0}{26}{5 0}{%
      dup 3 1 roll -4 div exch 2 mul sub}
  \psplotDiffEqn[linecolor=black,algebraic]{0}{26}{5 0}{y[1]|-y[1]/4-2*y[0]}
\end{pspicture}
\end{lstlisting}


\clearpage
\subsection{Save final state of a equation}
With the macros \Lcs{BeginSaveFinalState} and \Lcs{EndSaveFinalState} the
end values of a differential equation
can be saved and then used with the optional argument \Lkeyword{GetFinalState}  
as starting values for another equation.

\begin{lstlisting}
\psset{unit=10cm,linewidth=2pt}
\begin{pspicture}(1,1)\psgrid[subgridcolor=black!20,subgriddiv=20]
\BeginSaveFinalState
 \psplotDiffEqn[
   whichabs=0,whichord=1,linecolor=red,method=rk4,
   plotpoints=10,showpoints=true]{0}{1}{0 0}{
   pop pop
   x dup mul 2 div 180 mul cos %% dx/dt
   x dup mul 2 div 180 mul sin %% dy/dt
 }
 \psplotDiffEqn[GetFinalState,
   whichabs=0,whichord=1,linecolor=blue,method=rk4,%FinalState,
   plotpoints=10,showpoints=true]{1}{2}{0 0}{
   pop pop
   x dup mul 2 div 180 mul cos %% dx/dt
   x dup mul 2 div 180 mul sin %% dy/dt
 }
 \psplotDiffEqn[GetFinalState,
   whichabs=0,whichord=1,linecolor=cyan,method=rk4,%FinalState,
   plotpoints=19,showpoints=true]{2}{3}{0 0 }{
   pop pop
   x dup mul 2 div 180 mul cos %% dx/dt
   x dup mul 2 div 180 mul sin %% dy/dt
 }
\EndSaveFinalState
\end{pspicture}
\end{lstlisting}


\bigskip
\begin{center}
\psset{unit=6cm,linewidth=2pt}
\begin{pspicture}(1,1)\psgrid[subgridcolor=black!20,subgriddiv=20]
\BeginSaveFinalState
 \psplotDiffEqn[
   whichabs=0,whichord=1,linecolor=red,method=rk4,
   plotpoints=10,showpoints=true]{0}{1}{0 0}{
   pop pop
   x dup mul 2 div 180 mul cos %% dx/dt
   x dup mul 2 div 180 mul sin %% dy/dt
 }
 \psplotDiffEqn[GetFinalState,
   whichabs=0,whichord=1,linecolor=blue,method=rk4,%FinalState,
   plotpoints=10,showpoints=true]{1}{2}{0 0}{
   pop pop
   x dup mul 2 div 180 mul cos %% dx/dt
   x dup mul 2 div 180 mul sin %% dy/dt
 }
 \psplotDiffEqn[GetFinalState,
   whichabs=0,whichord=1,linecolor=cyan,method=rk4,%FinalState,
   plotpoints=19,showpoints=true]{2}{3}{0 0 }{
   pop pop
   x dup mul 2 div 180 mul cos %% dx/dt
   x dup mul 2 div 180 mul sin %% dy/dt
 }
\EndSaveFinalState
\end{pspicture}
\end{center}

\psset{unit=1cm,linewidth=0.75pt}


%--------------------------------------------------------------------------------------
\clearpage
\section{\nxLcs{psMatrixPlot}}\label{sec:psMatrix}
%--------------------------------------------------------------------------------------

This macro allows you to visualize a matrix. The datafile must be
defined as a PostScript matrix named \Lps{dotmatrix}:
\begin{lstlisting}[style=syntax]
/dotmatrix [ %  <------------ important line
0  1  1  0  0  0  0  1  1  1
0  1  1  0  1  1  1  0  1  0
1  0  1  1  0  0  0  1  1  0
0  0  1  0  0  0  0  0  1  1
1  1  1  1  1  0  1  0  0  1
0  0  1  1  0  1  0  1  1  1
1  0  0  0  1  1  0  0  0  1
0  0  0  1  1  1  0  1  1  0
1  1  0  0  0  0  1  0  0  1
1  0  1  0  0  1  1  1  0  0
] def        %  <------------ important line
\end{lstlisting}

Only the value 0 is important, in which case nothing happens, and
for all other cases a dot is printed. The syntax of the macro is:

\begin{BDef}
\Lcs{psMatrixPlot}\OptArgs\Largb{rows}\Largb{columns}\Largb{data file}
\end{BDef}

The \Index{matrix} is scanned line by line from the the first one to the
last. In general it appears as a bottom-to-top version of the
above listed matrix, the first row $0\,1\,1\,0\,0\,0\,0\,1\,1\,1$
is the first plotted line ($y=1$). With the option
\Lkeyword{ChangeOrder}=\true\ it looks exactly like the above view.

\bgroup
\begin{center}
\psscalebox{0.6}{%
\begin{pspicture}(-0.5,-0.75)(11,11)
  \psaxes{->}(11,11)
  \psMatrixPlot[dotsize=1.1cm,dotstyle=square*,linecolor=magenta]%
    {10}{10}{data/matrix.data}
  \psMatrixPlot[dotsize=.5cm,dotstyle=o,ChangeOrder]{10}{10}{data/matrix.data}
\end{pspicture}}\quad
\psscalebox{0.6}{%
\begin{pspicture}(-0.5,-0.75)(11,11)
  \psaxes[ticksize=-5pt 0]{->}(11,11)
  \psMatrixPlot[dotsize=1.1cm,dotstyle=square*,linecolor=magenta,XYoffset=-0.5]%
    {10}{10}{data/matrix.data}
  \psMatrixPlot[dotsize=.5cm,dotstyle=o,ChangeOrder,XYoffset=-0.5]{10}{10}{data/matrix.data}
\end{pspicture}}
\end{center}

\begin{lstlisting}
\psscalebox{0.6}{%
\begin{pspicture}(-0.5,-0.75)(11,11)
  \psaxes[ticksize=-5pt 0]{->}(11,11)
  \psMatrixPlot[dotsize=1.1cm,dotstyle=square*,linecolor=magenta]%
    {10}{10}{data/matrix.data}
  \psMatrixPlot[dotsize=.5cm,dotstyle=o,ChangeOrder]{10}{10}{data/matrix.data}
\end{pspicture}}\quad
\psscalebox{0.6}{%
\begin{pspicture}(-0.5,-0.75)(11,11)
  \psaxes{->}(11,11)
  \psMatrixPlot[dotsize=1.1cm,dotstyle=square*,linecolor=magenta,XYoffset=-0.5]%
    {10}{10}{data/matrix.data}
  \psMatrixPlot[dotsize=.5cm,dotstyle=o,ChangeOrder,XYoffset=-0.5]{10}{10}{data/matrix.data}
\end{pspicture}}
\end{lstlisting}

\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(-0.5,-0.75)(11,11)
  \psaxes[ticksize=-5pt 0]{->}(11,11)
  \psMatrixPlot[dotscale=3,dotstyle=*,linecolor=blue]{10}{8}{data/matrix.data}
\end{pspicture}
\end{LTXexample}

\clearpage
With the \Lkeyword{colorType}=1 the data is printed as continous color
in the range of the wavelength. The smallest value of the data array
is set to red and the biggest value is set to violett. All other values
are substituted by the corresponding color of the wavlength.
\Lkeyword{colorType}=2 ist the same, but vice versa
with the color, from violet to red. \Lkeyword{colorType}=3 is the grayscale
image and \Lkeyword{colorType}=4 the same invers.

The following examples use a 200$\times$200
matrix data, which is saved as /dotmatrix [...] in the file \LFile{pstricks-add-doc.dat}.

\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(10,10)
  \psMatrixPlot[colorType=1,xStep=0.05,yStep=0.05]{200}{200}{data/dotmatrix.data}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(10,10)
  \psMatrixPlot[colorType=2,xStep=0.05,yStep=0.05]{200}{200}{data/dotmatrix.data}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(10,10)
  \psMatrixPlot[colorType=3,xStep=0.05,yStep=0.05]{200}{200}{data/dotmatrix.data}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(10,10)
  \psMatrixPlot[colorType=4,xStep=0.05,yStep=0.05]{200}{200}{data/dotmatrix.data}
\end{pspicture}
\end{LTXexample}
\egroup

\clearpage
With the \Lkeyword{colorType}=5 the color setting can be user defined by the
optional argument \Lkeyword{colorTypeDef}. On the stack is the current value
which can be used for the setting but must be left on the stack when everything
is finished. The following example prints the 0 as color white, the value 1 as
black and all other values depending to the corresponding gray value.


\begin{center}
\psscalebox{0.7}{%
\begin{pspicture}(-0.5,-0.75)(11,11)
\psaxes[ticksize=-5pt 0]{->}(11,11)
\psMatrixPlot[
  colorType=5,
  colorTypeDef={
    dup /value exch def % save value and leave one on the stack
    value Min sub dMaxMin div neg 1 add 300 mul 400 add \pswavelengthToGRAY 
    value 0 eq \pslbrace 1 \psrbrace if % 
    value 1 eq \pslbrace 0 \psrbrace if  
    setgray 
  },
  dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{data/matrix1.data}
\end{pspicture}}
\end{center}


\begin{lstlisting}
\begin{filecontents}{data/matrix1.data}
/dotmatrix [ % <------------ important line
3 0 0 0 0 0 0 0 1 2
0 0 0 0 0 0 0 1 2 1
8 0 0 0 0 0 1 2 1 0
0 0 0 0 0 1 2 1 0 0
0 0 0 0 1 2 1 0 0 0
9 0 0 1 2 1 3 0 0 0
0 0 1 2 1 4 0 0 0 0
0 1 2 1 5 0 0 0 0 0
1 2 1 6 0 0 0 0 0 0
2 1 7 0 0 0 0 0 0 3
] def % <------------ important line
\end{filecontents}
\psscalebox{0.7}{%
\begin{pspicture}(-0.5,-0.75)(11,11)
\psaxes[ticksize=-5pt 0]{->}(11,11)
\psMatrixPlot[
  colorType=5,
  colorTypeDef={
    dup /value exch def % save value and leave one on the stack
    value Min sub dMaxMin div neg 1 add 300 mul 400 add \pswavelengthToGRAY 
    value 0 eq \pslbrace 1 \psrbrace if % 
    value 1 eq \pslbrace 0 \psrbrace if  
    setgray 
  },
  dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{data/matrix1.data}
\end{pspicture}}
\end{lstlisting}


\Lps{if} statements in the color definition must be enclosed with \Lcs{pslbrace} and \Lcs{psrbrace}
when they are parentheses used in PostScript. In the above example the color definition should be
modified when the matrix is a real big one, in such a case a nested \Lps{ifelse} makes more sense:

\begin{lstlisting}
  colorTypeDef={
    dup /value exch def 
    value 0 eq 
      \pslbrace 1 setgray \psrbrace
      \pslbrace value 1 eq 
        \pslbrace 0 setgray \psrbrace
        \pslbrace Min sub dMaxMin div neg 1 add 300 mul 400 add
          \pswavelengthToGRAY setgray \psrbrace ifelse
      \psrbrace ifelse 
  },
\end{lstlisting}

Replace the \Lcs{pslbrace} and \Lcs{psrbrace} with \{ and \} if it maybe confusing to read:

\begin{lstlisting}
    dup /value exch def 
    value 0 eq 
      { 1 setgray }
      { value 1 eq 
        { 0 setgray }
        { Min sub dMaxMin div neg 1 add 300 mul 400 add
          \pswavelengthToGRAY setgray } ifelse
      } ifelse 
\end{lstlisting}

Another possibility is to define the color procedure onside the data file, where
it \emph{must} be named \Lps{colorTypeDef}. If such a definition exists, the one from
the optional argument \Lkeyword{colorTypeDef} will be ignored. There can be no
\TeX-specific code inside this definition because it is read on PostScript level,
the reason why \Lcs{pswavelengthToGRAY} cannot be used.

\begin{center}
\psscalebox{0.7}{%
\begin{pspicture}(-0.5,-0.75)(11,11)
\psaxes[ticksize=-5pt 0]{->}(11,11)
\psMatrixPlot[
  colorType=5,dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{data/matrix2.data}
\end{pspicture}}
\end{center}

\begin{lstlisting}
\begin{filecontents}{data/matrix2.data}
/colorTypeDef {
  dup /value exch def 
  value 0 eq 
    { 1 setgray }
    { value 1 eq 
      { 0 setgray }
      { Min sub dMaxMin div neg 1 add 300 mul 400 add
%        \pswavelengthToRGB not possible
         tx@addDict begin wavelengthToRGB Red Green Blue end 
        setrgbcolor
      } ifelse
    } ifelse 
} def
/dotmatrix [ % <------------ important line
3 0 0 0 0 0 0 0 1 2
0 0 0 0 0 0 0 1 2 1
8 0 0 0 0 0 1 2 1 0
0 0 0 0 0 1 2 1 0 0
0 0 0 0 1 2 1 0 0 0
9 0 0 1 2 1 3 0 0 0
0 0 1 2 1 4 0 0 0 0
0 1 2 1 5 0 0 0 0 0
1 2 1 6 0 0 0 0 0 0
2 1 7 0 0 0 0 0 0 3
] def % <------------ important line
\end{filecontents}
\psscalebox{0.7}{%
\begin{pspicture}(-0.5,-0.75)(11,11)
\psaxes[ticksize=-5pt 0]{->}(11,11)
\psMatrixPlot[colorType=5,dotsize=1.1cm,xStep=1,yStep=1,
  dotstyle=square*]{10}{10}{data/matrix1.data}
\end{pspicture}}
\end{lstlisting}



%--------------------------------------------------------------------------------------
\section{Dashed Lines}
%--------------------------------------------------------------------------------------
Tobias Nähring has implemented an enhanced feature for dashed
lines. The number of arguments is no longer limited.

\begin{BDef}
\Lkeyword{dash}=value1\OptArg*{unit} value2\OptArg*{unit} \ldots
\end{BDef}

\begin{LTXexample}[width=0.4\linewidth]
\psset{linewidth=2.5pt,unit=0.6}
\begin{pspicture}(-5,-4)(5,4)
 \psgrid[subgriddiv=0,griddots=10,gridlabels=0pt]
  \psset{linestyle=dashed}
  \pscurve[dash=5mm 1mm 1mm 1mm,linewidth=0.1](-5,4)(-4,3)(-3,4)(-2,3)
  \psline[dash=5mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm](-5,0.9)(5,0.9)
  \psccurve[linestyle=solid](0,0)(1,0)(1,1)(0,1)
  \psccurve[linestyle=dashed,dash=5mm 2mm 0.1 0.2,linetype=0](0,0)(-2.5,0)(-2.5,-2.5)(0,-2.5)
  \pscurve[dash=3mm 3mm 1mm 1mm,linecolor=red,linewidth=2pt](5,-4)(5,2)(4.5,3.5)(3,4)(-5,4)
\end{pspicture}
\end{LTXexample}





\section{Ticks and other marks along a curve}
\subsection{Quick overview}

The macros described below allow you to place tick and other marks along an arbitrary 
parametric curve with placement rules similar to those used by \Lcs{psaxes} in 
the \LPack{pst-plot} package. You have to define a metric function along the curve to 
govern tick placement. That function can be a specified function of \texttt{x,y} which 
should increase along the curve, or it can be an function whose increment is a specified 
positive function of \texttt{x, y, dx, dy, ds} where the last term is the arc-length element 
that you could specify alternately as \texttt{dx dup mul dy dup mul add sqrt}.
% start new material


In addition, a new command \Lcs{Put} is proposed, expanding as appropriate to \Lcs{rput} or \Lcs{uput}. Its syntax is

\begin{BDef}
\LcsStar{Put}\OptArgs\OptArg*{\Largb{<ref>}}\Largr{<position>}\Largb{<stuff>}
\end{BDef}

where the optional \texttt{*} blanks the background, the optional \OptArgs\ may be used to specify a rotation 
using any form acceptable to \Lcs{SpecialCoor} (eg, \nxLkeyword{rot=45} or \Lkeyword{rot}\verb|={(1,1)}| 
or \Lkeyword{rot}\verb|=(P)|, and \Larg{ref} takes one of 
two forms: \verb=(a)= a refpt such as \texttt{Bl}, in which case \Lcs{rput} is called; (b) a polar form of offset 
(eg, \verb=7pt;30=, or \verb=;(P)= --- in the latter case, \Ldim{pslabelsep} is substituted for the missing 
radius), in which case a modified form of \Lcs{uput} is called. The idea of \Lcs{Put} is to allow  \texttt{position}, 
\texttt{ref} and \texttt{rot} to be specified in any of the forms acceptable to \Lcs{SpecialCoor} and to do so with 
the same output no matter what form is used. The cost of this consistency is that \Lcs{Put} can lead to results 
that differ from \Lcs{uput} in some special cases. 


\subsection{Details}
Suppose you have drawn a parametric curve using \Lcs{psparametricplot}, and you wish to 
indicate some points on the curve using tick-marks like those  on the axes. This is a 
two-step process, the first of which serves to define at the PostScript level a 
number of data arrays containing information about the curve. Those arrays are used 
in the second step to compute tick positions and draw the ticks. The first step is 
to run the macro \Lcs{pscurvepoints}. For example,

\begin{verbatim}
\pscurvepoints[plotpoints=20]{0}{6}{t t t mul 12 div}{Pt}%
\end{verbatim}
makes a virtual (ie, data only---nothing is rendered) polyline with 20 vertices approximating 
the curve $x(t)=t, y(t)=t^2/12$, $0\le t\le 6$. The last argument \texttt{Pt} is the root name 
given to the data arrays.  PostScript arrays will be created with the following names: \texttt{Pt.X, Pt.Y} 
for the coordinates of the vertices, \texttt{PtDelta.X, PtDelta.Y} for the increments between the 
vertices (using, eg, \texttt{PtDelta.X[2]=Pt.X[2]-Pt.X[1]}) and \texttt{PtNormal.X, PtNormal.Y} for 
a vector normal to \texttt{PtDelta.X, PtDelta.Y} in the visual, not mathematical, sense. 
(Both senses are the same if the scales on the axes are identical.) The \texttt{Normal} is 
always constructed so as to point ``upward'' (ie, to your left) as you traverse the curve 
in the positive direction. The PostScript variable \texttt{unitratio} provides the ratio of 
the unit on the y axis to that on x axis, and \texttt{unitratiosq} is its square. All of 
these PostScript objects are stored in the main \texttt{pstricks} dictionary \Lps{tx@Dict} 
which should be automatically made available when using many \texttt{pstricks} macros. 
If \texttt{gs} returns you an error message like
\begin{verbatim}
Error: /undefined in Pt.X
\end{verbatim}
then you may need to enclose the offending PostScript code within a block of the form
\begin{verbatim}
tx@Dict begin ... end
\end{verbatim}
so that the dictionary is made available.

With this preparation, the main tick-making macro may be run. For example,
\begin{verbatim}
\pspolylineticks{Pt}{ dx dy add 3 div }{1}{2}%
\end{verbatim}
looks for data arrays made using \Lcs{pscurvepoints} with the root name \texttt{Pt}. The next argument, 
\texttt{dx dy add 3 div}, specifies the (PostScript) function of increments that should be used to 
construct the metric. If the keyword \verb|metricInitValue| is defined, eg, with 
\Lcs{psset}\Largb{\Lkeyword{metricInitValue}=2.5}, it is used as the initial value of the metric, 
otherwise it is defined to be 0. In the previous example, the increment function is always 
positive, and care should be taken to guarantee this is so or the results will not be meaningful. 
(If we wanted to use arc-length, the function would have been \texttt{ds}, assuming equal scales on 
the axes.) The last two arguments determine the index of the first tick and the number of ticks. 
Tick numbering begins with index 0, so the example says to drop the first tick and draw the 
next 2 ticks. In this example, where all keywords take their default values, ticks are 
potentially located at values on the curve where the metric takes a positive integer value. 
In the arc-length example, the tick with index 0 is at the beginning of the curve, and subsequent 
ticks are at unit distance, measured along the curve. At each index where a tick is drawn, a 
\Lcs{pnode} is created: In this example, you create nodes \texttt{PtTick1, PtTick2} on the curve 
where the ticks are located. This is handy for placing labels using, eg, \Lcs{Put}. In 
addition, PostScript data arrays (in this example, \texttt{PtTickN.X, PtTickN.Y} of the normals 
at these nodes are stored in the dictionary \texttt{TDict}. More importantly, the tangent and 
normal vectors at \texttt{PtTick0} etc are constructed as nodes with names \texttt{PtTangent0, PtNormal0} 
etc. See the last example below for typical usage.

The shape of the ticks is governed by the keywords \Lkeyword{ticksize} (default value \texttt{-4pt 4pt})
 and \Lkeyword{tickwidth} (default value \verb|.5\linewidth|.) With the default settings, ticks 
 are drawn perpendicular the the curve extending \texttt{4pt} to each side. The line
\begin{verbatim}
\pspolylineticks[ticksize=-6pt 6pt]{Pt}{ dx dy add 3 div }{1}{2}%
\end{verbatim}
would draw longer ticks than the default.

Placement of the ticks is governed by the keywords \Lkeyword{Ds} and \Lkeyword{Os}, whose meaning for the 
curve is similar to (but not the same as) the meanings of \Lkeyword{Dx} and \Lkeyword{Ox} with respect to the x axis. 
That is, if \texttt{Ds=2} and \texttt{Os=0}, ticks will be drawn where the metric takes 
values 0, 2, 4 and so on. More generally, ticks are placed where the metric takes 
value \texttt{Os, Os+Ds, Os+2*Ds,...}, as long as those positions are on the curve. If \Lkeyword{Os} 
has an empty value as a result, say, of \verb|\psset{Os=}|, then \Lkeyword{Os} is set internally 
to the initial metric value. If \Lkeyword{Ds} has an empty value, it is set internally to the 
final metric value less the initial metric value, divided by 10. 

To draw major and minor ticks requires two passes---one to draw the minor ticks and then one to draw the major ticks.

Note that a ticks may be placed at arbitrary metric values on the curve by running the macro once for each point, like:
\begin{verbatim}
\pspolylineticks[ticksize=-6pt 6pt,Os=1.3]{Pt}{ dx dy add 3 div }{0}{1}%
\pspolylineticks[ticksize=-6pt 6pt,Os=2.4]{Pt}{ dx dy add 3 div }{0}{1}%
\end{verbatim}

You may also dispense entirely with the tick and use the macro to generate a node sequence 
that can be used to place other graphic objects. For example:
\begin{verbatim}
\pspolylineticks[ticksize=0pt 0pt]{Pt}{ dx dy add 3 div }{0}{3}%
%This defines nodes PtTick0..PtTick2
\multido{\iA=0+1}{3}{\psdot(PtTick\iA)}
\end{verbatim}


There is another way to define a metric function without using increments. If the keywork \Lkeyword{metricFunction} is set to \true, 
then the function you present as an argument to \Lcs{pspolylineticks} must be a function of 
$x$ and $y$ only, and must be designed to increase along the curve. It is useful only in 
those cases where, in essence, the increment function can be explicitly integrated. 
For example, in the elliptical motion of planets and comets around the sun, it is not hard 
to integrate the area function explicitly, and this provides a convenient metric, being proportional to time elapsed.

There is some useful information left in the log by these macros. 
They report the starting and ending values of the metric function, 
the the range of indices for the Tick related arrays.

\subsection{Examples}
The examples in this section make use of very recent (as of May, 2010) versions 
of \LPack{pstricks} and related packages. 
%If the \texttt{pst-grapha} package is not available on CTAN,  download it from
%\begin{verbatim}
%http://math.ucsd.edu/~msharpe/pst-grapha.dmg
%\end{verbatim}

The first couple of examples are constructed entirely by hand, and have no interest 
other than to illustrate what is going on under the surface in the simplest case.

\begin{LTXexample}[pos=t]
\begin{pspicture}(-1,-1)(10,4)
\psline[showpoints=true](1,2)(4,0)(9,3)%
\uput[180](1,2){$s=0$}%
\uput[-90](4,0){$s=1$}%
\uput[0](9,3){$s=2$}%
\makeatletter% need to use macro names containing @
\pstVerb{tx@Dict begin %the pstricks dictionary
% declare arrays of length 3 (indices 0,1,2) to hold points, differences and normals
/unitratiosq 1 def % yunit=xunit
/P.X [ 1 4 9 ] def %array of x coords
/P.Y [ 2 0 3 ] def %array of y coords
/PDelta.X [ 0 3 5 ] def % 3=4-1, 5=9-4, 0 never used
/PDelta.Y [ 0 -2 3 ] def % -2=0-2, 3=3-0, 0 never used
% normal to (3,-2) is (2,3), normal to (5,3) is (-3,5)
/PNormal.X [ 2 2 -3 ] def % index 0 =index 1
/PNormal.Y [ 3 3 5 ] def % index 0 = index 1
end }
\def\Ppointcount{2}
\makeatother % make ticks using metric function with values 0,1,2
\pspolylineticks[Os=.5,Ds=1]{P}{1}{0}{2}
\uput[-135](PTick0){$s=0.5$}% % ticks at s=0.5,1.5 (increment function =1)
\uput[-45](PTick1){$s=1.5$}%
\end{pspicture}
\end{LTXexample}

\clearpage
Now the same data, but with arc-length as metric. We change the last few lines:

\begin{LTXexample}[pos=t]
\begin{pspicture}(-1,-1)(10,4)
\psline[showpoints=true](1,2)(4,0)(9,3)%
%\uput[180](1,2){$s=0$}%
%\uput[-90](4,0){$s=1$}%
%\uput[0](9,3){$s=2$}%
\makeatletter% need to use macro names containing @
\pstVerb{tx@Dict begin %the pstricks dictionary
% declare arrays of length 3 (indices 0,1,2) to hold points, 
% differences and normals
/unitratiosq 1 def % yunit=xunit
/P.X [ 1 4 9 ] def %array of x coords
/P.Y [ 2 0 3 ] def %array of y coords
/PDelta.X [ 0 3 5 ] def % 3=4-1, 5=9-4, 0 never used
/PDelta.Y [ 0 -2 3 ] def % -2=0-2, 3=3-0, 0 never used
% normal to (3,-2) is (2,3), normal to (5,3) is (-3,5)
/PNormal.X [ 2 2 -3 ] def % index 0 =index 1
/PNormal.Y [ 3 3 5 ] def % index 0 = index 1
end }
\def\Ppointcount{2}
\makeatother
% make ticks using metric function arc-length
\pspolylineticks[Os=1,Ds=1]{P}{ ds }{0}{9}
% ticks at s=1,2... (increment function = distance)
\uput[-135](PTick0){$s=1$}%
\uput[-135](PTick1){$s=2$}%
\end{pspicture}
\end{LTXexample}



\clearpage
Once again the same data, but with metric equal to the x coordinate. Change the last few lines to:

\begin{LTXexample}[pos=t]
\begin{pspicture}(-1,-1)(10,4)
\psline[showpoints=true](1,2)(4,0)(9,3)%
%\uput[180](1,2){$s=0$}%
%\uput[-90](4,0){$s=1$}%
%\uput[0](9,3){$s=2$}%
\makeatletter% need to use macro names containing @
\pstVerb{tx@Dict begin %the pstricks dictionary
% declare arrays of length 3 (indices 0,1,2) to hold points, 
% differences and normals
/unitratiosq 1 def % yunit=xunit
/P.X [ 1 4 9 ] def %array of x coords
/P.Y [ 2 0 3 ] def %array of y coords
/PDelta.X [ 0 3 5 ] def % 3=4-1, 5=9-4, 0 never used
/PDelta.Y [ 0 -2 3 ] def % -2=0-2, 3=3-0, 0 never used
% normal to (3,-2) is (2,3), normal to (5,3) is (-3,5)
/PNormal.X [ 2 2 -3 ] def % index 0 =index 1
/PNormal.Y [ 3 3 5 ] def % index 0 = index 1
end }
\def\Ppointcount{2}
\makeatother
% make ticks using metric function arc-length
\pspolylineticks[metricFunction,Os=1,Ds=2]{P}{ x }{0}{5}
% ticks at x=1,3,... , start at tick index 0, draw 5 ticks
% the tick at s=1 has index 0
% ticks at s=1,2... (increment function = distance)
\uput[-135](PTick0){$s=1$}%
\uput[-135](PTick1){$s=3$}%
\end{pspicture}
\end{LTXexample}






\clearpage
The next example is a smooth path where subticks are drawn first, followed by major ticks. 
The metric is arc-length with initial value $s=1$.
\begin{LTXexample}[pos=t]
\begin{pspicture}(-1,-1)(10,4)
%\parametricplot[algebraic]{0}{9}{(t^2)/9 | 4*Ex(-t)*(1+t+(t^{2})/2+(t^{3})/6)}
\psparametricplot[algebraic]{0}{9}{t^2/9 | sin(t)+1}%
\pscurvepoints{0}{9}{(t^2)/9 | sin(t)+1}{P}%
% make ticks using  arc-length metric
\pspolylineticks[metricInitValue=1,ticksize=-2pt 2pt,Os=1,Ds=.2]{P}{ ds }{1}{56}%
\pspolylineticks[metricInitValue=1,Os=1,Ds=2]{P}{ ds }{0}{6}%
\multido{\iA=1+1,\iB=3+2}{5}{\Put{6pt;(PNormal\iA)}(PTick\iA){\tiny \iB}}
%\nodexn{(PTick\iA)+(10pt;{(PNormal\iA)})}{Q}\rput(Q){\tiny \iB}}%
%\multido{\iA=1+1,\iB=3+2}{5}{\uput{6pt}[{(PNormal\iA)}](PTick\iA){\iB}}%
% ticks at x=1,3,... , start at tick index 0, draw 5 ticks
% the tick at s=1 has index 0
% ticks at s=1,2... (increment function = distance)
\end{pspicture}
\end{LTXexample}




\clearpage
Suppose for the next example that we have an ellipse $x^2/a^2+y^2/b^2=1$ ($a>b$) with 
eccentricity $\epsilon=(1-b^2/a^2)^{1/2}$. With planetary motion in mind, a natural metric 
for the ellipse is the area swept out by the radial line from the focus $(\epsilon a,0)$ 
starting from $(a,0)$ around to an arbitrary location $(x,y)$, where $y>0$, as this quantity 
is proportional to the time elapsed since perihelion. A routine calculation gives the following formula:
\[A=\frac{ab}{2}\arccos\bigg(\frac{x}{a}\bigg)-\frac{\epsilon a y}{2}.\]
Remembering that PostScript's \texttt{acos} gives  its result in degrees, not radians, we have the 
following, drawn for the case $a=4$, $b=3$.

\begin{LTXexample}[pos=t]
\begin{pspicture}(-4.5,-.5)(4.5,3.5)
\pstVerb{ /smajor 4 def /sminor 3 def % define semimajor, semiminor 
/ecc 1 sminor smajor div dup mul sub sqrt def % compute eccentricity
/ab smajor sminor mul 2 div def %first coeff
/ea smajor ecc mul 2 div def }% second coeff
\psparametricplot[algebraic]{0}{3.142}{smajor*cos(t) | sminor*sin(t)}%
\pscurvepoints{0}{3.142}{smajor*cos(t) | sminor*sin(t)}{P}%
\pspolylineticks[metricFunction,Ds=2,ticksize=-1.5pt 0]{P}{ ab x smajor div acos %
180 div PI mul mul  ea y mul sub }{1}{9}%
\pnode(! ecc smajor mul 0){S}% focus
\psline[linecolor=lightgray](S)(!smajor 0)%
\multido{\i=1+1}{9}{\psline[linecolor=lightgray](S)(PTick\i)}
\psdot(S)
\end{pspicture}
\end{LTXexample}





\clearpage
The next examples works without visible ticks, using the macros to construct nodes at which other objects will be placed.

\begin{LTXexample}[pos=t]
\begin{pspicture}(-1,-1)(10,4)
\psparametricplot[algebraic]{0}{9}{t| 3*Ex(-t)*(1+t+t^2/2+t^3/6)}
\pscurvepoints{0}{9}{t| 3*Ex(-t)*(1+t+t^2/2+t^3/6)}{P}%
\pspolylineticks[Os=1,Ds=1,ticksize=0 0]{P}{ ds }{0}{9}%
\multido{\i=0+1}{9}{\psdot[dotscale=1.5,dotstyle=o](PTick\i)}%
% ticks at s=1,2,... , start at tick index 0, set 9 ticks
% the tick at s=1 has index 0
% ticks at s=1,2... (increment function = distance)
\multido{\i=0+3}{3}{\Put[rot=(PTangent\i)]{7pt;(PNormal\i)}(PTick\i){PTick\i}}%
\uput[-135](PTick1){$s=2$}%
\end{pspicture}
\end{LTXexample}





This variant also has no visible ticks, but makes a color gradient along the curve based on arc-length from the start.

\begin{LTXexample}[pos=t]
\begin{pspicture}(-1,-1)(10,4)
\psparametricplot[plotpoints=200,linecolor=white]{0}{360}{ t cos 1 add 4 mul t 1 add 20 div ln 2 div 1 add }
\pscurvepoints[plotpoints=200]{0}{360}{ t cos 1 add 4 mul t 1 add 20 div ln 2 div 1 add }{P}%
\pspolylineticks[Os=0,Ds=.2,ticksize=0 0]{P}{ ds }{0}{90}%
\definecolorseries{ctest}{hsb}{last}{green}{violet}
\resetcolorseries[88]{ctest}%
\multido{\iA=0+1,\iB=1+1}{87}{\psline[linewidth=2pt,linecolor=ctest!![\iB](PTick\iA)(PTick\iB)}%
\end{pspicture}
\end{LTXexample}

\clearpage
Here is a another variant of this technique which allows arrows to be placed at locations 
on the curve where the metric takes particular values.




\begin{LTXexample}[pos=t]
\begin{pspicture}(-1,-1)(10,4.5)
\psparametricplot[plotpoints=100]{0}{360}{t cos 1 add 5 mul t sin 1 add 2 mul}
\pscurvepoints[plotpoints=100]{0}{360}{t cos 1 add 5 mul t sin 1 add 2 mul}{P}%
\pspolylineticks[Os=0,Ds=2.3,ticksize=0 0]{P}{ ds }{0}{10}% distance
\multido{\i=0+1}{10}{\psrline[arrows=->,arrowscale=1.5](PTick\i)(2pt;{(PTangent\i)})}%
\end{pspicture}
\end{LTXexample}

\section{Troubleshooting}
If you get PostScript errors when you process your file, the  most likely culprit is the 
function you specified to define the metric. There are some  things to look out for:
\begin{itemize}
\item If \Lkeyword{metricFunction}, the function you specify in PostScript code must 
involve only \texttt{x} and \texttt{y}, and must leave exactly one real value on the stack as a result of 
substituting specific values for \texttt{x} and \texttt{y}. The function must be strictly increasing on the curve.
\item If \Lkeyword{metricFunction}=\false (the default), the function you specify in PostScript 
code must involve only the variables \texttt{x}, \texttt{y}, \texttt{dx}, \texttt{dy}, \texttt{ds} (where \texttt{ds} 
is defined to be the arc-length element \texttt{dx dup mul dy dup mul add sqrt}, and must leave exactly 
one strictly positive real value on the stack when specific values are substituted for those variables. 
The constant function \texttt{1} gives equal weight to each segment in the curve, so in effect it gives 
you the original parametrization, up to a constant factor.
\item If the function you specify in \Lcs{parametricplot} and \Lcs{pscurvepoints} is \Lkeyword{algebraic}, 
make sure you follow precisely the syntax it understands. In complex cases, PostScript may be the safer solution.
\item It is unwise to use a different resolution for \Lcs{psparametricplot} and \Lcs{pscurvepoints}. 
The default value of \Lkeyword{plotpoints}=50 is marginal except for modest curve segments, and 200 should 
suffice for most smooth curves.
\end{itemize}


%--------------------------------------------------------------------------------------
\section{Transparent colors}
%--------------------------------------------------------------------------------------

Transparency is now part of the main \LPack{pstricks} package.
But pay attention, the names and syntax have changed and you need
to run \Lprog{ps2pdf} with the option
\Loption{-dCompatibilityLevel}=1.4.


%--------------------------------------------------------------------------------------
\section{,,Manipulating transparent colors''}
%--------------------------------------------------------------------------------------

\LPack{pstricks-add} supports real transparency and a simulated one with hatch lines:
\begin{lstlisting}
\def\defineTColor{\@ifnextchar[{\defineTColor@i}{\defineTColor@i[]}}
\def\defineTColor@i[#1]#2#3{%     transparency "Colors"
  \newpsstyle{#2}{%
     fillstyle=vlines,hatchwidth=0.1\pslinewidth,
     hatchsep=1\pslinewidth,hatchcolor=#3,#1%
  }%
}
\defineTColor{TRed}{red}
\defineTColor{TGreen}{green}
\defineTColor{TBlue}{blue}
\end{lstlisting}

There are three predefined "'transparent"` colors \verb+TRed+,
\verb+TGreen+, \verb+TBlue+. They are used as \PST{} styles and
not as colors:




\bgroup
\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(-3,-5)(5,5)
\psframe(-1,-3)(5,5) % objet de base
\psrotate(2,-2){15}{%
  \psframe[style=TRed](-1,-3)(5,5)}
\psrotate(2,-2){30}{%
  \psframe[style=TGreen](-1,-3)(5,5)}
\psrotate(2,-2){45}{%
  \psframe[style=TBlue](-1,-3)(5,5)}
\psframe[linewidth=3pt](-1,-3)(5,5)
\psdots[dotstyle=+,dotangle=45,dotscale=3](2,-2) % centre de la rotation
\end{pspicture}
\end{LTXexample}
\egroup

%--------------------------------------------------------------------------------------
\section{Calculated colors}
%--------------------------------------------------------------------------------------
The \verb+xcolor+ package (version 2.6) has a new feature for defining colors:
\begin{lstlisting}[style=syntax]
  \definecolor[ps]{<name>}{<model>}{< PS code >}
\end{lstlisting}

\verb+model+ can be one of the color models, which \PS will
understand, e.g. \verb+rgb+. With this definition the color is
calculated on the \PS side.
\begin{LTXexample}[pos=t,preset=\centering]
\definecolor[ps]{bl}{rgb}{tx@addDict begin  Red Green Blue end}%
\psset{unit=1bp}
\begin{pspicture}(0,-30)(400,100)
\multido{\iLAMBDA=0+1}{400}{%
  \pstVerb{
    \iLAMBDA\space 379 add dup /lambda exch def
    tx@addDict begin  wavelengthToRGB end
  }%
  \psline[linecolor=bl](\iLAMBDA,0)(\iLAMBDA,100)%
}
\psaxes[yAxis=false,Ox=350,dx=50bp,Dx=50]{->}(-29,-10)(420,100)
\uput[-90](420,-10){$\lambda$[\textsf{nm}]}
\end{pspicture}
\end{LTXexample}





\begin{center}
\newcommand{\Touch}{%
\psframe[linestyle=none,fillstyle=solid,fillcolor=bl,dimen=middle](0.1,0.75)}
\definecolor[ps]{bl}{rgb}{tx@addDict begin Red Green Blue end}%
% Echelle 1cm <-> 40 nm
%         1 nm <-> 0.025 cm
\psframebox[fillstyle=solid,fillcolor=black]{%
\begin{pspicture}(-1,-0.5)(12,1.5)
\multido{\iLAMBDA=380+2}{200}{%
  \pstVerb{
    /lambda \iLAMBDA\space def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! lambda 0.025 mul 9.5 sub 0){\Touch}
}
\multido{\n=0+1,\iDiv=380+40}{11}{%
    \psline[linecolor=white](\n,0.1)(\n,-0.1)
    \uput[270](\n,0){\textbf{\white\iDiv}}}
    \psline[linecolor=white]{->}(11,0)
    \uput[270](11,0){\textbf{\white$\lambda$(nm)}}
\end{pspicture}}

\psframebox[fillstyle=solid,fillcolor=black]{%
\begin{pspicture}(-1,-0.5)(12,1)
  \pstVerb{
    /lambda 656 def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! 656 0.025 mul 9.5 sub 0){\Touch}
  \pstVerb{
    /lambda 486 def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! 486 0.025 mul 9.5 sub 0){\Touch}
   \pstVerb{
    /lambda 434 def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! 434 0.025 mul 9.5 sub 0){\Touch}
  \pstVerb{
    /lambda 410 def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! 410 0.025 mul 9.5 sub 0){\Touch}
\multido{\n=0+1,\iDiv=380+40}{11}{%
    \psline[linecolor=white](\n,0.1)(\n,-0.1)
    \uput[270](\n,0){\textbf{\white\iDiv}}}
    \psline[linecolor=white]{->}(11,0)
    \uput[270](11,0){\textbf{\white$\lambda$(nm)}}
\end{pspicture}}

\Index{Spectrum} of \Index{hydrogen} emission (Manuel Luque)
\end{center}

\begin{lstlisting}
\newcommand\Touch{%
\psframe[linestyle=none,fillstyle=solid,fillcolor=bl,dimen=middle](0.1,0.75)}
\definecolor[ps]{bl}{rgb}{tx@addDict begin Red Green Blue end}%
% Echelle 1cm <-> 40 nm
%         1 nm <-> 0.025 cm
\psframebox[fillstyle=solid,fillcolor=black]{%
\begin{pspicture}(-1,-0.5)(12,1.5)
\multido{\iLAMBDA=380+2}{200}{%
  \pstVerb{
    /lambda \iLAMBDA\space def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! lambda 0.025 mul 9.5 sub 0){\Touch}
}
\multido{\n=0+1,\iDiv=380+40}{11}{%
    \psline[linecolor=white](\n,0.1)(\n,-0.1)
    \uput[270](\n,0){\textbf{\white\iDiv}}}
    \psline[linecolor=white]{->}(11,0)
    \uput[270](11,0){\textbf{\white$\lambda$(nm)}}
\end{pspicture}}

\psframebox[fillstyle=solid,fillcolor=black]{%
\begin{pspicture}(-1,-0.5)(12,1)
  \pstVerb{
    /lambda 656 def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! 656 0.025 mul 9.5 sub 0){\Touch}
  \pstVerb{
    /lambda 486 def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! 486 0.025 mul 9.5 sub 0){\Touch}
   \pstVerb{
    /lambda 434 def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! 434 0.025 mul 9.5 sub 0){\Touch}
  \pstVerb{
    /lambda 410 def
    lambda
    tx@addDict begin  wavelengthToRGB end
  }%
 \rput(! 410 0.025 mul 9.5 sub 0){\Touch}
\multido{\n=0+1,\iDiv=380+40}{11}{%
    \psline[linecolor=white](\n,0.1)(\n,-0.1)
    \uput[270](\n,0){\textbf{\white\iDiv}}}
    \psline[linecolor=white]{->}(11,0)
    \uput[270](11,0){\textbf{\white$\lambda$(nm)}}
\end{pspicture}}

Spectrum of hydrogen emission (Manuel Luque)
\end{lstlisting}




%--------------------------------------------------------------------------------------
\section{Gouraud shading}
%--------------------------------------------------------------------------------------
\begin{quotation}
\Index{Gouraud} shading is a method used in computer graphics to simulate the differing effects of
light and colour across the surface of an object. In practice, Gouraud shading is used to
achieve smooth lighting on low-polygon surfaces without the heavy computational requirements
of calculating lighting for each pixel. The technique was first presented by Henri Gouraud in 1971.\\
~\hfill{\small \url{http://www.wikipedia.org}}
\end{quotation}

PostScript level 3 supports this kind of shading and it can only
be seen with Acroread 7 or later. The syntax is easy:

\begin{lstlisting}[style=syntax]
  \psGTriangle(x1,y1)(x2,y2)(x3,y3){color1}{color2}{color3}
\end{lstlisting}

\psset{unit=0.75cm}

\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(0,-.25)(10,10)
  \psGTriangle(0,0)(5,10)(10,0){red}{green}{blue}
\end{pspicture}
\end{LTXexample}



\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(0,-.25)(10,10)
  \psGTriangle*(0,0)(9,10)(10,3){black}{white!50}{red!50!green!95}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(0,-.25)(10,10)
  \psGTriangle*(0,0)(5,10)(10,0){-red!100!green!84!blue!86}
                               {-red!80!green!100!blue!40}
                               {-red!60!green!30!blue!100}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\definecolor{rose}{rgb}{1.00, 0.84, 0.88}
\definecolor{vertpommepasmure}{rgb}{0.80, 1.0, 0.40}
\definecolor{fushia}{rgb}{0.60, 0.30, 1.0}
\begin{pspicture}(0,-.25)(10,10)
  \psGTriangle(0,0)(5,10)(10,0){rose}{vertpommepasmure}{fushia}
\end{pspicture}
\end{LTXexample}





\section{\Lcs{psCallout}}

\begin{BDef}
\Lcs{psCallout}\OptArgs\Largr{$x_0,y_0$}\Largb{Text}
\end{BDef}

Possible parameter are:

\begin{description}
  \item[tipAngle] The angle of the tip depending to the horizontal line. 
  \item[tipLength] The length of the tip from the coordinates to the box.
  \item[tipWidth] The width of the tip end.
  \item[tipPos] Relative position of the tip end to the width of the box.
\end{description}




\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(-5.5,-1)(4,5.5)
\psaxes[labels=none,ticks=none]{->}(0,0)(-5,-1)(3.5,5)[$x$,-90][$y$,0]
\psyTick(1){1}\uput[225](0,0){0}
\psplot[algebraic,,yMaxValue=4.5,linecolor=red,linewidth=1.5pt]{-2.5}{3}{Euler^(-(x))}
\psCallout(1,0.5){\scriptsize $f(x)=e^{-x}$}
\psCallout[tipAngle=90](1,1.6){\scriptsize $f(x)=e^{-x}$}
\psCallout[tipLength=10mm](1,3){$f(x)=e^{-x}$}
\psCallout[tipLength=10mm,tipAngle=120,tipPos=0.8](-1,1){$f(x)=e^{-x}$}
\psCallout[tipAngle=120,fillcolor=red!40,fillstyle=solid](-4,3){%
   \shortstack{Some math\\$f(x)=e^{-x}$}}
\end{pspicture}
\end{LTXexample}




\begin{LTXexample}[pos=t,preset=\centering]
\begin{pspicture}(-5.5,-1)(4,5.5)
\psaxes[labels=none,ticks=none]{->}(0,0)(-5,-1)(3.5,5)[$x$,-90][$y$,0]
\psyTick(1){1}\uput[225](0,0){0}
\psplot[algebraic,,yMaxValue=4.5,linecolor=red,linewidth=1.5pt]{-2.5}{3}{Euler^(-(x))}
\psset{linearc=0.4}%
\psCallout(1,0.5){\scriptsize $f(x)=e^{-x}$}
\psCallout[tipAngle=90](1,1.6){\scriptsize $f(x)=e^{-x}$}
\psCallout[tipLength=10mm](1,3){$f(x)=e^{-x}$}
\psCallout[tipLength=10mm,tipAngle=120,tipPos=0.8](-1,1){$f(x)=e^{-x}$}
\psCallout[tipAngle=120,fillcolor=red!40,fillstyle=solid](-4,3){%
   \shortstack{Some math\\$f(x)=e^{-x}$}}
\end{pspicture}
\end{LTXexample}



\section{Internal color macros}
The internal macros \Lcs{pswavelengthToRGB} and \Lcs{pswavelengthToRGB} can be used for own purposed.
They are defines as follows:

\begin{lstlisting}
\def\pswavelengthToGRAY{ tx@addDict begin wavelengthToGRAY end }
\def\pswavelengthToRGB{ tx@addDict begin wavelengthToRGB Red Green Blue end }
\end{lstlisting}

both macros leave the value(s) on the stack which then can be used for further
manipulating or setting the color with \Lps{setgray} or \Lps{setrgbcolor}. 
For an example see Section~\ref{sec:psMatrix}.




\appendix


%--------------------------------------------------------------------------------------
\clearpage
\section{\nxLcs{resetOptions}}
%--------------------------------------------------------------------------------------

Sometimes it is difficult to know what options, which are changed
inside a long document, are different to the default ones. With
this macro all options belonging to \LPack{pst-plot} can be reset.
This refers to all options of the packages \LPack{pstricks},
\LPack{pst-plot} and \LPack{pst-node}.



%--------------------------------------------------------------------------------------
\section{PostScript}
%--------------------------------------------------------------------------------------

\Index{PostScript} uses the stack system and the LIFO system, "'Last In, First Out"`.

\newlength{\Li}\settowidth{\Li}{Function}
\begin{table}[htbp]
\caption{Some primitive PostScript macros}\label{tab:primpost}
\centering
\ttfamily
    \begin{tabular}{@{} l | r@{ $\rightarrow$ } l @{}}\hline
    \multirow{2}{\Li}{\normalfont\emph{Function}} & \multicolumn{2}{ c }{\normalfont\emph{Meaning}}\\
    &\normalfont\emph{on stack before} & \normalfont\emph{after}\\\hline
    \Lps{add} & $x\quad y$&$x+y$\\ 
    \Lps{sub} & $x\quad y$&$x-y$\\ 
    \Lps{mul} & $x\quad y$&$x\times y$\\ 
    \Lps{div} & $x\quad y$&$x\div y$\\ 
    \Lps{sqrt} & $x$&$\sqrt{x}$\\ 
    \Lps{abs} & $x$&$|x|$\\ 
    \Lps{neg} & $x$&$-x$\\ 
    \Lps{cos} & $x$&$\cos(x)$ ($x$ in degrees)\\ 
    \Lps{sin} & $x$&$\sin(x)$ ($x$  in degrees)\\ 
    \Lps{tan} & $x$&$\tan(x)$ ($x$  in degrees)\\ 
    \Lps{atan} & $y\quad x$&$\angle{(\vec{Ox};\vec{OM})}$ (in degrees of $M(x,y)$)\\ 
    \Lps{ln} & $x$&$\ln(x)$\\ 
    \Lps{log} & $x$&$\log(x)$\\ 
    \Lps{array} & $n$&\normalfont$v$ (of dimension $n$)\\ 
    \Lps{aload} & $v$&$x_1\quad x_2\quad \cdots\quad x_n\quad v$\\ 
    \Lps{astore} & $x_1\quad x_2\quad \cdots\quad x_n\quad v$ & $[v]$\\ 
    \Lps{pop} & $x$ & --\\ 
    \Lps{dup} & $x$ & $x\quad x$ \\\hline
%    \Lps{roll} & $x_1\quad x_2\quad \cdots\quad x_n\quad n p$ &\\\hline
  \end{tabular}
\end{table}


\clearpage
\section{List of all optional arguments for \texttt{pstricks-add}}

\xkvview{family=pstricks-add,columns={key,type,default}}


\nocite{*}
\bgroup
\RaggedRight
\printbibliography
\egroup

\printindex




\end{document}