summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex
blob: 08a64c173fa7202990a2f8e80b3675ef9e0271af (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
\documentclass[dvips,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pst-news}
\usepackage{pst-func}
\let\pstFuncFV\fileversion
\usepackage{pst-math}
\lstset{pos=t,wide=true,language=PSTricks,
    morekeywords={psGammaDist,psChiIIDist,psTDist,psFDist,psBetaDist,psPlotImpl},basicstyle=\footnotesize\ttfamily}
%
\def\pshlabel#1{\footnotesize#1}
\def\psvlabel#1{\footnotesize#1}
%
\begin{document}
\title{\texttt{pst-func}\\[1cm]
plotting special mathematical functions\\[5mm]
		  {\small v.\pstFuncFV}}
%\thanks{%
%		This document was written with \texttt{Kile: 1.6a (Qt: 3.1.1; KDE: 3.1.1;}
%		\protect\url{http://sourceforge.net/projects/kile/}) and the PDF output
%		  was build with VTeX/Free (\protect\url{http://www.micropress-inc.com/linux})}\\
\author{Herbert Vo\ss\thanks{%
Thanks to: 
    Jean-C\^ome Charpentier,
    Martin Chicoine, 
    Gerry Coombes, 
    John Frampton, 
    Attila Gati, 
    Horst Gierhardt,  
    Lars Kotthoff, 
    and Jose-Emilio Vila-Forcen.
}}
\date{\today}

\maketitle

\vfill
\begin{center}
\fbox{\parbox{0.8\textwidth}{%
\texttt{pst-func} loads by default the following packages: \texttt{pst-plot}, 
\texttt{pstricks-add}, \texttt{pst-math}, \texttt{pst-xkey}, and, of course \texttt{pstricks}.
All should be already part of your local \TeX\ installation. If not, or in case
of having older versions, go to \url{http://www.CTAN.org/} and load the newest version.

{\itshape If \LPack{pstricks-add} is loaded together with the package  \LPack{pst-func} then the \Lkeyword{InsideArrow}
    of the \Lcs{psbezier} macro doesn't work!}}}

\end{center}
\vfill
\clearpage
\tableofcontents

\clearpage

\section{\Lcs{psBezier\#}}
This macro can plot a B\'ezier spline from order 1 up to 9 which needs
(order+1) pairs of given coordinates.

Given a set of $n+1$ control points $P_0$, $P_1$, \ldots, $P_n$, the corresponding \Index{B\'ezier} curve 
(or \Index{Bernstein-B\'ezier} curve) is given by 

\begin{align}
C(t)=\sum_{i=0}^n P_i B_{i,n}(t)
\end{align}

Where $B_{i,n}(t)$ is a Bernstein polynomial $B_{i,n}(t)=\binom{n}{i}t^i(1-t)^{n-i}$, 
 and $t \in [0,1]$. 
The Bézier curve starts through the first and last given point and 
lies within the convex hull of all control points. The curve is tangent 
to $P_1-P_0$ and $P_n-P_{n-1}$ at the endpoint.
Undesirable properties of Bézier curves are their numerical instability for 
large numbers of control points, and the fact that moving a single control 
point changes the global shape of the curve. The former is sometimes avoided 
by smoothly patching together low-order Bézier curves. 

The macro \Lcs{psBezier} (note the upper case B) expects the number of the order 
and $n=order+1$ pairs of coordinates:

\begin{lstlisting}[style=syntax]
\psBezier#[<options>](x0,y0)(x1,y1)...(xn,yn)
\end{lstlisting}

The number of steps between the first and last control points is given
by the keyword \Lkeyword{plotpoints} and preset to 200. It can be
changed in the usual way. 


\begin{lstlisting}
\psset{showpoints=true,linewidth=1.5pt}
\begin{pspicture}(-2,-2)(2,2)% order 1 -- linear
  \psBezier1{<->}(-2,0)(-2,2)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 2 -- quadratric
  \psBezier2{<->}(-2,0)(-2,2)(0,2)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 3 -- cubic
  \psBezier3{<->}(-2,0)(-2,2)(0,2)(2,2)
\end{pspicture}\qquad

\vspace{1cm}
\begin{pspicture}(-2,-2)(2,2)% order 4 -- quartic
  \psBezier4{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 5 -- quintic
  \psBezier5{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 6
  \psBezier6{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)
\end{pspicture}\qquad

\vspace{1cm}
\begin{pspicture}(-2,-2)(2,2)% order 7
  \psBezier7{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 8
  \psBezier8{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 9
  \psBezier9{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)(0,0)
\end{pspicture}
\end{lstlisting}


\begingroup
\psset{showpoints=true,linewidth=1.5pt}
\begin{pspicture}(-2,-2)(2,2)% order 1 -- linear
  \psBezier1{<->}(-2,0)(-2,2)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 2 -- quadratric
  \psBezier2{<->}(-2,0)(-2,2)(0,2)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 3 -- cubic
  \psBezier3{<->}(-2,0)(-2,2)(0,2)(2,2)
\end{pspicture}\qquad

\vspace{1cm}
\begin{pspicture}(-2,-2)(2,2)% order 4 -- quartic
  \psBezier4{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 5 -- quintic
  \psBezier5{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 6
  \psBezier6{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)
\end{pspicture}\qquad

\vspace{1cm}
\begin{pspicture}(-2,-2)(2,2)% order 7
  \psBezier7{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 8
  \psBezier8{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)
\end{pspicture}\qquad
%
\begin{pspicture}(-2,-2)(2,2)% order 9
  \psBezier9{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)(0,0)
\end{pspicture}
\endgroup


\section{Polynomials}
\subsection{\Lcs{psPolynomial}}
The polynomial function is defined as
\begin{align}
f(x) &= a_0 + a_1x + a_2x^2 + a_3x^3 + \ldots +a_{n-1}x^{n-1} + a_nx^n\\
f^{\prime}(x) &= a_1 + 2a_2x + 3a_3x^2 + \ldots +(n-1)a_{n-1}x^{n-2} + na_nx^{n-1}\\
f^{\prime\prime}(x) &= 2a_2 + 6a_3x + \ldots +(n-1)(n-2)a_{n-1}x^{n-3} + n(n-1)a_nx^{n-2}
\end{align}


\noindent so \LPack{pst-func} needs only the \Index{coefficients} of the
polynomial to calculate the function. The syntax is

\begin{lstlisting}[style=syntax]
\psPolynomial[<options>]{xStart}{xEnd}
\end{lstlisting}

With the option \Lkeyword{xShift} one can do a horizontal shift to the graph of the function. With another
than the predefined value the macro replaces $x$ by $x-x\mathrm{Shift}$; \Lkeyword{xShift}=1
moves the graph of the polynomial function one unit to the right.


\begin{center}
\bgroup
\psset{yunit=0.5cm,xunit=1cm}
\begin{pspicture*}(-3,-5)(5,10)
  \psaxes[Dy=2]{->}(0,0)(-3,-5)(5,10)
  \psset{linewidth=1.5pt}
  \psPolynomial[coeff=6 3 -1,linecolor=red]{-3}{5}
  \psPolynomial[coeff=2 -1 -1 .5 -.1 .025,linecolor=blue]{-2}{4}
  \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta]{-2}{4}
  \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta,xShift=1,linestyle=dashed]{-2}{4}
  \rput[lb](4,4){\textcolor{red}{$f(x)$}}
  \rput[lb](4,8){\textcolor{blue}{$g(x)$}}
  \rput[lb](2,4){\textcolor{magenta}{$h(x)$}}
\end{pspicture*}
\egroup
\end{center}


\begin{lstlisting}
\psset{yunit=0.5cm,xunit=1cm}
\begin{pspicture*}(-3,-5)(5,10)
  \psaxes[Dy=2]{->}(0,0)(-3,-5)(5,10)
  \psset{linewidth=1.5pt}
  \psPolynomial[coeff=6 3 -1,linecolor=red]{-3}{5}
  \psPolynomial[coeff=2 -1 -1 .5 -.1 .025,linecolor=blue]{-2}{4}
  \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta]{-2}{4}
  \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta,xShift=1,linestyle=dashed]{-2}{4}
  \rput[lb](4,4){\textcolor{red}{$f(x)$}}
  \rput[lb](4,8){\textcolor{blue}{$g(x)$}}
  \rput[lb](2,4){\textcolor{magenta}{$h(x)$}}
\end{pspicture*}
\end{lstlisting}


The plot is easily clipped using the star version of the
\verb+pspicture+ environment, so that points whose coordinates
are outside of the desired range are not plotted.
The plotted polynomials are:
\begin{align}
f(x) & = 6 + 3x -x^2 \\
g(x) & = 2 -x -x^2 +0.5x^3 -0.1x^4 +0.025x^5\\
h(x) & = -2 +x -x^2 +0.5x^3 +0.1x^4 +0.025x^5+0.2x^6\\
h^*(x) & = -2 +(x-1) -(x-1)^2 +0.5(x-1)^3 +\nonumber\\
       & \phantom{ = }+0.1(x-1)^4 +0.025(x-1)^5+0.2(x-1)^6
\end{align}




There are the following new options:

\noindent\medskip
{\tabcolsep=2pt
\begin{tabularx}{\linewidth}{@{}l>{\ttfamily}l>{\ttfamily}lX@{}}
Name & \textrm{Value}  & \textrm{Default}\\\hline
\Lkeyword{coeff}        & a0 a1 a2 ... & 0 0 1 & The coefficients must have the order $a_0\ a_1\ a_2 \ldots$ and
be separated by \textbf{spaces}. The number of coefficients
is limited only by the memory of the computer ... The default
value of the parameter \verb+coeff+ is \verb+0 0 1+, which gives
the parabola $y=a_0+a_1x+a_2x^2=x^2$.\\
\Lkeyword{xShift} & <number>     & 0     & $(x-xShift)$ for the horizontal shift of the polynomial\\
\Lkeyword{Derivation} & <number>     & 0     & the default is the function itself\\
\Lkeyword{markZeros}    & false|true       & false & dotstyle can be changed\\
\Lkeyword{epsZero}      & <value> &  0.1 & The distance between two zeros, important for
                                  the iteration function to test, if the zero value still
				  exists\\
\Lkeyword{dZero}      & <value> &  0.1 & When searching for all zero values, the function is scanned
                              with this step\\
\Lkeyword{zeroLineTo}    & <number>  & false & plots a line from the zero point to the value of the
                                    zeroLineTo's Derivation of the polynomial function\\
\end{tabularx}
}

\noindent
{\tabcolsep=2pt
\begin{tabularx}{\linewidth}{@{}l>{\ttfamily}l>{\ttfamily}lX@{}}
Name & \textrm{Value}  & \textrm{Default}\\\hline
\Lkeyword{zeroLineStyle}    & <line style>  & dashed & the style is one of the for PSTricks valid styles.\\
\Lkeyword{zeroLineColor}  & <color>  & black & any valid xolor is possible\\
\Lkeyword{zeroLineWidth}  & <width> & \rlap{0.5\textbackslash pslinewidth} & \\
\end{tabularx}
}



\bigskip
The above parameter are only 
valid for the \Lcs{psPolynomial} macro, except \verb+x0+, which can also be used for the Gauss function. All
options can be set in the usual way with \Lcs{psset}. 



\bigskip
\begin{LTXexample}
\psset{yunit=0.5cm,xunit=2cm}
\begin{pspicture*}(-3,-5)(3,10)
  \psaxes[Dy=2]{->}(0,0)(-3,-5)(3,10)
  \psset{linewidth=1.5pt}
  \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta]{-2}{4}
  \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=red,%
    linestyle=dashed,Derivation=1]{-2}{4}
  \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=blue,%
    linestyle=dotted,Derivation=2]{-2}{4}
  \rput[lb](2,4){\textcolor{magenta}{$h(x)$}}
  \rput[lb](1,1){\textcolor{red}{$h^{\prime}(x)$}}
  \rput[lb](-1,6){\textcolor{blue}{$h^{\prime\prime}(x)$}}
\end{pspicture*}
\end{LTXexample}
%$

\begin{LTXexample}
\psset{yunit=0.5cm,xunit=2cm}
\begin{pspicture*}(-3,-5)(3,10)
  \psaxes[Dy=2]{->}(0,0)(-3,-5)(3,10)
  \psset{linewidth=1.5pt}
  \psPolynomial[coeff=0 0 0 1,linecolor=blue]{-2}{4}
  \psPolynomial[coeff=0 0 0 1,linecolor=red,%
    linestyle=dashed,Derivation=2]{-2}{4}
  \psPolynomial[coeff=0 0 0 1,linecolor=cyan,%
    linestyle=dotted,Derivation=3]{-2}{4}
  \rput[lb](1.8,4){\textcolor{blue}{$f(x)=x^3$}}
  \rput[lb](0.2,8){\textcolor{red}{$f^{\prime\prime}(x)=6x$}}
  \rput[lb](-2,5){\textcolor{cyan}{$f^{\prime\prime\prime}(x)=6$}}
\end{pspicture*}
\end{LTXexample}
%$

\begin{LTXexample}
\begin{pspicture*}(-5,-5)(5,5)
  \psaxes{->}(0,0)(-5,-5)(5,5)%
  \psset{dotscale=2}
  \psPolynomial[markZeros,linecolor=red,linewidth=2pt,coeff=-1 1 -1 0 0.15]{-4}{3}%
  \psPolynomial[markZeros,linecolor=blue,linewidth=1pt,linestyle=dashed,%
    coeff=-1 1 -1 0 0.15,Derivation=1,zeroLineTo=0]{-4}{3}%
  \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
    coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=0]{-4}{3}%
  \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
    coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=1]{-4}{3}%
\end{pspicture*}
\end{LTXexample}

\begin{LTXexample}
\psset{xunit=1.5}
\begin{pspicture*}(-5,-5)(5,5)
  \psaxes{->}(0,0)(-5,-5)(5,5)%
  \psset{dotscale=2,dotstyle=x,zeroLineStyle=dotted,zeroLineWidth=1pt}
  \psPolynomial[markZeros,linecolor=red,linewidth=2pt,coeff=-1 1 -1 0 0.15]{-4}{3}%
  \psPolynomial[markZeros,linecolor=blue,linewidth=1pt,linestyle=dashed,%
    coeff=-1 1 -1 0 0.15,Derivation=1,zeroLineTo=0]{-4}{3}%
  \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
    coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=0]{-4}{3}%
  \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
    coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=1]{-4}{3}%
\end{pspicture*}
\end{LTXexample}

\clearpage
\subsection{\Lcs{psBernstein}}
The polynomials defined by
%
\[ B_{i,n}(t)=\binom{n}{i}t^i(1-t)^{n-i} \]
%
where $\tbinom{n}{k}$ is a binomial coefficient are named Bernstein polynomials of degree $n$.
They form a basis for the power polynomials of degree $n$.
The Bernstein polynomials satisfy symmetry
\[B_{i,n}(t)=B_{n-i,n}(1-t)\]
positivity \[B_{i,n}(t)\ge0 \mbox{\qquad for } 0\le t\le1\]
normalization \[\sum_{i=0}^nB_{i,n}(t)=1\] 	
and $B_{i,n}$ with $i!=0$, $n$ has a single unique local maximum of
\[i^in^{-n}(n-i)^{n-i}\binom{n}{i}\]	
occurring at $t=\frac{i}{n}$.
The envelope $f_n(x)$ of the Bernstein polynomials $B_{i,n}(x)$ for $i=0,1,\ldots,n$ 
is given by \[f_n(x)=\frac{1}{\sqrt{\pi n\cdot x(1-x)}}\] 	
illustrated below for $n=20$. 

\begin{lstlisting}[style=syntax]
\psBernstein[<options>](tStart,tEnd)(i,n)
\end{lstlisting}

The (\Lkeyword{tStart}, \Lkeyword{tEnd}) are \emph{optional} and preset by \verb=(0,1)=. The only new optional
argument is the boolean key \Lkeyword{envelope}, which plots the envelope curve instead
of the Bernstein polynomial.

\begin{LTXexample}[width=5cm,pos=l]
\psset{xunit=4.5cm,yunit=3cm}
\begin{pspicture}(1,1.1)
  \psaxes{->}(0,0)(1,1)[$t$,0][$B_{0,0}$,90]
  \psBernstein[linecolor=red,linewidth=1pt](0,0)
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=5cm,pos=l]
\psset{xunit=4.5cm,yunit=3cm}
\begin{pspicture}(1,1.1)
  \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,1}$,90]
  \psBernstein[linecolor=blue,linewidth=1pt](0,1)
  \psBernstein[linecolor=blue,linewidth=1pt](1,1)
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=5cm,pos=l]
\psset{xunit=4.5cm,yunit=3cm}
\begin{pspicture}(1,1.1)
  \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,2}$,90]
  \multido{\i=0+1}{3}{\psBernstein[linecolor=red,
    linewidth=1pt](\i,2)}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=5cm,pos=l]
\psset{xunit=4.5cm,yunit=3cm}
\begin{pspicture}(1,1.1)
  \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,3}$,90]
  \multido{\i=0+1}{4}{\psBernstein[linecolor=magenta,
    linewidth=1pt](\i,3)}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=5cm,pos=l]
\psset{xunit=4.5cm,yunit=3cm}
\begin{pspicture}(1,1.1)
  \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,4}$,90]
  \multido{\i=0+1}{5}{\psBernstein[linecolor=cyan,
    linewidth=1pt](\i,4)}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=5cm,pos=l]
\psset{xunit=4.5cm,yunit=3cm}
\begin{pspicture}(-0.1,-0.05)(1.1,1.1)
  \multido{\i=0+1}{20}{\psBernstein[linecolor=green,
    linewidth=1pt](\i,20)}
  \psBernstein[envelope,linecolor=black](0.02,0.98)(0,20)
  \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,20}$,180]
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[width=5cm,pos=l]
\psset{xunit=4.5cm,yunit=3cm}
\begin{pspicture*}(-0.2,-0.05)(1.1,1.1)
  \psaxes{->}(0,0)(1,1)[$t$,0][$B_{env}$,180]
  \multido{\i=2+1}{20}{\psBernstein[envelope,
    linewidth=1pt](0.01,0.99)(0,\i)}
\end{pspicture*}
\end{LTXexample}


\psset{unit=1cm}
\clearpage
\section{\Lcs{psFourier}}

A Fourier sum has the form:
\begin{align}
s(x) = \frac{a_0}{2} & + a_1\cos{\omega x} + a_2\cos{2\omega x} +
   a_3\cos{3\omega x} +
	\ldots + a_n\cos{n\omega x}\\
	& + b_1\sin{\omega x} + b_2\sin{2\omega x} + b_3\sin{3\omega x} +
	\ldots + b_m\sin{m\omega x}
\end{align}

\noindent The macro \Lcs{psFourier} plots \Index{Fourier sums}. The
syntax is similiar to \Lcs{psPolynomial}, except that there are
two kinds of coefficients:

\begin{lstlisting}[style=syntax]
\psFourier[cosCoeff=a0 a1 a2 ..., sinCoeff=b1 b2 ...]{xStart}{xEnd}
\end{lstlisting}
The coefficients must have the orders $a_0\ a_1\ a_2\ \ldots$
and $b_1\ b_2\ b_3\ \ldots$ and be separated by
\textbf{spaces}. The default is \Lkeyword{cosCoeff}=0,\Lkeyword{sinCoeff}=1,
which gives the standard \verb+sin+ function. Note that
%%JF, I think it is better without the angle brackets, but
%%you know the conventions used better than I do, so you
%%may disagree.
%the constant value can only be set with \verb+cosCoeff=<a0>+.
the constant value can only be set with \Lkeyword{cosCoeff}=\verb+a0+.

\begin{LTXexample}
\begin{pspicture}(-5,-3)(5,5.5)
\psaxes{->}(0,0)(-5,-2)(5,4.5)
\psset{plotpoints=500,linewidth=1pt}
\psFourier[cosCoeff=2, linecolor=green]{-4.5}{4.5}
\psFourier[cosCoeff=0 0 2, linecolor=magenta]{-4.5}{4.5}
\psFourier[cosCoeff=2 0 2, linecolor=red]{-4.5}{4.5}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}
\psset{yunit=0.75}
\begin{pspicture}(-5,-6)(5,7)
\psaxes{->}(0,0)(-5,-6)(5,7)
\psset{plotpoints=500}
\psFourier[linecolor=red,linewidth=1pt]{-4.5}{4.5}
\psFourier[sinCoeff= -1 1 -1 1 -1 1 -1 1,%
	linecolor=blue,linewidth=1.5pt]{-4.5}{4.5}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}
\begin{pspicture}(-5,-5)(5,5.5)
\psaxes{->}(0,0)(-5,-5)(5,5)
\psset{plotpoints=500,linewidth=1.5pt}
\psFourier[sinCoeff=-.5 1 1 1 1 ,cosCoeff=-.5 1 1 1 1 1,%
	linecolor=blue]{-4.5}{4.5}
\end{pspicture}
\end{LTXexample}

\clearpage
\section{\Lcs{psBessel}}
The Bessel function of order $n$ is defined as
\begin{align}
J_n(x) &=\frac{1}{\pi}\int_0^\pi\cos(x\sin t-nt)\dt\\
       &=\sum_{k=0}^{\infty}\frac{(-1)^k \left(\frac{x}{2}\right)^{n+2k}}{k!\Gamma(n+k+1)}
\end{align}

\noindent The syntax of the macro is

\begin{lstlisting}[style=syntax]
\psBessel[options]{order}{xStart}{xEnd}
\end{lstlisting}

There are two special parameters for the Bessel function, and also the
settings of many \LPack{pst-plot} or \LPack{pstricks} parameters
affect the plot. 

\begin{lstlisting}[style=syntax]
\def\psset@constI#1{\edef\psk@constI{#1}}
\def\psset@constII#1{\edef\psk@constII{#1}}
\psset{constI=1,constII=0}
\end{lstlisting}

These two ,,constants`` have the following meaning:
\[
f(t) = constI \cdot J_n + constII
\]

\noindent
where \Lkeyword{constI} and \Lkeyword{constII} must be real PostScript expressions, e.g.:

\begin{lstlisting}[style=syntax]
\psset{constI=2.3,constII=t k sin 1.2 mul 0.37 add}
\end{lstlisting}

The Bessel function is plotted with the parametricplot macro, this is the
reason why the variable is named \verb+t+. The internal procedure \verb+k+ 
converts the value t from radian into degrees. The above setting is
the same as
\[
f(t) = 2.3 \cdot J_n + 1.2\cdot \sin t + 0.37
\]
 

In particular, note that the default for
\Lkeyword{plotpoints} is $500$. If the plotting computations are too
time consuming at this setting, it can be decreased in the usual
way, at the cost of some reduction in graphics resolution.

\begin{LTXexample}
{
\psset{xunit=0.25,yunit=5}
\begin{pspicture}(-13,-.85)(13,1.25)
\rput(13,0.8){%
	$\displaystyle J_n(x)=\frac{1}{\pi}\int_0^\pi\cos(x\sin t-nt)\dt$%
}
\psaxes[Dy=0.2,Dx=4]{->}(0,0)(-30,-.8)(30,1.2)
\psset{linewidth=1pt}
\psBessel[linecolor=red]{0}{-28}{28}%
\psBessel[linecolor=blue]{1}{-28}{28}%
\psBessel[linecolor=green]{2}{-28}{28}%
\psBessel[linecolor=magenta]{3}{-28}{28}%
\end{pspicture}
}
\end{LTXexample}


\begin{LTXexample}
{
\psset{xunit=0.25,yunit=2.5}
\begin{pspicture}(-13,-1.5)(13,3)
\rput(13,0.8){%
	$\displaystyle f(t) = 2.3 \cdot J_0 + 1.2\cdot \sin t + 0.37$%
}
\psaxes[Dy=0.8,dy=2cm,Dx=4]{->}(0,0)(-30,-1.5)(30,3)
\psset{linewidth=1pt}
\psBessel[linecolor=red,constI=2.3,constII={t k sin 1.2 mul 0.37 add}]{0}{-28}{28}%
\end{pspicture}
}
\end{LTXexample}



\clearpage
\section{\Lcs{psSi}, \Lcs{pssi} and \Lcs{psCi}}
The integral sin  and cosin are defined as
\begin{align}
\mathrm{Si}(x) &= \int_0^x\dfrac{\sin t}{t}\dt\\
\mathrm{si}(x) &= - \int_x^{\infty}\dfrac{\sin t}{t}\dt=\mathrm{Si}(x)-\frac{\pi}{2}\\
\mathrm{Ci}(x) &= -\int_x^{\infty}\dfrac{\cos t}{t}\dt=\gamma+\ln x +\int_0^{x}\dfrac{\cos t -1}{t}\dt
\end{align}
%
\noindent The syntax of the macros is

\begin{lstlisting}[style=syntax]
\psSi[options]{xStart}{xEnd}
\pssi[options]{xStart}{xEnd}
\psCi[options]{xStart}{xEnd}
\end{lstlisting}


\begin{LTXexample}[pos=t]
\def\pshlabel#1{\footnotesize#1} \def\psvlabel#1{\footnotesize#1}
\psset{xunit=0.5}
\begin{pspicture}(-15,-4.5)(15,2)
  \psaxes[dx=1cm,Dx=2]{->}(0,0)(-15.1,-4)(15,2)
  \psplot[plotpoints=1000]{-14.5}{14.5}{ x RadtoDeg sin x div }
  \psSi[plotpoints=1500,linecolor=red,linewidth=1pt]{-14.5}{14.5}
  \pssi[plotpoints=1500,linecolor=blue,linewidth=1pt]{-14.5}{14.5}
  \rput(-5,1.5){\color{red}$Si(x)=\int\limits_{0}^x \frac{\sin(t)}{t}\dt$}  
  \rput(8,-1.5){\color{blue}$si(x)=-\int\limits_{x}^{\infty} \frac{\sin(t)}{t}\dt=Si(x)-\frac{\pi}{2}$}  
  \rput(8,.5){$f(x)= \frac{\sin(t)}{t}$}
\end{pspicture}
\end{LTXexample}



\begin{LTXexample}[pos=t]
\def\pshlabel#1{\footnotesize#1} \def\psvlabel#1{\footnotesize#1}
\psset{xunit=0.5}
\begin{pspicture*}(-15,-4.2)(15,4.2)
  \psaxes[dx=1cm,Dx=2]{->}(0,0)(-15.1,-4)(15,4)
  \psplot[plotpoints=1000]{-14.5}{14.5}{ x RadtoDeg cos x Div }
  \psCi[plotpoints=500,linecolor=red,linewidth=1pt]{-11.5}{11.5}
  \psci[plotpoints=500,linecolor=blue,linewidth=1pt]{-11.5}{11.5}
  \rput(-8,1.5){\color{red}$Ci(x)=-\int\limits_{x}^{\infty} \frac{\cos(t)}{t}\dt$}  
  \rput(8,1.5){\color{blue}$ci(x)=-Ci(x)+\ln(x)+\gamma$}  
\end{pspicture*}
\end{LTXexample}


\clearpage
\section{\Lcs{psIntegral}, \Lcs{psCumIntegral} and \Lcs{psConv}}
These new macros\footnote{Created by Jose-Emilio Vila-Forcen}
allows to plot the result of an integral using the Simpson numerical integration rule. 
The first one is the result of the integral of a function with two variables, and 
the integral is performed over one of them. The second one is the cumulative 
integral of a function (similar to \Lcs{psGaussI} but valid for all functions). The third 
one is the result of a convolution. They are defined as:
\begin{align}
\text{psIntegral}(x) &= \int_a^b f(x,t)\mathrm{d}t \\
\text{psCumIntegral}(x) &= \int_{\text{xStart}}^{x} f(t)\mathrm{d}t \\
\text{psConv}(x) & = \int_a^b f(t)g(x-t)\mathrm{d}t
\end{align}
In the first one, the integral is performed from $a$ to $b$ and the function $f$ depends 
on two parameters. In the second one, the function $f$ depends on only one parameter, and the 
integral is performed from the minimum value specified for $x$ (\Lkeyword{xStart}) and the current 
value of $x$ in the plot. The third one uses the \Lcs{psIntegral} macro to perform an approximation 
to the convolution, where the integration is performed from $a$ to $b$.

The syntax of these macros is:

\begin{lstlisting}[style=syntax]
\psIntegral[<options>]{xStart}{xEnd}(a,b){ function }
\psCumIngegral[<options>]{xStart}{xEnd}{ function }
\psConv[<options>]{xStart}{xEnd}(a,b){ function f }{ function g }
\end{lstlisting}

In the first macro, the function should be created such that it accepts two values: \verb|<x t function>| 
should be a value. For the second and the third functions, they only need to accept one 
parameter: \verb|<x function>| should be a value.

There are no new parameters for these functions. The two most important ones are \Lkeyword{plotpoints}, 
which controls the number of points of the plot (number of divisions on $x$ for the plot) and 
\Lkeyword{Simpson}, which controls the precision of the integration (a larger number means a smallest 
step). The precision and the smoothness of the plot depend strongly on these two parameters.

\bigskip
\begin{LTXexample}
%\usepackage{pst-math}
\psset{xunit=0.5cm,yunit=2cm}
\begin{pspicture}[linewidth=1pt](-10,-.5)(10,1.5)
  \psaxes[dx=1cm,Dx=2]{->}(0,0)(-10,0)(10,1.5)
  \psCumIntegral[plotpoints=200,Simpson=10]{-10}{10}{0 1 GAUSS}
  \psIntegral[plotpoints=200,Simpson=100,linecolor=green]{.1}{10}(-3,3){0 exch GAUSS}
  \psIntegral[plotpoints=200,Simpson=10,linecolor=red,
    fillcolor=red!40,fillstyle=solid,opacity=0.5]{-10}{10}(-4,6){1 GAUSS}
\end{pspicture}
\end{LTXexample}

In the example, the cumulative integral of a Gaussian is presented in black. In red, a 
Gaussian is varying its mean from -10 to 10, and the result is the integral from -4 to 6. 
Finally, in green it is presented the integral of a Gaussian from -3 to 3, where the 
variance is varying from .1 to 10.

\begin{LTXexample}
\psset{xunit=1cm,yunit=4cm}
\begin{pspicture}[linewidth=1pt](-5,-.2)(5,0.75)
  \psaxes[dx=1cm,Dx=1,Dy=0.5]{->}(0,0)(-5,0)(5,0.75)
  \psplot[linecolor=blue,plotpoints=200]{-5}{5}{x abs 2 le {0.25}{0} ifelse}
  \psplot[linecolor=green,plotpoints=200]{-5}{5}{x abs 1 le {.5}{0} ifelse}
  \psConv[plotpoints=100,Simpson=1000,linecolor=red]{-5}{5}(-10,10)%
    {abs 2 le {0.25}{0} ifelse}{abs 1 le {.5} {0} ifelse}
\end{pspicture}
\end{LTXexample}

In the second example, a convolution is performed using two rectangle functions. 
The result (in red) is a \Index{trapezoid function}.

\clearpage
\section{Distributions}
All distributions which use the $\Gamma$- or $\ln\Gamma$-function need the \LPack{pst-math} package,
it defines the PostScript functions \Lps{GAMMA} and \Lps{GAMMALN}. \LPack{pst-func} reads by default the PostScript
file \LFile{pst-math.pro}. It is part of any \TeX\ distribution and should also be on
your system, otherwise install or update it from \textsc{CTAN}. It must the latest version. 

\begin{LTXexample}[pos=l,width=7cm]
\begin{pspicture*}(-0.5,-0.5)(6.2,5.2)
 \psaxes{->}(0,0)(6,5)
 \psset{plotpoints=100,linewidth=1pt}
 \psplot[linecolor=red]{0.01}{4}{ x GAMMA }
 \psplot[linecolor=blue]{0.01}{5}{ x GAMMALN }
\end{pspicture*}
\end{LTXexample}



\clearpage
\subsection{Normal distribution (Gauss)}
The Gauss function is defined as
%
\begin{align}
f(x) &= \dfrac{1}{\sigma\sqrt{2\pi}}\,e^{-\dfrac{\left(x-\mu\right)^2}{2\sigma{}^2}}
\end{align}
%
\noindent The syntax of the macros is

\begin{lstlisting}[style=syntax]
\psGauss[options]{xStart}{xEnd}
\psGaussI[options]{xStart}{xEnd}
\end{lstlisting}

\noindent where the only new parameter are \Lkeyword{sigma}=<value>+ and  \Lkeyword{mue}=<value>+ for the
horizontal shift,
which can also be set in the usual way with \Lcs{psset}. It is
significant only for the \Lcs{psGauss}- and \Lcs{psGaussI}-macro. The default is
\Lkeyword{sigma}=0.5 and \Lkeyword{mue}=0. The integral is caclulated wuth the Simson algorithm 
and has one special option, called \Lkeyword{Simpson}, which defines the number of intervalls per step
and is predefined with 5.


\begin{LTXexample}[pos=t,preset=\centering,wide=true]
\psset{yunit=4cm,xunit=3}
\begin{pspicture}(-2,-0.2)(2,1.4)
%  \psgrid[griddots=10,gridlabels=0pt, subgriddiv=0]
  \psaxes[Dy=0.25]{->}(0,0)(-2,0)(2,1.25)
  \uput[-90](6,0){x}\uput[0](0,1){y}
  \rput[lb](1,0.75){\textcolor{red}{$\sigma =0.5$}}
  \rput[lb](1,0.5){\textcolor{blue}{$\sigma =1$}}
  \rput[lb](-2,0.5){$f(x)=\dfrac{1}{\sigma\sqrt{2\pi}}\,e^{-\dfrac{(x-\mu)^2}{2\sigma{}^2}}$}
  \psGauss[linecolor=red, linewidth=2pt]{-1.75}{1.75}%
  \psGaussI[linewidth=1pt,yunit=0.75]{-2}{2}%
  \psGauss[linecolor=cyan, mue=0.5, linewidth=2pt]{-1.75}{1.75}%
  \psGauss[sigma=1, linecolor=blue, linewidth=2pt]{-1.75}{1.75}
\end{pspicture}
\end{LTXexample}



\clearpage
\subsection{Binomial distribution}\label{sec:bindistri}

These two macros plot binomial distribution, \Lcs{psBinomialN} the normalized one. It is always 
done in the $x$-Intervall $[0;1]$.
Rescaling to another one can be done by setting the \Lkeyword{xunit} option
to any other value. 

The binomial distribution gives the discrete probability distribution $P_p(n|N)$ of obtaining
exactly $n$ successes out of $N$ Bernoulli trials (where the result of each 
Bernoulli trial is true with probability $p$ and false with probability
$q=1-p$.  The binomial distribution is therefore given by

\begin{align}
P_p(n|N) &= \binom{N}{n}p^nq^{N-n} \\
         &= \frac{N!}{n!(N-n)!}p^n(1-p)^{N-n},
\end{align}
where $(N; n)$ is a binomial coefficient and $P$ the probability. 

The syntax is quite easy:

\begin{lstlisting}[style=syntax]
\psBinomial[<options>]{N}{probability p}
\psBinomial[<options>]{m,N}{probability p}
\psBinomial[<options>]{m,n,N}{probability p}
\psBinomialN[<options>]{N}{probability p}
\end{lstlisting}

\begin{itemize}
\item with one argument $N$ the sequence $0\ldots N$ is calculated and plotted
\item with two arguments $m,N$ the sequence $0\ldots N$ is calculated and 
    the sequence $m\ldots N$ is plotted
\item with three arguments $m,n,N$ the sequence $0\ldots N$ is calculated and 
    the sequence $m\ldots n$ is plotted
\end{itemize}

There is a restriction in using the value for N. It depends to the probability, but in general
one should expect problems with $N>100$. PostScript cannot handle such small values and there will
be no graph printed. This happens on PostScript side, so \TeX\ doesn't report any problem in
the log file. The valid options for the macros are \Lkeyword{markZeros} to draw rectangles instead
of a continous line and \Lkeyword{printValue} for printing the $y$-values on top of the lines,
rotated by 90\textdegree. For this option all other options from section~\ref{sec:printValue}
for the macro \Lcs{psPrintValue} are valid, too. The only special option is \Lkeyword{barwidth},
which is a factor (no dimension) and set by default to 1. This option is only valid for
the macro \Lcs{psBinomial} and not for the normalized one!

\psset[pst-func]{barwidth=1}
\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=5cm}%
\begin{pspicture}(-1,-0.15)(7,0.55)%
\psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(7,0.5)
\uput[-90](7,0){$k$} \uput[90](0,0.5){$P(X=k)$}
\psBinomial[markZeros,printValue,fillstyle=vlines]{6}{0.4}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=10cm}%
\begin{pspicture}(-1,-0.05)(8,0.6)%
\psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(8,0.5)
\uput[-90](8,0){$k$} \uput[90](0,0.5){$P(X=k)$}
\psBinomial[linecolor=red,markZeros,printValue,fillstyle=solid,
	fillcolor=blue,barwidth=0.2]{7}{0.6}
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=10cm}%
\begin{pspicture}(-1,-0.05)(8,0.6)%
\psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(8,0.5)
\uput[-90](8,0){$k$} \uput[90](0,0.5){$P(X=k)$}
\psBinomial[linecolor=black!30]{0,7}{0.6}
\psBinomial[linecolor=blue,markZeros,printValue,fillstyle=solid,
	fillcolor=blue,barwidth=0.4]{2,5,7}{0.6}
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=0.25cm,yunit=10cm}
\begin{pspicture*}(-1,-0.05)(61,0.52)
\psaxes[Dx=5,dx=5\psxunit,Dy=0.2,dy=0.2\psyunit]{->}(60,0.5)
\uput[-90](60,0){$k$} \uput[0](0,0.5){$P(X=k)$}
\psBinomial[markZeros,linecolor=red]{4}{.5}
\psset{linewidth=1pt}
\psBinomial[linecolor=green]{5}{.5} \psBinomial[linecolor=blue]{10}{.5}
\psBinomial[linecolor=red]{20}{.5}  \psBinomial[linecolor=magenta]{50}{.5}
\psBinomial[linecolor=cyan]{0,55,75}{.5}
\end{pspicture*}
\end{LTXexample}

The default binomial distribution has the mean of $\mu=E(X)=N\cdot p$ and a variant of $\sigma^2=\mu\cdot(1-p)$.
The normalized distribution has a mean of $0$. Instead of $P(X=k)$ we use $P(Z=z)$ with $Z=\dfrac{X-E(X)}{\sigma(X)}$
and $P\leftarrow P\cdot\sigma$.
The macros use the rekursive definition of the binomial distribution:
%
\begin{align}
P(k) &= P(k-1)\cdot\frac{N-k+1}{k}\cdot\frac{p}{1-p}
\end{align}



\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=5cm}%
\begin{pspicture}(-3,-0.15)(4,0.55)%
\psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-3,0)(4,0.5)
\uput[-90](4,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
\psBinomialN[markZeros,fillstyle=vlines]{6}{0.4}
\end{pspicture}
\end{LTXexample}



\begin{LTXexample}[pos=t,preset=\centering]
\psset{yunit=10}
\begin{pspicture*}(-8,-0.07)(8.1,0.55)
\psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-8,0)(8,0.5)
\uput[-90](8,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
\psBinomialN{125}{.5}
\psBinomialN[markZeros,linewidth=1pt,linecolor=red]{4}{.5}
\end{pspicture*}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{yunit=10}
\begin{pspicture*}(-8,-0.07)(8.1,0.52)
\psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-8,0)(8,0.5)
\uput[-90](8,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
\psBinomialN[markZeros,linecolor=red]{4}{.5}
\psset{linewidth=1pt}
\psBinomialN[linecolor=green]{5}{.5}\psBinomialN[linecolor=blue]{10}{.5}
\psBinomialN[linecolor=red]{20}{.5} \psBinomialN[linecolor=gray]{50}{.5}
\end{pspicture*}
\end{LTXexample}



For the normalized distribution the plotstyle can be set to \Lkeyval{curve} (\Lkeyword{plotstyle}=\Lkeyval{curve}), 
then the binomial distribution looks like a normal distribution. This option is only
valid vor \Lcs{psBinomialN}. The option \Lkeyword{showpoints} is valid if \Lkeyval{curve} was chosen.


\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=10cm}%
\begin{pspicture*}(-4,-0.06)(4.1,0.57)%
\psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-4,0)(4,0.5)%
\uput[-90](4,0){$z$} \uput[90](0,0.5){$P(Z=z)$}%
\psBinomialN[linecolor=red,fillstyle=vlines,showpoints=true,markZeros]{36}{0.5}%
\psBinomialN[linecolor=blue,showpoints=true,plotstyle=curve]{36}{0.5}%
\end{pspicture*}
\end{LTXexample}


\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=10cm}%
\begin{pspicture*}(-4,-0.06)(4.2,0.57)%
\psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-4,0)(4,0.5)%
\uput[-90](4,0){$z$} \uput[90](0,0.5){$P(Z=z)$}%
\psBinomialN[linecolor=red]{10}{0.6}%
\psBinomialN[linecolor=blue,showpoints=true,plotstyle=curve]{10}{0.6}%
\end{pspicture*}
\end{LTXexample}


\clearpage
\subsection{Poisson distribution}
Given a Poisson process\footnote{\url{http://mathworld.wolfram.com/PoissonProcess.html}}, 
the probability of obtaining exactly $n$ successes in $N$ trials is given by the 
limit of a binomial distribution (see Section~\ref{sec:bindistri})
%
\begin{align}
P_p(n|N) &= \frac{N!}{n!(N-n)!}\cdot p^n(1-p)^{N-n}\label{eq:normaldistri}
\end{align}
%
Viewing the distribution as a function of the expected number of successes
%	
\begin{align}\label{eq:nu}
\lambda &= n\cdot p
\end{align}
%
instead of the sample size $N$ for fixed $p$, equation (2) then becomes
eq.~\ref{eq:normaldistri}
%	
\begin{align}\label{eq:nuN}
P_{\frac{\lambda}{n}}(n|N) &= \frac{N!}{n!(N-n)!}{\frac{\lambda}{N}}^n {\frac{1-\lambda}{N}}^{N-n}
\end{align}
%
Viewing the distribution as a function of the expected number of successes
%
\[ P_\lambda(X=k)=\frac{\lambda^k}{k!}\,e^{-\lambda} \]
%
Letting the sample size  become large ($N\to\infty$), the distribution then 
approaches (with $p=\frac{\lambda}{n}$)
%
\begin{align}
\lim_{n\to\infty} P(X=k) &= \lim_{n\to\infty}\frac{n!}{(n-k)!\,k!}
	 \left(\frac{\lambda}{n}\right)^k \left(1-\frac{\lambda}{n}\right)^{n-k} \\
  &= \lim_{n\to\infty} \left(\frac{(n-k)!\cdot (n-k+1)\cdots(n-2)(n-1)n}{(n-k)!\,n^k}\right)\cdot\\
  &\qquad \left(\frac{\lambda^k}{k!}\right)\left(1-\frac{\lambda}{n}\right)^n 
	\left(1-\frac{\lambda}{n}\right)^{-k}\\
  &= \frac{\lambda^k}{k!}\cdot \lim_{n\to\infty}
     \underbrace{\left(\frac{n}{n}\cdot \frac{n-1}{n}\cdot\frac{n-2}{n}\cdot\ldots\cdot 
    	\frac{n-k+1}{n}\right)}_{\to 1} \cdot\\
  &\qquad   \underbrace{\left(1-\frac{\lambda}{n}\right)^n}_{\to{e^{-\lambda}}}  
     \underbrace{\left(1-\frac{\lambda}{n}\right)^{-k}}_{\to 1}\\
  &=  \lambda^k e^{\frac{-\lambda}{k!}}
\end{align}
%
which is known as the Poisson distribution and has the follwing syntax:


\begin{lstlisting}[style=syntax]
\psPoisson[settings]{N}{lambda}
\psPoisson[settings]{M,N}{lambda}
\end{lstlisting}

in which \texttt{M} is an optional argument with a default of 0.


\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=20cm}%
\begin{pspicture}(-1,-0.05)(14,0.25)%
\uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
\psPoisson[linecolor=red,markZeros,fillstyle=solid,
	fillcolor=blue!10,printValue,valuewidth=20]{13}{6} % N lambda
\psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(14,0.2)
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=20cm}%
\begin{pspicture}(-1,-0.05)(14,0.25)%
\uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
\psPoisson[linecolor=blue,markZeros,fillstyle=solid,barwidth=0.4,
	fillcolor=blue!10,printValue,valuewidth=20]{10}{6} % N lambda
\psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(11,0.2)
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1cm,yunit=20cm}%
\begin{pspicture}(-1,-0.05)(14,0.25)%
\uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
\psPoisson[printValue,valuewidth=20]{2,11}{6} % M,N lambda
\psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(14,0.2)
\end{pspicture}
\end{LTXexample}



\clearpage
\subsection{Gamma distribution}
A gamma distribution is a general type of statistical distribution that is related 
to the beta distribution and arises naturally in processes for which the waiting 
times between Poisson distributed events are relevant. Gamma distributions have 
two free parameters, labeled $alpha$ and $beta$. It is defined as
%
\[
f(x)=\frac{\beta(\beta x)^{\alpha-1}e^{-\beta x}}{\Gamma(\alpha)} \qquad
\text{for $x>0$ and $\alpha$, $\beta>0$}
\]
%
and has the syntax

\begin{lstlisting}[style=syntax]
\psGammaDist[options]{x0}{x1}
\end{lstlisting}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1.2cm,yunit=10cm,plotpoints=200}
\begin{pspicture*}(-0.75,-0.05)(9.5,0.6)
 \psGammaDist[linewidth=1pt,linecolor=red]{0.01}{9}
 \psGammaDist[linewidth=1pt,linecolor=blue,alpha=0.3,beta=0.7]{0.01}{9}
 \psaxes[Dy=0.1]{->}(0,0)(9.5,.6)
\end{pspicture*}
\end{LTXexample}


\clearpage
\subsection{$\chi^2$-distribution}
The $\chi^2$-distribution is a continuous probability distribution. It
usually arises when a k-dimensional vector's orthogonal components are 
independent and each follow a standard normal distribution. 
The length of the vector will then have a $\chi^2$-distribution.

\iffalse
If Y_i have normal independent  distributions with mean 0 and variance 1, then
chi^2=sum_(i==1)^rY_i^2	
(1)

is distributed as chi^2 with r degrees of freedom. This makes a chi^2 distribution 
a gamma distribution with theta=2 and alpha=r/2, where r is the number of degrees of freedom.

More generally, if chi_i^2 are independently distributed according to a chi^2 
distribution with r_1, r_2, ..., r_k degrees of freedom, then
sum_(j==1)^kchi_j^2	

is distributed according to chi^2 with r=sum_(j==1)^(k)r_j degrees of freedom. 
\fi

The $\chi^2$ with parameter $\nu$ is the same as a Gamma distribution 
 with $\alpha=\nu/2$ and $\beta=1/2$ and the syntax

\begin{lstlisting}[style=syntax]
\psChiIIDist[options]{x0}{x1}
\end{lstlisting}

\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1.2cm,yunit=10cm,plotpoints=200}
\begin{pspicture*}(-0.75,-0.05)(9.5,.65)
 \multido{\rnue=0.5+0.5,\iblue=0+10}{10}{%
   \psChiIIDist[linewidth=1pt,linecolor=blue!\iblue,nue=\rnue]{0.01}{9}}
 \psaxes[Dy=0.1]{->}(0,0)(9.5,.6)
\end{pspicture*}
\end{LTXexample}

\iffalse
The cumulative distribution function is 
\begin{align*}
D_r(\chi^2) &=	int_0^{\chi^2}\frac{t^{r/2-1}e^{-t/2}\mathrm{d}t}{\Gamma(1/2r)2^{r/2}}	\\

	    &=	1-\frac{\Gamma(1/2r,1/2\chi^2)}{\Gamma(1/2r)}
\end{align*}
\fi



%The $\chi^2_\nu$-distribution has mode $\nu-2$ for $\nu\geq2$.

\clearpage
\subsection{Student's $t$-distribution}

A \Index{statistical distribution} published by \Index{William Gosset} in 1908 under his %. His employer, Guinness Breweries, 
%required him to publish under a 
pseudonym %, so he chosed 
,,Student``. 
%Given N independent measurements x_i, let
%t=(x^_-mu)/(s/sqrt(N)),
The $t$-distribution with parameter $\nu$ has the \Index{density function}
\[
f(x)=\frac1{\sqrt{\nu\pi}}\cdot
 \frac{\Gamma[(\nu+1)/2]}{\Gamma(\nu/2)}\cdot\frac1{[1+(x^2/\nu)]^{(\nu+1)/2}} \qquad
\text{for $-\infty<x<\infty$ and $\nu>0$}\]
%
and the following syntax

\begin{lstlisting}[style=syntax]
\psTDist[options]{x0}{x1}
\end{lstlisting}


\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=1.25cm,yunit=10cm}
\begin{pspicture}(-6,-0.1)(6,.5)
 \psaxes[Dy=0.1]{->}(0,0)(-4.5,0)(5.5,0.5)
 \psset{linewidth=1pt,plotpoints=100}
 \psGauss[mue=0,sigma=1]{-4.5}{4.5}
 \psTDist[linecolor=blue]{-4}{4}
 \psTDist[linecolor=red,nue=4]{-4}{4}
\end{pspicture}
\end{LTXexample}


%The $t_\nu$-distribution has mode 0.

\clearpage
\subsection{$F$-distribution}
A continuous statistical distribution which arises in the testing of 
whether two observed samples have the same variance. 

The F-distribution with parameters $\mu$ and $\nu$ has the probability function
\[
f_{n,m}(x)=\frac{\Gamma[(\mu+\nu)/2]}{\Gamma(\mu/2)\Gamma(\nu/2)}\cdot
 \left(\mu/\nu\right)^{\mu/2}\frac{x^{(\mu/2)-1}}{[1+(\mu x/\nu)]^{(\mu+\nu)/2}}\quad
\text{ for $x>0$ and $\mu$, $\nu>0$}\]
%
and the syntax 

\begin{lstlisting}[style=syntax]
\psFDist[options]{x0}{x1}
\end{lstlisting}
%
The default settings are $\mu=1$ and $\nu=1$.

\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=2cm,yunit=10cm,plotpoints=100}
\begin{pspicture*}(-0.5,-0.07)(5.5,0.8)
 \psline[linestyle=dashed](0.5,0)(0.5,0.75)
 \psline[linestyle=dashed](! 2 7 div 0)(! 2 7 div 0.75)
 \psset{linewidth=1pt}
 \psFDist{0.1}{5} 
 \psFDist[linecolor=red,nue=3,mue=12]{0.01}{5}
 \psFDist[linecolor=blue,nue=12,mue=3]{0.01}{5}
 \psaxes[Dy=0.1]{->}(0,0)(5,0.75)
\end{pspicture*}
\end{LTXexample}


\clearpage
\subsection{Beta distribution}
	
A general type of statistical distribution which is related to the gamma distribution. 
Beta distributions have two free parameters, which are labeled according to one of two 
notational conventions. The usual definition calls these $\alpha$ and $\beta$, and the other 
uses $\beta^\prime=\beta-1$ and $\alpha^\prime=\alpha-1$. The beta distribution is 
used as a prior distribution for binomial proportions in \Index{Bayesian analysis}. 
%
%The plots are for various values of ($\alpha,\beta$) with $\alpha=1$ and $\beta$ ranging from 0.25 to 3.00.
%
The domain is $[0,1]$, and the probability function $P(x)$ is given by
%
\[
P(x)	=	\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}(1-x)^{\beta-1}x^{\alpha-1}
\quad\text{ $\alpha,\beta>0$}
\]
%
and has the syntax (with a default setting of $\alpha=1$ and $\beta=1$):

\begin{lstlisting}[style=syntax]
\psBetaDist[options]{x0}{x1}
\end{lstlisting}
%


\begin{LTXexample}[pos=t,preset=\centering]
\psset{xunit=10cm,yunit=5cm}
\begin{pspicture*}(-0.1,-0.1)(1.1,2.05)
 \psset{linewidth=1pt}
 \multido{\rbeta=0.25+0.25,\ired=0+5,\rblue=50.0+-2.5}{20}{%
   \psBetaDist[beta=\rbeta,linecolor=red!\ired!blue!\rblue]{0.01}{0.99}}
 \psaxes[Dy=0.2,Dx=0.1]{->}(0,0)(1,2.01)
\end{pspicture*}
\end{LTXexample}


\iffalse
\clearpage
\subsection{Bose-Einstein distribution}
A distribution which arises in the study of integer \Index{spin particles} in physics,
\[
P(x)=\frac{x^s}{e^{x-mu}-1}\qquad\text{with $s\in\mathbb{Z}$ and $\mu\in\mathbb{R}}
\]
%
and has the syntax (with a default setting of $s=1$ and $\mu=1$):

\begin{lstlisting}[style=syntax]
\psBoseEInsteinDist[options]{x0}{x1}
\end{lstlisting}
\fi


\clearpage
\section{\nxLcs{psLame} -- Lam\'e Curve, a superellipse}
A superellipse is a curve with Cartesian equation
%	
\begin{align}
\left|\frac{x}{a}\right|^r + \left|\frac{y}{b}\right|^r & =1
\end{align}
%
first discussed in 1818 by Gabriel Lam\'e (1795--1870)%
\footnote{Lam\'e worked on a wide variety of different topics. 
His work on differential geometry and contributions to Fermat's Last Theorem 
are important. He proved the theorem for $n = 7$ in 1839.}. 
A superellipse may be described parametrically by
%
\begin{align}
x = a\cdot\cos^{\frac{2}{r}} t\\
y = b\cdot\sin^{\frac{2}{r}} t
\end{align}
%			
\Index{Superellipses} with $a=b$ are also known as \Index{Lam\'e} curves or Lam\'e ovals and
the restriction to $r>2$ is sometimes also made. The following 
table summarizes a few special cases. \Index{Piet Hein} used $\frac{5}{2}$ with a number of different 
$\frac{a}{b}$ ratios for various of his projects. For example, he used $\frac{a}{b}=\frac{6}{5}$ 
for Sergels Torg 
(Sergel's Square) in Stockholm, and $\frac{a}{b}=\frac{3}{2}$ for his table.

\begin{center}
\begin{tabular}{@{}llm{1.5cm}@{}}
r & curve type & example\\\hline
$\frac{2}{3}$ &	(squashed) astroid 
  & \pspicture(-.5,-.5)(.5,.5)\psLame[radiusA=.5,radiusB=.5]{0.6667}\endpspicture\\
1             & (squashed) diamond
  & \pspicture(-.5,-.5)(.5,.5)\psLame[radiusA=.5,radiusB=.5]{1}\endpspicture\\
2	      & ellipse
  & \pspicture(-.5,-.5)(.5,.5)\psLame[radiusA=.5,radiusB=.5]{2}\endpspicture\\
$\frac{5}{2}$ & Piet Hein's ,,superellipse``
  & \pspicture(-.5,-.5)(.5,.5)\psLame[radiusA=.5,radiusB=.5]{2.5}\endpspicture
\end{tabular}
\end{center}

If $r$ is a rational, then a \Index{superellipse} is algebraic. However, for irrational $r$, 
it is transcendental. For even integers $r=n$, the curve becomes closer to a 
rectangle as $n$ increases. The syntax of the \Lcs{psLame} macro is:

\begin{lstlisting}[style=syntax]
\psLame[settings]{r}
\end{lstlisting}

It is internally plotted as a \Index{parametric plot} with $0\le\alpha\le360$. Available keywords
are \Lkeyword{radiusA} and \Lkeyword{radiusB}, both are preset to 1, but can have any valid value
and unit.

\bgroup
\begin{LTXexample}[pos=t,preset=\centering]
\definecolorseries{col}{rgb}{last}{red}{blue}
\resetcolorseries[41]{col}
\psset{unit=.5}
\pspicture(-9,-9)(9,9)
  \psaxes[Dx=2,Dy=2,tickstyle=bottom,ticksize=2pt]{->}(0,0)(-9,-9)(9,9)
  \multido{\rA=0.2+0.1,\iA=0+1}{40}{%
    \psLame[radiusA=8,radiusB=7,linecolor={col!![\iA]},linewidth=.5pt]{\rA}}
\endpspicture
\end{LTXexample}
\egroup


\clearpage
\section{\Lcs{psThomae} -- the popcorn function}

\Index{Thomae's function}, also known as the \Index{popcorn function}, 
the \Index{raindrop function}, the \Index{ruler function} or the 
\Index{Riemann function}, is a modification of the \Index{Dirichlet} function. 
This real-valued function $f(x)$ is defined as follows:

\[ f(x)=\begin{cases} 
	    \frac{1}{q}\mbox{ if }x=\frac{p}{q}\mbox{ is a rational number}\\ 
	    0\mbox{ if }x\mbox{ is irrational} 
	\end{cases}
\]
It is assumed here that $\mathop{gcd}(p,q) = 1$ and $q > 0$ so that the function is well-defined 
and nonnegative. The syntax is:

\begin{lstlisting}[style=syntax]
\psThomae[options](x0,x1){points}
\end{lstlisting}

\verb+(x0,x1)+ is the plotted interval, both values must be grater zero and $x_1>x_0$. 
The plotted number of points is the third parameter. 

\begin{LTXexample}[width=6cm,wide=false]
\psset{unit=4cm}
\begin{pspicture}(-0.1,-0.2)(2.5,1.15)
    \psaxes{->}(0,0)(2.5,1.1)
    \psThomae[dotsize=2.5pt,linecolor=red](0,2){300}
\end{pspicture}
\end{LTXexample}


\clearpage
\section{\Lcs{psplotImp} -- plotting implicit defined functions}
This macro is still experimental! For a given area, the macro calculates in a
first step row by row for every pixel (1pt) the function $f(x,y)$ and checks for an
changing of the value from $f(x,y)<0$ to $f(x,y)>0$ or vice versa. If this happens,
then the pixel must be a part of the curve of the function $f(x,y)=0$. In a second step the same is
done column by column. This will take some time because an area of $400\times 300$
pixel needs $120$ thousand calculations of the function value. The user still defines
this area in his own coordinates, the translation into pixel (pt) is done internally by the
macro.

\begin{lstlisting}[style=syntax]
\psplotImp[<options>](xMin,yMin)(xMax,yMax){<function f(x,y)>}
\end{lstlisting}

The function must be of $f(x,y)=0$ and described in \PS code, or alternatively with
the option \\Lkeyword{algebraic} (\LPack{pstricks-add}) in an algebraic form. No other value names than $x$ and $y$
are possible. In general a starred \verb+pspicture+ environment maybe a good choice here.
The given area for \Lcs{psplotImp} should be \textbf{greater} than the given \Lenv{pspicture} area.

\begin{LTXexample}[preset=\centering]
\begin{pspicture*}(-3,-3.2)(3.5,3.5)
\psaxes{->}(0,0)(-3,-3)(3.2,3)%
\psplotImp[linewidth=2pt,linecolor=red](-5,-2.1)(5,2.1){%
	 x dup mul y dup mul add 4 sub }% circle r=2
\uput[45](0,2){$x^2+y^2-4=0$}
\psplotImp[linewidth=2pt,linecolor=blue,algebraic]%
	(-5,-3)(4,2.4){ (x+1)^2+y^2-4 }% circle r=2
\end{pspicture*}
\end{LTXexample}

\begin{LTXexample}[preset=\centering]
\begin{pspicture*}(-3,-2.2)(3.5,2.5)
\psaxes{->}(0,0)(-3,-2)(3.2,2)%
\psplotImp[linewidth=2pt,linecolor=blue](-5,-2.2)(5,2.4){%
      /xqu x dup mul def
      /yqu y dup mul def
      xqu yqu add dup mul 2 dup add 2 mul xqu yqu sub mul sub }
\uput*[0](-3,2){$\left(x^2+y^2\right)^2-8(x^2-y^2)=0$}
\psplotImp[linewidth=1pt,linecolor=red,algebraic](-5,-2.2)(5,2.4){% Lemniskate a =2
    (x^2+y^2)^2-4*(x^2-y^2) }
\end{pspicture*}
\end{LTXexample}

\begin{LTXexample}[preset=\centering]
\begin{pspicture*}(-3,-3.2)(3.5,3.5)
\psaxes{->}(0,0)(-3,-3)(3.2,3)%
\psplotImp[linewidth=2pt,linecolor=green](-6,-6)(4,2.4){%
	 x 3 exp y 3 exp add 4 x y mul mul sub } 
\uput*[45](-2.5,2){$\left(x^3+y^3\right)-4xy=0$}
\end{pspicture*}
\end{LTXexample}


\begin{LTXexample}[preset=\centering]
\begin{pspicture*}(-5,-3.2)(5.5,4.5)
\psaxes{->}(0,0)(-5,-3)(5.2,4)%
\psplotImp[algebraic,linecolor=red](-6,-4)(5,4){ y*cos(x*y)-0.2 }
\psplotImp[algebraic,linecolor=blue](-6,-4)(5,4){ y*cos(x*y)-1.2 }
\end{pspicture*}
\end{LTXexample}



Using the \Lkeyword{polarplot} option implies using the variables $r$ and $phi$ for describing
the function, $y$ and $x$ are not respected in this case. Using the \Lkeyword{algebraic} option
for polar plots are also possible (see next example).

\begin{LTXexample}[preset=\centering]
\begin{pspicture*}(-3,-2.5)(3.75,2.75)\psaxes{->}(0,0)(-3,-2.5)(3.2,2.5)%
\psplotImp[linewidth=2pt,linecolor=cyan,polarplot](-6,-3)(4,2.4){ r 2 sub }% circle r=2
\uput*[45](0.25,2){$f(r,\phi)=r-2=0$}
\psplotImp[polarplot,algebraic](-6,-3)(4,2.4){ r-1 }% circle r=1
\end{pspicture*}
\end{LTXexample}

\begin{LTXexample}[preset=\centering]
\begin{pspicture*}(-5,-2.2)(5.5,3.5)
\pscircle(0,0){1}% 
\psaxes{->}(0,0)(-5,-2)(5.2,3)%
\multido{\rA=0.01+0.2}{5}{%
\psplotImp[linewidth=1pt,linecolor=blue,polarplot](-6,-6)(5,2.4){%
	 r dup mul 1.0 r div sub phi sin dup mul mul \rA\space sub }}%
\uput*[45](0,2){$f(r,\phi)=\left(r^2-\frac{1}{r}\right)\cdot\sin^2\phi=0$}
\end{pspicture*}
\end{LTXexample}

\begin{LTXexample}[preset=\centering]
\begin{pspicture*}(-4,-3.2)(4.5,4.5)
\psaxes{->}(0,0)(-4,-3)(4.2,4)%
\psplotImp[algebraic,polarplot,linecolor=red](-5,-4)(5,4){ r+cos(phi/r)-2 }
\end{pspicture*}
\end{LTXexample}



\clearpage
\section{\Lcs{psVolume} -- Rotating functions around the x-axis}

This macro shows the behaviour of a \Index{rotated function} around the x-axis.

\begin{lstlisting}[style=syntax]
\psVolume[<options>](xMin,xMax){<steps>}{<function f(x)>}
\end{lstlisting}

$f(x)$ has to be described as usual for the macro psplot.

\makebox[\linewidth]{%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=magenta!30](0,4){1}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=red!40](0,4){2}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=blue!40](0,4){4}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
}

\makebox[\linewidth]{%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=green!40](0,4){8}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=yellow!40](0,4){16}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=cyan!40](0,4){32}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
}

\begin{lstlisting} 
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=magenta!30](0,4){1}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=red!40](0,4){2}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=blue!40](0,4){4}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}

\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=green!40](0,4){8}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=yellow!40](0,4){16}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-2)(5,2.5)
\psaxes{->}(0,0)(0,-2)(3,2.5)
\psVolume[fillstyle=solid,fillcolor=cyan!40](0,4){32}{x sqrt}
\psline{->}(4,0)(5,0)
\end{pspicture}
\end{lstlisting} 


\psset{xunit=2}
\makebox[\linewidth]{%
\begin{pspicture}(-0.5,-4)(3,4)
  \psaxes{->}(0,0)(0,-4)(3,4)
  \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){4}{x}
  \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){4}{x dup mul}
  \psline(2,0)(3,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-4)(3,4)
  \psaxes{->}(0,0)(0,-4)(3,4)
  \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){20}{x}
  \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){20}{x dup mul}
  \psline(2,0)(3,0)
\end{pspicture}
}
\begin{lstlisting} 
\psset{xunit=2}
\begin{pspicture}(-0.5,-4)(3,4)
  \psaxes{->}(0,0)(0,-4)(3,4)
  \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){4}{x}
  \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){4}{x dup mul}
  \psline(2,0)(3,0)
\end{pspicture}
%
\begin{pspicture}(-0.5,-4)(3,4)
  \psaxes{->}(0,0)(0,-4)(3,4)
  \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){20}{x}
  \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){20}{x dup mul}
  \psline(2,0)(3,0)
\end{pspicture}
\end{lstlisting} 

\clearpage

\section{\Lcs{psPrintValue}}\label{sec:printValue}
This new macro allows to \Index{print} single values of a math function. It has the syntax

\begin{lstlisting}[style=syntax]
\psPrintValue[<options>]{<PostScript code>}
\end{lstlisting}

Important is the fact, that \Lcs{psPrintValue} works on \PS\ side. For \TeX\ it is only a box of
zero dimension. This is the reason why you have to put it into a box, which reserves horizontal
space.

There are the following new options:

\noindent\medskip
\begin{tabularx}{\linewidth}{>{\ttfamily}l|>{\ttfamily}l>{\ttfamily}lX@{}}
\textrm{Name} & \textrm{Value}  & \textrm{Default}\\\hline
PSfont        & PS font name & Times & only valid \PS font names are possible, e.g. \texttt{Times-Roman}, \texttt{Helvetica}, \texttt{Courier}, \texttt{AvantGard}, \texttt{Bookman}\\
fontscale & <number>     & 10     & the font scale in pt\\
valuewidth & <number>     & 10     & the width of the string for the converted 
    real number; if it is too small, no value is printed\\
decimals  & <number>     & -1     & the number of printed decimals, a negative value
    prints all possible digits.\\ 
\end{tabularx}

\begin{center}
\psset{fontscale=12}
\makebox[2em]{x(deg)} \makebox[5em]{$\sin x$} \makebox[4em]{$\cos x$}\hspace{1em}
\makebox[5em]{$\sqrt x$}\makebox[7em]{$\sin x+\cos x$}\makebox[6em]{$\sin^2 x+\cos^2 x$}\\[3pt]
\multido{\iA=0+10}{18}{
  \makebox[1em]{\iA}
  \makebox[5em]{\psPrintValue[PSfont=Helvetica]{\iA\space sin}}
  \makebox[4em][r]{\psPrintValue[PSfont=Courier,fontscale=10,decimals=3]{\iA\space cos}}\hspace{1em}
  \makebox[5em]{\psPrintValue[valuewidth=15,linecolor=blue,PSfont=AvantGarde]{\iA\space sqrt}}
  \makebox[7em]{\psPrintValue[PSfont=Times-Italic]{\iA\space dup sin exch cos add}}
  \makebox[6em]{\psPrintValue[PSfont=Palatino-Roman]{\iA\space dup sin dup mul exch cos dup mul add}}\\}
\end{center}

\bigskip

\begin{lstlisting}
\psset{fontscale=12}
\makebox[2em]{x(deg)} \makebox[5em]{$\sin x$} \makebox[4em]{$\cos x$}\hspace{1em}
\makebox[5em]{$\sqrt x$}\makebox[7em]{$\sin x+\cos x$}\makebox[6em]{$\sin^2 x+\cos^2 x$}\\[3pt]
\multido{\iA=0+10}{18}{
  \makebox[1em]{\iA}
  \makebox[5em]{\psPrintValue[PSfont=Helvetica]{\iA\space sin}}
  \makebox[4em][r]{\psPrintValue[PSfont=Courier,fontscale=10,decimals=3]{\iA\space cos}\hspace{1em}}
  \makebox[5em]{\psPrintValue[valuewidth=15,linecolor=blue,PSfont=AvantGarde]{\iA\space sqrt}}
  \makebox[7em]{\psPrintValue[PSfont=Times-Italic]{\iA\space dup sin exch cos add}}
  \makebox[6em]{\psPrintValue[PSfont=Palatino-Roman]{\iA\space dup sin dup mul exch cos dup mul add}}\\}
\end{lstlisting}


\section{Examples}

\begin{LTXexample}[preset=\centering]
\psset{xunit=0.5cm,yunit=20cm,arrowscale=1.5}
\begin{pspicture}(-1,-0.1)(21,0.2)
\psChiIIDist[linewidth=1pt,nue=5]{0.01}{19.5}
\psaxes[labels=none,ticks=none]{->}(20,0.2)
\pscustom[fillstyle=solid,fillcolor=red!30]{%
  \psChiIIDist[linewidth=1pt,nue=5]{8}{19.5}%
  \psline(20,0)(8,0)}
\end{pspicture}
\end{LTXexample}

\clearpage
\section{List of all optional arguments for \texttt{pst-func}}

\xkvview{family=pst-func,columns={key,type,default}}


\section{Credits}
Rafal Bartczuk | Gerry Coombes | Denis Girou | Christophe Jorssen | Manuel Luque | Timothy Van Zandt 
and \url{http://mathworld.wolfram.com}

\printindex

\bgroup
\raggedright
\nocite{*}
\bibliographystyle{plain}
\bibliography{pst-func-doc}
\egroup
\end{document}