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
|
%% $Id: pst-func.tex 885 2024-03-31 07:25:14Z herbert $
%%
%% This is file `pst-func.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-func.tex'
%%
%% Herbert Voss <hvoss@tug.org>
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%% `pst-func' is a PSTricks package to plot special functions
%%
%% For a ChangeLog go the the end
%%
\csname PSTfuncLoaded\endcsname
\let\PSTfuncLoaded\endinput
% Requires some PSTricks packages
\ifx\PSTricksLoaded\endinput\else \input pstricks.tex\fi
\ifx\PSTnodesLoaded\endinput\else \input pst-plot.tex\fi
\ifx\PSTmathLoaded\endinput \else \input pst-math.tex\fi
\ifx\PSTtoolsLoaded\endinput \else \input pst-tools.tex\fi
\ifx\PSTricksAddLoaded\endinput\else\input pstricks-add.tex\fi
\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey.tex \fi
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
% interface to the `xkeyval' package
\pst@addfams{pst-func}
%
\def\fileversion{1.02a}
\def\filedate{2024/03/31}
\message{`PST-func' v\fileversion, \filedate\space (hv)}
%
\pstheader{pst-func.pro}
%\pstheader{pst-math.pro}% for GAMMALN
%
% Shortcuts ....
\def\ChebyshevT{ tx@FuncDict begin ChebyshevT end }
\def\ChebyshevU{ tx@FuncDict begin ChebyshevU end }
%
\define@key[psset]{pst-func}{epsilon}[1.e-08]{\def\psk@epsilon{#1 }}
\psset[pst-func]{epsilon=1.e-08}
\define@key[psset]{pst-func}{xShift}[0]{\def\psk@xShift{#1}}
\psset[pst-func]{xShift=0}
%
\define@key[psset]{pst-func}{cosCoeff}[0]{\def\psk@cosCoeff{#1}}
\define@key[psset]{pst-func}{sinCoeff}[1]{\def\psk@sinCoeff{#1}}
\psset[pst-func]{cosCoeff=0,sinCoeff=1} % coeff=a0 a1 a2 a3 ...
%
\def\psFourier{\@ifnextchar[{\psFourier@i}{\psFourier@i[]}}
\def\psFourier@i[#1]#2#3{{%
\pst@killglue
\psset{#1}
\psplot[algebraic=false]{#2}{#3}{%
/psFtype (cos) def
/Fourier {
aload length /n exch def
n -1 roll 2 div n 1 roll % a0/2
n 1 sub -1 0 {
/i exch def
i x mul 180 mul 3.141592 div
psFtype (sin) eq {sin}{cos} ifelse
mul n 1 roll
} for
n 1 sub -1 1 { pop add } for
} def
[\psk@cosCoeff] Fourier
/psFtype (sin) def
[0 \psk@sinCoeff] Fourier add
}%
}\ignorespaces}
%
\define@key[psset]{pst-func}{coeff}[0 1]{\def\psk@coeff{#1}}
\define@key[psset]{pst-func}{Derivation}[0]{\def\psk@Derivation{#1}}
\define@boolkey[psset]{pst-func}[Pst@]{markZeros}[true]{}
\define@key[psset]{pst-func}{epsZero}[0.1]{\def\psk@epsZero{#1}}
\define@key[psset]{pst-func}{dZero}[0.1]{\def\psk@dZero{#1}}
\define@key[psset]{pst-func}{zeroLineTo}[-1]{\def\psk@zeroLineTo{#1}}
\define@key[psset]{pst-func}{zeroLineColor}[black]{\pst@getcolor{#1}\psk@zeroLineColor}
\newdimen\psk@zeroLineWidth
\define@key[psset]{pst-func}{zeroLineWidth}[0.5\pslinewidth]{\pssetlength\psk@zeroLineWidth{#1}}
\define@key[psset]{pst-func}{zeroLineStyle}[dashed]{%
\@ifundefined{psls@#1}%
{\@pstrickserr{Line style `#1' not defined}\@eha}%
{\edef\psk@zeroLineStyle{#1}}%
}
\psset[pst-func]{%
coeff=0 1, % coeff=a0 a1 a2 a3 ...
Derivation=0, % 0 is the original function
markZeros=false,% no dots for the zeros
epsZero=0.1, % the distance between two zero points
dZero=0.1, % the distance of the x value for scanning the function
zeroLineTo=-1, % a line to the value of the lineTo's Derivation (-1= none)
zeroLineStyle=dashed,%
zeroLineWidth=0.5\pslinewidth,%
zeroLineColor=black}%
%
\def\psGetZeros{\pst@object{psGetZeros}}
\def\psGetZeros@i(#1,#2)#3{%
\pst@killglue
\begin@SpecialObj
\use@par
\addto@pscode{
tx@FuncDict begin
/xStart #1 def /xEnd #2 def
/x xStart def
/func { /x exch def \ifPst@algebraic (#3) AlgParser cvx exec \else #3 \fi } def
#1 Steffensen
\ifPst@markZeros \fi
end
}%
\end@SpecialObj
\ignorespaces
}
\iffalse
/Steffensen {% the start value and the function must be on top of the stack
/y0 exch def % the start value
/Iter 0 def /MaxIter 200 def
{
y0 Function /F exch def
F abs eps2 lt { exit } if
y0 F sub /Phi exch def
Phi Function /F2 exch def
F2 abs eps2 le { exit }{
Phi y0 sub dup mul Phi F2 sub 2 Phi mul sub y0 add Div /Diff exch def
y0 Diff sub /y0 exch def
Diff abs eps1 le { exit } if
} ifelse
/Iter Iter 1 add def
Iter MaxIter gt { exit } if
} loop
y0 % the returned value ist the zero point
0 \tx@ScreenCoor pstack
3 0 360 arc gsave 0 0 1 setrgbcolor fill grestore 1 setlinewidth stroke
} def
\fi
%
\def\psPolynomial{\pst@object{psPolynomial}}
\def\psPolynomial@i#1#2{%
\pst@killglue%
\begingroup%
\use@par%
\@nameuse{beginplot@\psplotstyle}%
\gdef\psplot@init{}%
\@nameuse{testqp@\psplotstyle}%
\addto@pscode{%
tx@FuncDict begin
/coeff [ \psk@coeff ] def
/x0 #1 def /x1 #2 def
/dx x1 x0 sub \psk@plotpoints\space div def
/Derivation \psk@Derivation\space def
/x x0 def
\ifPst@markZeros
5 dict begin % hold all local!
gsave
\pst@number\psk@zeroLineWidth SLW
\pst@usecolor\psk@zeroLineColor
\psk@epsZero\space \psk@dZero\space FindZeros
aload length { % zero array is on stack
/xZero exch def
xZero \pst@number\psxunit mul /xPixel exch def
\psk@dotsize
\@nameuse{psds@\psk@dotstyle}%
xPixel 0 Dot
\psk@zeroLineTo\space 0 ge { % line to function \psk@lineTo
xPixel 0 moveto
xZero coeff \psk@zeroLineTo\space FuncValue
\pst@number\psyunit mul xPixel exch L
\@nameuse{psls@\psk@zeroLineStyle}
} if
} repeat
grestore
end
\fi
/xy {
x \psk@xShift\space sub coeff Derivation FuncValue \pst@number\psyunit mul
x \pst@number\psxunit mul exch
} def
xy moveto
}%
\if@pst% lines and dots
\psPolynomial@iii
\else% curves
\psPolynomial@ii
\fi
\endgroup
\ignorespaces}
%
\def\psPolynomial@ii{%
\addto@pscode{%
xy \@nameuse{beginqp@\psplotstyle}
\psk@plotpoints {
xy \@nameuse{doqp@\psplotstyle}
/x x dx add def
} repeat
xy \@nameuse{doqp@\psplotstyle}
end
}%
\@nameuse{endqp@\psplotstyle}%
}
\def\psPolynomial@iii{% curves
\addto@pscode{%
mark
/n 2 def
\psk@plotpoints {
xy
n 2 roll
/n n 2 add def
/x x dx add def
} repeat
/x x1 def
xy
n 2 roll
end
}%
\@nameuse{endplot@\psplotstyle}%
}
%
% Bessel 2004-06-08
% Manuel Luque, Herbert Voss
% Look at the end for some more documentation about the algorithm
%
\define@key[psset]{pst-func}{constI}[1]{\def\psk@constI{#1 }}
\define@key[psset]{pst-func}{constII}[0]{\def\psk@constII{#1 }}
\psset{constI=1,constII=0}
%
\def\psBessel{\@ifnextchar[{\psBessel@i}{\psBessel@i[]}}
\def\psBessel@i[#1]#2#3#4{{%%% #2 = n
\pst@killglue
\psset{plotpoints=500,constI=1,constII=0}%
\psset{#1,algebraic=false}%
\pstVerb{ /toDegrees { 57.29577951 mul } def }
\parametricplot{#3}{#4}{%
/J1 0 def
/xBessel t toDegrees def
0 0.1 180 {
/tB exch toDegrees def
/J1 J1 0.1 xBessel
tB sin mul tB #2\space mul sub cos mul add def
} for
t J1 180 div \psk@constI mul \psk@constII add
}%
}\ignorespaces}
%
%
\def\psModBessel{\@ifnextchar[{\psModBessel@i}{\psModBessel@i[]}}%% hv 20111021
\def\psModBessel@i[#1]#2#3{{%%% #2 = n
\pst@killglue%
\psset{nue=0,#1}%
\psplot{#2}{#3}[ /nue \psk@nue def /epsilon 1e-20 def ]{%
/Sum 0 def
/Iter 0 def
{/Sum_Iter
x dup mul 4 div Iter exp % nominator
nue Iter add 1 add GAMMA Iter tx@AddMathFunc begin ! end mul % denominator
Div def
Sum_Iter abs epsilon lt { exit } if
/Sum Sum Sum_Iter add def
/Iter Iter 1 add def
} loop
x 0.5 mul nue exp Sum mul
}%
}\ignorespaces}
%
\define@key[psset]{pst-func}{n}[1]{\def\psk@func@n{#1 }}
\psset[pst-func]{n=0}
%
\def\psLaguerre{\@ifnextchar[\psLaguerre@i{\psLaguerre@i[]}}%% hv 20200111
\def\psLaguerre@i[#1](#2,#3){{%%% n
\pst@killglue
\psplot[#1]{#2}{#3}{%
/L_n 1 def
0 1 \psk@func@n {
/k_i ED
-1 k_i exp k_i factorial div
\psk@func@n k_i MoverN mul
x k_i exp mul L_n add
/L_n ED
} for
x \pst@number\psxunit mul L_n
%dup == %\pst@number\psyunit div
}%
}\ignorespaces}
%
\def\psLaguerreC{\pst@object{psLaguerreC}}%% hv 20200612
\def\psLaguerreC@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
\pst@killglue
\begin@SpecialObj
\addto@pscode{%
% 20 dict begin
/yC #3 def
/dx #2 #1 sub \psk@plotpoints div def
/dy #4 #3 sub \psk@plotpoints div def
/L_i {
5 userdict begin
/X ED
/n_i ED
/L_n 0 def
0 1 n_i {
/k_i ED
-1 k_i exp k_i factorial div
n_i k_i MoverN mul
X k_i exp mul L_n add
/L_n ED
} for
L_n % return L_n(x)
end
} def
/n \psk@func@n def
[ % start array of x/y values
\psk@plotpoints { /xC #1 def \psk@plotpoints {
/Re 0 def
0 1 \psk@func@n 2 div floor {
/j ED % loop index
/j2 j dup add def % 2j
n j2 sub xC L_i % calculate L_{n-2j}(x)
j2 exp % L_{n-2j}^{2j}(x)
-1 j exp yC j2 exp mul % (-1^j)*y^(2j)
j2 factorial % (2*j)!
div
mul
Re add /Re ED
} for
/Im 0 def
0 1 \psk@func@n 1 sub 2 div floor {
/j ED % loop index
/j2 j dup add def % 2j
n j2 sub 1 sub xC L_i % calculate L_{n-2j-1}(x)
j2 1 add exp % L_{n-2j}^{2j+1}(x)
-1 j 1 sub exp yC j2 1 add exp mul % (-1^j)*y^(2j+1)
j2 1 add factorial % (2*j+1)!
div
mul
Im add /Im ED
} for
Re Im 2 copy \tx@ScreenCoor
% Re Im dup mul exch dup mul add sqrt dup 4 gt {pop 4} if 4 div setgray
% xC yC \tx@ScreenCoor 0 360 2 arc gsave fill stroke grestore
xC dx add /xC ED
} repeat
yC dy add /yC ED
} repeat
false \tx@NArray
\psk@dotsize
\@nameuse{psds@\psk@dotstyle}
\tx@setStrokeTransparency
newpath
n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat
%% end
}%
\end@SpecialObj
}\ignorespaces}
%
\def\psLaguerreCC{\pst@object{psLaguerreCC}}%% hv 20200612
\def\psLaguerreCC@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
\pst@killglue
\begin@SpecialObj
\addto@pscode{%
% 20 dict begin
gsave
/yC #3 def
/dx #2 #1 sub \psk@plotpoints div def
/dy #4 #3 sub \psk@plotpoints div def
/n \psk@func@n def
[ % start array of x/y values
\psk@plotpoints { /xC #1 def \psk@plotpoints {
/z [xC yC ] def
/L0 [1 0] def
/L1 [1 z {-1 mul} forall 3 1 roll add exch] def
n 1 le {
n 0 eq {/L1 L0 def} if
n 1 eq {/L1 L1 def} if
}{
/m 1 def
n 1 sub
{
/L2 1 m 1 add div
[2 m mul 1 add z {-1 mul} forall 3 1 roll add exch] L1 cxmul
L0 m neg cxrmul cxadd
exch cxrmul def
/L0 L1 def
/L1 L2 def
/m m 1 add def
} repeat
} ifelse
L1 aload pop \tx@ScreenCoor
xC dx add /xC ED
} repeat
yC dy add /yC ED
} repeat
false \tx@NArray
\psk@dotsize
\@nameuse{psds@\psk@dotstyle}
\tx@setStrokeTransparency
newpath
n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat
grestore
%% end
}%
\end@SpecialObj
}\ignorespaces}
%
\def\psLaguerreCCC{\pst@object{psLaguerreCCC}}%% hv 20200612
\def\psLaguerreCCC@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
\pst@killglue
\begin@SpecialObj
\addto@pscode{%
% 20 dict begin
/yC #3 def
/dx #2 #1 sub \psk@plotpoints div def
/dy #4 #3 sub \psk@plotpoints div def
[ % start array of x/y values
\psk@plotpoints {
/xC #1 def
\psk@plotpoints {
/Z [xC yC] def
/L [1 0] def
0 1 \psk@func@n {
/k ED
\psk@func@n k MoverN -1 k exp k factorial div mul
Z k
tx@FuncDict begin cxexp exch
cxrmul L cxadd end /L ED
} for
L aload pop \tx@ScreenCoor
xC dx add /xC ED
} repeat
yC dy add /yC ED
} repeat
% ] aload length 3 1 roll moveto 2 div cvi 1 sub { lineto } repeat 1 0 0 setrgbcolor 0.1 setlinewidth stroke
false \tx@NArray
\psk@dotsize
\@nameuse{psds@\psk@dotstyle}
\tx@setStrokeTransparency
newpath
n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat
%% end
}%
\end@SpecialObj
}\ignorespaces}
%
\def\psLaguerreCCCC{\pst@object{psLaguerreCCCC}}%% hv 20200612
\def\psLaguerreCCCC@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
\pst@killglue
\begin@SpecialObj
\addto@pscode{%
% 20 dict begin
/yC #3 def
/dx #2 #1 sub \psk@plotpoints div def
/dy #4 #3 sub \psk@plotpoints div def
% start array of x/y values
\psk@plotpoints {
/xC #1 def
[
\psk@plotpoints {
/Z [xC yC] def
/L [1 0] def
0 1 \psk@func@n {
/k ED
\psk@func@n k MoverN -1 k exp k factorial div mul
Z k
tx@FuncDict begin cxexp exch
cxrmul L cxadd end /L ED
} for
L aload pop \tx@ScreenCoor
xC dx add /xC ED
} repeat
]
aload length 3 1 roll moveto 2 div cvi 1 sub { lineto } repeat 1 0 0 setrgbcolor 0.1 setlinewidth stroke
yC dy add /yC ED
} repeat
% ] aload length 3 1 roll moveto 2 div cvi 1 sub { lineto } repeat 1 0 0 setrgbcolor 0.1 setlinewidth stroke
% false \tx@NArray
% \psk@dotsize
% \@nameuse{psds@\psk@dotstyle}
% \tx@setStrokeTransparency
% newpath
% n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat
%% end
}%
\end@SpecialObj
}\ignorespaces}
%
\def\psContourLaguerre{\pst@object{psContourLaguerre}}%% hv 20200612
\def\psContourLaguerre@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
\pst@killglue
\begin@SpecialObj
\addto@pscode{%
/yC #3 def
/dx #2 #1 sub \psk@plotpoints div def
/dy #4 #3 sub \psk@plotpoints div def
/contourdata [ % start array of x/y values
\psk@plotpoints {
/xC #1 def
[
\psk@plotpoints {
/Z [xC yC] def
/L [1 0] def
0 1 \psk@func@n {
/k ED
\psk@func@n k MoverN -1 k exp k factorial div mul
Z k
tx@FuncDict begin cxexp exch
cxrmul L cxadd end /L ED
} for
% L aload cxnorm exch pop
xC yC L cxre exch pop
xC dx add /xC ED
} repeat
]
yC dy add /yC ED
} repeat
] def
/zMax 0 def /zMin 0 def % lowest and highest value
contourdata aload length /N ED % get the no of arrays
N { % inside contourdata
/data ED % save first inner array
data aload length 3 div round cvi { % get the records
\psk@colorOffset
dup zMin lt % z<zMin?
{ /zMin ED } % yes, save it
{ dup zMax gt { /zMax ED }{ pop } ifelse } ifelse
pop pop % delete x y
} repeat
} repeat
clear % clear stack
/dz zMax zMin sub def % value range
/steps \psk@colSteps\space 0 gt { true }{ false } ifelse def
0 1 N 1 sub { % for i=0 to N-1
contourdata exch get /data ED % get first array
data aload length 3 div round cvi {
\psk@colorOffset
/z ED /y ED /x ED
z zMin sub dz div % relative z (0..1)
\ifPst@colored 400 mul 380 add tx@addDict begin wavelengthToRGB
Red Green Blue end setrgbcolor % set color
\else
steps {\psk@colSteps\space mul round \psk@colSteps\space div} if
setgray
\fi
x \pst@number\psxunit mul y \pst@number\psyunit mul
\pst@number\pst@dimb 0 360 arc fill
} repeat
} for
}%
\end@SpecialObj
}\ignorespaces}
\def\psLegendre{\@ifnextchar[{\psLegendre@i}{\psLegendre@i[]}}%% hv 20200115
\def\psLegendre@i[#1](#2,#3){{%%% n
\pst@killglue%
\psplot[#1]{#2}{#3}{%
/P_n 0 def
\psk@func@n 0 eq { /P_1 1 def }{ \psk@func@n 1 eq { /P_1 x def }
{ /P_0 1 def
/P_1 x def
2 1 \psk@func@n {
/k_i ED
k_i dup add 1 sub x mul P_1 mul % (2n-1)*x*P_1
k_i 1 sub P_0 mul sub % − ( n−1 ) P_{n-2}(x)
k_i div
/P_0 P_1 def
/P_1 ED
} for
%n Pn ( x ) = ( 2n − 1 ) P_{n−1}(x) − ( n−1 ) P_{n-2}(x)
} ifelse } ifelse
x \pst@number\psxunit mul P_1
%dup == %\pst@number\psyunit div
}%
}\ignorespaces}
%
\define@key[psset]{pst-func}{sigma}[0.5]{\def\psk@sigma{#1 }}
\define@key[psset]{pst-func}{mue}[0]{\def\psk@mue{#1 }}
\define@key[psset]{pst-func}{nue}[1]{\def\psk@nue{#1 }}
\psset[pst-func]{sigma=0.5,mue=0,nue=1}
%
\def\psGauss{\@ifnextchar[{\psGauss@i}{\psGauss@i[]}}
\def\psGauss@i[#1]#2#3{{%
\pst@killglue%
\psset{plotpoints=200}%
\psset{#1}%
\psplot[algebraic=false]{#2}{#3}{%
Euler x \psk@mue sub dup mul 2 div \psk@sigma dup mul div neg exp
1.0 \psk@sigma div TwoPi sqrt div mul%
}%
}\ignorespaces}
%
\define@key[psset]{pst-func}{Simpson}[5]{\def\psk@Simpson{#1 }}
\psset[pst-func]{Simpson=5}
%
\def\psGaussI{\pst@object{psGaussI}}
\def\psGaussI@i#1#2{%
\addbefore@par{plotpoints=200,plotstyle=line}
\begin@OpenObj%
\addto@pscode{
/a #1 def
/dx #2 #1 sub \psk@plotpoints\space div def
/b a dx add def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
tx@FuncDict begin
/C 1 \psk@sigma div TwoPi sqrt div def
/SFunc {% x on Stack
Euler exch \psk@mue\space sub dup mul 2 div \psk@sigma\space dup mul div neg exp C mul
} def
end
% a scx 0 moveto
a scx 0 \@nameuse{beginqp@\psplotstyle}
\psk@plotpoints 1 sub {
a b \psk@Simpson false % a b M useXval on Stack
tx@FuncDict begin Simpson I end % y value on stack
scy b scx exch \@nameuse{doqp@\psplotstyle} %lineto
/b b dx add def
} repeat
% stroke
}%
\end@OpenObj%
}
%
\def\psSi{\pst@object{psSi}}
\def\psSi@i#1#2{%
\begin@OpenObj%
\addto@pscode{
/x #1 def
/dx #2 #1 sub \psk@plotpoints\space div def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
x scx x tx@FuncDict begin Si end scy moveto
\psk@plotpoints 1 sub {
x dup scx exch tx@FuncDict begin Si end scy lineto
/x x dx add def
} repeat
stroke
}%
\end@OpenObj%
}
\def\pssi{\pst@object{pssi}}
\def\pssi@i#1#2{%
\begin@OpenObj%
\addto@pscode{
/x #1 def
/dx #2 #1 sub \psk@plotpoints\space div def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
x scx x tx@FuncDict begin si end scy moveto
\psk@plotpoints 1 sub {
x dup scx exch tx@FuncDict begin si end scy lineto
/x x dx add def
} repeat
stroke
}%
\end@OpenObj%
}
%
\def\psCi{\pst@object{psCi}}
\def\psCi@i#1#2{%
\begin@OpenObj%
\addto@pscode{
/x #1 def
/dx #2 #1 sub \psk@plotpoints\space div def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
x scx x tx@FuncDict begin Ci end scy moveto
\psk@plotpoints 1 sub {
x dup scx exch tx@FuncDict begin Ci end scy lineto
/x x dx add def
} repeat
stroke
}%
\end@OpenObj%
}
\def\psci{\pst@object{psci}}
\def\psci@i#1#2{%
\begin@OpenObj%
\addto@pscode{
/x #1 def
/dx #2 #1 sub \psk@plotpoints\space div def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
x scx x tx@FuncDict begin ci end scy moveto
\psk@plotpoints 1 sub {
x dup scx exch tx@FuncDict begin ci end scy lineto
/x x dx add def
} repeat
stroke
}%
\end@OpenObj%
}
%
\define@key[psset]{pst-func}{PSfont}[NimbusRomNo9L-Regu]{\def\psk@PSfont{/#1 }}
\define@key[psset]{pst-func}{valuewidth}[20]{\pst@getint{#1}\psk@valuewidth }
\define@key[psset]{pst-func}{fontscale}[10]{\pst@checknum{#1}\psk@fontscale }
\define@key[psset]{pst-func}{decimals}[-1]{\pst@getint{#1}\psk@decimals }
\psset[pst-func]{PSfont=NimbusRomNo9L-Regu,fontscale=10,valuewidth=20,decimals=-1}
%
\def\psPrintValue{\pst@object{psPrintValue}}
\def\psPrintValue@i#1{\expandafter\psPrintValue@ii#1,,\@nil}
\def\psPrintValue@ii#1,#2,#3\@nil{% #1,#2 only for algebraic code
\addbefore@par{algebraic=false}%
\begin@SpecialObj
\use@par
\addto@pscode{
gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont
\ifPst@algebraic
/x #1 def
/Func (#2) tx@AlgToPs begin AlgToPs end cvx def
Func
\else #1 \fi
\psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul cvi exch div } if
%\psk@valuewidth
100 string cvs %/Output exch def % save output
\ifPst@comma dot2comma \fi % do we have to change dot to comma
\psk@xShift\space 0 moveto %Output
show grestore
}%
\end@SpecialObj%
}
\define@boolkey[psset]{pst-func}[Pst@]{round}[true]{}%
\define@boolkey[psset]{pst-func}[Pst@]{science}[true]{%
\ifPst@science\def\psk@Scin{true }\else\def\psk@Scin{false }\fi}
\psset[pst-func]{science=false,round=false}
\def\psPrintValueNew{\pst@object{psPrintValueNew}}
\def\psPrintValueNew@i#1{\expandafter\psPrintValueNew@ii#1,,\@nil}
\def\psPrintValueNew@ii#1,#2,#3\@nil{% #1,#2 only for algebraic code
\begin@SpecialObj
\addto@pscode{ % thanks to Buddy Ledger
/mfont { \psk@PSfont\space findfont \psk@fontscale scalefont setfont } bind def
/mfontexp { \psk@PSfont\space findfont \psk@fontscale 1.2 div scalefont setfont } bind def
/s1 { /StandardSymbolsPS findfont \psk@fontscale scalefont setfont } bind def
\ifPst@algebraic
/x #1 def
/Func (#2) tx@AlgToPs begin AlgToPs end cvx def
Func
\else #1 \fi
/value ED
\psk@Scin {
value 0 ne { value log floor cvi /expon ED }{ /expon 0 def } ifelse
value 10 expon exp div
\psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul
\ifPst@round round \else cvi \fi exch div } if
\psk@decimals 0 eq { cvi } if /numb ED
expon \psk@valuewidth string cvs /expon exch def
numb \psk@valuewidth string cvs
\ifPst@comma dot2comma \fi % do we have to change dot to comma
/Output exch def
/txspc \psk@fontscale 4 div def
\psk@xShift\space 0 moveto mfont Output show
txspc 0 rmoveto s1 (\string\264) show
txspc 0 rmoveto mfont (10) show
txspc 2 div txspc 1.5 mul rmoveto mfontexp expon show }
{ value
\psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul
\ifPst@round round \else cvi \fi exch div } if
\psk@decimals 0 eq { cvi } if %inserted to handle decimals=0
\psk@valuewidth string cvs
\ifPst@comma dot2comma \fi % do we have to change dot to comma
\psk@xShift\space 0 moveto mfont %Output
show
} ifelse
}%
\end@SpecialObj%
}
%
% Integrals 2006-01-16
% Jose-Emilio Vila-Forcen, Herbert Voss
%
\def\psCumIntegral{\pst@object{psCumIntegral}}
\def\psCumIntegral@i#1#2#3{%
\begin@OpenObj%
\addto@pscode{
/a #1 def
/dx #2 #1 sub \psk@plotpoints\space div def
/b a dx add def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
tx@FuncDict begin
/SFunc \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else { #3 } \fi def
end
a scx 0 moveto
\psk@plotpoints 1 sub {
a b \psk@Simpson\space \ifPst@algebraic true \else false \fi % a b M useX on Stack
tx@FuncDict begin Simpson I end % y value on stack
scy b scx exch lineto
/b b dx add def
} repeat
% stroke
}%
% \psk@fillstyle%
% \pst@stroke%
\end@OpenObj%
}
%
\def\psIntegral{\pst@object{psIntegral}}
\def\psIntegral@i#1#2(#3,#4)#5{%
\begin@OpenObj%
\addto@pscode{
/a #3 def
/dx #4 #3 sub \psk@plotpoints\space div def
/b #4 def
/aa #1 def
/dd #2 #1 sub \psk@plotpoints\space div def
/t aa dd add def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
tx@FuncDict begin /SFunc { t #5 } def end
a b \psk@Simpson false % a b M useX on Stack
tx@FuncDict begin Simpson I end % y value on stack
scy t scx exch moveto
/t t dd add def
\psk@plotpoints 1 sub {
a b \psk@Simpson false % a b M useXon Stack
tx@FuncDict begin Simpson I end % y value on stack
scy t scx exch lineto
/t t dd add def
} repeat
% stroke
}%
% \psk@fillstyle%
% \pst@stroke%
\end@OpenObj%
}
%
\def\psConv{\@ifnextchar[{\psConv@i}{\psConv@i[]}}
\def\psConv@i[#1]#2#3(#4,#5)#6#7{%
\psIntegral[#1]{#2}{#3}(#4,#5){pop pop xVal #6\space xVal t neg add #7\space mul}%
}%
%
\define@key[psset]{pst-func}{PrintVLimit}[1e-6]{\def\psFunc@PrintVLimit{#1 }}
\define@key[psset]{pst-func}{Switch2Log}[80]{\def\psFunc@Switch2Log{#1 }}
\define@boolkey[psset]{pst-func}[Pst@]{printValue}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{LineEnding}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{VLines}[true]{}
\define@key[psset]{pst-func}{barwidth}[1]{\def\psFunc@barwidth{#1 }}% a factor, not a dimen
\define@key[psset]{pst-func}{rightEnd}[2]{\def\psFunc@rightEnd{#1 }}
\define@key[psset]{pst-func}{leftEnd}[2]{\def\psFunc@leftEnd{#1 }}
\define@key[psset]{pst-func}{labelangle}[90]{\def\psFunc@langle{#1 }}
\define@key[psset]{pst-func}{xlabelsep}[0]{\def\psFunc@xlabelsep{#1 }}
\define@key[psset]{pst-func}{radiusout}[2]{\def\psFunc@radiusout{#1 }}
\define@key[psset]{pst-func}{radiusinL}[0]{\def\psFunc@radiusinL{#1 }}
\define@key[psset]{pst-func}{radiusinR}[1.5]{\def\psFunc@radiusinR{#1 }}
\define@key[psset]{pst-func}{LabelColor}[black]{\pst@getcolor{#1}\psk@LabelColor}
\define@key[psset]{pst-func}{LineEndColorL}[green]{\pst@getcolor{#1}\psk@LineEndColorL}
\define@key[psset]{pst-func}{LineEndColorR}[red]{\pst@getcolor{#1}\psk@LineEndColorR}
\define@key[psset]{pst-func}{fillcolorA}[blue!40]{\pst@getcolor{#1}\psk@fillcolorA}
\define@key[psset]{pst-func}{fillcolorB}[red!40]{\pst@getcolor{#1}\psk@fillcolorB}
\define@key[psset]{pst-func}{vlinestyle}[solid]{\def\psvlinestyle{#1}}
\def\psfs@alternateColors{}
\def\pst@alternateColors{alternateColors}
%
\psset[pst-func]{printValue=false,barwidth=1,labelangle=90,xlabelsep=0,LabelColor=black,LineEndColorL=green,LineEndColorR=red,radiusout=2, radiusinL=0,radiusinR=1.5,LineEnding=true,leftEnd=1,rightEnd=2,VLines=false,
fillcolorA=blue!40,fillcolorB=red!40,PrintVLimit=1e-64,Switch2Log=80}
%
\def\psBinomial{\pst@object{psBinomial}}
\def\psBinomial@i#1#2{\psBinomial@ii#1,,,\@nil{#2}}%
\def\psBinomial@ii#1,#2,#3,#4\@nil#5{%
\def\pst@tempA{#2}%
\ifx\pst@tempA\@empty
\psBinomial@iii{0}{#1}{#1}{#5}%
\else
\def\pst@tempA{#3}%
\ifx\pst@tempA\@empty\psBinomial@iii{#1}{#2}{#2}{#5}%
\else\psBinomial@iii{#1}{#2}{#3}{#5}\fi
\fi}
%
\def\psBinomial@iii#1#2#3#4{%
\addbefore@par{valuewidth=15}%
\begin@OpenObj
\addto@pscode{%
/toggle false def
\ifx\psk@fillstylename\pst@alternateColors
/ColA { \pst@usecolor\psk@fillcolorA } def
/ColB { \pst@usecolor\psk@fillcolorB } def
\fi
/ValueSwitch2Log \psFunc@Switch2Log\space def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
/m #1 def
/n #2 def
/N #3 def
/p #4 def
/dx \psFunc@barwidth 2 div def
/q 1 p sub def
/kOld dx neg m add def
kOld scx 0 moveto % starting point#
%%----------------------------------------------------------------------------------------------------------------------------------------------------------------
%%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque ---------------------------------------------
/SumLog {% log(1) + log(2) + ... + log(n) = log(n!)
2 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n
/nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert
/iV 1 def % Startwert ist iV=1
0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n) Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen
end
} def
/binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)]
2 dict begin
/nV exch def
/NV exch def
NV SumLog nV SumLog sub
NV nV sub SumLog sub
end
} def
/PnN {
3 dict begin
/pV exch def
/nV exch def
/NV exch def
10
NV nV binomial_comb
nV pV log mul
NV nV sub 1 pV sub log mul add add
exp
end
} def
%%------------------------------------------------------------------------------------------------
%%------------------------------------------------------------------------------------------------
N ValueSwitch2Log gt
{ }
{ 0 1 m 1 sub
{%
/k exch def % save loop variable
k 0 eq
{ /Y q N exp def }
{ /Y Y N k sub 1 add mul k div p mul q div def }
ifelse
} for
} ifelse
m 1 n {% % n-m+1 times
/k exch def % save loop variable
N ValueSwitch2Log gt
{ N k p PnN /Y exch def }
{ k 0 eq
{ /Y q N exp def }
{ /Y Y N k sub 1 add mul k div p mul q div def }
ifelse
}
ifelse % recursive definition
\ifx\psk@fillstylename\pst@alternateColors
newpath
kOld scx 0 moveto
\fi
kOld scx Y scy L k dx add scx Y scy L
\ifPst@markZeros k dx add scx 0 L kOld 1 add scx 0 L \fi
\ifx\psk@fillstylename\pst@alternateColors
closepath
gsave toggle {ColA}{ColB} ifelse \tx@setTransparency fill grestore
/toggle toggle not def
\fi
\ifPst@printValue
gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor %
Y \psFunc@PrintVLimit le { () } { Y \psk@valuewidth\space string cvs } ifelse
\ifPst@comma dot2comma \fi
k scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add
Y scy \pst@number\pslabelsep add moveto
\psFunc@langle rotate show grestore
\fi
/kOld kOld 1 add def
} for
\ifPst@markZeros\else k dx add scx 0 L \fi % last line down to x-axis
}%
% \psk@fillstyle
% \pst@stroke
\end@OpenObj
}%
%
%
\def\psBinomialN{\pst@object{psBinomialN}}%
\def\psBinomialN@i#1#2{%
\leavevmode
\pst@killglue
\begingroup
\use@par
\init@pscode
\def\cplotstyle{curve}%
\ifx\psplotstyle\cplotstyle \@nameuse{beginplot@\psplotstyle}\fi
\addto@pscode{%
\ifx\psplotstyle\cplotstyle /Curve true def \else /Curve false def \fi
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
/N #1 def
/p #2 def % probability
/q 1 p sub def
/E N p mul def
/sigma E q mul sqrt def % variant
/dx 1.0 sigma div 2 div def
/xOld dx neg E sub sigma div def
/xEnd xOld neg dx add scx def
Curve
{ /Coors [xOld dx sub scx 0] def }% saves the coordinates for curve
{ xOld scx 0 moveto } % starting point
ifelse
0 1 N {% % N times
/k exch def % save loop variable
k 0 eq
{ /Y q N exp def }
{ /Y Y N k sub 1 add mul k div p mul q div def }
ifelse % recursive definition
/x k E sub sigma div dx add def
/y Y sigma mul def % normalize
Curve
{ x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def}
{ xOld scx y scy L x scx y scy L
\ifPst@markZeros x scx 0 L \fi %
} ifelse
\ifPst@printValue
gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor %
y \psk@valuewidth string cvs %/Output exch def
\ifPst@comma dot2comma \fi % do we have to change dot to comma
x dx sub scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add
y scy \pst@number\pslabelsep add moveto
\psFunc@langle rotate show grestore
\fi
/xOld x def
} for
Curve { [ xEnd 0 Coors aload pop } if% showpoints on top of the stack
}%
\ifx\psplotstyle\cplotstyle\@nameuse{endplot@\psplotstyle}\else
\psk@fillstyle
\pst@stroke
\fi
\use@pscode
\endgroup
\ignorespaces
}%
\def\psBinomialF{\pst@object{psBinomialF}}
\def\psBinomialF@i#1#2{\psBinomialF@ii#1,,,\@nil{#2}}%
\def\psBinomialF@ii#1,#2,#3,#4\@nil#5{%
\def\pst@tempA{#2}%
\ifx\pst@tempA\@empty
\psBinomialF@iii{0}{#1}{#1}{#5}%
\else
\def\pst@tempA{#3}%
\ifx\pst@tempA\@empty\psBinomialF@iii{#1}{#2}{#2}{#5}%
\else\psBinomialF@iii{#1}{#2}{#3}{#5}\fi
\fi}%
\def\psBinomialF@iii#1#2#3#4{%
\addbefore@par{valuewidth=15}%
\begin@OpenObj
\addto@pscode{%
/ValueSwitch2Log \psFunc@Switch2Log\space def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
/m #1 def
/n #2 def
/N #3 def
/p #4 def
/dx \psFunc@barwidth 2 div def
/q 1 p sub def
\ifPst@markZeros /kOld dx neg m add def \else
/kOld m def \fi
\psFunc@leftEnd 0 eq
{ }
{ kOld 0 eq
{ kOld \psFunc@leftEnd sub scx 0 moveto % starting point
\ifPst@LineEnding
kOld \psFunc@radiusout\pst@number\psxunit div sub scx 0 L stroke
kOld scx 0 newpath \psFunc@radiusout 0 360 arc kOld scx 0
\psFunc@radiusinR 360 0 arcn closepath \pst@usecolor\psk@LineEndColorR fill
\else
kOld scx 0 L stroke
\fi
}{ } ifelse } ifelse
kOld scx 0 moveto % starting point
%%----------------------------------------------------------------------------------------------------------------------------------------------------------------
%%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque ---------------------------------------------
/SumLog {% log(1) + log(2) + ... + log(n) = log(n!)
2 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n
/nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert
/iV 1 def % Startwert ist iV=1
0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n) Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen
end
} def
/binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)]
2 dict begin
/nV exch def
/NV exch def
NV SumLog nV SumLog sub
NV nV sub SumLog sub
end
} def
/PnN {
3 dict begin
/pV exch def
/nV exch def
/NV exch def
10
NV nV binomial_comb
nV pV log mul
NV nV sub 1 pV sub log mul add add
exp
end
} def
%%------------------------------------------------------------------------------------------------
%%------------------------------------------------------------------------------------------------
0 1 m 1 sub {
/k exch def % save loop variable
N ValueSwitch2Log gt { k 0 eq
{ N k p PnN /Y exch def /F Y def }
{ N k p PnN /Y exch def /F F Y add def }
ifelse
}{ k 0 eq
{ /Y q N exp def /F Y def }
{ /Y Y N k sub 1 add mul k div p mul q div def
/F F Y add def
} ifelse
} ifelse
} for
m 1 n { % n-m+1 times
/k exch def % save loop variable
N ValueSwitch2Log gt
{ k 0 eq
{ N k p PnN /Y exch def /F Y def }
{ N k p PnN /Y exch def /F F Y add def }
ifelse }
{ k 0 eq
{ /Y q N exp def /F Y def }
{ /Y Y N k sub 1 add mul k div p mul q div def /F F Y add def
} ifelse
} ifelse % recursive definition
F 1 gt { /F 1 def } if
\ifPst@markZeros kOld scx F scy L k dx add scx F scy L k dx add scx 0 L kOld 1 add scx 0 L
\else
kOld scx F scy newpath \psFunc@radiusout 0 360 arc kOld scx F scy \psFunc@radiusinL 360 0 arcn closepath \pst@usecolor\psk@LineEndColorL fill
kOld \ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div add \fi
scx F scy moveto
k 1 add
\ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div sub \fi
k N eq
{ \psFunc@rightEnd add }
{ } ifelse
scx F scy L \pst@usecolor\pslinecolor [1 0] 0 setdash stroke
\ifPst@LineEnding
k N eq
{ }
{ k 1 add scx F scy newpath \psFunc@radiusout 0 360 arc k 1 add scx F scy \psFunc@radiusinR 360 0 arcn closepath \pst@usecolor\psk@LineEndColorR fill }
ifelse
\ifPst@VLines
Y \psFunc@radiusout\pst@number\psyunit div 2 mul le
{ }
{ k scx F Y sub \psFunc@radiusout\pst@number\psyunit div add scy moveto k scx F \psFunc@radiusout\pst@number\psyunit div sub scy L \pst@usecolor\pslinecolor [3 2] 0 setdash stroke } ifelse \fi
\else
\ifPst@VLines
Y \psFunc@radiusout\pst@number\psyunit div 0.1 mul le
{ }
{ k scx F Y sub scy moveto k scx F scy L \pst@usecolor\pslinecolor [3 2] 0 setdash stroke } ifelse
\fi\fi\fi
\ifPst@printValue
gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor %
Y \psFunc@PrintVLimit le { () } { F \psk@valuewidth\space string cvs } ifelse
\ifPst@comma dot2comma \fi
k scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add
F scy \pst@number\pslabelsep add moveto
\psFunc@langle rotate show grestore
\fi
/kOld kOld 1 add def
} for
}%
\end@OpenObj%
}%
%
\def\psBinomialFS{\pst@object{psBinomialFS}}
\def\psBinomialFS@i#1#2{\psBinomialFS@ii#1,,,\@nil{#2}}%
\def\psBinomialFS@ii#1,#2,#3,#4\@nil#5{%
\def\pst@tempA{#2}%
\ifx\pst@tempA\@empty
\psBinomialFS@iii{0}{#1}{#1}{#5}%
\else
\def\pst@tempA{#3}%
\ifx\pst@tempA\@empty\psBinomialFS@iii{#1}{#2}{#2}{#5}%
\else\psBinomialFS@iii{#1}{#2}{#3}{#5}\fi
\fi}%
\def\psBinomialFS@iii#1#2#3#4{%
\addbefore@par{valuewidth=15}%
\begin@OpenObj
\addto@pscode{%
/ValueSwitch2Log \psFunc@Switch2Log\space def
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
/m #1 def
/n #2 def
/N #3 def
/p #4 def
/dx \psFunc@barwidth 2 div def
/q 1 p sub def
\ifPst@markZeros /kOld dx neg m add def \else
/kOld m def \fi
kOld scx 0 moveto % starting point
%%----------------------------------------------------------------------------------------------------------------------------------------------------------------
%%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque ---------------------------------------------
/SumLog {% log(1) + log(2) + ... + log(n) = log(n!)
2 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n
/nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert
/iV 1 def % Startwert ist iV=1
0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n) Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen
end
} def
/binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)]
2 dict begin
/nV exch def
/NV exch def
NV SumLog nV SumLog sub
NV nV sub SumLog sub
end
} def
/PnN {
3 dict begin
/pV exch def
/nV exch def
/NV exch def
10
NV nV binomial_comb
nV pV log mul
NV nV sub 1 pV sub log mul add add
exp
end
} def
%%------------------------------------------------------------------------------------------------
0 1 m 1 sub {
/k exch def % save loop variable
N ValueSwitch2Log gt { k 0 eq
{ N k p PnN /Y exch def /F Y def /FS 1 F sub def }
{ N k p PnN /Y exch def /F F Y add def /FS 1 F sub def }
ifelse }
{ k 0 eq
{ /Y q N exp def /F Y def /FS 1 F sub def }
{ /Y Y N k sub 1 add mul k div p mul q div def
/F F Y add def /FS 1 F sub def }
ifelse } ifelse
} for
m 1 n { % n-m+1 times
/k exch def % save loop variable
N ValueSwitch2Log gt { k 0 eq
{ N k p PnN /Y exch def /F Y def /FS 1 F sub def }
{ N k p PnN /Y exch def /F F Y add def /FS 1 F sub def } ifelse }
{ k 0 eq
{ /Y q N exp def /F Y def /FS 1 F sub def }
{ /Y Y N k sub 1 add mul k div p mul q div def
/F F Y add def /FS 1 F sub def }
ifelse
} ifelse % recursive definition
FS 0 lt { /FS 0 def } if
\ifPst@markZeros kOld scx FS scy L k dx add scx FS scy L k dx add scx 0 L kOld 1 add scx 0 L
\else
\ifPst@LineEnding
k 0 eq
{ \psFunc@leftEnd neg scx 1 scy moveto \psFunc@radiusout neg 1 scy L gsave \pst@usecolor\pslinecolor stroke grestore } if
k m eq {kOld scx \psFunc@radiusout add FS Y add scy moveto kOld scx FS Y add scy newpath \psFunc@radiusout 0 360 arc kOld scx FS Y add scy \psFunc@radiusinR 360 0 arcn closepath
gsave \pst@usecolor\psk@LineEndColorR fill grestore } if
kOld scx FS scy newpath \psFunc@radiusout 0 360 arc kOld scx FS scy \psFunc@radiusinL 360 0 arcn closepath \pst@usecolor\psk@LineEndColorL fill % } ifelse
\fi
kOld \ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div add \fi
% k 0 eq
% { \psFunc@leftEnd sub }
% { } ifelse
scx FS scy moveto
k 1 add
\ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div sub \fi
k N eq
{ \psFunc@rightEnd add }
{ } ifelse
scx FS scy L \pst@usecolor\pslinecolor [1 0] 0 setdash stroke
\ifPst@LineEnding
k N eq
{ }
{ k 1 add scx FS scy newpath \psFunc@radiusout 0 360 arc k 1 add scx FS scy \psFunc@radiusinR 360 0 arcn closepath \pst@usecolor\psk@LineEndColorR fill }
ifelse
\ifPst@VLines
Y \psFunc@radiusout\pst@number\psyunit div 2 mul le
{ }
{ k scx FS Y add \psFunc@radiusout\pst@number\psyunit div sub scy moveto k scx FS \psFunc@radiusout\pst@number\psyunit div add scy L \pst@usecolor\pslinecolor [3 2] 0 setdash stroke } ifelse \fi
\else
\ifPst@VLines
Y \psFunc@radiusout\pst@number\psyunit div 0.1 mul le
{ }
{ k scx FS Y add scy moveto k scx FS scy L \pst@usecolor\pslinecolor [3 2] 0 setdash stroke } ifelse
\fi\fi\fi
\ifPst@printValue
gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor %
Y \psFunc@PrintVLimit le { () } { FS \psk@valuewidth\space string cvs } ifelse
\ifPst@comma dot2comma \fi
k 0.1 add scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add
FS scy \pst@number\pslabelsep add moveto
\psFunc@langle rotate show grestore
\fi
/kOld kOld 1 add def
} for
}%
\end@OpenObj
}%
%
%
\define@key[psset]{pst-func}{LeftClipX}[-1]{\def\psFunc@LeftClipX{#1 }}
\define@key[psset]{pst-func}{RightClipX}[-1]{\def\psFunc@RightClipX{#1 }}
\psset[pst-func]{LeftClipX=-1,RightClipX=1}
\def\psBinomialC{\pst@object{psBinomialC}}
\def\psBinomialC@i#1#2{%
\leavevmode
\pst@killglue
\begingroup
\use@par
\begin{psclip}%
{\psframe[linestyle=none,fillstyle=none](\psFunc@LeftClipX,-0.1)(!#1 \psFunc@RightClipX\space add 1)}%
% \use@par
\init@pscode
\beginplot@cspline
% \addto@pscode{/D {} def mark}%
\addto@pscode{%
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
/N #1 def
/p #2 def % Wahrscheinlichkeit
/q 1 p sub def % q = 1 - p
/E N p mul def % Erwartungswert
/sigma E q mul sqrt def % Varianz
/dx 1.0 2 div def
/xOld dx neg 3 sub def
/xEnd 0 def
/Coors [xOld dx sub scx 0] def % speichern der Koordinaten f\"{u}r den Spline
%%----------------------------------------------------------------------------------------------------------------------------------------------------------------
%%-------------------- Code, der \"{u}ber den Logarithmus arbeitet von Manuel Luque ---------------------------------------------
/SumLog {% log(1) + log(2) + ... + log(n) = log(n!)
2 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n
/nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert
/iV 1 def % Startwert ist iV=1
0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n)
%Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen
end
} def
/binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)]
2 dict begin
/nV exch def
/NV exch def
NV SumLog nV SumLog sub
NV nV sub SumLog sub
end
} def
/PnN {
3 dict begin
/pV exch def
/nV exch def
/NV exch def
10
NV nV binomial_comb
nV pV log mul
NV nV sub 1 pV sub log mul add add
exp
end
} def
%%------------------------------------------------------------------------------------------------
%%------------------------------------------------------------------------------------------------
%------------------------------- 3 Punkte um die Kurve links auf Null zu bringen mit dem weiter oben gew\"{a}hlten Startwert sind es also 4 ------------
/x -2 dx add def
/y 0 def
x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
/x -0.65 dx add def
/y N 0 p PnN 10 -1.3 exp mul def
x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
/x -0.375 dx add def
/y N 0 p PnN 3 div def
x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
%---------------------------- Ende der 3 Punkte und Beginn eigentlicher Code ----------------
0 1 N {% % Schleife geht von 0 bis N in 1-er Schritten
/k exch def % save loop variable
N k p PnN /Y exch def
/x k dx add def
/y Y def
x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
/xOld x def
} for
%--------------------------- Ende des eigentlichen Codes und Beginn von ---
%------------------------------- 4 Punkte um die Kurve rechts auf Null zu bringen -----------
/x N 0.375 add dx add def
/y Y 3 div def
x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
/x N 0.65 add dx add def
/y Y 10 -1.3 exp mul def
x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
/x N 2 add dx add def
/y 0 def
x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
/x N 3 add dx add def
/y 0 def
x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
%---------------------------- Ende der 4 Punkte und Laden der Koordinaten des arrays ; L\"{o}schen (pop) von showpoints??----------------------
[ xEnd 1 add 0 Coors aload pop % showpoints on top of the stack
}%
\endplot@cspline
\use@pscode
\end{psclip}%
\endgroup
\ignorespaces}%
%
\def\psPoisson{\pst@object{psPoisson}}% with contributions from Gerry Coombes
\def\psPoisson@i#1#2{\psPoisson@ii#1,,\@nil{#2}}%
\def\psPoisson@ii#1,#2,#3\@nil#4{%
\def\pst@tempA{#2}%
\ifx\pst@tempA\@empty\psPoisson@iii{0}{#1}{#4}\else
\psPoisson@iii{#1}{#2}{#4}\fi}%
\def\psPoisson@iii#1#2#3{% M N lambda
\begin@OpenObj%
\addto@pscode{
/scx { \pst@number\psxunit mul } def
/scy { \pst@number\psyunit mul } def
/M #1 def
/N #2 def
/lambda #3 def
/elambda Euler #3 neg exp def % e^-lambda
/dx \psFunc@barwidth 2 div def
/kOld dx neg M add def % addition of M here
kOld scx 0 moveto % starting point
/Y elambda def % start value
0 1 M 1 sub { % skip over first M-1 rectangles
/k exch def % whilst recursing probabilities
k 0 eq { /Y elambda def }{ /Y Y lambda mul k div def } ifelse
} for % nothing happens if M=0
M 1 N { % N-M+1 times
/k exch def % save loop variable
k 0 eq { /Y elambda def }{ /Y Y lambda mul k div def } ifelse
kOld scx Y scy L k dx add scx Y scy L
\ifPst@markZeros k dx add scx 0 L \fi
\ifPst@printValue
gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont
Y \psk@valuewidth string cvs %/Output exch def
\ifPst@comma dot2comma \fi % do we have to change dot to comma
k scx \psk@fontscale 2 div add
Y scy \pst@number\pslabelsep add moveto
90 rotate show grestore
\fi
/kOld kOld 1 add def
\ifPst@markZeros kOld scx 0 moveto \fi
} for
\ifPst@markZeros \else k dx add scx 0 L \fi % last line down to x-axis
}%
% \psk@fillstyle
% \pst@stroke
\end@OpenObj%
}
%
\define@key[psset]{pst-func}{alpha}[0.5]{\pst@checknum{#1}\psk@alpha }
\define@key[psset]{pst-func}{beta}[0.5]{\pst@checknum{#1}\psk@beta }
\psset[pst-func]{alpha=0.5,beta=0.5}
%
\def\psGammaDist{\pst@object{psGammaDist}}
\def\psGammaDist@i#1#2{%
\ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!}
\else
\addbefore@par{plotpoints=500,alpha=0.5,beta=0.5}%
\begin@OpenObj
\psplot[algebraic=false]{#1}{#2}{
\psk@beta x mul \psk@alpha exp x div Euler \psk@beta neg x mul \psk@alpha GAMMALN sub exp mul}
\end@OpenObj%
\fi%
\ignorespaces%
}
%
\def\psBetaDist{\pst@object{psBetaDist}}
\def\psBetaDist@i#1#2{%
\ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!}
\else
\begingroup
\addbefore@par{plotpoints=200,alpha=1,beta=1}%
\addto@par{algebraic=false}%
% \begin@OpenObj
\use@par
\psplot{#1}{#2}{
\psk@beta \psk@alpha add GAMMA
\psk@beta GAMMA \psk@alpha GAMMA mul div
1 x sub \psk@beta 1.0 sub exp mul
x \psk@alpha 1.0 sub exp mul }
% \end@OpenObj%
\endgroup
\fi%
\ignorespaces%
}
%
\def\psChiIIDist{\pst@object{psChiIIDist}}
\def\psChiIIDist@i#1#2{%
\addbefore@par{plotpoints=500,nue=1}%
\begin@OpenObj
% \ifdim\psk@nue pt<\z@ \psframebox*{\color{red}!!!nue must be greater than 0!!!}
% \else
\psplot[algebraic=false]{#1}{#2}{%
x 2 div \psk@nue 2 div exp x div Euler -0.5 x mul \psk@nue 2 div GAMMALN sub exp mul }%
% \fi%
\end@OpenObj%
\ignorespaces%
}
%
\def\psTDist{\pst@object{psTDist}}
\def\psTDist@i#1#2{%
\leavevmode
\pst@killglue
\begingroup
\addbefore@par{plotpoints=500}%
\use@par
\ifdim\psk@nue pt<\z@ \psframebox*{\color{red}!!!nue must be greater than 0!!!}
\else
\psplot[algebraic=false]{#1}{#2}{
1 x 2 exp \psk@nue div 1 add \psk@nue 1 add 2 div exp div
\psk@nue Pi mul sqrt div
Euler \psk@nue 1 add 2 div GAMMALN \psk@nue 2 div GAMMALN sub exp mul
}%
\fi%
\endgroup%
\ignorespaces%
}
\define@key[psset]{pst-func}{lambda}[1]{\def\psk@lambda{#1 }}
\psset[pst-func]{lambda=0.5}
\def\psNonCentralTDist{\pst@object{psNonCentralTDist}}
\def\psNonCentralTDist@i#1#2{%
\leavevmode
\pst@killglue
\begingroup
\addbefore@par{plotpoints=500}%
\use@par
\ifdim\psk@nue pt<\z@ \psframebox*{\color{red}!!!nue must be greater than 0!!!}
\else
\psplot[algebraic=false]{#1}{#2}{% P(x) = a ( b/c + d/e )
\psk@nue dup 2 div exp \psk@nue factorial mul % nominator of a
2 \psk@nue exp Euler \psk@lambda dup mul 2 div exp mul
\psk@nue x dup mul add \psk@nue 2 div exp mul
\psk@nue 2 div GAMMA mul % denominator of a
div % a
2 sqrt \psk@lambda mul x mul
\psk@nue 2 div 1 add
1.5
\psk@lambda dup mul x dup mul mul 2 div \psk@nue x dup mul add div
tx@FuncDict begin ConfHyperFunc end % Confluent Hypergeometric Funtion of the First Kind
mul % b
\psk@nue x dup mul add \psk@nue 1 add 2 div GAMMA mul % c
div % b/c
\psk@nue 1 add 2 div 0.5 \psk@lambda dup mul x dup mul mul 2 div \psk@nue x dup mul add div
tx@FuncDict begin ConfHyperFunc end % d
\psk@nue x dup mul add sqrt \psk@nue 2 div 1 add GAMMA mul % e
div % d/e
add % b/c + d/e
mul % (b/c + d/e) * a
}%
\fi
\endgroup
\ignorespaces
}
%
\def\psFDist{\pst@object{psFDist}}
\def\psFDist@i#1#2{%
\ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!}
\else
\leavevmode
\pst@killglue
\begingroup
\addbefore@par{plotpoints=500,mue=1}%
\use@par
\psplot[algebraic=false]{#1}{#2}{
x \psk@mue mul \psk@nue div dup \psk@mue 2 div exp x div
exch 1 add \psk@mue \psk@nue add 2 div exp div
Euler \psk@mue \psk@nue add 2 div GAMMALN
\psk@mue 2 div GAMMALN sub \psk@nue 2 div GAMMALN sub exp mul
}%
\endgroup%
\fi%
\ignorespaces%
}
%
\def\psNonCentralFDist{\pst@object{psNonCentralFDist}}
\def\psNonCentralFDist@i#1#2{%
\ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!}
\else
\leavevmode
\pst@killglue
\begingroup
\addbefore@par{plotpoints=500,nue=1,mue=1,lambda=0,saveData=false}%
\use@par
\ifluatex
\ifPst@saveData
\luaexec{ require("pst-func")
printDataPlotFileFDist(#1,#2,\psk@plotpoints,\psk@mue,\psk@nue,\psk@lambda,"\jobname-lua","true","true") }%
\else
\luaexec{ require("pst-func")
printDataPlotFileFDist(#1,#2,\psk@plotpoints,\psk@mue,\psk@nue,\psk@lambda,"\jobname-lua","true","false") }%
\fi
% \typeout{\stringData}
\pslistplot{\stringData}%
\else
\psplot[algebraic=false]{#1}{#2}[/F_BETA \psk@mue 2 div \psk@nue 2 div tx@FuncDict begin BETA end def]{
/constA Euler \psk@lambda -2 div exp def
/Sum
constA F_BETA
div % first fraction
\psk@mue \psk@nue div \psk@mue 2 div exp
mul
\psk@nue dup \psk@mue x mul add div \psk@mue \psk@nue add 2 div exp
mul
x \psk@mue 2 div 1 sub exp
mul
def
/K 1 def
{
constA \psk@lambda 2 div K exp mul % nominator
\psk@nue 2 div \psk@mue 2 div K add tx@FuncDict begin BETA end K factorial mul % denominator
div % first fraction
\psk@mue \psk@nue div \psk@mue 2 div K add exp
mul
\psk@nue dup \psk@mue x mul add div \psk@mue \psk@nue add 2 div K add exp
mul
x \psk@mue 2 div 1 sub K add exp
mul
dup abs 1e-5 lt
{ pop exit }
{ Sum add /Sum ED
K 1 add /K ED } ifelse
K 100 ge { (Error ConfHyperFunc: K=100) == exit } if
} loop
Sum
}%
\fi
\endgroup
\fi
\ignorespaces
}
%
\define@key[psset]{pst-func}{m}[0]{\def\psk@cauchy@m{#1 }}
\define@key[psset]{pst-func}{b}[1]{\def\psk@cauchy@b{#1 }}
\psset[pst-func]{m=0,b=1}
%
\def\psCauchy{\pst@object{psCauchy}}
\def\psCauchy@i#1#2{{%
\pst@killglue%
\addbefore@par{plotpoints=200}%
\use@par%
\psplot[algebraic=false]{#1}{#2}{
\psk@cauchy@b dup dup mul x \psk@cauchy@m sub dup mul add div Pi div
}%
}\ignorespaces}
%
\def\psCauchyI{\pst@object{psCauchyI}}
\def\psCauchyI@i#1#2{{%
\pst@killglue%
\addbefore@par{plotpoints=200}%
\use@par%
\psplot[algebraic=false]{#1}{#2}{
x \psk@cauchy@m sub \psk@cauchy@b div ATAN1 DegtoRad Pi div 0.5 add
}%
}\ignorespaces}
%
\def\psWeibull{\pst@object{psWeibull}}
\def\psWeibull@i#1#2{%
\addbefore@par{plotpoints=500,alpha=1,beta=1}%
\begin@OpenObj
\def\pst@tempA{#1}%
\ifdim#1pt<\z@ \psline(#1,0)(0,0)\def\pst@tempA{0}\fi
\psplot[algebraic=false]{\pst@tempA}{#2}{
\psk@alpha \psk@beta \psk@alpha neg Power mul % alpha*beta^(-alpha)
x \psk@alpha 1 sub Power % x^(alpha-1)
mul
Euler x \psk@beta div \psk@alpha Power neg Power % e^(-(x/beta)^alpha))
mul }
\end@OpenObj%
\ignorespaces%
}
\def\psWeibullI{\pst@object{psWeibullI}}
\def\psWeibullI@i#1#2{%
\addbefore@par{plotpoints=500,alpha=1,beta=1}%
\begin@OpenObj
\def\pst@tempA{#1}%
\ifdim#1pt<\z@ \psline(#1,0)(0,0)\def\pst@tempA{0}\fi
\psplot[algebraic=false]{\pst@tempA}{#2}{
1
Euler x \psk@beta div \psk@alpha Power neg Power % e^(-(x/beta)^alpha))
sub
}%
\end@OpenObj%
\ignorespaces%
}
%
\define@key[psset]{pst-func}{pd}[0.22]{\pst@checknum{#1}\psk@probability }
\define@key[psset]{pst-func}{R2}[0.11]{\pst@checknum{#1}\psk@portfolio }
\psset[pst-func]{pd=0.22,R2=0.11}
%
\def\psVasicek{\pst@object{psVasicek}}
\def\psVasicek@i#1#2{%
\addbefore@par{plotpoints=500}%
\begin@OpenObj
\psplot{#1}{#2}[/pd \psk@probability\space def /R2 \psk@portfolio\space def ]{x tx@FuncDict begin vasicek end}
\end@OpenObj%
\ignorespaces%
}
\define@boolkey[psset]{pst-func}[Pst@]{Gini}[true]{}
\psset[pst-func]{Gini=false}
%
\def\psLorenz{\def\pst@par{}\pst@object{psLorenz}}
\def\psLorenz@i{\@ifnextchar<\psLorenz@ii{\psLorenz@ii<>}}
\def\psLorenz@ii<#1>#2{%
\if@star\addto@par{fillstyle=solid,fillcolor=\pslinecolor}\fi
\begingroup
\use@par
\def\Lorenz@code{
25 dict begin
[ #2 ] dup length /nVal ED
bubblesort /Yval ED
Yval arraySum /Ysum ED
Yval { Ysum div } forall nVal array astore /YvalRel ED % Pred dist
\if$#1$
/temp {1 nVal div} bind def
[ nVal { temp } repeat ] /XvalRel ED
[ 1 1 nVal { nVal div } for ] /XvalRelCum ED
%YvalRel bubblesort /YvalRel ED
\else
[ #1 ] /Xval ED
Xval arraySum /Xsum ED
Xval { Xsum div } forall nVal array astore /XvalRel ED % Freq dist
/CumFreq 0 def
[
0 1 nVal 1 sub {
XvalRel exch get CumFreq add dup /CumFreq ED
} for
] /XvalRelCum ED
% XvalRelCum ==
\fi
/CumPred 0 def
[
0 1 nVal 1 sub {
YvalRel exch get CumPred add dup /CumPred ED
} for
] /YvalRelCum ED
% YvalRelCum ==
% Xsum == Ysum ==
\ifPst@Gini
[ 0 1 nVal 1 sub {
/Index ED
YvalRelCum Index get
Index 0 eq { 0 }{ YvalRelCum Index 1 sub get } ifelse
add 0.5 mul XvalRel Index get mul
} for
] /Area ED
% Area ==
Area arraySum /B ED
0.5 B sub dup B add div
\psk@PSfont\space findfont \psk@fontscale scalefont setfont
\psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul cvi exch div } if
\psk@valuewidth string cvs %/Output exch def % save output
\ifPst@comma dot2comma \fi % do we have to change dot to comma
/Output ED
\psk@xShift\space -30 moveto (Gini: ) show
Output show
\fi
0 0 % the start point
0 1 nVal 1 sub { dup XvalRelCum exch get exch YvalRelCum exch get } for
% pstack
\if@star 1 0 0 0 \fi % add values for the closed curve
end
}% filling the area under the curve.
\if@star\listplot*{\Lorenz@code}\else\listplot{\Lorenz@code}%
% \listplot[plotstyle=bezier,linecolor=red]{\Lorenz@code}
\fi
\endgroup
\ignorespaces}
%
% Superellipese / Lamefunction
\define@key[psset]{pst-func}{radiusA}[1]{\pst@getlength{#1}\pst@radiusA}
\define@key[psset]{pst-func}{radiusB}[1]{\pst@getlength{#1}\pst@radiusB}
\define@key[psset]{pst-func}{endAngle}[0]{\pst@getangle{#1}\psk@endAngle}
\psset[pst-func]{radiusA=1,radiusB=1,endAngle=0}% startAngle is defined in PSTricks
%
\def\psLame{\pst@object{psLame}}
\def\psLame@i#1{%
\leavevmode
\pst@killglue
\begingroup
\addbefore@par{plotpoints=200,startAngle=0,endAngle=360,algebraic=false}%
\use@par
\parametricplot{\psk@startAngle}{\psk@endAngle}{%
t cos dup mul 1 #1\space div exp \pst@radiusA \pst@number\psxunit div mul
t 90 gt { t 270 lt { neg } if } if
t sin dup mul 1 #1\space div exp \pst@radiusB \pst@number\psyunit div mul
t 180 gt { neg } if }
\endgroup
\ignorespaces
}
%
\def\psWeierstrass{\pst@object{psWeierstrass}}
\def\psWeierstrass@i(#1,#2){\@ifnextchar[{\psWeierstrass@ii(#1,#2)}{\psWeierstrass@iii(#1,#2)}}
\def\psWeierstrass@ii(#1,#2)[#3]#4{% #1 xStart; #2 xEnd; #3 a; #4 b %% the original definition
\addbefore@par{plotpoints=500}%
\begin@SpecialObj
\psplot{#1}{#2}[/ps@a #3 def /ps@b #4 def]{
/ps@n 0 def
/ps@WS 0 def
{
ps@a ps@n exp ps@b ps@n exp Pi mul x mul RadtoDeg cos mul
dup abs \psk@epsilon gt { ps@WS add /ps@WS ED }{ ps@WS add exit } ifelse
ps@n 1 add /ps@n ED
} loop
}%
\end@SpecialObj
}
\def\psWeierstrass@iii(#1,#2)#3{% #1 xStart; #2 xEnd; #3 a
\addbefore@par{plotpoints=500}%
\begin@SpecialObj
\psplot{#1}{#2}[/ps@a #3 def]{
/ps@k 1 def
/ps@WS 0 def
{
ps@k ps@a exp Pi mul dup x mul RadtoDeg sin exch div
dup abs \psk@epsilon gt { ps@WS add /ps@WS ED }{ ps@WS add exit } ifelse
ps@k 1 add /ps@k ED
} loop
}%
\end@SpecialObj
}
%
% For polar plots
%\define@boolkey[psset]{pst-func}[PstAdd@]{polarplot}[true]{}
%\psset[pst-func]{polarplot=false}
%
%\define@boolkey[psset]{pstricks-add}[Pst@]{GetFinalState}[true]{}
%\define@key[psset]{pstricks-add}{filename}{\def\psk@filename{#1}}%
%\define@boolkey[psset]{pstricks-add}[Pst@]{saveData}[true]{} % \ifPst@saveData
%\psset[pstricks-add]{GetFinalState=false,saveData=false,filename=PSTdata}
%
\define@key[psset]{pst-func}{stepFactor}[0.67]{\pst@checknum{#1}\psk@stepFactor }
\psset[pst-func]{stepFactor=0.67}
%
\def\psplotImp{\pst@object{psplotImp}}% 20060420
\def\psplotImp@i(#1,#2)(#3,#4){%
\@ifnextchar[{\psplotImp@ii(#1,#2)(#3,#4)}{\psplotImp@ii(#1,#2)(#3,#4)[]}}
\def\psplotImp@ii(#1,#2)(#3,#4)[#5]#6{%
\addbefore@par{filename=\jobname.data}%
\begin@OpenObj%
\addto@pscode{
\ifPst@saveData /Pst@data (\psk@filename) (w) file def \fi
/xMin #1 def
/xMax #3 def
/yMin #2 def
/yMax #4 def
#5 % additional PS code
\ifPst@polarplot
/@PolarAlgPlot (#6) tx@addDict begin AlgParser end cvx def
/Func {
/phi y x atan def
/r x y Pyth def
\ifPst@algebraic @PolarAlgPlot \else #6 \fi } def
\else
/Func \ifPst@algebraic (#6) tx@addDict begin AlgParser end cvx \else { #6 } \fi def
\fi
/xPixel xMax xMin sub \pst@number\psxunit mul round cvi def
/yPixel yMax yMin sub \pst@number\psyunit mul round cvi def
/dx xMax xMin sub xPixel div def
/dy yMax yMin sub yPixel div def
/setpixel {
dy div exch
dx div exch
\ifPst@saveData
2 copy
\pst@number\psyunit div exch \pst@number\psxunit div
20 string cvs Pst@data exch writestring
Pst@data (\space) writestring
20 string cvs Pst@data exch writestring
% Pst@data (\string\]) writestring
Pst@data (\string\n) writestring
\fi
\pst@number\pslinewidth 2 div 0 360 arc fill } bind def
%
/VZ true def % suppose that F(x,y)>=0
/x xMin def /y yMin def Func 0.0 lt { /VZ false def } if % erster Wert
xMin dx \psk@stepFactor\space mul xMax {
/x exch def
\ifPst@saveData Pst@data ([\string\n) writestring \fi
yMin dy \psk@stepFactor\space mul yMax {
/y exch def
Func 0 lt
{ VZ { x y setpixel /VZ false def} if }
{ VZ {}{ x y setpixel /VZ true def } ifelse } ifelse
} for
\ifPst@saveData Pst@data (]\string\n) writestring \fi
} for
%% the same for the other way round without saving the data
/VZ true def % suppose that F(x,y)>=0
/x xMin def /y yMin def Func 0.0 lt { /VZ false def } if % erster Wert
yMin dy \psk@stepFactor\space mul yMax {
/y exch def
\ifPst@saveData Pst@data ([\string\n) writestring \fi
xMin dx \psk@stepFactor\space mul xMax {
/x exch def
Func 0 lt
{ VZ { x y setpixel /VZ false def} if }
{ VZ {}{ x y setpixel /VZ true def } ifelse } ifelse
} for
\ifPst@saveData Pst@data (]\string\n) writestring \fi
} for
%
\iffalse
/x xMin def /y yMin def Func 0.0 lt { /VZ false def } if % erster Wert
yMin dy \psk@stepFactor\space mul yMax {
/y exch def
xMin dx \psk@stepFactor\space mul xMax {
/x exch def
Func 0 lt
{ VZ { x y setpixel /VZ false def} if }
{ VZ {}{ x y setpixel /VZ true def } ifelse } ifelse
} for
} for
\fi
\ifPst@saveData Pst@data closefile \fi
}%
\end@OpenObj%
}
%
\def\psVolume{\pst@object{psVolume}}% 2007-06-23
\def\psVolume@i(#1,#2)#3#4{%
\leavevmode
\pst@killglue
\begingroup
\use@par
\psplot[fillstyle=none]{#1}{#2}{#4}% original function
\ifPst@algebraic
\psplot[fillstyle=none]{#1}{#2}{-(#4)}
\else
\psplot[fillstyle=none]{#1}{#2}{#4 neg}% mirrored at the x-axis
\fi
\multido{\iA=1+1}{#3}{% run it #3 times with increment \A
\pscustom{% to get a closed filled ellipse
\code{ % the PS code
/dX #2 #1 sub #3 div def % delta x, the step
/Start dX \iA\space 1 sub mul #1 add def % xStart
/End Start dX add def % xEnd=xStart+dX
/Height End Start add 2 div /x ED
\ifPst@algebraic (#4) AlgParser cvx exec \else #4 \fi def } % height=f(x)
% x is the mean between Start+End
\psellipticarc(!Start 0)(! Height 8 div Height){90}{270}
% draw the first falf of the ellipse
\rlineto(! dX 0)% draw a line in x-direction
\psellipticarc(!End 0)(! Height 8 div Height){270}{90}
% draw the other half of the ellipse
\rlineto(!dX neg 0)}}% draw a line in negative x-direction
\psset{fillstyle=none}
% \psellipse(#2,0)(!#2 dup #1 sub #3 div 2 div sub /x ED #4 dup
% 8 div exch)% draw again the ellipse to get the borderline.
\psellipse(#2,0)(!{ #2 dup #1 sub #3 div 2 div sub /x ED
\ifPst@algebraic (#4) AlgParser cvx exec \else #4 \fi dup
8 div exch}) % draw again the ellipse to get the borderline.
\psset{plotstyle=line,linestyle=dashed,
plotpoints=40,dotstyle=*,dotsize=0.5pt}
\psplot[fillstyle=none]{#1}{#2}{#4}
\ifPst@algebraic
\psplot[fillstyle=none]{#1}{#2}{-(#4)}
\else
\psplot[fillstyle=none]{#1}{#2}{#4 neg}% mirrored at the x-axis
\fi
% draw again the curves to get the borderline
\endgroup%
\ignorespaces%
}
\def\txFunc@BezierCurve{ tx@FuncDict begin BezierCurve Points end }
\def\txFunc@BezierShowPoints{ tx@Dict begin /Points ED BezierShowPoints end }
\def\pst@BezierType{2 } % the default
%
\def\psBezier#1{% % allowed order is 1 ... 9
\ifnum#1>0 \ifnum#1<10 \def\pst@BezierType{#1 }\fi\fi%
\pst@object{psBezier}}
\def\psBezier@i{%
\pst@getarrows{%
\addbefore@par{plotpoints=200}%
\begin@OpenObj
\pst@getcoors[\psBezier@ii%
}}
\def\psBezier@ii{%
\addto@pscode{%
\psk@plotpoints % step for Bezier T=0,0+epsilon,0+i*epsilon,...,1
\pst@BezierType % type of the Bezier curve 2,3,4,...
\txFunc@BezierCurve
\ifshowpoints \txFunc@BezierShowPoints \else pop \fi
}%
\end@OpenObj}
%
\def\tx@Bernstein{ tx@FuncDict begin Bernstein end }
\define@boolkey[psset]{pst-func}[Pst@]{envelope}[true]{}
\psset[pst-func]{envelope=false}
%
\def\psBernstein{\pst@object{psBernstein}}% \psBernstein[options](t1,t2)(i,n)
\def\psBernstein@i(#1,#2){%
\@ifnextchar({\psBernstein@ii(#1,#2)}{\psBernstein@ii(0,1)(#1,#2)}}
%
\def\psBernstein@ii(#1,#2)(#3,#4){% (tStart,tEnd)(i,n)
\addbefore@par{plotpoints=200}%
\begin@OpenObj
\addto@pscode{%
/ScreenCoor { \tx@ScreenCoor } def
#1\space #2\space
1.0 \psk@plotpoints\space div % step=1/plotpoints
#3\space #4\space
% on stack we have tStart tEnd epsilon i n
\ifPst@envelope true \else false \fi
\tx@Bernstein
}%
\end@OpenObj}
%
\def\psThomae{\pst@object{psThomae}}
\def\psThomae@i(#1,#2)#3{%
\addbefore@par{dotsize=1pt}
\begin@ClosedObj
\addto@pscode{
1 1 #3 {
dup
/ipSave ED % save loop value
/ip ED % dito
1 1 #3 {
dup
/iqSave ED % save loop value
/iq ED % dito
{
iq 0 le { exit } if
ip iq mod
/ip iq def
/iq ED
} loop
ip 1 eq {
/xVal ipSave iqSave div def
xVal #1 ge { xVal #2 le {
\psk@dotsize
\@nameuse{psds@\psk@dotstyle}
\pst@usecolor\pslinecolor xVal 1 iqSave div \tx@ScreenCoor
2 copy pop 0 moveto lineto } if } if
% 2 copy moveto Dot } if } if
} if
} for
} for
}%
\end@ClosedObj%
}
%
\def\psCplot{\def\pst@par{}\pst@object{psCplot}}
\def\psCplot@i#1#2#3#4{% start | end | complex variables | function
\pst@killglue
\begingroup
\use@par
\@nameuse{beginplot@\psplotstyle}%
\addto@pscode{%
\psplot@init
/x #1 def
/x1 #2 def
/dx x1 x sub \psk@plotpoints div def
#3
/xy {
% x
tx@FuncDict begin
#4 aload pop \pst@number\psyunit mul exch \pst@number\psxunit mul exch
end
} def}%
\gdef\psplot@init{}%
\@pstfalse
\@nameuse{testqp@\psplotstyle}%
\if@pst
\psplot@ii
\else
\psplot@iii
\fi
\endgroup
\ignorespaces}
%
\define@boolkey[psset]{pst-func}[Pst@]{xory}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{approx}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{Framed}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{Newton}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{PrintCoord}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{onlyNode}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{onlyYVal}[true]{}
\define@boolkey[psset]{pst-func}[Pst@]{originV}[true]{}
\define@key[psset]{pst-func}{PointName}[I]{\def\psk@func@PointName{#1}}
\define@key[psset]{pst-func}{ydecimals}[2]{\pst@getint{#1}\psk@ydecimals }
\define@key[psset]{pst-func}{labeldistance}[0]{\def\psk@ldistance{#1 }}
\psset[pst-func]{originV=false,onlyNode=false,ydecimals=2,labeldistance=0,
PrintCoord=false,onlyYVal=false,Newton=false,PointName=I,Framed=false,xory=false,approx=true}
%
%--------------------------------------------------------------------
%------------- calculate the value of an intersectionpoint -----------
%---------------------------------------------------------------------
%
\def\psZero{\def\pst@par{}\pst@object{psZero}}
\def\psZero@i(#1,#2)#3{\@ifnextchar[{\psZero@ii(#1,#2)#3}{\psZero@ii(#1,#2){#3}[0]}}
\def\psZero@ii(#1,#2)#3[#4]#5{%
% (#1,#2) Intervall f\"{u}r die Nullstelle, bzw #1 Startwert f\"{u}r Newton, #3 1. Funktion, #4 2. Funktion, #5 Knotenname
\begingroup
\pst@killglue
\addbefore@par{labelangle=0,framesep=1pt}%fontscale=40,PSfont=NimbusRomNo9L-Regu}%
% labelangle=0 -> take xShift and yShift into account, otherwise xShift=pslabelsep * cos(labelangle)
% yShift=pslabelsep * sin(labelangle)
\use@par
\pst@Verb{
/FunctionA
\ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else {#3} \fi def
/FunctionB
\ifPst@algebraic (#4) tx@AlgToPs begin AlgToPs end cvx \else {#4} \fi def
\ifPst@Newton % --------------------------- Newton-Verfahren --- TS 05.2014
/eps 1e-6 def % eps f\"{u}r (f(x+eps)-f(x))/eps
/x0 #1 def % Startwert wird vorgegeben
/Xend x0 def
{
/xe x0 eps add def % xe=x+eps
/x x0 def % x nun x0 setzen, damit f(x0) berechnet werden kann
/func0 FunctionA FunctionB sub def % func0=F(x0)-FB(x0)
func0 0 eq {exit} if % wenn func0 = 0 -> exit
/x xe def % x xe setzen
/func1 FunctionA FunctionB sub def % func1=F(xe)-FB(xe)
/Xend x0 func0 eps mul func1 func0 sub div sub def % Xend=x0-(func0*eps)/(func1-func0)
/x Xend def % x wird nun Xend
/funcend FunctionA FunctionB sub def % funcend=F(Xend)-FB(Xend)
funcend abs 1e-6 le {exit} if % Wenn funcend < 1e-6 -> exit
/x0 Xend def % sonst x0 = Xend und
} loop % die Schleife beginnt mit x0 = Xend
/xM Xend def
\else % -------------------- Intervallhalbierungsverfahren von Manuel L.
/Xinf #1 def % linker Wert des Intervalls, in dem die Nullstelle gesucht wird
/Xsup #2 def % linker Wert des Intervalls, in dem die Nullstelle gesucht wird
{ /xM Xinf Xsup add 2 div def % Mittelwert -> Mitte des Intervalls ist xM2
/x Xinf def % Variable x wird als linker Wert festgelegt
/F_1 FunctionA FunctionB sub def % Definition der Differenzfunktion F_1 an der Stelle x=Xinf2
/x xM def % Variable x wird als Mittelwert festgelegt
/F_M FunctionA FunctionB sub def % Definition der Differenzfunktion F_M an der Stelle x=xM2
F_M 0 eq {exit} if % Ist F_M = 0 => fertig
F_1 F_M mul 0 ge {/Xinf xM def} {/Xsup xM def} ifelse % F_1 * F_M > 0 (F_1 und F_M haben gleiches VZ) => neuer linker x-Wert = xM2
Xinf Xsup sub abs 1e-6 le {exit} if } loop % Die Schleife endet, wenn die Differenz von linkem und rechtem Wert < 10^-6
\fi
/x xM def FunctionA /yM exch def % x wird Mittelwert und an dieser Stelle die Funktion berechnet und als yM definiert
}%
\pnode(! xM yM){#5}%
\addto@pscode{%
\iftrue %\psFunc@langle pt>\z@
/xShift \psFunc@langle cos \psk@ldistance mul def
/yShift \psFunc@langle sin \psk@ldistance mul def
\else
/xShift \psk@xShift\space def
/yShift \psk@yShift\space def
\fi
\ifPst@onlyNode\else
/dec \psk@decimals\space def % Anzahl der Dezimahlen f\"{u}r x
/ydec \psk@ydecimals\space def % Anzahl der Dezimalen f\"{u}r y
/symb { /StandardSymbolsPS findfont \psk@fontscale\space scalefont setfont } bind def % Symbolschrift f\"{u}r Klammer und senkrechten Strich
/schrift { \psk@PSfont\space findfont \psk@fontscale scalefont setfont } bind def % Schrift f\"{u}r die Ergebnisse
/TiefSchrift { /StandardSymbolsPS findfont \psk@fontscale 1.8 div scalefont setfont } bind def % Schrift f\"{u}r tiefergestellte Buchstaben
/spdx \psk@fontscale 4 div def % Abstand, der mit der Schriftg\"{o}{\ss}e skaliert ist
/spdy \psk@fontscale 15 div def % Abstand, der mit der Schriftg\"{o}{\ss}e skaliert ist
/Wert { dec -1 le { /dec 15 def } if 10 dec exp mul round 10 dec exp div dec 0 eq { cvi 15 string cvs } { 15 string cvs } ifelse % x-Wert runden und als string ablegen
\ifPst@comma dot2comma \fi show } def % gegebenenfalls Komma statt Punkt und Ergebnis anzeigen
/yWert { 10 ydec exp mul round 10 ydec exp div ydec 0 eq { cvi 15 string cvs } { 15 string cvs } ifelse % y-Wert runden und als string ablegen
\ifPst@comma dot2comma \fi show } def % gegebenenfalls Komma statt Punkt und Ergebnis anzeigen
/FunctionA \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else {#3} \fi def
/FunctionB \ifPst@algebraic (#4) tx@AlgToPs begin AlgToPs end cvx \else {#4} \fi def
/frs \pst@number\psframesep def
\ifPst@Newton
/eps 1e-6 def
/x0 #1 def
/Xend x0 def
{ /xe x0 eps add def
/x x0 def
/func0 FunctionA FunctionB sub def
func0 0 eq {exit} if
/x xe def
/func1 FunctionA FunctionB sub def
/Xend x0 func0 eps mul func1 func0 sub div sub def
/x Xend def
/funcend FunctionA FunctionB sub def
funcend abs 1e-6 le {exit} if
/x0 Xend def
} loop
/xM Xend def
\else
/Xinf #1 def /Xsup #2 def
{ /xM Xinf Xsup add 2 div def
/x Xinf def /F_1 FunctionA FunctionB sub def
/x Xsup def /F_2 FunctionA FunctionB sub def
/x xM def /F_M FunctionA FunctionB sub def
F_M 0 eq {exit} if
F_1 F_M mul 0 ge {/Xinf xM def} {/Xsup xM def} ifelse
Xinf Xsup sub abs 1e-6 le {exit} if } loop
\fi
/x xM def FunctionA /yM exch def
\ifPst@originV 0 0 \else
xM xShift add \pst@number\psxunit mul
yM yShift add \pst@number\psyunit mul
\fi
\pst@usecolor\pslinecolor
\ifPst@PrintCoord
/xytext { moveto schrift (\psk@func@PointName) show
0 spdy 2 mul neg rmoveto TiefSchrift (\psk@postString) show
0 spdy 3 mul rmoveto symb (\string\050) show
0 spdy neg rmoveto schrift xM Wert
spdx 3 div spdy rmoveto symb (\string\174) show
spdx 3 div spdy neg rmoveto schrift yM yWert 0 spdy rmoveto symb (\string\051) show } bind def
xytext
0 spdy neg rmoveto
% ------------------------------------------------------------------------------ TS 03.2017
\ifPst@Framed
frs \psk@fontscale 0.15 mul frs add neg rmoveto
0 \psk@fontscale 0.9 mul frs 2 mul add rlineto
\ifPst@originV
frs neg \psk@fontscale 0.75 mul frs add L
\else
xM xShift add \pst@number\psxunit mul frs sub
yM yShift add \pst@number\psyunit mul \psk@fontscale 0.75 mul add frs add L
\fi
0 \psk@fontscale 0.9 mul frs 2 mul add neg rlineto closepath
gsave
\pst@usecolor\psfillcolor \tx@setTransparency fill
grestore
\ifx\pslinestyle\@none\else
\pst@number\pslinewidth SLW \pst@usecolor\pslinecolor \tx@setStrokeTransparency \@nameuse{psls@\pslinestyle} stroke
\fi
\ifPst@originV 0 0 \else
xM xShift add \pst@number\psxunit mul
yM yShift add \pst@number\psyunit mul
\fi
xytext
0 spdy neg rmoveto
\fi
%------------------------------ Wenn nicht die Form P(a|b) sondern x = a oder y = b oder nur a oder nur b -------------------
\else
\ifPst@originV 0 0 \else
xM xShift add \pst@number\psxunit mul
yM yShift add \pst@number\psyunit mul
\fi
/xorytext { moveto schrift
\ifPst@onlyYVal% nur der y-Wert
\ifPst@xory% in Form von y=b
(\psk@func@PointName) show
spdx 5 div neg spdy 2.2 mul neg rmoveto TiefSchrift (\psk@postString) show
spdx 1.5 div spdy 2 mul rmoveto symb(\ifPst@approx \string \273 \else \string = \fi) show
spdx 1.5 div neg 0 rmoveto schrift yM yWert
\else schrift yM yWert
\fi
\else
\ifPst@xory% in Form x = a
(\psk@func@PointName) show
spdx 7 div neg spdy 2.2 mul neg rmoveto TiefSchrift (\psk@postString) show
spdx 1.5 div spdy 2 mul rmoveto symb (\ifPst@approx \string \273 \else \string = \fi) show
spdx 1.5 div neg 0 rmoveto schrift xM Wert
\else schrift xM Wert
\fi
\fi } bind def
xorytext
\ifPst@Framed%------------------------------ Rahmenbeginn ------------------------------
frs \psk@fontscale 0.14 mul frs add neg rmoveto
0 \psk@fontscale 0.9 mul frs 2 mul add rlineto
\ifPst@originV
frs neg \psk@fontscale 0.75 mul frs add L
\else
xM xShift add \pst@number\psxunit mul frs sub
yM yShift add \pst@number\psyunit mul \psk@fontscale 0.75 mul add frs add L
\fi
0 \psk@fontscale 0.9 mul frs 2 mul add neg rlineto closepath
gsave
\pst@usecolor\psfillcolor \tx@setTransparency fill
grestore
\ifx\pslinestyle\@none\else
\pst@number\pslinewidth SLW \pst@usecolor\pslinecolor \tx@setStrokeTransparency \@nameuse{psls@\pslinestyle} stroke
\fi
\ifPst@originV 0 0 \else
xM xShift add \pst@number\psxunit mul
yM yShift add \pst@number\psyunit mul
\fi
xorytext
\fi
\fi
\fi}%
\ifPst@markZeros\psdot(#5)\fi
\endgroup\use@pscode\ignorespaces
}%
%
\catcode`\@=\PstAtCode\relax
%
%% END: pst-func.tex
\endinput
%
|