%% $Id: pstricks-add.sty 721 2018-02-03 20:37:57Z herbert $
%
\RequirePackage{pstricks}
\RequirePackage{pst-plot}
\RequirePackage{pst-node}
\RequirePackage{pst-3d}
\RequirePackage{pst-math}
\RequirePackage{multido}

\ProvidesPackage{pstricks-add}[2018/02/03 v. 0.15 package wrapper for 
  pstricks-add.tex (hv)]
\input{pstricks-add.tex}
\ProvidesFile{pstricks-add.tex}
  [\filedate\space v\fileversion\space `PSTricks-add' (hv)]
\IfFileExists{pstricks-add.pro}{%
  \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@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@rightY{\psCalc{\psFunction@{\rB}}}%
  	\def\ps@leftY{\psCalc{\psFunction@{\rA}}}%
  	\def\ps@middleY{\psCalc{\psFunction@{\rC}}}%
%  	\typeout{\ps@leftY, \ps@rightY }%
  	\edef\psLeftSumValue{\psCalc{\psLeftSumValue+\ps@@dx*\ps@leftY}}%
  	\edef\psRightSumValue{\psCalc{\psRightSumValue+\ps@@dx*\ps@rightY}}%
  	\edef\psMiddleSumValue{\psCalc{\psMiddleSumValue+\ps@@dx*\ps@middleY}}%
  	\edef\psDiffSumValue{\psCalc{\psDiffSumValue+abs(\ps@@dx*(\ps@rightY-\ps@leftY))}}%
%  	\typeout{\psLeftSumValue , \psRightSumValue }%
  }% end \Multido
}


\endinput
