From bf6d61e576dd9107b5e449872ce0ea965df5e673 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 27 Jun 2014 00:38:33 +0000 Subject: pst-func git-svn-id: svn://tug.org/texlive/trunk@34441 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/generic/pst-func/Changes | 2 + .../doc/generic/pst-func/pst-func-doc.pdf | Bin 3397668 -> 3397652 bytes .../texmf-dist/tex/generic/pst-func/pst-func.tex | 210 +++++++++++---------- 3 files changed, 108 insertions(+), 104 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/generic/pst-func/Changes b/Master/texmf-dist/doc/generic/pst-func/Changes index c15453770a6..571ff1975d9 100644 --- a/Master/texmf-dist/doc/generic/pst-func/Changes +++ b/Master/texmf-dist/doc/generic/pst-func/Changes @@ -1,4 +1,6 @@ ..... pst-func.tex +0.81 2014-05-20 - changed \pstVerb to \pst@Verb in \psZero to allow + variables from tx@Dict 0.80 2014-05-19 - added \psZero for calculating and printing the zeros of a function or the intermediate point of two functions. diff --git a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf index 367b9332fdf..92627795960 100644 Binary files a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf and b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf differ diff --git a/Master/texmf-dist/tex/generic/pst-func/pst-func.tex b/Master/texmf-dist/tex/generic/pst-func/pst-func.tex index 790f1d01006..8559a83985b 100644 --- a/Master/texmf-dist/tex/generic/pst-func/pst-func.tex +++ b/Master/texmf-dist/tex/generic/pst-func/pst-func.tex @@ -1,4 +1,4 @@ -%% $Id: pst-func.tex 918 2014-05-19 12:32:37Z herbert $ +%% $Id: pst-func.tex 920 2014-05-20 18:21:51Z herbert $ %% %% This is file `pst-func.tex', %% @@ -31,8 +31,8 @@ % interface to the `xkeyval' package \pst@addfams{pst-func} % -\def\fileversion{0.80} -\def\filedate{2015/05/19} +\def\fileversion{0.81} +\def\filedate{2015/05/20} \message{`PST-func' v\fileversion, \filedate\space (hv)} % \pstheader{pst-func.pro} @@ -1277,118 +1277,120 @@ \psset[pst-func]{originV=false,onlyNode=false,ydecimals=2, PrintCoord=false,onlyYVal=false,Newton=false,PointName=I, } +% %-------------------------------------------------------------------- %------------- calculate the value of an intersectionpoint ----------- %--------------------------------------------------------------------- \def\psZero{\def\pst@par{}\pst@object{psZero}} \def\psZero@i(#1,#2)#3{\@ifnextchar[{\psZero@ii(#1,#2)#3}{\psZero@ii(#1,#2){#3}[0]}} -\def\psZero@ii(#1,#2)#3[#4]#5{% +\def\psZero@ii(#1,#2)#3[#4]#5{% % (#1,#2) Intervall für die Nullstelle, bzw #1 Startwert für Newton, #3 1. Funktion, #4 2. Funktion, #5 Knotenname - \begingroup - \pst@killglue + \begingroup + \pst@killglue % \addbefore@par{fontscale=40,PSfont=Times-Roman}% - \use@par - \pstVerb{ - /FunctionA - \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else {#3} \fi def - /FunctionB - \ifPst@algebraic (#4) tx@AlgToPs begin AlgToPs end cvx \else {#4} \fi def - \ifPst@Newton % --------------------------- Newton-Verfahren --- TS 05.2014 - /eps 1e-6 def % eps f\"{u}r (f(x+eps)-f(x))/eps - /x0 #1 def % Startwert wird vorgegeben - /Xend x0 def - { - /xe x0 eps add def % xe=x+eps - /x x0 def % x nun x0 setzen, damit f(x0) berechnet werden kann - /func0 FunctionA FunctionB sub def % func0=F(x0)-FB(x0) - func0 0 eq {exit} if % wenn func0 = 0 -> exit - /x xe def % x xe setzen - /func1 FunctionA FunctionB sub def % func1=F(xe)-FB(xe) - /Xend x0 func0 eps mul func1 func0 sub div sub def % Xend=x0-(func0*eps)/(func1-func0) - /x Xend def % x wird nun Xend - /funcend FunctionA FunctionB sub def % funcend=F(Xend)-FB(Xend) - funcend abs 1e-6 le {exit} if % Wenn funcend < 1e-6 -> exit - /x0 Xend def % sonst x0 = Xend und - } loop % die Schleife beginnt mit x0 = Xend - /xM Xend def - \else % -------------------- Intervallhalbierungsverfahren von Manuel L. - /Xinf #1 def % linker Wert des Intervalls, in dem die Nullstelle gesucht wird - /Xsup #2 def % linker Wert des Intervalls, in dem die Nullstelle gesucht wird - { /xM Xinf Xsup add 2 div def % Mittelwert -> Mitte des Intervalls ist xM2 - /x Xinf def % Variable x wird als linker Wert festgelegt - /F_1 FunctionA FunctionB sub def % Definition der Differenzfunktion F_1 an der Stelle x=Xinf2 - /x xM def % Variable x wird als Mittelwert festgelegt - /F_M FunctionA FunctionB sub def % Definition der Differenzfunktion F_M an der Stelle x=xM2 - F_M 0 eq {exit} if % Ist F_M = 0 => fertig - F_1 F_M mul 0 ge {/Xinf xM def} {/Xsup xM def} ifelse % F_1 * F_M > 0 (F_1 und F_M haben gleiches VZ) => neuer linker x-Wert = xM2 - Xinf Xsup sub abs 1e-6 le {exit} if } loop % Die Schleife endet, wenn die Differenz von linkem und rechtem Wert < 10^-6 + \use@par + \pst@Verb{ + /FunctionA + \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else {#3} \fi def + /FunctionB + \ifPst@algebraic (#4) tx@AlgToPs begin AlgToPs end cvx \else {#4} \fi def + \ifPst@Newton % --------------------------- Newton-Verfahren --- TS 05.2014 + /eps 1e-6 def % eps für (f(x+eps)-f(x))/eps + /x0 #1 def % Startwert wird vorgegeben + /Xend x0 def + { + /xe x0 eps add def % xe=x+eps + /x x0 def % x nun x0 setzen, damit f(x0) berechnet werden kann + /func0 FunctionA FunctionB sub def % func0=F(x0)-FB(x0) + func0 0 eq {exit} if % wenn func0 = 0 -> exit + /x xe def % x xe setzen + /func1 FunctionA FunctionB sub def % func1=F(xe)-FB(xe) + /Xend x0 func0 eps mul func1 func0 sub div sub def % Xend=x0-(func0*eps)/(func1-func0) + /x Xend def % x wird nun Xend + /funcend FunctionA FunctionB sub def % funcend=F(Xend)-FB(Xend) + funcend abs 1e-6 le {exit} if % Wenn funcend < 1e-6 -> exit + /x0 Xend def % sonst x0 = Xend und + } loop % die Schleife beginnt mit x0 = Xend + /xM Xend def + \else % -------------------- Intervallhalbierungsverfahren von Manuel L. + /Xinf #1 def % linker Wert des Intervalls, in dem die Nullstelle gesucht wird + /Xsup #2 def % linker Wert des Intervalls, in dem die Nullstelle gesucht wird + { /xM Xinf Xsup add 2 div def % Mittelwert -> Mitte des Intervalls ist xM2 + /x Xinf def % Variable x wird als linker Wert festgelegt + /F_1 FunctionA FunctionB sub def % Definition der Differenzfunktion F_1 an der Stelle x=Xinf2 + /x xM def % Variable x wird als Mittelwert festgelegt + /F_M FunctionA FunctionB sub def % Definition der Differenzfunktion F_M an der Stelle x=xM2 + F_M 0 eq {exit} if % Ist F_M = 0 => fertig + F_1 F_M mul 0 ge {/Xinf xM def} {/Xsup xM def} ifelse % F_1 * F_M > 0 (F_1 und F_M haben gleiches VZ) => neuer linker x-Wert = xM2 + Xinf Xsup sub abs 1e-6 le {exit} if } loop % Die Schleife endet, wenn die Differenz von linkem und rechtem Wert < 10^-6 + \fi + /x xM def FunctionA /yM exch def % x wird Mittelwert und an dieser Stelle die Funktion berechnet und als yM2 definiert + }% + \pnode(! xM yM){#5}% + \addto@pscode{ + \ifPst@onlyNode \else + /dec \psk@decimals\space def % Anzahl der Dezimahlen für x + /ydec \psk@ydecimals\space def % Anzahl der Dezimalen für y + /symb { /Symbol findfont \psk@fontscale\space scalefont setfont } bind def % Symbolschrift für Klammer und senkrechten Strich + /schrift { \psk@PSfont findfont \psk@fontscale scalefont setfont } bind def % Schrift für die Ergebnisse + /TiefSchrift { /Symbol findfont \psk@fontscale 1.6 div scalefont setfont } bind def % Schrift für tiefergestellte Buchstaben + /spdx \psk@fontscale 4 div def % Abstand, der mit der Schriftgöße skaliert ist + /spdy \psk@fontscale 15 div def % Abstand, der mit der Schriftgöße skaliert ist + /Wert { 10 dec exp mul round 10 dec exp div dec 0 eq {cvi 15 string cvs} {15 string cvs } ifelse % x-Wert runden und als string ablegen + \ifPst@comma dot2comma \fi show } def % gegebenenfalls Komma statt Punkt und Ergebnis anzeigen + /yWert { 10 ydec exp mul round 10 ydec exp div ydec 0 eq {cvi 15 string cvs} {15 string cvs } ifelse % y-Wert runden und als string ablegen + \ifPst@comma dot2comma \fi show } def % gegebenenfalls Komma statt Punkt und Ergebnis anzeigen + /FunctionA \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else {#3} \fi def + /FunctionB \ifPst@algebraic (#4) tx@AlgToPs begin AlgToPs end cvx \else {#4} \fi def + \ifPst@Newton + /eps 1e-6 def + /x0 #1 def + /Xend x0 def + { /xe x0 eps add def + /x x0 def + /func0 FunctionA FunctionB sub def + func0 0 eq {exit} if + /x xe def + /func1 FunctionA FunctionB sub def + /Xend x0 func0 eps mul func1 func0 sub div sub def + /x Xend def + /funcend FunctionA FunctionB sub def + funcend abs 1e-6 le {exit} if + /x0 Xend def + } loop + /xM Xend def + \else + /Xinf #1 def /Xsup #2 def + { /xM Xinf Xsup add 2 div def + /x Xinf def /F_1 FunctionA FunctionB sub def + /x Xsup def /F_2 FunctionA FunctionB sub def + /x xM def /F_M FunctionA FunctionB sub def + F_M 0 eq {exit} if + F_1 F_M mul 0 ge {/Xinf xM def} {/Xsup xM def} ifelse + Xinf Xsup sub abs 1e-6 le {exit} if } loop + \fi + /x xM def FunctionA /yM exch def + \ifPst@originV 0 0 \else + xM \psk@xShift\space add \pst@number\psxunit mul + yM \psk@yShift\space add \pst@number\psyunit mul \fi - /x xM def FunctionA /yM exch def % x wird Mittelwert und an dieser Stelle die Funktion berechnet und als yM2 definiert - }% - \pnode(! xM yM){#5}% - \addto@pscode{ - \ifPst@onlyNode \else - /dec \psk@decimals\space def % Anzahl der Dezimahlen f\"{u}r x - /ydec \psk@ydecimals\space def % Anzahl der Dezimalen f\"{u}r y - /symb { /Symbol findfont \psk@fontscale\space scalefont setfont } bind def % Symbolschrift f\"{u}r Klammer und senkrechten Strich - /schrift { \psk@PSfont findfont \psk@fontscale scalefont setfont } bind def % Schrift f\"{u}r die Ergebnisse - /TiefSchrift { /Symbol findfont \psk@fontscale 1.6 div scalefont setfont } bind def % Schrift f\"{u}r tiefergestellte Buchstaben - /spdx \psk@fontscale 4 div def % Abstand, der mit der Schriftg\"{o}{\ss}e skaliert ist - /spdy \psk@fontscale 15 div def % Abstand, der mit der Schriftg\"{o}{\ss}e skaliert ist - /Wert { 10 dec exp mul round 10 dec exp div dec 0 eq {cvi 15 string cvs} {15 string cvs } ifelse % x-Wert runden und als string ablegen - \ifPst@comma dot2comma \fi show } def % gegebenenfalls Komma statt Punkt und Ergebnis anzeigen - /yWert { 10 ydec exp mul round 10 ydec exp div ydec 0 eq {cvi 15 string cvs} {15 string cvs } ifelse % y-Wert runden und als string ablegen - \ifPst@comma dot2comma \fi show } def % gegebenenfalls Komma statt Punkt und Ergebnis anzeigen - /FunctionA \ifPst@algebraic (#3) tx@AlgToPs begin AlgToPs end cvx \else {#3} \fi def - /FunctionB \ifPst@algebraic (#4) tx@AlgToPs begin AlgToPs end cvx \else {#4} \fi def - \ifPst@Newton - /eps 1e-6 def - /x0 #1 def - /Xend x0 def - { /xe x0 eps add def - /x x0 def - /func0 FunctionA FunctionB sub def - func0 0 eq {exit} if - /x xe def - /func1 FunctionA FunctionB sub def - /Xend x0 func0 eps mul func1 func0 sub div sub def - /x Xend def - /funcend FunctionA FunctionB sub def - funcend abs 1e-6 le {exit} if - /x0 Xend def - } loop - /xM Xend def + \pst@usecolor\pslinecolor + \ifPst@PrintCoord + moveto schrift (\psk@PointName) show + 0 spdy 2 mul neg rmoveto TiefSchrift (\psk@postString) show + 0 spdy 3 mul rmoveto symb (\string\050) show + 0 spdy neg rmoveto schrift xM Wert + spdx 3 div spdy rmoveto symb (\string\174) show + spdx 3 div spdy neg rmoveto yM yWert 0 spdy rmoveto symb (\string\051) show \else - /Xinf #1 def /Xsup #2 def - { /xM Xinf Xsup add 2 div def - /x Xinf def /F_1 FunctionA FunctionB sub def - /x Xsup def /F_2 FunctionA FunctionB sub def - /x xM def /F_M FunctionA FunctionB sub def - F_M 0 eq {exit} if - F_1 F_M mul 0 ge {/Xinf xM def} {/Xsup xM def} ifelse - Xinf Xsup sub abs 1e-6 le {exit} if } loop - \fi - /x xM def FunctionA /yM exch def - \ifPst@originV 0 0 \else - xM \psk@xShift\space add \pst@number\psxunit mul - yM \psk@yShift\space add \pst@number\psyunit mul - \fi - \ifPst@PrintCoord - moveto schrift (\psk@PointName) show - spdx neg spdy 2 mul neg rmoveto TiefSchrift (\psk@postString) show - 0 spdy 3 mul rmoveto symb (\string\050) show - 0 spdy neg rmoveto schrift xM Wert - spdx 3 div spdy rmoveto symb (\string\174) show - spdx 3 div spdy neg rmoveto yM yWert 0 spdy rmoveto symb (\string\051) show - \else - \ifPst@onlyYVal moveto schrift yM yWert \else moveto schrift xM Wert \fi - \fi\fi - }% - \ifPst@markZeros \psdot(#5)\fi + \ifPst@onlyYVal + moveto schrift yM yWert \else + moveto schrift xM Wert + \fi\fi\fi}% + \ifPst@markZeros \psdot(#5)\fi \endgroup\use@pscode\ignorespaces -}% +}% % - \catcode`\@=\PstAtCode\relax % %% END: pst-func.tex -- cgit v1.2.3