Debian Codegraph @

texmf-dist/tex/generic/pst-func/pst-func.tex

raw
1 %% $Id: pst-func.tex 885 2024-03-31 07:25:14Z herbert $
2 %%
3 %% This is file `pst-func.tex',
4 %%
5 %% IMPORTANT NOTICE:
6 %%
7 %% Package `pst-func.tex'
8 %%
9 %% Herbert Voss <[email protected]>
10 %%
11 %% This program can be redistributed and/or modified under the terms
12 %% of the LaTeX Project Public License Distributed from CTAN archives
13 %% in directory macros/latex/base/lppl.txt.
14 %%
15 %% DESCRIPTION:
16 %% `pst-func' is a PSTricks package to plot special functions
17 %%
18 %% For a ChangeLog go the the end
19 %%
20 \csname PSTfuncLoaded\endcsname
21 \let\PSTfuncLoaded\endinput
22 % Requires some PSTricks packages
23 \ifx\PSTricksLoaded\endinput\else \input pstricks.tex\fi
24 \ifx\PSTnodesLoaded\endinput\else \input pst-plot.tex\fi
25 \ifx\PSTmathLoaded\endinput \else \input pst-math.tex\fi
26 \ifx\PSTtoolsLoaded\endinput \else \input pst-tools.tex\fi
27 \ifx\PSTricksAddLoaded\endinput\else\input pstricks-add.tex\fi
28 \ifx\PSTXKeyLoaded\endinput\else \input pst-xkey.tex \fi
29 %
30 \edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
31 % interface to the `xkeyval' package
32 \pst@addfams{pst-func}
33 %
34 \def\fileversion{1.02a}
35 \def\filedate{2024/03/31}
36 \message{`PST-func' v\fileversion, \filedate\space (hv)}
37 %
38 \pstheader{pst-func.pro}
39 %\pstheader{pst-math.pro}% for GAMMALN
40 %
41 % Shortcuts ....
42
43 \def\ChebyshevT{ tx@FuncDict begin ChebyshevT end }
44 \def\ChebyshevU{ tx@FuncDict begin ChebyshevU end }
45
46 %
47 \define@key[psset]{pst-func}{epsilon}[1.e-08]{\def\psk@epsilon{#1 }}
48 \psset[pst-func]{epsilon=1.e-08}
49 \define@key[psset]{pst-func}{xShift}[0]{\def\psk@xShift{#1}}
50 \psset[pst-func]{xShift=0}
51 %
52 \define@key[psset]{pst-func}{cosCoeff}[0]{\def\psk@cosCoeff{#1}}
53 \define@key[psset]{pst-func}{sinCoeff}[1]{\def\psk@sinCoeff{#1}}
54 \psset[pst-func]{cosCoeff=0,sinCoeff=1} % coeff=a0 a1 a2 a3 ...
55 %
56 \def\psFourier{\@ifnextchar[{\psFourier@i}{\psFourier@i[]}}
57 \def\psFourier@i[#1]#2#3{{%
58 \pst@killglue
59 \psset{#1}
60 \psplot[algebraic=false]{#2}{#3}{%
61 /psFtype (cos) def
62 /Fourier {
63 aload length /n exch def
64 n -1 roll 2 div n 1 roll % a0/2
65 n 1 sub -1 0 {
66 /i exch def
67 i x mul 180 mul 3.141592 div
68 psFtype (sin) eq {sin}{cos} ifelse
69 mul n 1 roll
70 } for
71 n 1 sub -1 1 { pop add } for
72 } def
73 [\psk@cosCoeff] Fourier
74 /psFtype (sin) def
75 [0 \psk@sinCoeff] Fourier add
76 }%
77 }\ignorespaces}
78 %
79 \define@key[psset]{pst-func}{coeff}[0 1]{\def\psk@coeff{#1}}
80 \define@key[psset]{pst-func}{Derivation}[0]{\def\psk@Derivation{#1}}
81 \define@boolkey[psset]{pst-func}[Pst@]{markZeros}[true]{}
82 \define@key[psset]{pst-func}{epsZero}[0.1]{\def\psk@epsZero{#1}}
83 \define@key[psset]{pst-func}{dZero}[0.1]{\def\psk@dZero{#1}}
84 \define@key[psset]{pst-func}{zeroLineTo}[-1]{\def\psk@zeroLineTo{#1}}
85 \define@key[psset]{pst-func}{zeroLineColor}[black]{\pst@getcolor{#1}\psk@zeroLineColor}
86 \newdimen\psk@zeroLineWidth
87 \define@key[psset]{pst-func}{zeroLineWidth}[0.5\pslinewidth]{\pssetlength\psk@zeroLineWidth{#1}}
88 \define@key[psset]{pst-func}{zeroLineStyle}[dashed]{%
89 \@ifundefined{psls@#1}%
90 {\@pstrickserr{Line style `#1' not defined}\@eha}%
91 {\edef\psk@zeroLineStyle{#1}}%
92 }
93 \psset[pst-func]{%
94 coeff=0 1, % coeff=a0 a1 a2 a3 ...
95 Derivation=0, % 0 is the original function
96 markZeros=false,% no dots for the zeros
97 epsZero=0.1, % the distance between two zero points
98 dZero=0.1, % the distance of the x value for scanning the function
99 zeroLineTo=-1, % a line to the value of the lineTo's Derivation (-1= none)
100 zeroLineStyle=dashed,%
101 zeroLineWidth=0.5\pslinewidth,%
102 zeroLineColor=black}%
103 %
104 \def\psGetZeros{\pst@object{psGetZeros}}
105 \def\psGetZeros@i(#1,#2)#3{%
106 \pst@killglue
107 \begin@SpecialObj
108 \use@par
109 \addto@pscode{
110 tx@FuncDict begin
111 /xStart #1 def /xEnd #2 def
112 /x xStart def
113 /func { /x exch def \ifPst@algebraic (#3) AlgParser cvx exec \else #3 \fi } def
114 #1 Steffensen
115 \ifPst@markZeros \fi
116 end
117 }%
118 \end@SpecialObj
119 \ignorespaces
120 }
121 \iffalse
122 /Steffensen {% the start value and the function must be on top of the stack
123 /y0 exch def % the start value
124 /Iter 0 def /MaxIter 200 def
125 {
126 y0 Function /F exch def
127 F abs eps2 lt { exit } if
128 y0 F sub /Phi exch def
129 Phi Function /F2 exch def
130 F2 abs eps2 le { exit }{
131 Phi y0 sub dup mul Phi F2 sub 2 Phi mul sub y0 add Div /Diff exch def
132 y0 Diff sub /y0 exch def
133 Diff abs eps1 le { exit } if
134 } ifelse
135 /Iter Iter 1 add def
136 Iter MaxIter gt { exit } if
137 } loop
138 y0 % the returned value ist the zero point
139 0 \tx@ScreenCoor pstack
140 3 0 360 arc gsave 0 0 1 setrgbcolor fill grestore 1 setlinewidth stroke
141 } def
142 \fi
143 %
144 \def\psPolynomial{\pst@object{psPolynomial}}
145 \def\psPolynomial@i#1#2{%
146 \pst@killglue%
147 \begingroup%
148 \use@par%
149 \@nameuse{beginplot@\psplotstyle}%
150 \gdef\psplot@init{}%
151 \@nameuse{testqp@\psplotstyle}%
152 \addto@pscode{%
153 tx@FuncDict begin
154 /coeff [ \psk@coeff ] def
155 /x0 #1 def /x1 #2 def
156 /dx x1 x0 sub \psk@plotpoints\space div def
157 /Derivation \psk@Derivation\space def
158 /x x0 def
159 \ifPst@markZeros
160 5 dict begin % hold all local!
161 gsave
162 \pst@number\psk@zeroLineWidth SLW
163 \pst@usecolor\psk@zeroLineColor
164 \psk@epsZero\space \psk@dZero\space FindZeros
165 aload length { % zero array is on stack
166 /xZero exch def
167 xZero \pst@number\psxunit mul /xPixel exch def
168 \psk@dotsize
169 \@nameuse{psds@\psk@dotstyle}%
170 xPixel 0 Dot
171 \psk@zeroLineTo\space 0 ge { % line to function \psk@lineTo
172 xPixel 0 moveto
173 xZero coeff \psk@zeroLineTo\space FuncValue
174 \pst@number\psyunit mul xPixel exch L
175 \@nameuse{psls@\psk@zeroLineStyle}
176 } if
177 } repeat
178 grestore
179 end
180 \fi
181 /xy {
182 x \psk@xShift\space sub coeff Derivation FuncValue \pst@number\psyunit mul
183 x \pst@number\psxunit mul exch
184 } def
185 xy moveto
186 }%
187 \if@pst% lines and dots
188 \psPolynomial@iii
189 \else% curves
190 \psPolynomial@ii
191 \fi
192 \endgroup
193 \ignorespaces}
194 %
195 \def\psPolynomial@ii{%
196 \addto@pscode{%
197 xy \@nameuse{beginqp@\psplotstyle}
198 \psk@plotpoints {
199 xy \@nameuse{doqp@\psplotstyle}
200 /x x dx add def
201 } repeat
202 xy \@nameuse{doqp@\psplotstyle}
203 end
204 }%
205 \@nameuse{endqp@\psplotstyle}%
206 }
207 \def\psPolynomial@iii{% curves
208 \addto@pscode{%
209 mark
210 /n 2 def
211 \psk@plotpoints {
212 xy
213 n 2 roll
214 /n n 2 add def
215 /x x dx add def
216 } repeat
217 /x x1 def
218 xy
219 n 2 roll
220 end
221 }%
222 \@nameuse{endplot@\psplotstyle}%
223 }
224 %
225 % Bessel 2004-06-08
226 % Manuel Luque, Herbert Voss
227 % Look at the end for some more documentation about the algorithm
228 %
229 \define@key[psset]{pst-func}{constI}[1]{\def\psk@constI{#1 }}
230 \define@key[psset]{pst-func}{constII}[0]{\def\psk@constII{#1 }}
231 \psset{constI=1,constII=0}
232 %
233 \def\psBessel{\@ifnextchar[{\psBessel@i}{\psBessel@i[]}}
234 \def\psBessel@i[#1]#2#3#4{{%%% #2 = n
235 \pst@killglue
236 \psset{plotpoints=500,constI=1,constII=0}%
237 \psset{#1,algebraic=false}%
238 \pstVerb{ /toDegrees { 57.29577951 mul } def }
239 \parametricplot{#3}{#4}{%
240 /J1 0 def
241 /xBessel t toDegrees def
242 0 0.1 180 {
243 /tB exch toDegrees def
244 /J1 J1 0.1 xBessel
245 tB sin mul tB #2\space mul sub cos mul add def
246 } for
247 t J1 180 div \psk@constI mul \psk@constII add
248 }%
249 }\ignorespaces}
250 %
251 %
252 \def\psModBessel{\@ifnextchar[{\psModBessel@i}{\psModBessel@i[]}}%% hv 20111021
253 \def\psModBessel@i[#1]#2#3{{%%% #2 = n
254 \pst@killglue%
255 \psset{nue=0,#1}%
256 \psplot{#2}{#3}[ /nue \psk@nue def /epsilon 1e-20 def ]{%
257 /Sum 0 def
258 /Iter 0 def
259 {/Sum_Iter
260 x dup mul 4 div Iter exp % nominator
261 nue Iter add 1 add GAMMA Iter tx@AddMathFunc begin ! end mul % denominator
262 Div def
263 Sum_Iter abs epsilon lt { exit } if
264 /Sum Sum Sum_Iter add def
265 /Iter Iter 1 add def
266 } loop
267 x 0.5 mul nue exp Sum mul
268 }%
269 }\ignorespaces}
270 %
271 \define@key[psset]{pst-func}{n}[1]{\def\psk@func@n{#1 }}
272 \psset[pst-func]{n=0}
273 %
274 \def\psLaguerre{\@ifnextchar[\psLaguerre@i{\psLaguerre@i[]}}%% hv 20200111
275 \def\psLaguerre@i[#1](#2,#3){{%%% n
276 \pst@killglue
277 \psplot[#1]{#2}{#3}{%
278 /L_n 1 def
279 0 1 \psk@func@n {
280 /k_i ED
281 -1 k_i exp k_i factorial div
282 \psk@func@n k_i MoverN mul
283 x k_i exp mul L_n add
284 /L_n ED
285 } for
286 x \pst@number\psxunit mul L_n
287 %dup == %\pst@number\psyunit div
288 }%
289 }\ignorespaces}
290 %
291 \def\psLaguerreC{\pst@object{psLaguerreC}}%% hv 20200612
292 \def\psLaguerreC@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
293 \pst@killglue
294 \begin@SpecialObj
295 \addto@pscode{%
296 % 20 dict begin
297 /yC #3 def
298 /dx #2 #1 sub \psk@plotpoints div def
299 /dy #4 #3 sub \psk@plotpoints div def
300 /L_i {
301 5 userdict begin
302 /X ED
303 /n_i ED
304 /L_n 0 def
305 0 1 n_i {
306 /k_i ED
307 -1 k_i exp k_i factorial div
308 n_i k_i MoverN mul
309 X k_i exp mul L_n add
310 /L_n ED
311 } for
312 L_n % return L_n(x)
313 end
314 } def
315 /n \psk@func@n def
316 [ % start array of x/y values
317 \psk@plotpoints { /xC #1 def \psk@plotpoints {
318 /Re 0 def
319 0 1 \psk@func@n 2 div floor {
320 /j ED % loop index
321 /j2 j dup add def % 2j
322 n j2 sub xC L_i % calculate L_{n-2j}(x)
323 j2 exp % L_{n-2j}^{2j}(x)
324 -1 j exp yC j2 exp mul % (-1^j)*y^(2j)
325 j2 factorial % (2*j)!
326 div
327 mul
328 Re add /Re ED
329 } for
330 /Im 0 def
331 0 1 \psk@func@n 1 sub 2 div floor {
332 /j ED % loop index
333 /j2 j dup add def % 2j
334 n j2 sub 1 sub xC L_i % calculate L_{n-2j-1}(x)
335 j2 1 add exp % L_{n-2j}^{2j+1}(x)
336 -1 j 1 sub exp yC j2 1 add exp mul % (-1^j)*y^(2j+1)
337 j2 1 add factorial % (2*j+1)!
338 div
339 mul
340 Im add /Im ED
341 } for
342 Re Im 2 copy \tx@ScreenCoor
343 % Re Im dup mul exch dup mul add sqrt dup 4 gt {pop 4} if 4 div setgray
344 % xC yC \tx@ScreenCoor 0 360 2 arc gsave fill stroke grestore
345 xC dx add /xC ED
346 } repeat
347 yC dy add /yC ED
348 } repeat
349 false \tx@NArray
350 \psk@dotsize
351 \@nameuse{psds@\psk@dotstyle}
352 \tx@setStrokeTransparency
353 newpath
354 n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat
355 %% end
356 }%
357 \end@SpecialObj
358 }\ignorespaces}
359 %
360
361 \def\psLaguerreCC{\pst@object{psLaguerreCC}}%% hv 20200612
362 \def\psLaguerreCC@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
363 \pst@killglue
364 \begin@SpecialObj
365 \addto@pscode{%
366 % 20 dict begin
367 gsave
368 /yC #3 def
369 /dx #2 #1 sub \psk@plotpoints div def
370 /dy #4 #3 sub \psk@plotpoints div def
371 /n \psk@func@n def
372 [ % start array of x/y values
373 \psk@plotpoints { /xC #1 def \psk@plotpoints {
374 /z [xC yC ] def
375 /L0 [1 0] def
376 /L1 [1 z {-1 mul} forall 3 1 roll add exch] def
377 n 1 le {
378 n 0 eq {/L1 L0 def} if
379 n 1 eq {/L1 L1 def} if
380 }{
381 /m 1 def
382 n 1 sub
383 {
384 /L2 1 m 1 add div
385 [2 m mul 1 add z {-1 mul} forall 3 1 roll add exch] L1 cxmul
386 L0 m neg cxrmul cxadd
387 exch cxrmul def
388 /L0 L1 def
389 /L1 L2 def
390 /m m 1 add def
391 } repeat
392 } ifelse
393 L1 aload pop \tx@ScreenCoor
394 xC dx add /xC ED
395 } repeat
396 yC dy add /yC ED
397 } repeat
398 false \tx@NArray
399 \psk@dotsize
400 \@nameuse{psds@\psk@dotstyle}
401 \tx@setStrokeTransparency
402 newpath
403 n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat
404 grestore
405 %% end
406 }%
407 \end@SpecialObj
408 }\ignorespaces}
409 %
410
411 \def\psLaguerreCCC{\pst@object{psLaguerreCCC}}%% hv 20200612
412 \def\psLaguerreCCC@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
413 \pst@killglue
414 \begin@SpecialObj
415 \addto@pscode{%
416 % 20 dict begin
417 /yC #3 def
418 /dx #2 #1 sub \psk@plotpoints div def
419 /dy #4 #3 sub \psk@plotpoints div def
420 [ % start array of x/y values
421 \psk@plotpoints {
422 /xC #1 def
423 \psk@plotpoints {
424 /Z [xC yC] def
425 /L [1 0] def
426 0 1 \psk@func@n {
427 /k ED
428 \psk@func@n k MoverN -1 k exp k factorial div mul
429 Z k
430 tx@FuncDict begin cxexp exch
431 cxrmul L cxadd end /L ED
432 } for
433 L aload pop \tx@ScreenCoor
434 xC dx add /xC ED
435 } repeat
436 yC dy add /yC ED
437 } repeat
438 % ] aload length 3 1 roll moveto 2 div cvi 1 sub { lineto } repeat 1 0 0 setrgbcolor 0.1 setlinewidth stroke
439 false \tx@NArray
440 \psk@dotsize
441 \@nameuse{psds@\psk@dotstyle}
442 \tx@setStrokeTransparency
443 newpath
444 n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat
445 %% end
446 }%
447 \end@SpecialObj
448 }\ignorespaces}
449 %
450 \def\psLaguerreCCCC{\pst@object{psLaguerreCCCC}}%% hv 20200612
451 \def\psLaguerreCCCC@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
452 \pst@killglue
453 \begin@SpecialObj
454 \addto@pscode{%
455 % 20 dict begin
456 /yC #3 def
457 /dx #2 #1 sub \psk@plotpoints div def
458 /dy #4 #3 sub \psk@plotpoints div def
459 % start array of x/y values
460 \psk@plotpoints {
461 /xC #1 def
462 [
463 \psk@plotpoints {
464 /Z [xC yC] def
465 /L [1 0] def
466 0 1 \psk@func@n {
467 /k ED
468 \psk@func@n k MoverN -1 k exp k factorial div mul
469 Z k
470 tx@FuncDict begin cxexp exch
471 cxrmul L cxadd end /L ED
472 } for
473 L aload pop \tx@ScreenCoor
474 xC dx add /xC ED
475 } repeat
476 ]
477 aload length 3 1 roll moveto 2 div cvi 1 sub { lineto } repeat 1 0 0 setrgbcolor 0.1 setlinewidth stroke
478 yC dy add /yC ED
479 } repeat
480 % ] aload length 3 1 roll moveto 2 div cvi 1 sub { lineto } repeat 1 0 0 setrgbcolor 0.1 setlinewidth stroke
481 % false \tx@NArray
482 % \psk@dotsize
483 % \@nameuse{psds@\psk@dotstyle}
484 % \tx@setStrokeTransparency
485 % newpath
486 % n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat
487 %% end
488 }%
489 \end@SpecialObj
490 }\ignorespaces}
491 %
492 \def\psContourLaguerre{\pst@object{psContourLaguerre}}%% hv 20200612
493 \def\psContourLaguerre@i(#1,#2)(#3,#4){{%%% n (xMin,xMax)(yMin,yMax)
494 \pst@killglue
495 \begin@SpecialObj
496 \addto@pscode{%
497 /yC #3 def
498 /dx #2 #1 sub \psk@plotpoints div def
499 /dy #4 #3 sub \psk@plotpoints div def
500 /contourdata [ % start array of x/y values
501 \psk@plotpoints {
502 /xC #1 def
503 [
504 \psk@plotpoints {
505 /Z [xC yC] def
506 /L [1 0] def
507 0 1 \psk@func@n {
508 /k ED
509 \psk@func@n k MoverN -1 k exp k factorial div mul
510 Z k
511 tx@FuncDict begin cxexp exch
512 cxrmul L cxadd end /L ED
513 } for
514 % L aload cxnorm exch pop
515 xC yC L cxre exch pop
516 xC dx add /xC ED
517 } repeat
518 ]
519 yC dy add /yC ED
520 } repeat
521 ] def
522 /zMax 0 def /zMin 0 def % lowest and highest value
523 contourdata aload length /N ED % get the no of arrays
524 N { % inside contourdata
525 /data ED % save first inner array
526 data aload length 3 div round cvi { % get the records
527 \psk@colorOffset
528 dup zMin lt % z<zMin?
529 { /zMin ED } % yes, save it
530 { dup zMax gt { /zMax ED }{ pop } ifelse } ifelse
531 pop pop % delete x y
532 } repeat
533 } repeat
534 clear % clear stack
535 /dz zMax zMin sub def % value range
536 /steps \psk@colSteps\space 0 gt { true }{ false } ifelse def
537 0 1 N 1 sub { % for i=0 to N-1
538 contourdata exch get /data ED % get first array
539 data aload length 3 div round cvi {
540 \psk@colorOffset
541 /z ED /y ED /x ED
542 z zMin sub dz div % relative z (0..1)
543 \ifPst@colored 400 mul 380 add tx@addDict begin wavelengthToRGB
544 Red Green Blue end setrgbcolor % set color
545 \else
546 steps {\psk@colSteps\space mul round \psk@colSteps\space div} if
547 setgray
548 \fi
549 x \pst@number\psxunit mul y \pst@number\psyunit mul
550 \pst@number\pst@dimb 0 360 arc fill
551 } repeat
552 } for
553 }%
554 \end@SpecialObj
555 }\ignorespaces}
556
557
558
559 \def\psLegendre{\@ifnextchar[{\psLegendre@i}{\psLegendre@i[]}}%% hv 20200115
560 \def\psLegendre@i[#1](#2,#3){{%%% n
561 \pst@killglue%
562 \psplot[#1]{#2}{#3}{%
563 /P_n 0 def
564 \psk@func@n 0 eq { /P_1 1 def }{ \psk@func@n 1 eq { /P_1 x def }
565 { /P_0 1 def
566 /P_1 x def
567 2 1 \psk@func@n {
568 /k_i ED
569 k_i dup add 1 sub x mul P_1 mul % (2n-1)*x*P_1
570 k_i 1 sub P_0 mul sub % − ( n−1 ) P_{n-2}(x)
571 k_i div
572 /P_0 P_1 def
573 /P_1 ED
574 } for
575 %n Pn ( x ) = ( 2n − 1 ) P_{n−1}(x) − ( n−1 ) P_{n-2}(x)
576 } ifelse } ifelse
577 x \pst@number\psxunit mul P_1
578 %dup == %\pst@number\psyunit div
579 }%
580 }\ignorespaces}
581 %
582 \define@key[psset]{pst-func}{sigma}[0.5]{\def\psk@sigma{#1 }}
583 \define@key[psset]{pst-func}{mue}[0]{\def\psk@mue{#1 }}
584 \define@key[psset]{pst-func}{nue}[1]{\def\psk@nue{#1 }}
585 \psset[pst-func]{sigma=0.5,mue=0,nue=1}
586 %
587 \def\psGauss{\@ifnextchar[{\psGauss@i}{\psGauss@i[]}}
588 \def\psGauss@i[#1]#2#3{{%
589 \pst@killglue%
590 \psset{plotpoints=200}%
591 \psset{#1}%
592 \psplot[algebraic=false]{#2}{#3}{%
593 Euler x \psk@mue sub dup mul 2 div \psk@sigma dup mul div neg exp
594 1.0 \psk@sigma div TwoPi sqrt div mul%
595 }%
596 }\ignorespaces}
597 %
598 \define@key[psset]{pst-func}{Simpson}[5]{\def\psk@Simpson{#1 }}
599 \psset[pst-func]{Simpson=5}
600 %
601 \def\psGaussI{\pst@object{psGaussI}}
602 \def\psGaussI@i#1#2{%
603 \addbefore@par{plotpoints=200,plotstyle=line}
604 \begin@OpenObj%
605 \addto@pscode{
606 /a #1 def
607 /dx #2 #1 sub \psk@plotpoints\space div def
608 /b a dx add def
609 /scx { \pst@number\psxunit mul } def
610 /scy { \pst@number\psyunit mul } def
611 tx@FuncDict begin
612 /C 1 \psk@sigma div TwoPi sqrt div def
613 /SFunc {% x on Stack
614 Euler exch \psk@mue\space sub dup mul 2 div \psk@sigma\space dup mul div neg exp C mul
615 } def
616 end
617 % a scx 0 moveto
618 a scx 0 \@nameuse{beginqp@\psplotstyle}
619 \psk@plotpoints 1 sub {
620 a b \psk@Simpson false % a b M useXval on Stack
621 tx@FuncDict begin Simpson I end % y value on stack
622 scy b scx exch \@nameuse{doqp@\psplotstyle} %lineto
623 /b b dx add def
624 } repeat
625 % stroke
626 }%
627 \end@OpenObj%
628 }
629 %
630 \def\psSi{\pst@object{psSi}}
631 \def\psSi@i#1#2{%
632 \begin@OpenObj%
633 \addto@pscode{
634 /x #1 def
635 /dx #2 #1 sub \psk@plotpoints\space div def
636 /scx { \pst@number\psxunit mul } def
637 /scy { \pst@number\psyunit mul } def
638 x scx x tx@FuncDict begin Si end scy moveto
639 \psk@plotpoints 1 sub {
640 x dup scx exch tx@FuncDict begin Si end scy lineto
641 /x x dx add def
642 } repeat
643 stroke
644 }%
645 \end@OpenObj%
646 }
647 \def\pssi{\pst@object{pssi}}
648 \def\pssi@i#1#2{%
649 \begin@OpenObj%
650 \addto@pscode{
651 /x #1 def
652 /dx #2 #1 sub \psk@plotpoints\space div def
653 /scx { \pst@number\psxunit mul } def
654 /scy { \pst@number\psyunit mul } def
655 x scx x tx@FuncDict begin si end scy moveto
656 \psk@plotpoints 1 sub {
657 x dup scx exch tx@FuncDict begin si end scy lineto
658 /x x dx add def
659 } repeat
660 stroke
661 }%
662 \end@OpenObj%
663 }
664 %
665 \def\psCi{\pst@object{psCi}}
666 \def\psCi@i#1#2{%
667 \begin@OpenObj%
668 \addto@pscode{
669 /x #1 def
670 /dx #2 #1 sub \psk@plotpoints\space div def
671 /scx { \pst@number\psxunit mul } def
672 /scy { \pst@number\psyunit mul } def
673 x scx x tx@FuncDict begin Ci end scy moveto
674 \psk@plotpoints 1 sub {
675 x dup scx exch tx@FuncDict begin Ci end scy lineto
676 /x x dx add def
677 } repeat
678 stroke
679 }%
680 \end@OpenObj%
681 }
682 \def\psci{\pst@object{psci}}
683 \def\psci@i#1#2{%
684 \begin@OpenObj%
685 \addto@pscode{
686 /x #1 def
687 /dx #2 #1 sub \psk@plotpoints\space div def
688 /scx { \pst@number\psxunit mul } def
689 /scy { \pst@number\psyunit mul } def
690 x scx x tx@FuncDict begin ci end scy moveto
691 \psk@plotpoints 1 sub {
692 x dup scx exch tx@FuncDict begin ci end scy lineto
693 /x x dx add def
694 } repeat
695 stroke
696 }%
697 \end@OpenObj%
698 }
699 %
700 \define@key[psset]{pst-func}{PSfont}[NimbusRomNo9L-Regu]{\def\psk@PSfont{/#1 }}
701 \define@key[psset]{pst-func}{valuewidth}[20]{\pst@getint{#1}\psk@valuewidth }
702 \define@key[psset]{pst-func}{fontscale}[10]{\pst@checknum{#1}\psk@fontscale }
703 \define@key[psset]{pst-func}{decimals}[-1]{\pst@getint{#1}\psk@decimals }
704 \psset[pst-func]{PSfont=NimbusRomNo9L-Regu,fontscale=10,valuewidth=20,decimals=-1}
705 %
706 \def\psPrintValue{\pst@object{psPrintValue}}
707 \def\psPrintValue@i#1{\expandafter\psPrintValue@ii#1,,\@nil}
708 \def\psPrintValue@ii#1,#2,#3\@nil{% #1,#2 only for algebraic code
709 \addbefore@par{algebraic=false}%
710 \begin@SpecialObj
711 \use@par
712 \addto@pscode{
713 gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont
714 \ifPst@algebraic
715 /x #1 def
716 /Func (#2) tx@AlgToPs begin AlgToPs end cvx def
717 Func
718 \else #1 \fi
719 \psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul cvi exch div } if
720 %\psk@valuewidth
721 100 string cvs %/Output exch def % save output
722 \ifPst@comma dot2comma \fi % do we have to change dot to comma
723 \psk@xShift\space 0 moveto %Output
724 show grestore
725 }%
726 \end@SpecialObj%
727 }
728
729 \define@boolkey[psset]{pst-func}[Pst@]{round}[true]{}%
730 \define@boolkey[psset]{pst-func}[Pst@]{science}[true]{%
731 \ifPst@science\def\psk@Scin{true }\else\def\psk@Scin{false }\fi}
732 \psset[pst-func]{science=false,round=false}
733 \def\psPrintValueNew{\pst@object{psPrintValueNew}}
734 \def\psPrintValueNew@i#1{\expandafter\psPrintValueNew@ii#1,,\@nil}
735 \def\psPrintValueNew@ii#1,#2,#3\@nil{% #1,#2 only for algebraic code
736 \begin@SpecialObj
737 \addto@pscode{ % thanks to Buddy Ledger
738 /mfont { \psk@PSfont\space findfont \psk@fontscale scalefont setfont } bind def
739 /mfontexp { \psk@PSfont\space findfont \psk@fontscale 1.2 div scalefont setfont } bind def
740 /s1 { /StandardSymbolsPS findfont \psk@fontscale scalefont setfont } bind def
741 \ifPst@algebraic
742 /x #1 def
743 /Func (#2) tx@AlgToPs begin AlgToPs end cvx def
744 Func
745 \else #1 \fi
746 /value ED
747 \psk@Scin {
748 value 0 ne { value log floor cvi /expon ED }{ /expon 0 def } ifelse
749 value 10 expon exp div
750 \psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul
751 \ifPst@round round \else cvi \fi exch div } if
752 \psk@decimals 0 eq { cvi } if /numb ED
753 expon \psk@valuewidth string cvs /expon exch def
754 numb \psk@valuewidth string cvs
755 \ifPst@comma dot2comma \fi % do we have to change dot to comma
756 /Output exch def
757 /txspc \psk@fontscale 4 div def
758 \psk@xShift\space 0 moveto mfont Output show
759 txspc 0 rmoveto s1 (\string\264) show
760 txspc 0 rmoveto mfont (10) show
761 txspc 2 div txspc 1.5 mul rmoveto mfontexp expon show }
762 { value
763 \psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul
764 \ifPst@round round \else cvi \fi exch div } if
765 \psk@decimals 0 eq { cvi } if %inserted to handle decimals=0
766 \psk@valuewidth string cvs
767 \ifPst@comma dot2comma \fi % do we have to change dot to comma
768 \psk@xShift\space 0 moveto mfont %Output
769 show
770 } ifelse
771 }%
772 \end@SpecialObj%
773 }
774 %
775 % Integrals 2006-01-16
776 % Jose-Emilio Vila-Forcen, Herbert Voss
777 %
778 \def\psCumIntegral{\pst@object{psCumIntegral}}
779 \def\psCumIntegral@i#1#2#3{%
780 \begin@OpenObj%
781 \addto@pscode{
782 /a #1 def
783 /dx #2 #1 sub \psk@plotpoints\space div def
784 /b a dx add def
785 /scx { \pst@number\psxunit mul } def
786 /scy { \pst@number\psyunit mul } def
787 tx@FuncDict begin
788 /SFunc \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else { #3 } \fi def
789 end
790 a scx 0 moveto
791 \psk@plotpoints 1 sub {
792 a b \psk@Simpson\space \ifPst@algebraic true \else false \fi % a b M useX on Stack
793 tx@FuncDict begin Simpson I end % y value on stack
794 scy b scx exch lineto
795 /b b dx add def
796 } repeat
797 % stroke
798 }%
799 % \psk@fillstyle%
800 % \pst@stroke%
801 \end@OpenObj%
802 }
803 %
804 \def\psIntegral{\pst@object{psIntegral}}
805 \def\psIntegral@i#1#2(#3,#4)#5{%
806 \begin@OpenObj%
807 \addto@pscode{
808 /a #3 def
809 /dx #4 #3 sub \psk@plotpoints\space div def
810 /b #4 def
811 /aa #1 def
812 /dd #2 #1 sub \psk@plotpoints\space div def
813 /t aa dd add def
814 /scx { \pst@number\psxunit mul } def
815 /scy { \pst@number\psyunit mul } def
816 tx@FuncDict begin /SFunc { t #5 } def end
817 a b \psk@Simpson false % a b M useX on Stack
818 tx@FuncDict begin Simpson I end % y value on stack
819 scy t scx exch moveto
820 /t t dd add def
821 \psk@plotpoints 1 sub {
822 a b \psk@Simpson false % a b M useXon Stack
823 tx@FuncDict begin Simpson I end % y value on stack
824 scy t scx exch lineto
825 /t t dd add def
826 } repeat
827 % stroke
828 }%
829 % \psk@fillstyle%
830 % \pst@stroke%
831 \end@OpenObj%
832 }
833 %
834 \def\psConv{\@ifnextchar[{\psConv@i}{\psConv@i[]}}
835 \def\psConv@i[#1]#2#3(#4,#5)#6#7{%
836 \psIntegral[#1]{#2}{#3}(#4,#5){pop pop xVal #6\space xVal t neg add #7\space mul}%
837 }%
838 %
839 \define@key[psset]{pst-func}{PrintVLimit}[1e-6]{\def\psFunc@PrintVLimit{#1 }}
840 \define@key[psset]{pst-func}{Switch2Log}[80]{\def\psFunc@Switch2Log{#1 }}
841 \define@boolkey[psset]{pst-func}[Pst@]{printValue}[true]{}
842 \define@boolkey[psset]{pst-func}[Pst@]{LineEnding}[true]{}
843 \define@boolkey[psset]{pst-func}[Pst@]{VLines}[true]{}
844 \define@key[psset]{pst-func}{barwidth}[1]{\def\psFunc@barwidth{#1 }}% a factor, not a dimen
845 \define@key[psset]{pst-func}{rightEnd}[2]{\def\psFunc@rightEnd{#1 }}
846 \define@key[psset]{pst-func}{leftEnd}[2]{\def\psFunc@leftEnd{#1 }}
847 \define@key[psset]{pst-func}{labelangle}[90]{\def\psFunc@langle{#1 }}
848 \define@key[psset]{pst-func}{xlabelsep}[0]{\def\psFunc@xlabelsep{#1 }}
849 \define@key[psset]{pst-func}{radiusout}[2]{\def\psFunc@radiusout{#1 }}
850 \define@key[psset]{pst-func}{radiusinL}[0]{\def\psFunc@radiusinL{#1 }}
851 \define@key[psset]{pst-func}{radiusinR}[1.5]{\def\psFunc@radiusinR{#1 }}
852 \define@key[psset]{pst-func}{LabelColor}[black]{\pst@getcolor{#1}\psk@LabelColor}
853 \define@key[psset]{pst-func}{LineEndColorL}[green]{\pst@getcolor{#1}\psk@LineEndColorL}
854 \define@key[psset]{pst-func}{LineEndColorR}[red]{\pst@getcolor{#1}\psk@LineEndColorR}
855 \define@key[psset]{pst-func}{fillcolorA}[blue!40]{\pst@getcolor{#1}\psk@fillcolorA}
856 \define@key[psset]{pst-func}{fillcolorB}[red!40]{\pst@getcolor{#1}\psk@fillcolorB}
857 \define@key[psset]{pst-func}{vlinestyle}[solid]{\def\psvlinestyle{#1}}
858 \def\psfs@alternateColors{}
859 \def\pst@alternateColors{alternateColors}
860 %
861 \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,
862 fillcolorA=blue!40,fillcolorB=red!40,PrintVLimit=1e-64,Switch2Log=80}
863 %
864 \def\psBinomial{\pst@object{psBinomial}}
865 \def\psBinomial@i#1#2{\psBinomial@ii#1,,,\@nil{#2}}%
866 \def\psBinomial@ii#1,#2,#3,#4\@nil#5{%
867 \def\pst@tempA{#2}%
868 \ifx\pst@tempA\@empty
869 \psBinomial@iii{0}{#1}{#1}{#5}%
870 \else
871 \def\pst@tempA{#3}%
872 \ifx\pst@tempA\@empty\psBinomial@iii{#1}{#2}{#2}{#5}%
873 \else\psBinomial@iii{#1}{#2}{#3}{#5}\fi
874 \fi}
875 %
876 \def\psBinomial@iii#1#2#3#4{%
877 \addbefore@par{valuewidth=15}%
878 \begin@OpenObj
879 \addto@pscode{%
880 /toggle false def
881 \ifx\psk@fillstylename\pst@alternateColors
882 /ColA { \pst@usecolor\psk@fillcolorA } def
883 /ColB { \pst@usecolor\psk@fillcolorB } def
884 \fi
885 /ValueSwitch2Log \psFunc@Switch2Log\space def
886 /scx { \pst@number\psxunit mul } def
887 /scy { \pst@number\psyunit mul } def
888 /m #1 def
889 /n #2 def
890 /N #3 def
891 /p #4 def
892 /dx \psFunc@barwidth 2 div def
893 /q 1 p sub def
894 /kOld dx neg m add def
895 kOld scx 0 moveto % starting point#
896 %%----------------------------------------------------------------------------------------------------------------------------------------------------------------
897 %%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque ---------------------------------------------
898 /SumLog {% log(1) + log(2) + ... + log(n) = log(n!)
899 2 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n
900 /nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert
901 /iV 1 def % Startwert ist iV=1
902 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
903 end
904 } def
905 /binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)]
906 2 dict begin
907 /nV exch def
908 /NV exch def
909 NV SumLog nV SumLog sub
910 NV nV sub SumLog sub
911 end
912 } def
913 /PnN {
914 3 dict begin
915 /pV exch def
916 /nV exch def
917 /NV exch def
918 10
919 NV nV binomial_comb
920 nV pV log mul
921 NV nV sub 1 pV sub log mul add add
922 exp
923 end
924 } def
925 %%------------------------------------------------------------------------------------------------
926 %%------------------------------------------------------------------------------------------------
927 N ValueSwitch2Log gt
928 { }
929 { 0 1 m 1 sub
930 {%
931 /k exch def % save loop variable
932 k 0 eq
933 { /Y q N exp def }
934 { /Y Y N k sub 1 add mul k div p mul q div def }
935 ifelse
936 } for
937 } ifelse
938 m 1 n {% % n-m+1 times
939 /k exch def % save loop variable
940 N ValueSwitch2Log gt
941 { N k p PnN /Y exch def }
942 { k 0 eq
943 { /Y q N exp def }
944 { /Y Y N k sub 1 add mul k div p mul q div def }
945 ifelse
946 }
947 ifelse % recursive definition
948 \ifx\psk@fillstylename\pst@alternateColors
949 newpath
950 kOld scx 0 moveto
951 \fi
952 kOld scx Y scy L k dx add scx Y scy L
953 \ifPst@markZeros k dx add scx 0 L kOld 1 add scx 0 L \fi
954 \ifx\psk@fillstylename\pst@alternateColors
955 closepath
956 gsave toggle {ColA}{ColB} ifelse \tx@setTransparency fill grestore
957 /toggle toggle not def
958 \fi
959 \ifPst@printValue
960 gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor %
961 Y \psFunc@PrintVLimit le { () } { Y \psk@valuewidth\space string cvs } ifelse
962 \ifPst@comma dot2comma \fi
963 k scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add
964 Y scy \pst@number\pslabelsep add moveto
965 \psFunc@langle rotate show grestore
966 \fi
967 /kOld kOld 1 add def
968 } for
969 \ifPst@markZeros\else k dx add scx 0 L \fi % last line down to x-axis
970 }%
971 % \psk@fillstyle
972 % \pst@stroke
973 \end@OpenObj
974 }%
975 %
976 %
977 \def\psBinomialN{\pst@object{psBinomialN}}%
978 \def\psBinomialN@i#1#2{%
979 \leavevmode
980 \pst@killglue
981 \begingroup
982 \use@par
983 \init@pscode
984 \def\cplotstyle{curve}%
985 \ifx\psplotstyle\cplotstyle \@nameuse{beginplot@\psplotstyle}\fi
986 \addto@pscode{%
987 \ifx\psplotstyle\cplotstyle /Curve true def \else /Curve false def \fi
988 /scx { \pst@number\psxunit mul } def
989 /scy { \pst@number\psyunit mul } def
990 /N #1 def
991 /p #2 def % probability
992 /q 1 p sub def
993 /E N p mul def
994 /sigma E q mul sqrt def % variant
995 /dx 1.0 sigma div 2 div def
996 /xOld dx neg E sub sigma div def
997 /xEnd xOld neg dx add scx def
998 Curve
999 { /Coors [xOld dx sub scx 0] def }% saves the coordinates for curve
1000 { xOld scx 0 moveto } % starting point
1001 ifelse
1002 0 1 N {% % N times
1003 /k exch def % save loop variable
1004 k 0 eq
1005 { /Y q N exp def }
1006 { /Y Y N k sub 1 add mul k div p mul q div def }
1007 ifelse % recursive definition
1008 /x k E sub sigma div dx add def
1009 /y Y sigma mul def % normalize
1010 Curve
1011 { x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def}
1012 { xOld scx y scy L x scx y scy L
1013 \ifPst@markZeros x scx 0 L \fi %
1014 } ifelse
1015 \ifPst@printValue
1016 gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor %
1017 y \psk@valuewidth string cvs %/Output exch def
1018 \ifPst@comma dot2comma \fi % do we have to change dot to comma
1019 x dx sub scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add
1020 y scy \pst@number\pslabelsep add moveto
1021 \psFunc@langle rotate show grestore
1022 \fi
1023 /xOld x def
1024 } for
1025 Curve { [ xEnd 0 Coors aload pop } if% showpoints on top of the stack
1026 }%
1027 \ifx\psplotstyle\cplotstyle\@nameuse{endplot@\psplotstyle}\else
1028 \psk@fillstyle
1029 \pst@stroke
1030 \fi
1031 \use@pscode
1032 \endgroup
1033 \ignorespaces
1034 }%
1035 \def\psBinomialF{\pst@object{psBinomialF}}
1036 \def\psBinomialF@i#1#2{\psBinomialF@ii#1,,,\@nil{#2}}%
1037 \def\psBinomialF@ii#1,#2,#3,#4\@nil#5{%
1038 \def\pst@tempA{#2}%
1039 \ifx\pst@tempA\@empty
1040 \psBinomialF@iii{0}{#1}{#1}{#5}%
1041 \else
1042 \def\pst@tempA{#3}%
1043 \ifx\pst@tempA\@empty\psBinomialF@iii{#1}{#2}{#2}{#5}%
1044 \else\psBinomialF@iii{#1}{#2}{#3}{#5}\fi
1045 \fi}%
1046 \def\psBinomialF@iii#1#2#3#4{%
1047 \addbefore@par{valuewidth=15}%
1048 \begin@OpenObj
1049 \addto@pscode{%
1050 /ValueSwitch2Log \psFunc@Switch2Log\space def
1051 /scx { \pst@number\psxunit mul } def
1052 /scy { \pst@number\psyunit mul } def
1053 /m #1 def
1054 /n #2 def
1055 /N #3 def
1056 /p #4 def
1057 /dx \psFunc@barwidth 2 div def
1058 /q 1 p sub def
1059 \ifPst@markZeros /kOld dx neg m add def \else
1060 /kOld m def \fi
1061 \psFunc@leftEnd 0 eq
1062 { }
1063 { kOld 0 eq
1064 { kOld \psFunc@leftEnd sub scx 0 moveto % starting point
1065 \ifPst@LineEnding
1066 kOld \psFunc@radiusout\pst@number\psxunit div sub scx 0 L stroke
1067 kOld scx 0 newpath \psFunc@radiusout 0 360 arc kOld scx 0
1068 \psFunc@radiusinR 360 0 arcn closepath \pst@usecolor\psk@LineEndColorR fill
1069 \else
1070 kOld scx 0 L stroke
1071 \fi
1072 }{ } ifelse } ifelse
1073 kOld scx 0 moveto % starting point
1074 %%----------------------------------------------------------------------------------------------------------------------------------------------------------------
1075 %%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque ---------------------------------------------
1076 /SumLog {% log(1) + log(2) + ... + log(n) = log(n!)
1077 2 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n
1078 /nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert
1079 /iV 1 def % Startwert ist iV=1
1080 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
1081 end
1082 } def
1083 /binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)]
1084 2 dict begin
1085 /nV exch def
1086 /NV exch def
1087 NV SumLog nV SumLog sub
1088 NV nV sub SumLog sub
1089 end
1090 } def
1091 /PnN {
1092 3 dict begin
1093 /pV exch def
1094 /nV exch def
1095 /NV exch def
1096 10
1097 NV nV binomial_comb
1098 nV pV log mul
1099 NV nV sub 1 pV sub log mul add add
1100 exp
1101 end
1102 } def
1103 %%------------------------------------------------------------------------------------------------
1104 %%------------------------------------------------------------------------------------------------
1105 0 1 m 1 sub {
1106 /k exch def % save loop variable
1107 N ValueSwitch2Log gt { k 0 eq
1108 { N k p PnN /Y exch def /F Y def }
1109 { N k p PnN /Y exch def /F F Y add def }
1110 ifelse
1111 }{ k 0 eq
1112 { /Y q N exp def /F Y def }
1113 { /Y Y N k sub 1 add mul k div p mul q div def
1114 /F F Y add def
1115 } ifelse
1116 } ifelse
1117 } for
1118 m 1 n { % n-m+1 times
1119 /k exch def % save loop variable
1120 N ValueSwitch2Log gt
1121 { k 0 eq
1122 { N k p PnN /Y exch def /F Y def }
1123 { N k p PnN /Y exch def /F F Y add def }
1124 ifelse }
1125 { k 0 eq
1126 { /Y q N exp def /F Y def }
1127 { /Y Y N k sub 1 add mul k div p mul q div def /F F Y add def
1128 } ifelse
1129 } ifelse % recursive definition
1130 F 1 gt { /F 1 def } if
1131 \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
1132 \else
1133 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
1134 kOld \ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div add \fi
1135 scx F scy moveto
1136 k 1 add
1137 \ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div sub \fi
1138 k N eq
1139 { \psFunc@rightEnd add }
1140 { } ifelse
1141 scx F scy L \pst@usecolor\pslinecolor [1 0] 0 setdash stroke
1142 \ifPst@LineEnding
1143 k N eq
1144 { }
1145 { 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 }
1146 ifelse
1147 \ifPst@VLines
1148 Y \psFunc@radiusout\pst@number\psyunit div 2 mul le
1149 { }
1150 { 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
1151 \else
1152 \ifPst@VLines
1153 Y \psFunc@radiusout\pst@number\psyunit div 0.1 mul le
1154 { }
1155 { k scx F Y sub scy moveto k scx F scy L \pst@usecolor\pslinecolor [3 2] 0 setdash stroke } ifelse
1156 \fi\fi\fi
1157 \ifPst@printValue
1158 gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor %
1159 Y \psFunc@PrintVLimit le { () } { F \psk@valuewidth\space string cvs } ifelse
1160 \ifPst@comma dot2comma \fi
1161 k scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add
1162 F scy \pst@number\pslabelsep add moveto
1163 \psFunc@langle rotate show grestore
1164 \fi
1165 /kOld kOld 1 add def
1166 } for
1167 }%
1168 \end@OpenObj%
1169 }%
1170 %
1171 \def\psBinomialFS{\pst@object{psBinomialFS}}
1172 \def\psBinomialFS@i#1#2{\psBinomialFS@ii#1,,,\@nil{#2}}%
1173 \def\psBinomialFS@ii#1,#2,#3,#4\@nil#5{%
1174 \def\pst@tempA{#2}%
1175 \ifx\pst@tempA\@empty
1176 \psBinomialFS@iii{0}{#1}{#1}{#5}%
1177 \else
1178 \def\pst@tempA{#3}%
1179 \ifx\pst@tempA\@empty\psBinomialFS@iii{#1}{#2}{#2}{#5}%
1180 \else\psBinomialFS@iii{#1}{#2}{#3}{#5}\fi
1181 \fi}%
1182 \def\psBinomialFS@iii#1#2#3#4{%
1183 \addbefore@par{valuewidth=15}%
1184 \begin@OpenObj
1185 \addto@pscode{%
1186 /ValueSwitch2Log \psFunc@Switch2Log\space def
1187 /scx { \pst@number\psxunit mul } def
1188 /scy { \pst@number\psyunit mul } def
1189 /m #1 def
1190 /n #2 def
1191 /N #3 def
1192 /p #4 def
1193 /dx \psFunc@barwidth 2 div def
1194 /q 1 p sub def
1195 \ifPst@markZeros /kOld dx neg m add def \else
1196 /kOld m def \fi
1197 kOld scx 0 moveto % starting point
1198 %%----------------------------------------------------------------------------------------------------------------------------------------------------------------
1199 %%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque ---------------------------------------------
1200 /SumLog {% log(1) + log(2) + ... + log(n) = log(n!)
1201 2 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n
1202 /nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert
1203 /iV 1 def % Startwert ist iV=1
1204 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
1205 end
1206 } def
1207 /binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)]
1208 2 dict begin
1209 /nV exch def
1210 /NV exch def
1211 NV SumLog nV SumLog sub
1212 NV nV sub SumLog sub
1213 end
1214 } def
1215 /PnN {
1216 3 dict begin
1217 /pV exch def
1218 /nV exch def
1219 /NV exch def
1220 10
1221 NV nV binomial_comb
1222 nV pV log mul
1223 NV nV sub 1 pV sub log mul add add
1224 exp
1225 end
1226 } def
1227 %%------------------------------------------------------------------------------------------------
1228 0 1 m 1 sub {
1229 /k exch def % save loop variable
1230 N ValueSwitch2Log gt { k 0 eq
1231 { N k p PnN /Y exch def /F Y def /FS 1 F sub def }
1232 { N k p PnN /Y exch def /F F Y add def /FS 1 F sub def }
1233 ifelse }
1234 { k 0 eq
1235 { /Y q N exp def /F Y def /FS 1 F sub def }
1236 { /Y Y N k sub 1 add mul k div p mul q div def
1237 /F F Y add def /FS 1 F sub def }
1238 ifelse } ifelse
1239 } for
1240 m 1 n { % n-m+1 times
1241 /k exch def % save loop variable
1242 N ValueSwitch2Log gt { k 0 eq
1243 { N k p PnN /Y exch def /F Y def /FS 1 F sub def }
1244 { N k p PnN /Y exch def /F F Y add def /FS 1 F sub def } ifelse }
1245 { k 0 eq
1246 { /Y q N exp def /F Y def /FS 1 F sub def }
1247 { /Y Y N k sub 1 add mul k div p mul q div def
1248 /F F Y add def /FS 1 F sub def }
1249 ifelse
1250 } ifelse % recursive definition
1251 FS 0 lt { /FS 0 def } if
1252 \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
1253 \else
1254 \ifPst@LineEnding
1255 k 0 eq
1256 { \psFunc@leftEnd neg scx 1 scy moveto \psFunc@radiusout neg 1 scy L gsave \pst@usecolor\pslinecolor stroke grestore } if
1257 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
1258 gsave \pst@usecolor\psk@LineEndColorR fill grestore } if
1259 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
1260 \fi
1261 kOld \ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div add \fi
1262 % k 0 eq
1263 % { \psFunc@leftEnd sub }
1264 % { } ifelse
1265 scx FS scy moveto
1266 k 1 add
1267 \ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div sub \fi
1268 k N eq
1269 { \psFunc@rightEnd add }
1270 { } ifelse
1271 scx FS scy L \pst@usecolor\pslinecolor [1 0] 0 setdash stroke
1272 \ifPst@LineEnding
1273 k N eq
1274 { }
1275 { 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 }
1276 ifelse
1277 \ifPst@VLines
1278 Y \psFunc@radiusout\pst@number\psyunit div 2 mul le
1279 { }
1280 { 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
1281 \else
1282 \ifPst@VLines
1283 Y \psFunc@radiusout\pst@number\psyunit div 0.1 mul le
1284 { }
1285 { k scx FS Y add scy moveto k scx FS scy L \pst@usecolor\pslinecolor [3 2] 0 setdash stroke } ifelse
1286 \fi\fi\fi
1287 \ifPst@printValue
1288 gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor %
1289 Y \psFunc@PrintVLimit le { () } { FS \psk@valuewidth\space string cvs } ifelse
1290 \ifPst@comma dot2comma \fi
1291 k 0.1 add scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add
1292 FS scy \pst@number\pslabelsep add moveto
1293 \psFunc@langle rotate show grestore
1294 \fi
1295 /kOld kOld 1 add def
1296 } for
1297 }%
1298 \end@OpenObj
1299 }%
1300 %
1301 %
1302 \define@key[psset]{pst-func}{LeftClipX}[-1]{\def\psFunc@LeftClipX{#1 }}
1303 \define@key[psset]{pst-func}{RightClipX}[-1]{\def\psFunc@RightClipX{#1 }}
1304 \psset[pst-func]{LeftClipX=-1,RightClipX=1}
1305 \def\psBinomialC{\pst@object{psBinomialC}}
1306 \def\psBinomialC@i#1#2{%
1307 \leavevmode
1308 \pst@killglue
1309 \begingroup
1310 \use@par
1311 \begin{psclip}%
1312 {\psframe[linestyle=none,fillstyle=none](\psFunc@LeftClipX,-0.1)(!#1 \psFunc@RightClipX\space add 1)}%
1313 % \use@par
1314 \init@pscode
1315 \beginplot@cspline
1316 % \addto@pscode{/D {} def mark}%
1317 \addto@pscode{%
1318 /scx { \pst@number\psxunit mul } def
1319 /scy { \pst@number\psyunit mul } def
1320 /N #1 def
1321 /p #2 def % Wahrscheinlichkeit
1322 /q 1 p sub def % q = 1 - p
1323 /E N p mul def % Erwartungswert
1324 /sigma E q mul sqrt def % Varianz
1325 /dx 1.0 2 div def
1326 /xOld dx neg 3 sub def
1327 /xEnd 0 def
1328 /Coors [xOld dx sub scx 0] def % speichern der Koordinaten f\"{u}r den Spline
1329 %%----------------------------------------------------------------------------------------------------------------------------------------------------------------
1330 %%-------------------- Code, der \"{u}ber den Logarithmus arbeitet von Manuel Luque ---------------------------------------------
1331 /SumLog {% log(1) + log(2) + ... + log(n) = log(n!)
1332 2 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n
1333 /nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert
1334 /iV 1 def % Startwert ist iV=1
1335 0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n)
1336 %Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen
1337 end
1338 } def
1339 /binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)]
1340 2 dict begin
1341 /nV exch def
1342 /NV exch def
1343 NV SumLog nV SumLog sub
1344 NV nV sub SumLog sub
1345 end
1346 } def
1347 /PnN {
1348 3 dict begin
1349 /pV exch def
1350 /nV exch def
1351 /NV exch def
1352 10
1353 NV nV binomial_comb
1354 nV pV log mul
1355 NV nV sub 1 pV sub log mul add add
1356 exp
1357 end
1358 } def
1359 %%------------------------------------------------------------------------------------------------
1360 %%------------------------------------------------------------------------------------------------
1361 %------------------------------- 3 Punkte um die Kurve links auf Null zu bringen mit dem weiter oben gew\"{a}hlten Startwert sind es also 4 ------------
1362 /x -2 dx add def
1363 /y 0 def
1364 x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
1365 /x -0.65 dx add def
1366 /y N 0 p PnN 10 -1.3 exp mul def
1367 x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
1368 /x -0.375 dx add def
1369 /y N 0 p PnN 3 div def
1370 x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
1371 %---------------------------- Ende der 3 Punkte und Beginn eigentlicher Code ----------------
1372 0 1 N {% % Schleife geht von 0 bis N in 1-er Schritten
1373 /k exch def % save loop variable
1374 N k p PnN /Y exch def
1375 /x k dx add def
1376 /y Y def
1377 x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
1378 /xOld x def
1379 } for
1380 %--------------------------- Ende des eigentlichen Codes und Beginn von ---
1381 %------------------------------- 4 Punkte um die Kurve rechts auf Null zu bringen -----------
1382 /x N 0.375 add dx add def
1383 /y Y 3 div def
1384 x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
1385 /x N 0.65 add dx add def
1386 /y Y 10 -1.3 exp mul def
1387 x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
1388 /x N 2 add dx add def
1389 /y 0 def
1390 x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
1391 /x N 3 add dx add def
1392 /y 0 def
1393 x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def
1394 %---------------------------- Ende der 4 Punkte und Laden der Koordinaten des arrays ; L\"{o}schen (pop) von showpoints??----------------------
1395 [ xEnd 1 add 0 Coors aload pop % showpoints on top of the stack
1396 }%
1397 \endplot@cspline
1398 \use@pscode
1399 \end{psclip}%
1400 \endgroup
1401 \ignorespaces}%
1402 %
1403 \def\psPoisson{\pst@object{psPoisson}}% with contributions from Gerry Coombes
1404 \def\psPoisson@i#1#2{\psPoisson@ii#1,,\@nil{#2}}%
1405 \def\psPoisson@ii#1,#2,#3\@nil#4{%
1406 \def\pst@tempA{#2}%
1407 \ifx\pst@tempA\@empty\psPoisson@iii{0}{#1}{#4}\else
1408 \psPoisson@iii{#1}{#2}{#4}\fi}%
1409 \def\psPoisson@iii#1#2#3{% M N lambda
1410 \begin@OpenObj%
1411 \addto@pscode{
1412 /scx { \pst@number\psxunit mul } def
1413 /scy { \pst@number\psyunit mul } def
1414 /M #1 def
1415 /N #2 def
1416 /lambda #3 def
1417 /elambda Euler #3 neg exp def % e^-lambda
1418 /dx \psFunc@barwidth 2 div def
1419 /kOld dx neg M add def % addition of M here
1420 kOld scx 0 moveto % starting point
1421 /Y elambda def % start value
1422 0 1 M 1 sub { % skip over first M-1 rectangles
1423 /k exch def % whilst recursing probabilities
1424 k 0 eq { /Y elambda def }{ /Y Y lambda mul k div def } ifelse
1425 } for % nothing happens if M=0
1426 M 1 N { % N-M+1 times
1427 /k exch def % save loop variable
1428 k 0 eq { /Y elambda def }{ /Y Y lambda mul k div def } ifelse
1429 kOld scx Y scy L k dx add scx Y scy L
1430 \ifPst@markZeros k dx add scx 0 L \fi
1431 \ifPst@printValue
1432 gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont
1433 Y \psk@valuewidth string cvs %/Output exch def
1434 \ifPst@comma dot2comma \fi % do we have to change dot to comma
1435 k scx \psk@fontscale 2 div add
1436 Y scy \pst@number\pslabelsep add moveto
1437 90 rotate show grestore
1438 \fi
1439 /kOld kOld 1 add def
1440 \ifPst@markZeros kOld scx 0 moveto \fi
1441 } for
1442 \ifPst@markZeros \else k dx add scx 0 L \fi % last line down to x-axis
1443 }%
1444 % \psk@fillstyle
1445 % \pst@stroke
1446 \end@OpenObj%
1447 }
1448 %
1449 \define@key[psset]{pst-func}{alpha}[0.5]{\pst@checknum{#1}\psk@alpha }
1450 \define@key[psset]{pst-func}{beta}[0.5]{\pst@checknum{#1}\psk@beta }
1451 \psset[pst-func]{alpha=0.5,beta=0.5}
1452 %
1453 \def\psGammaDist{\pst@object{psGammaDist}}
1454 \def\psGammaDist@i#1#2{%
1455 \ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!}
1456 \else
1457 \addbefore@par{plotpoints=500,alpha=0.5,beta=0.5}%
1458 \begin@OpenObj
1459 \psplot[algebraic=false]{#1}{#2}{
1460 \psk@beta x mul \psk@alpha exp x div Euler \psk@beta neg x mul \psk@alpha GAMMALN sub exp mul}
1461 \end@OpenObj%
1462 \fi%
1463 \ignorespaces%
1464 }
1465 %
1466 \def\psBetaDist{\pst@object{psBetaDist}}
1467 \def\psBetaDist@i#1#2{%
1468 \ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!}
1469 \else
1470 \begingroup
1471 \addbefore@par{plotpoints=200,alpha=1,beta=1}%
1472 \addto@par{algebraic=false}%
1473 % \begin@OpenObj
1474 \use@par
1475 \psplot{#1}{#2}{
1476 \psk@beta \psk@alpha add GAMMA
1477 \psk@beta GAMMA \psk@alpha GAMMA mul div
1478 1 x sub \psk@beta 1.0 sub exp mul
1479 x \psk@alpha 1.0 sub exp mul }
1480 % \end@OpenObj%
1481 \endgroup
1482 \fi%
1483 \ignorespaces%
1484 }
1485 %
1486 \def\psChiIIDist{\pst@object{psChiIIDist}}
1487 \def\psChiIIDist@i#1#2{%
1488 \addbefore@par{plotpoints=500,nue=1}%
1489 \begin@OpenObj
1490 % \ifdim\psk@nue pt<\z@ \psframebox*{\color{red}!!!nue must be greater than 0!!!}
1491 % \else
1492 \psplot[algebraic=false]{#1}{#2}{%
1493 x 2 div \psk@nue 2 div exp x div Euler -0.5 x mul \psk@nue 2 div GAMMALN sub exp mul }%
1494 % \fi%
1495 \end@OpenObj%
1496 \ignorespaces%
1497 }
1498 %
1499 \def\psTDist{\pst@object{psTDist}}
1500 \def\psTDist@i#1#2{%
1501 \leavevmode
1502 \pst@killglue
1503 \begingroup
1504 \addbefore@par{plotpoints=500}%
1505 \use@par
1506 \ifdim\psk@nue pt<\z@ \psframebox*{\color{red}!!!nue must be greater than 0!!!}
1507 \else
1508 \psplot[algebraic=false]{#1}{#2}{
1509 1 x 2 exp \psk@nue div 1 add \psk@nue 1 add 2 div exp div
1510 \psk@nue Pi mul sqrt div
1511 Euler \psk@nue 1 add 2 div GAMMALN \psk@nue 2 div GAMMALN sub exp mul
1512 }%
1513 \fi%
1514 \endgroup%
1515 \ignorespaces%
1516 }
1517
1518 \define@key[psset]{pst-func}{lambda}[1]{\def\psk@lambda{#1 }}
1519 \psset[pst-func]{lambda=0.5}
1520
1521 \def\psNonCentralTDist{\pst@object{psNonCentralTDist}}
1522 \def\psNonCentralTDist@i#1#2{%
1523 \leavevmode
1524 \pst@killglue
1525 \begingroup
1526 \addbefore@par{plotpoints=500}%
1527 \use@par
1528 \ifdim\psk@nue pt<\z@ \psframebox*{\color{red}!!!nue must be greater than 0!!!}
1529 \else
1530 \psplot[algebraic=false]{#1}{#2}{% P(x) = a ( b/c + d/e )
1531 \psk@nue dup 2 div exp \psk@nue factorial mul % nominator of a
1532 2 \psk@nue exp Euler \psk@lambda dup mul 2 div exp mul
1533 \psk@nue x dup mul add \psk@nue 2 div exp mul
1534 \psk@nue 2 div GAMMA mul % denominator of a
1535 div % a
1536 2 sqrt \psk@lambda mul x mul
1537 \psk@nue 2 div 1 add
1538 1.5
1539 \psk@lambda dup mul x dup mul mul 2 div \psk@nue x dup mul add div
1540 tx@FuncDict begin ConfHyperFunc end % Confluent Hypergeometric Funtion of the First Kind
1541 mul % b
1542 \psk@nue x dup mul add \psk@nue 1 add 2 div GAMMA mul % c
1543 div % b/c
1544 \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
1545 tx@FuncDict begin ConfHyperFunc end % d
1546 \psk@nue x dup mul add sqrt \psk@nue 2 div 1 add GAMMA mul % e
1547 div % d/e
1548 add % b/c + d/e
1549 mul % (b/c + d/e) * a
1550 }%
1551 \fi
1552 \endgroup
1553 \ignorespaces
1554 }
1555 %
1556 \def\psFDist{\pst@object{psFDist}}
1557 \def\psFDist@i#1#2{%
1558 \ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!}
1559 \else
1560 \leavevmode
1561 \pst@killglue
1562 \begingroup
1563 \addbefore@par{plotpoints=500,mue=1}%
1564 \use@par
1565 \psplot[algebraic=false]{#1}{#2}{
1566 x \psk@mue mul \psk@nue div dup \psk@mue 2 div exp x div
1567 exch 1 add \psk@mue \psk@nue add 2 div exp div
1568 Euler \psk@mue \psk@nue add 2 div GAMMALN
1569 \psk@mue 2 div GAMMALN sub \psk@nue 2 div GAMMALN sub exp mul
1570 }%
1571 \endgroup%
1572 \fi%
1573 \ignorespaces%
1574 }
1575 %
1576 \def\psNonCentralFDist{\pst@object{psNonCentralFDist}}
1577 \def\psNonCentralFDist@i#1#2{%
1578 \ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!}
1579 \else
1580 \leavevmode
1581 \pst@killglue
1582 \begingroup
1583 \addbefore@par{plotpoints=500,nue=1,mue=1,lambda=0,saveData=false}%
1584 \use@par
1585 \ifluatex
1586 \ifPst@saveData
1587 \luaexec{ require("pst-func")
1588 printDataPlotFileFDist(#1,#2,\psk@plotpoints,\psk@mue,\psk@nue,\psk@lambda,"\jobname-lua","true","true") }%
1589 \else
1590 \luaexec{ require("pst-func")
1591 printDataPlotFileFDist(#1,#2,\psk@plotpoints,\psk@mue,\psk@nue,\psk@lambda,"\jobname-lua","true","false") }%
1592 \fi
1593 % \typeout{\stringData}
1594 \pslistplot{\stringData}%
1595 \else
1596 \psplot[algebraic=false]{#1}{#2}[/F_BETA \psk@mue 2 div \psk@nue 2 div tx@FuncDict begin BETA end def]{
1597 /constA Euler \psk@lambda -2 div exp def
1598 /Sum
1599 constA F_BETA
1600 div % first fraction
1601 \psk@mue \psk@nue div \psk@mue 2 div exp
1602 mul
1603 \psk@nue dup \psk@mue x mul add div \psk@mue \psk@nue add 2 div exp
1604 mul
1605 x \psk@mue 2 div 1 sub exp
1606 mul
1607 def
1608 /K 1 def
1609 {
1610 constA \psk@lambda 2 div K exp mul % nominator
1611 \psk@nue 2 div \psk@mue 2 div K add tx@FuncDict begin BETA end K factorial mul % denominator
1612 div % first fraction
1613 \psk@mue \psk@nue div \psk@mue 2 div K add exp
1614 mul
1615 \psk@nue dup \psk@mue x mul add div \psk@mue \psk@nue add 2 div K add exp
1616 mul
1617 x \psk@mue 2 div 1 sub K add exp
1618 mul
1619 dup abs 1e-5 lt
1620 { pop exit }
1621 { Sum add /Sum ED
1622 K 1 add /K ED } ifelse
1623 K 100 ge { (Error ConfHyperFunc: K=100) == exit } if
1624 } loop
1625 Sum
1626 }%
1627 \fi
1628 \endgroup
1629 \fi
1630 \ignorespaces
1631 }
1632
1633
1634 %
1635 \define@key[psset]{pst-func}{m}[0]{\def\psk@cauchy@m{#1 }}
1636 \define@key[psset]{pst-func}{b}[1]{\def\psk@cauchy@b{#1 }}
1637 \psset[pst-func]{m=0,b=1}
1638 %
1639 \def\psCauchy{\pst@object{psCauchy}}
1640 \def\psCauchy@i#1#2{{%
1641 \pst@killglue%
1642 \addbefore@par{plotpoints=200}%
1643 \use@par%
1644 \psplot[algebraic=false]{#1}{#2}{
1645 \psk@cauchy@b dup dup mul x \psk@cauchy@m sub dup mul add div Pi div
1646 }%
1647 }\ignorespaces}
1648 %
1649 \def\psCauchyI{\pst@object{psCauchyI}}
1650 \def\psCauchyI@i#1#2{{%
1651 \pst@killglue%
1652 \addbefore@par{plotpoints=200}%
1653 \use@par%
1654 \psplot[algebraic=false]{#1}{#2}{
1655 x \psk@cauchy@m sub \psk@cauchy@b div ATAN1 DegtoRad Pi div 0.5 add
1656 }%
1657 }\ignorespaces}
1658 %
1659 \def\psWeibull{\pst@object{psWeibull}}
1660 \def\psWeibull@i#1#2{%
1661 \addbefore@par{plotpoints=500,alpha=1,beta=1}%
1662 \begin@OpenObj
1663 \def\pst@tempA{#1}%
1664 \ifdim#1pt<\z@ \psline(#1,0)(0,0)\def\pst@tempA{0}\fi
1665 \psplot[algebraic=false]{\pst@tempA}{#2}{
1666 \psk@alpha \psk@beta \psk@alpha neg Power mul % alpha*beta^(-alpha)
1667 x \psk@alpha 1 sub Power % x^(alpha-1)
1668 mul
1669 Euler x \psk@beta div \psk@alpha Power neg Power % e^(-(x/beta)^alpha))
1670 mul }
1671 \end@OpenObj%
1672 \ignorespaces%
1673 }
1674 \def\psWeibullI{\pst@object{psWeibullI}}
1675 \def\psWeibullI@i#1#2{%
1676 \addbefore@par{plotpoints=500,alpha=1,beta=1}%
1677 \begin@OpenObj
1678 \def\pst@tempA{#1}%
1679 \ifdim#1pt<\z@ \psline(#1,0)(0,0)\def\pst@tempA{0}\fi
1680 \psplot[algebraic=false]{\pst@tempA}{#2}{
1681 1
1682 Euler x \psk@beta div \psk@alpha Power neg Power % e^(-(x/beta)^alpha))
1683 sub
1684 }%
1685 \end@OpenObj%
1686 \ignorespaces%
1687 }
1688 %
1689 \define@key[psset]{pst-func}{pd}[0.22]{\pst@checknum{#1}\psk@probability }
1690 \define@key[psset]{pst-func}{R2}[0.11]{\pst@checknum{#1}\psk@portfolio }
1691 \psset[pst-func]{pd=0.22,R2=0.11}
1692 %
1693 \def\psVasicek{\pst@object{psVasicek}}
1694 \def\psVasicek@i#1#2{%
1695 \addbefore@par{plotpoints=500}%
1696 \begin@OpenObj
1697 \psplot{#1}{#2}[/pd \psk@probability\space def /R2 \psk@portfolio\space def ]{x tx@FuncDict begin vasicek end}
1698 \end@OpenObj%
1699 \ignorespaces%
1700 }
1701 \define@boolkey[psset]{pst-func}[Pst@]{Gini}[true]{}
1702 \psset[pst-func]{Gini=false}
1703 %
1704 \def\psLorenz{\def\pst@par{}\pst@object{psLorenz}}
1705 \def\psLorenz@i{\@ifnextchar<\psLorenz@ii{\psLorenz@ii<>}}
1706 \def\psLorenz@ii<#1>#2{%
1707 \if@star\addto@par{fillstyle=solid,fillcolor=\pslinecolor}\fi
1708 \begingroup
1709 \use@par
1710 \def\Lorenz@code{
1711 25 dict begin
1712 [ #2 ] dup length /nVal ED
1713 bubblesort /Yval ED
1714 Yval arraySum /Ysum ED
1715 Yval { Ysum div } forall nVal array astore /YvalRel ED % Pred dist
1716 \if$#1$
1717 /temp {1 nVal div} bind def
1718 [ nVal { temp } repeat ] /XvalRel ED
1719 [ 1 1 nVal { nVal div } for ] /XvalRelCum ED
1720 %YvalRel bubblesort /YvalRel ED
1721 \else
1722 [ #1 ] /Xval ED
1723 Xval arraySum /Xsum ED
1724 Xval { Xsum div } forall nVal array astore /XvalRel ED % Freq dist
1725 /CumFreq 0 def
1726 [
1727 0 1 nVal 1 sub {
1728 XvalRel exch get CumFreq add dup /CumFreq ED
1729 } for
1730 ] /XvalRelCum ED
1731 % XvalRelCum ==
1732 \fi
1733 /CumPred 0 def
1734 [
1735 0 1 nVal 1 sub {
1736 YvalRel exch get CumPred add dup /CumPred ED
1737 } for
1738 ] /YvalRelCum ED
1739 % YvalRelCum ==
1740 % Xsum == Ysum ==
1741 \ifPst@Gini
1742 [ 0 1 nVal 1 sub {
1743 /Index ED
1744 YvalRelCum Index get
1745 Index 0 eq { 0 }{ YvalRelCum Index 1 sub get } ifelse
1746 add 0.5 mul XvalRel Index get mul
1747 } for
1748 ] /Area ED
1749 % Area ==
1750 Area arraySum /B ED
1751 0.5 B sub dup B add div
1752 \psk@PSfont\space findfont \psk@fontscale scalefont setfont
1753 \psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul cvi exch div } if
1754 \psk@valuewidth string cvs %/Output exch def % save output
1755 \ifPst@comma dot2comma \fi % do we have to change dot to comma
1756 /Output ED
1757 \psk@xShift\space -30 moveto (Gini: ) show
1758 Output show
1759 \fi
1760 0 0 % the start point
1761 0 1 nVal 1 sub { dup XvalRelCum exch get exch YvalRelCum exch get } for
1762 % pstack
1763 \if@star 1 0 0 0 \fi % add values for the closed curve
1764 end
1765 }% filling the area under the curve.
1766 \if@star\listplot*{\Lorenz@code}\else\listplot{\Lorenz@code}%
1767 % \listplot[plotstyle=bezier,linecolor=red]{\Lorenz@code}
1768 \fi
1769 \endgroup
1770 \ignorespaces}
1771 %
1772 % Superellipese / Lamefunction
1773 \define@key[psset]{pst-func}{radiusA}[1]{\pst@getlength{#1}\pst@radiusA}
1774 \define@key[psset]{pst-func}{radiusB}[1]{\pst@getlength{#1}\pst@radiusB}
1775 \define@key[psset]{pst-func}{endAngle}[0]{\pst@getangle{#1}\psk@endAngle}
1776 \psset[pst-func]{radiusA=1,radiusB=1,endAngle=0}% startAngle is defined in PSTricks
1777 %
1778 \def\psLame{\pst@object{psLame}}
1779 \def\psLame@i#1{%
1780 \leavevmode
1781 \pst@killglue
1782 \begingroup
1783 \addbefore@par{plotpoints=200,startAngle=0,endAngle=360,algebraic=false}%
1784 \use@par
1785 \parametricplot{\psk@startAngle}{\psk@endAngle}{%
1786 t cos dup mul 1 #1\space div exp \pst@radiusA \pst@number\psxunit div mul
1787 t 90 gt { t 270 lt { neg } if } if
1788 t sin dup mul 1 #1\space div exp \pst@radiusB \pst@number\psyunit div mul
1789 t 180 gt { neg } if }
1790 \endgroup
1791 \ignorespaces
1792 }
1793 %
1794 \def\psWeierstrass{\pst@object{psWeierstrass}}
1795 \def\psWeierstrass@i(#1,#2){\@ifnextchar[{\psWeierstrass@ii(#1,#2)}{\psWeierstrass@iii(#1,#2)}}
1796 \def\psWeierstrass@ii(#1,#2)[#3]#4{% #1 xStart; #2 xEnd; #3 a; #4 b %% the original definition
1797 \addbefore@par{plotpoints=500}%
1798 \begin@SpecialObj
1799 \psplot{#1}{#2}[/ps@a #3 def /ps@b #4 def]{
1800 /ps@n 0 def
1801 /ps@WS 0 def
1802 {
1803 ps@a ps@n exp ps@b ps@n exp Pi mul x mul RadtoDeg cos mul
1804 dup abs \psk@epsilon gt { ps@WS add /ps@WS ED }{ ps@WS add exit } ifelse
1805 ps@n 1 add /ps@n ED
1806 } loop
1807 }%
1808 \end@SpecialObj
1809 }
1810 \def\psWeierstrass@iii(#1,#2)#3{% #1 xStart; #2 xEnd; #3 a
1811 \addbefore@par{plotpoints=500}%
1812 \begin@SpecialObj
1813 \psplot{#1}{#2}[/ps@a #3 def]{
1814 /ps@k 1 def
1815 /ps@WS 0 def
1816 {
1817 ps@k ps@a exp Pi mul dup x mul RadtoDeg sin exch div
1818 dup abs \psk@epsilon gt { ps@WS add /ps@WS ED }{ ps@WS add exit } ifelse
1819 ps@k 1 add /ps@k ED
1820 } loop
1821 }%
1822 \end@SpecialObj
1823 }
1824 %
1825 % For polar plots
1826 %\define@boolkey[psset]{pst-func}[PstAdd@]{polarplot}[true]{}
1827 %\psset[pst-func]{polarplot=false}
1828 %
1829 %\define@boolkey[psset]{pstricks-add}[Pst@]{GetFinalState}[true]{}
1830 %\define@key[psset]{pstricks-add}{filename}{\def\psk@filename{#1}}%
1831 %\define@boolkey[psset]{pstricks-add}[Pst@]{saveData}[true]{} % \ifPst@saveData
1832 %\psset[pstricks-add]{GetFinalState=false,saveData=false,filename=PSTdata}
1833 %
1834 \define@key[psset]{pst-func}{stepFactor}[0.67]{\pst@checknum{#1}\psk@stepFactor }
1835 \psset[pst-func]{stepFactor=0.67}
1836 %
1837 \def\psplotImp{\pst@object{psplotImp}}% 20060420
1838 \def\psplotImp@i(#1,#2)(#3,#4){%
1839 \@ifnextchar[{\psplotImp@ii(#1,#2)(#3,#4)}{\psplotImp@ii(#1,#2)(#3,#4)[]}}
1840 \def\psplotImp@ii(#1,#2)(#3,#4)[#5]#6{%
1841 \addbefore@par{filename=\jobname.data}%
1842 \begin@OpenObj%
1843 \addto@pscode{
1844 \ifPst@saveData /Pst@data (\psk@filename) (w) file def \fi
1845 /xMin #1 def
1846 /xMax #3 def
1847 /yMin #2 def
1848 /yMax #4 def
1849 #5 % additional PS code
1850 \ifPst@polarplot
1851 /@PolarAlgPlot (#6) tx@addDict begin AlgParser end cvx def
1852 /Func {
1853 /phi y x atan def
1854 /r x y Pyth def
1855 \ifPst@algebraic @PolarAlgPlot \else #6 \fi } def
1856 \else
1857 /Func \ifPst@algebraic (#6) tx@addDict begin AlgParser end cvx \else { #6 } \fi def
1858 \fi
1859 /xPixel xMax xMin sub \pst@number\psxunit mul round cvi def
1860 /yPixel yMax yMin sub \pst@number\psyunit mul round cvi def
1861 /dx xMax xMin sub xPixel div def
1862 /dy yMax yMin sub yPixel div def
1863 /setpixel {
1864 dy div exch
1865 dx div exch
1866 \ifPst@saveData
1867 2 copy
1868 \pst@number\psyunit div exch \pst@number\psxunit div
1869 20 string cvs Pst@data exch writestring
1870 Pst@data (\space) writestring
1871 20 string cvs Pst@data exch writestring
1872 % Pst@data (\string\]) writestring
1873 Pst@data (\string\n) writestring
1874 \fi
1875 \pst@number\pslinewidth 2 div 0 360 arc fill } bind def
1876 %
1877 /VZ true def % suppose that F(x,y)>=0
1878 /x xMin def /y yMin def Func 0.0 lt { /VZ false def } if % erster Wert
1879 xMin dx \psk@stepFactor\space mul xMax {
1880 /x exch def
1881 \ifPst@saveData Pst@data ([\string\n) writestring \fi
1882 yMin dy \psk@stepFactor\space mul yMax {
1883 /y exch def
1884 Func 0 lt
1885 { VZ { x y setpixel /VZ false def} if }
1886 { VZ {}{ x y setpixel /VZ true def } ifelse } ifelse
1887 } for
1888 \ifPst@saveData Pst@data (]\string\n) writestring \fi
1889 } for
1890 %% the same for the other way round without saving the data
1891 /VZ true def % suppose that F(x,y)>=0
1892 /x xMin def /y yMin def Func 0.0 lt { /VZ false def } if % erster Wert
1893 yMin dy \psk@stepFactor\space mul yMax {
1894 /y exch def
1895 \ifPst@saveData Pst@data ([\string\n) writestring \fi
1896 xMin dx \psk@stepFactor\space mul xMax {
1897 /x exch def
1898 Func 0 lt
1899 { VZ { x y setpixel /VZ false def} if }
1900 { VZ {}{ x y setpixel /VZ true def } ifelse } ifelse
1901 } for
1902 \ifPst@saveData Pst@data (]\string\n) writestring \fi
1903 } for
1904 %
1905 \iffalse
1906 /x xMin def /y yMin def Func 0.0 lt { /VZ false def } if % erster Wert
1907 yMin dy \psk@stepFactor\space mul yMax {
1908 /y exch def
1909 xMin dx \psk@stepFactor\space mul xMax {
1910 /x exch def
1911 Func 0 lt
1912 { VZ { x y setpixel /VZ false def} if }
1913 { VZ {}{ x y setpixel /VZ true def } ifelse } ifelse
1914 } for
1915 } for
1916 \fi
1917 \ifPst@saveData Pst@data closefile \fi
1918 }%
1919 \end@OpenObj%
1920 }
1921 %
1922 \def\psVolume{\pst@object{psVolume}}% 2007-06-23
1923 \def\psVolume@i(#1,#2)#3#4{%
1924 \leavevmode
1925 \pst@killglue
1926 \begingroup
1927 \use@par
1928 \psplot[fillstyle=none]{#1}{#2}{#4}% original function
1929 \ifPst@algebraic
1930 \psplot[fillstyle=none]{#1}{#2}{-(#4)}
1931 \else
1932 \psplot[fillstyle=none]{#1}{#2}{#4 neg}% mirrored at the x-axis
1933 \fi
1934 \multido{\iA=1+1}{#3}{% run it #3 times with increment \A
1935 \pscustom{% to get a closed filled ellipse
1936 \code{ % the PS code
1937 /dX #2 #1 sub #3 div def % delta x, the step
1938 /Start dX \iA\space 1 sub mul #1 add def % xStart
1939 /End Start dX add def % xEnd=xStart+dX
1940 /Height End Start add 2 div /x ED
1941 \ifPst@algebraic (#4) AlgParser cvx exec \else #4 \fi def } % height=f(x)
1942 % x is the mean between Start+End
1943 \psellipticarc(!Start 0)(! Height 8 div Height){90}{270}
1944 % draw the first falf of the ellipse
1945 \rlineto(! dX 0)% draw a line in x-direction
1946 \psellipticarc(!End 0)(! Height 8 div Height){270}{90}
1947 % draw the other half of the ellipse
1948 \rlineto(!dX neg 0)}}% draw a line in negative x-direction
1949 \psset{fillstyle=none}
1950 % \psellipse(#2,0)(!#2 dup #1 sub #3 div 2 div sub /x ED #4 dup
1951 % 8 div exch)% draw again the ellipse to get the borderline.
1952 \psellipse(#2,0)(!{ #2 dup #1 sub #3 div 2 div sub /x ED
1953 \ifPst@algebraic (#4) AlgParser cvx exec \else #4 \fi dup
1954 8 div exch}) % draw again the ellipse to get the borderline.
1955 \psset{plotstyle=line,linestyle=dashed,
1956 plotpoints=40,dotstyle=*,dotsize=0.5pt}
1957 \psplot[fillstyle=none]{#1}{#2}{#4}
1958 \ifPst@algebraic
1959 \psplot[fillstyle=none]{#1}{#2}{-(#4)}
1960 \else
1961 \psplot[fillstyle=none]{#1}{#2}{#4 neg}% mirrored at the x-axis
1962 \fi
1963 % draw again the curves to get the borderline
1964 \endgroup%
1965 \ignorespaces%
1966 }
1967 \def\txFunc@BezierCurve{ tx@FuncDict begin BezierCurve Points end }
1968 \def\txFunc@BezierShowPoints{ tx@Dict begin /Points ED BezierShowPoints end }
1969 \def\pst@BezierType{2 } % the default
1970 %
1971 \def\psBezier#1{% % allowed order is 1 ... 9
1972 \ifnum#1>0 \ifnum#1<10 \def\pst@BezierType{#1 }\fi\fi%
1973 \pst@object{psBezier}}
1974 \def\psBezier@i{%
1975 \pst@getarrows{%
1976 \addbefore@par{plotpoints=200}%
1977 \begin@OpenObj
1978 \pst@getcoors[\psBezier@ii%
1979 }}
1980 \def\psBezier@ii{%
1981 \addto@pscode{%
1982 \psk@plotpoints % step for Bezier T=0,0+epsilon,0+i*epsilon,...,1
1983 \pst@BezierType % type of the Bezier curve 2,3,4,...
1984 \txFunc@BezierCurve
1985 \ifshowpoints \txFunc@BezierShowPoints \else pop \fi
1986 }%
1987 \end@OpenObj}
1988 %
1989 \def\tx@Bernstein{ tx@FuncDict begin Bernstein end }
1990 \define@boolkey[psset]{pst-func}[Pst@]{envelope}[true]{}
1991 \psset[pst-func]{envelope=false}
1992 %
1993 \def\psBernstein{\pst@object{psBernstein}}% \psBernstein[options](t1,t2)(i,n)
1994 \def\psBernstein@i(#1,#2){%
1995 \@ifnextchar({\psBernstein@ii(#1,#2)}{\psBernstein@ii(0,1)(#1,#2)}}
1996 %
1997 \def\psBernstein@ii(#1,#2)(#3,#4){% (tStart,tEnd)(i,n)
1998 \addbefore@par{plotpoints=200}%
1999 \begin@OpenObj
2000 \addto@pscode{%
2001 /ScreenCoor { \tx@ScreenCoor } def
2002 #1\space #2\space
2003 1.0 \psk@plotpoints\space div % step=1/plotpoints
2004 #3\space #4\space
2005 % on stack we have tStart tEnd epsilon i n
2006 \ifPst@envelope true \else false \fi
2007 \tx@Bernstein
2008 }%
2009 \end@OpenObj}
2010 %
2011 \def\psThomae{\pst@object{psThomae}}
2012 \def\psThomae@i(#1,#2)#3{%
2013 \addbefore@par{dotsize=1pt}
2014 \begin@ClosedObj
2015 \addto@pscode{
2016 1 1 #3 {
2017 dup
2018 /ipSave ED % save loop value
2019 /ip ED % dito
2020 1 1 #3 {
2021 dup
2022 /iqSave ED % save loop value
2023 /iq ED % dito
2024 {
2025 iq 0 le { exit } if
2026 ip iq mod
2027 /ip iq def
2028 /iq ED
2029 } loop
2030 ip 1 eq {
2031 /xVal ipSave iqSave div def
2032 xVal #1 ge { xVal #2 le {
2033 \psk@dotsize
2034 \@nameuse{psds@\psk@dotstyle}
2035 \pst@usecolor\pslinecolor xVal 1 iqSave div \tx@ScreenCoor
2036 2 copy pop 0 moveto lineto } if } if
2037 % 2 copy moveto Dot } if } if
2038 } if
2039 } for
2040 } for
2041 }%
2042 \end@ClosedObj%
2043 }
2044 %
2045 \def\psCplot{\def\pst@par{}\pst@object{psCplot}}
2046 \def\psCplot@i#1#2#3#4{% start | end | complex variables | function
2047 \pst@killglue
2048 \begingroup
2049 \use@par
2050 \@nameuse{beginplot@\psplotstyle}%
2051 \addto@pscode{%
2052 \psplot@init
2053 /x #1 def
2054 /x1 #2 def
2055 /dx x1 x sub \psk@plotpoints div def
2056 #3
2057 /xy {
2058 % x
2059 tx@FuncDict begin
2060 #4 aload pop \pst@number\psyunit mul exch \pst@number\psxunit mul exch
2061 end
2062 } def}%
2063 \gdef\psplot@init{}%
2064 \@pstfalse
2065 \@nameuse{testqp@\psplotstyle}%
2066 \if@pst
2067 \psplot@ii
2068 \else
2069 \psplot@iii
2070 \fi
2071 \endgroup
2072 \ignorespaces}
2073 %
2074 \define@boolkey[psset]{pst-func}[Pst@]{xory}[true]{}
2075 \define@boolkey[psset]{pst-func}[Pst@]{approx}[true]{}
2076 \define@boolkey[psset]{pst-func}[Pst@]{Framed}[true]{}
2077 \define@boolkey[psset]{pst-func}[Pst@]{Newton}[true]{}
2078 \define@boolkey[psset]{pst-func}[Pst@]{PrintCoord}[true]{}
2079 \define@boolkey[psset]{pst-func}[Pst@]{onlyNode}[true]{}
2080 \define@boolkey[psset]{pst-func}[Pst@]{onlyYVal}[true]{}
2081 \define@boolkey[psset]{pst-func}[Pst@]{originV}[true]{}
2082 \define@key[psset]{pst-func}{PointName}[I]{\def\psk@func@PointName{#1}}
2083 \define@key[psset]{pst-func}{ydecimals}[2]{\pst@getint{#1}\psk@ydecimals }
2084 \define@key[psset]{pst-func}{labeldistance}[0]{\def\psk@ldistance{#1 }}
2085 \psset[pst-func]{originV=false,onlyNode=false,ydecimals=2,labeldistance=0,
2086 PrintCoord=false,onlyYVal=false,Newton=false,PointName=I,Framed=false,xory=false,approx=true}
2087 %
2088 %--------------------------------------------------------------------
2089 %------------- calculate the value of an intersectionpoint -----------
2090 %---------------------------------------------------------------------
2091 %
2092 \def\psZero{\def\pst@par{}\pst@object{psZero}}
2093 \def\psZero@i(#1,#2)#3{\@ifnextchar[{\psZero@ii(#1,#2)#3}{\psZero@ii(#1,#2){#3}[0]}}
2094 \def\psZero@ii(#1,#2)#3[#4]#5{%
2095 % (#1,#2) Intervall f\"{u}r die Nullstelle, bzw #1 Startwert f\"{u}r Newton, #3 1. Funktion, #4 2. Funktion, #5 Knotenname
2096 \begingroup
2097 \pst@killglue
2098 \addbefore@par{labelangle=0,framesep=1pt}%fontscale=40,PSfont=NimbusRomNo9L-Regu}%
2099 % labelangle=0 -> take xShift and yShift into account, otherwise xShift=pslabelsep * cos(labelangle)
2100 % yShift=pslabelsep * sin(labelangle)
2101 \use@par
2102 \pst@Verb{
2103 /FunctionA
2104 \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else {#3} \fi def
2105 /FunctionB
2106 \ifPst@algebraic (#4) tx@AlgToPs begin AlgToPs end cvx \else {#4} \fi def
2107 \ifPst@Newton % --------------------------- Newton-Verfahren --- TS 05.2014
2108 /eps 1e-6 def % eps f\"{u}r (f(x+eps)-f(x))/eps
2109 /x0 #1 def % Startwert wird vorgegeben
2110 /Xend x0 def
2111 {
2112 /xe x0 eps add def % xe=x+eps
2113 /x x0 def % x nun x0 setzen, damit f(x0) berechnet werden kann
2114 /func0 FunctionA FunctionB sub def % func0=F(x0)-FB(x0)
2115 func0 0 eq {exit} if % wenn func0 = 0 -> exit
2116 /x xe def % x xe setzen
2117 /func1 FunctionA FunctionB sub def % func1=F(xe)-FB(xe)
2118 /Xend x0 func0 eps mul func1 func0 sub div sub def % Xend=x0-(func0*eps)/(func1-func0)
2119 /x Xend def % x wird nun Xend
2120 /funcend FunctionA FunctionB sub def % funcend=F(Xend)-FB(Xend)
2121 funcend abs 1e-6 le {exit} if % Wenn funcend < 1e-6 -> exit
2122 /x0 Xend def % sonst x0 = Xend und
2123 } loop % die Schleife beginnt mit x0 = Xend
2124 /xM Xend def
2125 \else % -------------------- Intervallhalbierungsverfahren von Manuel L.
2126 /Xinf #1 def % linker Wert des Intervalls, in dem die Nullstelle gesucht wird
2127 /Xsup #2 def % linker Wert des Intervalls, in dem die Nullstelle gesucht wird
2128 { /xM Xinf Xsup add 2 div def % Mittelwert -> Mitte des Intervalls ist xM2
2129 /x Xinf def % Variable x wird als linker Wert festgelegt
2130 /F_1 FunctionA FunctionB sub def % Definition der Differenzfunktion F_1 an der Stelle x=Xinf2
2131 /x xM def % Variable x wird als Mittelwert festgelegt
2132 /F_M FunctionA FunctionB sub def % Definition der Differenzfunktion F_M an der Stelle x=xM2
2133 F_M 0 eq {exit} if % Ist F_M = 0 => fertig
2134 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
2135 Xinf Xsup sub abs 1e-6 le {exit} if } loop % Die Schleife endet, wenn die Differenz von linkem und rechtem Wert < 10^-6
2136 \fi
2137 /x xM def FunctionA /yM exch def % x wird Mittelwert und an dieser Stelle die Funktion berechnet und als yM definiert
2138 }%
2139 \pnode(! xM yM){#5}%
2140 \addto@pscode{%
2141 \iftrue %\psFunc@langle pt>\z@
2142 /xShift \psFunc@langle cos \psk@ldistance mul def
2143 /yShift \psFunc@langle sin \psk@ldistance mul def
2144 \else
2145 /xShift \psk@xShift\space def
2146 /yShift \psk@yShift\space def
2147 \fi
2148 \ifPst@onlyNode\else
2149 /dec \psk@decimals\space def % Anzahl der Dezimahlen f\"{u}r x
2150 /ydec \psk@ydecimals\space def % Anzahl der Dezimalen f\"{u}r y
2151 /symb { /StandardSymbolsPS findfont \psk@fontscale\space scalefont setfont } bind def % Symbolschrift f\"{u}r Klammer und senkrechten Strich
2152 /schrift { \psk@PSfont\space findfont \psk@fontscale scalefont setfont } bind def % Schrift f\"{u}r die Ergebnisse
2153 /TiefSchrift { /StandardSymbolsPS findfont \psk@fontscale 1.8 div scalefont setfont } bind def % Schrift f\"{u}r tiefergestellte Buchstaben
2154 /spdx \psk@fontscale 4 div def % Abstand, der mit der Schriftg\"{o}{\ss}e skaliert ist
2155 /spdy \psk@fontscale 15 div def % Abstand, der mit der Schriftg\"{o}{\ss}e skaliert ist
2156 /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
2157 \ifPst@comma dot2comma \fi show } def % gegebenenfalls Komma statt Punkt und Ergebnis anzeigen
2158 /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
2159 \ifPst@comma dot2comma \fi show } def % gegebenenfalls Komma statt Punkt und Ergebnis anzeigen
2160 /FunctionA \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else {#3} \fi def
2161 /FunctionB \ifPst@algebraic (#4) tx@AlgToPs begin AlgToPs end cvx \else {#4} \fi def
2162 /frs \pst@number\psframesep def
2163 \ifPst@Newton
2164 /eps 1e-6 def
2165 /x0 #1 def
2166 /Xend x0 def
2167 { /xe x0 eps add def
2168 /x x0 def
2169 /func0 FunctionA FunctionB sub def
2170 func0 0 eq {exit} if
2171 /x xe def
2172 /func1 FunctionA FunctionB sub def
2173 /Xend x0 func0 eps mul func1 func0 sub div sub def
2174 /x Xend def
2175 /funcend FunctionA FunctionB sub def
2176 funcend abs 1e-6 le {exit} if
2177 /x0 Xend def
2178 } loop
2179 /xM Xend def
2180 \else
2181 /Xinf #1 def /Xsup #2 def
2182 { /xM Xinf Xsup add 2 div def
2183 /x Xinf def /F_1 FunctionA FunctionB sub def
2184 /x Xsup def /F_2 FunctionA FunctionB sub def
2185 /x xM def /F_M FunctionA FunctionB sub def
2186 F_M 0 eq {exit} if
2187 F_1 F_M mul 0 ge {/Xinf xM def} {/Xsup xM def} ifelse
2188 Xinf Xsup sub abs 1e-6 le {exit} if } loop
2189 \fi
2190 /x xM def FunctionA /yM exch def
2191 \ifPst@originV 0 0 \else
2192 xM xShift add \pst@number\psxunit mul
2193 yM yShift add \pst@number\psyunit mul
2194 \fi
2195 \pst@usecolor\pslinecolor
2196 \ifPst@PrintCoord
2197 /xytext { moveto schrift (\psk@func@PointName) show
2198 0 spdy 2 mul neg rmoveto TiefSchrift (\psk@postString) show
2199 0 spdy 3 mul rmoveto symb (\string\050) show
2200 0 spdy neg rmoveto schrift xM Wert
2201 spdx 3 div spdy rmoveto symb (\string\174) show
2202 spdx 3 div spdy neg rmoveto schrift yM yWert 0 spdy rmoveto symb (\string\051) show } bind def
2203 xytext
2204 0 spdy neg rmoveto
2205 % ------------------------------------------------------------------------------ TS 03.2017
2206 \ifPst@Framed
2207 frs \psk@fontscale 0.15 mul frs add neg rmoveto
2208 0 \psk@fontscale 0.9 mul frs 2 mul add rlineto
2209 \ifPst@originV
2210 frs neg \psk@fontscale 0.75 mul frs add L
2211 \else
2212 xM xShift add \pst@number\psxunit mul frs sub
2213 yM yShift add \pst@number\psyunit mul \psk@fontscale 0.75 mul add frs add L
2214 \fi
2215 0 \psk@fontscale 0.9 mul frs 2 mul add neg rlineto closepath
2216 gsave
2217 \pst@usecolor\psfillcolor \tx@setTransparency fill
2218 grestore
2219 \ifx\pslinestyle\@none\else
2220 \pst@number\pslinewidth SLW \pst@usecolor\pslinecolor \tx@setStrokeTransparency \@nameuse{psls@\pslinestyle} stroke
2221 \fi
2222 \ifPst@originV 0 0 \else
2223 xM xShift add \pst@number\psxunit mul
2224 yM yShift add \pst@number\psyunit mul
2225 \fi
2226 xytext
2227 0 spdy neg rmoveto
2228 \fi
2229 %------------------------------ Wenn nicht die Form P(a|b) sondern x = a oder y = b oder nur a oder nur b -------------------
2230 \else
2231 \ifPst@originV 0 0 \else
2232 xM xShift add \pst@number\psxunit mul
2233 yM yShift add \pst@number\psyunit mul
2234 \fi
2235 /xorytext { moveto schrift
2236 \ifPst@onlyYVal% nur der y-Wert
2237 \ifPst@xory% in Form von y=b
2238 (\psk@func@PointName) show
2239 spdx 5 div neg spdy 2.2 mul neg rmoveto TiefSchrift (\psk@postString) show
2240 spdx 1.5 div spdy 2 mul rmoveto symb(\ifPst@approx \string \273 \else \string = \fi) show
2241 spdx 1.5 div neg 0 rmoveto schrift yM yWert
2242 \else schrift yM yWert
2243 \fi
2244 \else
2245 \ifPst@xory% in Form x = a
2246 (\psk@func@PointName) show
2247 spdx 7 div neg spdy 2.2 mul neg rmoveto TiefSchrift (\psk@postString) show
2248 spdx 1.5 div spdy 2 mul rmoveto symb (\ifPst@approx \string \273 \else \string = \fi) show
2249 spdx 1.5 div neg 0 rmoveto schrift xM Wert
2250 \else schrift xM Wert
2251 \fi
2252 \fi } bind def
2253 xorytext
2254 \ifPst@Framed%------------------------------ Rahmenbeginn ------------------------------
2255 frs \psk@fontscale 0.14 mul frs add neg rmoveto
2256 0 \psk@fontscale 0.9 mul frs 2 mul add rlineto
2257 \ifPst@originV
2258 frs neg \psk@fontscale 0.75 mul frs add L
2259 \else
2260 xM xShift add \pst@number\psxunit mul frs sub
2261 yM yShift add \pst@number\psyunit mul \psk@fontscale 0.75 mul add frs add L
2262 \fi
2263 0 \psk@fontscale 0.9 mul frs 2 mul add neg rlineto closepath
2264 gsave
2265 \pst@usecolor\psfillcolor \tx@setTransparency fill
2266 grestore
2267 \ifx\pslinestyle\@none\else
2268 \pst@number\pslinewidth SLW \pst@usecolor\pslinecolor \tx@setStrokeTransparency \@nameuse{psls@\pslinestyle} stroke
2269 \fi
2270 \ifPst@originV 0 0 \else
2271 xM xShift add \pst@number\psxunit mul
2272 yM yShift add \pst@number\psyunit mul
2273 \fi
2274 xorytext
2275 \fi
2276 \fi
2277 \fi}%
2278 \ifPst@markZeros\psdot(#5)\fi
2279 \endgroup\use@pscode\ignorespaces
2280 }%
2281 %
2282 \catcode`\@=\PstAtCode\relax
2283 %
2284 %% END: pst-func.tex
2285 \endinput
2286 %
2287