texlive[46541] Master/texmf-dist: pstricks-add (4feb18)
commits+karl at tug.org
commits+karl at tug.org
Sun Feb 4 22:38:21 CET 2018
Revision: 46541
http://tug.org/svn/texlive?view=revision&revision=46541
Author: karl
Date: 2018-02-04 22:38:21 +0100 (Sun, 04 Feb 2018)
Log Message:
-----------
pstricks-add (4feb18)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/generic/pstricks-add/Changes
trunk/Master/texmf-dist/doc/generic/pstricks-add/data/demo3.data
trunk/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.pdf
trunk/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex
trunk/Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex
trunk/Master/texmf-dist/tex/latex/pstricks-add/pstricks-add.sty
Modified: trunk/Master/texmf-dist/doc/generic/pstricks-add/Changes
===================================================================
--- trunk/Master/texmf-dist/doc/generic/pstricks-add/Changes 2018-02-04 21:37:38 UTC (rev 46540)
+++ trunk/Master/texmf-dist/doc/generic/pstricks-add/Changes 2018-02-04 21:38:21 UTC (rev 46541)
@@ -1,4 +1,4 @@
-%% $Id: Changes 716 2018-01-29 22:19:16Z herbert $
+%% $Id: Changes 722 2018-02-03 20:39:07Z herbert $
%%
pstricks-add.pro -----------
0.23 2009-12-17 - add RGBtoGRAY and WavelengthToGRAY
@@ -32,6 +32,7 @@
pstricks-add.sty ----------- (hv)
+ v. 0.15 2018-02-03 added \psCalc from xpl3 (only for latex)
v. 0.14 2010-02-11 move pst-fp message into pstricks.sty
v. 0.13 2009-04-17 change pro file version number
v. 0.12 2007-11-18 change pro file version number
@@ -39,6 +40,7 @@
pstricks-add.tex ----------- (hv)
+ v 3.85a 2018-02-03 - added area computing for \psStep
v 3.85 2018-01-29 - added area computing for \psStep
v 3.84 2017-09-16 - added \psRandomPointsArea
v 3.83a 2017-08-24 - updated documentation
Modified: trunk/Master/texmf-dist/doc/generic/pstricks-add/data/demo3.data
===================================================================
--- trunk/Master/texmf-dist/doc/generic/pstricks-add/data/demo3.data 2018-02-04 21:37:38 UTC (rev 46540)
+++ trunk/Master/texmf-dist/doc/generic/pstricks-add/data/demo3.data 2018-02-04 21:38:21 UTC (rev 46541)
@@ -1,13 +1,13 @@
-1989 3.08
- 1990 3.10
+ 1989 3.08
+ 1990 3.1
1991 3.08
1992 3.21
- 1993 5.00
+ 1993 5.0
1994 2.27
1995 3.53
- 1996 3.80
- 1997 2.80
+ 1996 3.8
+ 1997 2.8
1998 4.15
1999 3.32
- 2000 1.40
+ 2000 1.4
2001 2.46
Modified: trunk/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex 2018-02-04 21:37:38 UTC (rev 46540)
+++ trunk/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex 2018-02-04 21:38:21 UTC (rev 46541)
@@ -1,4 +1,4 @@
-%% $Id: pstricks-add-doc.tex 718 2018-01-30 09:11:28Z herbert $
+%% $Id: pstricks-add-doc.tex 721 2018-02-03 20:37:57Z herbert $
%
\documentclass[11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small,
headinclude=false,footinclude=false,oneside]{pst-doc}
@@ -12,6 +12,15 @@
%}
\makeatother
+\usepackage{siunitx}
+\sisetup{add-decimal-zero,
+ round-mode=places,
+ round-precision=2,
+ output-decimal-marker={,},
+ detect-all}
+
+
+
%\input{data/pstricks-add-doc.data}
\usepackage[utf8]{inputenc}
@@ -1785,7 +1794,8 @@
With setting the optional argument \Lkeyword{saveSumValue}
-it is possible to calculate the area under the rectangles. The value is saved in a macro \Lcs{pstAreaA},
+it is possible to calculate the area under the rectangles. The value is calculated on PostScript level and then
+later saved in a macro \Lcs{pstAreaA},
for the next call of \Lcs{psStep} in the macro \Lcs{pstAreaB} and so on. The values are calculated
on PostScript level, the reason why two \LaTeX\ runs are needed. for every \Lcs{psStep} there will
be an external file \verb|\jobname-area#.tex| which has the definition of the macros \nxLcs{pstArea?}.
@@ -1846,9 +1856,90 @@
\rput[l](0.2,2){\textcolor{blue}{Lowersum: \pstAreaM}}%
\end{pspicture}
\end{lstlisting}
-\clearpage
%--------------------------------------------------------------------------------------
+
+The values for the Riemann sum can also be calculatet on \LaTeX\ level, but it needs
+the package xparse and fp from the new \LaTeX3 kernel. It is not available for running \TeX.
+
+\begin{BDef}
+\Lcs{psRiemannSum}\Largr{$x_0,x_1$}\Largb{n}\Largb{f(\#1)}
+\end{BDef}
+
+The variable name in the last argument must be \#1!
+After using the above macro the following four macros are defined:
+
+\begin{BDef}
+\Lcs{psLeftSumValue}\\
+\Lcs{psRightSumValue}\\
+\Lcs{psMiddleSumValue}\\
+\Lcs{psDiffSumValue}
+\end{BDef}
+
+They all sum up the Riemann sum for the rectangle of width $dx$ and the height of the left, right
+or middle value of the function $f(x)$. \Lcs{psDiffSumValue} sums up the absolute value of rextangles
+in difference to the other three macros which takes a negative area into account.
+
+%\begin{LTXexample}[pos=t,preset=\centering]
+\psset{plotpoints=200}%
+\begin{pspicture}(-0.5,-2.25)(10,3)
+\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)%
+\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}%
+\psset{linewidth=0.1pt}%
+\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)}
+\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){18}{sqrt(x)*sin(x)}%
+\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \psRightSumValue}}%
+\psStep[algebraic,linecolor=blue,saveSumValue](0,9){18}{sqrt(x)*sin(x)}%
+\rput[l](0.2,2){\textcolor{blue}{Lowersum: \psLeftSumValue}}%
+\end{pspicture}
+%\end{LTXexample}
+
+\begin{lstlisting}
+\psset{plotpoints=200}%
+\begin{pspicture}(-0.5,-2.25)(10,3)
+\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(0,-2.25)(10,3)%
+\psplot[linewidth=1.5pt,algebraic]{0}{10}{sqrt(x)*sin(x)}%
+\psset{linewidth=0.1pt}%
+\psRiemannSum(0,9){18}
+\psStep[algebraic,linecolor=magenta,StepType=upper,saveSumValue](0,9){18}{sqrt(x)*sin(x)}%
+\rput[l](0.2,2.5){\textcolor{magenta}{Uppersum: \psRightSumValue}}%
+\psStep[algebraic,linecolor=blue,saveSumValue](0,9){18}{sqrt(x)*sin(x)}%
+\rput[l](0.2,2){\textcolor{blue}{Lowersum: \psLeftSumValue}}%
+\end{pspicture}
+\end{lstlisting}
+
+
+With package \texttt{siunitx} it is possible to round the values:
+
+\begin{lstlisting}
+\usepackage{siunitx}
+\sisetup{add-decimal-zero,
+ round-mode=places,
+ round-precision=2,
+ output-decimal-marker={,},
+ detect-all}
+[...]
+\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)}%
+\num{\psLeftSumValue}\\
+\num{\psRightSumValue}\\
+\num{\psMiddleSumValue}\\
+\num{\psDiffSumValue}
+\end{lstlisting}
+
+\psRiemannSum(0,9){18}{sqrt(#1)*sin(#1)}%
+\num{\psLeftSumValue}\\
+\num{\psRightSumValue}\\
+\num{\psMiddleSumValue}\\
+\num{\psDiffSumValue}
+
+
+\clearpage
+
+
+
+
+
+
\section{Tangent lines}
There are two macros for plotting a tangent line or the tangent normal line.
The first one is \Lcs{psTangentLine} which expects three pairs of coordinates,
Modified: trunk/Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex 2018-02-04 21:37:38 UTC (rev 46540)
+++ trunk/Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex 2018-02-04 21:38:21 UTC (rev 46541)
@@ -1,4 +1,4 @@
-%% $Id: pstricks-add.tex 718 2018-01-30 09:11:28Z herbert $
+%% $Id: pstricks-add.tex 722 2018-02-03 20:39:07Z herbert $
%%
%% This is file `pstricks-add.tex',
%%
@@ -31,8 +31,8 @@
\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey \fi
\ifx\PSTmathLoaded\endinput\else \input pst-math \fi
%
-\def\fileversion{3.85}
-\def\filedate{2018/01/29}
+\def\fileversion{3.85a}
+\def\filedate{2018/02/03}
\let\pstricksaddFV\fileversion
\message{`pstricks-add' v\fileversion, \filedate\space (dr,hv)}
%
@@ -725,6 +725,8 @@
\psset{StepType=lower} % alternative StepType=upper/inf/sup/Riemann
\define at boolkey[psset]{pstricks-add}[Pst@]{noVerticalLines}[true]{}%
\psset{noVerticalLines=false}
+\define at boolkey[psset]{pstricks-add}[Pst@]{drawLines}[true]{}%
+\psset{drawLines=true}
%
\newcount\pst at stepcount
\pst at stepcount=1
@@ -752,23 +754,30 @@
/Area 0 def
%
\ifcase\psk at StepType % 0->lower, height is always f(x)
- x scx 0 moveto
+ \ifPst at drawLines x scx 0 moveto \fi
#3 {
Func dup dx mul Area add /Area ED
- scy dup x scx exch \ifPst at noVerticalLines moveto \else lineto \fi
+ \ifPst at drawLines scy dup x scx exch \ifPst at noVerticalLines moveto \else lineto \fi
+ \else pop \fi
/x x dx add def
- x scx exch lineto
- x scx 0 \ifPst at noVerticalLines moveto \else lineto \fi
+ \ifPst at drawLines
+ x scx exch lineto
+ x scx 0 \ifPst at noVerticalLines moveto \else lineto \fi
+ \fi
} repeat
\or % 1-> upper, height is always f(x+dx)
- x scx 0 moveto
+ \ifPst at drawLines x scx 0 moveto \fi
#3 {
/x x dx add def
Func \ifPst at saveSumValue dup dx mul Area add /Area ED \fi
- scy dup x dx sub scx exch
- \ifPst at noVerticalLines moveto \else lineto \fi
- x scx exch lineto
- x scx 0 \ifPst at noVerticalLines moveto \else lineto \fi
+ \ifPst at drawLines
+ scy dup x dx sub scx exch
+ \ifPst at noVerticalLines moveto \else lineto \fi
+ x scx exch lineto
+ x scx 0 \ifPst at noVerticalLines moveto \else lineto \fi
+ \else
+ pop
+ \fi
} repeat
\ifPst at saveSumValue
\fi
@@ -784,8 +793,8 @@
/t x def % save x value
eps3 {
Func \ifPst at saveSumValue dup dx mul Area add /Area ED \fi
- dup
- Max lt { /Max exch def } { dup Min gt { /Min exch def }{ pop } ifelse } ifelse
+ dup
+ Max lt { /Max exch def } { dup Min gt { /Min exch def }{ pop } ifelse } ifelse
/x x dt add def
} repeat
/x t def % restore
@@ -794,19 +803,21 @@
closepath
} repeat
/dx dx scx def
- xMinMax aload length 3 div cvi {
- /yMax ED /yMin ED /x ED
- x yMin moveto
- dx 0 \ifPst at noVerticalLines rmoveto \else rlineto \fi
- x dx add yMax lineto
- dx neg 0 \ifPst at noVerticalLines rmoveto \else rlineto \fi
- x yMin \ifPst at noVerticalLines moveto \else lineto \fi
- closepath
+ \ifPst at drawLines
+ xMinMax aload length 3 div cvi {
+ /yMax ED /yMin ED /x ED
+ x yMin moveto
+ dx 0 \ifPst at noVerticalLines rmoveto \else rlineto \fi
+ x dx add yMax lineto
+ dx neg 0 \ifPst at noVerticalLines rmoveto \else rlineto \fi
+ x yMin \ifPst at noVerticalLines moveto \else lineto \fi
+ closepath
+ \fi
} repeat
- \ifPst at saveSumValue
- \fi
\or % 3->inf(imum)
- x scx 0 moveto
+% \ifPst at drawLines
+ x scx 0 moveto
+% \fi
#3 {
\ifPst at algebraic Func \else #4 \fi
\ifPst at saveSumValue dup dx mul Area add /Area ED \fi
Modified: trunk/Master/texmf-dist/tex/latex/pstricks-add/pstricks-add.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/pstricks-add/pstricks-add.sty 2018-02-04 21:37:38 UTC (rev 46540)
+++ trunk/Master/texmf-dist/tex/latex/pstricks-add/pstricks-add.sty 2018-02-04 21:38:21 UTC (rev 46541)
@@ -1,4 +1,4 @@
-%% $Id: pstricks-add.sty 718 2018-01-30 09:11:28Z herbert $
+%% $Id: pstricks-add.sty 721 2018-02-03 20:37:57Z herbert $
%
\RequirePackage{pstricks}
\RequirePackage{pst-plot}
@@ -7,7 +7,7 @@
\RequirePackage{pst-math}
\RequirePackage{multido}
-\ProvidesPackage{pstricks-add}[2010/02/11 v. 0.14 package wrapper for
+\ProvidesPackage{pstricks-add}[2018/02/03 v. 0.15 package wrapper for
pstricks-add.tex (hv)]
\input{pstricks-add.tex}
\ProvidesFile{pstricks-add.tex}
@@ -16,4 +16,34 @@
\ProvidesFile{pstricks-add.pro}
[2009/12/17 v. 0.23, PostScript prologue file (hv)]
\@addtofilelist{pstricks-add.pro}}{}%
+
+\RequirePackage{xparse}
+
+\ExplSyntaxOn
+\DeclareExpandableDocumentCommand\psCalc{m}{\fp_to_decimal:n{#1}}%
+\ExplSyntaxOff
+
+\def\psRiemannSum(#1,#2)#3#4{% (x0,x1) n f(#1)
+ \def\psFunction@##1{#4}%
+ \edef\ps@@dx{\psCalc{(#2-#1)/#3}}%
+ \edef\ps@@dxHalf{\psCalc{\ps@@dx/2}}%
+% \typeout{dx=\ps at dx}%
+ \def\psRightSumValue{0}%
+ \def\psLeftSumValue{0}%
+ \def\psMiddleSumValue{0}%
+ \def\psDiffSumValue{0}%
+ \Multido{\rA=#1+\ps@@dx,\rB=\ps@@dx+\ps@@dx,\rC=\ps@@dxHalf+\ps@@dx}{#3}{%
+ \def\ps at rightY{\psCalc{\psFunction@{\rB}}}%
+ \def\ps at leftY{\psCalc{\psFunction@{\rA}}}%
+ \def\ps at middleY{\psCalc{\psFunction@{\rC}}}%
+% \typeout{\ps at leftY, \ps at rightY }%
+ \edef\psLeftSumValue{\psCalc{\psLeftSumValue+\ps@@dx*\ps at leftY}}%
+ \edef\psRightSumValue{\psCalc{\psRightSumValue+\ps@@dx*\ps at rightY}}%
+ \edef\psMiddleSumValue{\psCalc{\psMiddleSumValue+\ps@@dx*\ps at middleY}}%
+ \edef\psDiffSumValue{\psCalc{\psDiffSumValue+abs(\ps@@dx*(\ps at rightY-\ps at leftY))}}%
+% \typeout{\psLeftSumValue , \psRightSumValue }%
+ }% end \Multido
+}
+
+
\endinput
More information about the tex-live-commits
mailing list