\section{Sommes de Riemann}

\begin{NewMacroBox}{tkzFnRiemann}{\oarg{options}\parg{nom de la fonction}}
\emph{Représente les rectangles d'une somme de Riemann. Les quatre macros de \tkzname{tkz-fct} sont réunies en une seule ; la méthode est choisie avec une option.}

\begin{tabular}{lll}
\toprule
options             & défaut & définition                         \\
\midrule
\TOline{interval}{xmin:xmax}{intervalle sur lequel la méthode est appliquée}
\TOline{number}{10}{nombre de sous-intervalles}
\TOline{method}{left}{hauteur des rectangles : voir ci-dessous}
\TOline{clip}{false}{les rectangles sont découpés à la fenêtre}
\bottomrule
\end{tabular}

\begin{tabular}{ll}
\toprule
méthode & hauteur du rectangle $[x_i~;~x_{i+1}]$ \\
\midrule
\texttt{left}  & $f(x_i)$ \\
\texttt{right} & $f(x_{i+1})$ \\
\texttt{mid}   & $f\left(\frac{x_i+x_{i+1}}{2}\right)$ \\
\texttt{inf}   & $\min\big(f(x_i),f(x_{i+1})\big)$ \\
\texttt{sup}   & $\max\big(f(x_i),f(x_{i+1})\big)$ \\
\bottomrule
\end{tabular}

\emph{Les autres options sont celles de \TIKZ ; le style est \tkzname{tkzfn riemann}. La valeur de la somme est donnée par \texttt{riemann(f,a,b,n,"left")}.}
\end{NewMacroBox}

\subsection{Somme de Riemann}

\begin{tkzexample}[vbox]
\begin{tikzpicture}[scale=3.5]
\tkzFnInit[xmin=0,xmax=3,ymin=0,ymax=1.75]
\tkzFnAxes
\tkzFnGrid(0,0)(3,1.75)
\tkzFnDraw[name=f,color=red,domain=1/3:3]{0.125*(3*x-1)+0.375*(3*x-1)/(x*x)}
\tkzFnRiemann[fill=green!40,opacity=.2,color=green,
              line width=1pt,interval=1/2:e,number=10](f)
\end{tikzpicture}
\end{tkzexample}

\newpage
\subsection{Méthodes \tkzname{inf} et \tkzname{sup}}

\begin{tkzexample}[vbox]
\begin{tikzpicture}[scale=1.75]
  \tkzFnInit[xmin=-3,xmax=6,ymin=-2,ymax=14,ystep=2]
  \tkzFnAxes[ticks=false]
  \tkzFnDraw[name=f,line width=2pt,color=red,domain=-3:6]{(-x-2)*(x-5)}
  \tkzFnRiemann[method=sup,fill=blue!40,opacity=.5,interval=-1:5](f)
  \tkzFnRiemann[method=inf,fill=green!40,opacity=.5,interval=-1:5](f)
\end{tikzpicture}
\end{tkzexample}

\newpage
\subsection{Méthode \tkzname{mid}}

\begin{tkzexample}[vbox]
\begin{tikzpicture}[scale=1.75]
  \tkzFnInit[xmin=-3,xmax=6,ymin=-2,ymax=14,ystep=2]
  \tkzFnAxes[ticks=false]
  \tkzFnDraw[name=f,line width=2pt,color=red,domain=-3:6]{(-x-2)*(x-5)}
  \tkzFnRiemann[method=mid,fill=blue!40,opacity=.5,interval=-1:5](f)
\end{tikzpicture}
\end{tkzexample}

\subsection{Valeurs des sommes}

Pour $f(x)=(-x-2)(x-5)$ sur $[-1~;~5]$ avec 10 rectangles :

\begin{tkzexample}[latex=6cm]
\tkzFnDef{f}{(-x-2)*(x-5)}
\begin{tabular}{ll}
inf      & \tkzFnPrint{riemann(f,-1,5,10,"inf")}\\
mid      & \tkzFnPrint{riemann(f,-1,5,10,"mid")}\\
sup      & \tkzFnPrint{riemann(f,-1,5,10,"sup")}\\
intégrale & \tkzFnPrint{integral(f,-1,5)}
\end{tabular}
\end{tkzexample}

\endinput
