\documentclass[a4paper]{article}

\usepackage{pgf,tikz}
\usepackage[active,tightpage]{preview}
\usepackage{pgfplots}
\usetikzlibrary{intersections}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\tikzset{>=stealth',inner sep=0pt,outer sep=2pt}
\pgfplotsset{compat=1.15}
\begin{document}

\begin{tikzpicture}[scale=1.2]
\def\a{1.7}
\def\b{5.2}
\def\c{3.95}
\def\L{0.5} % width of interval

\pgfmathsetmacro{\Va}{2*sin(\a r+1)+4} \pgfmathresult
\pgfmathsetmacro{\Vb}{2*sin(\b r+1)+4} \pgfmathresult
\pgfmathsetmacro{\Vc}{2*sin(\c r+1)+4} \pgfmathresult

\draw[->,thick] (-0.5,0) -- (7,0) coordinate (x axis) node[below] {$x$};
\draw[->,thick] (0,-0.5) -- (0,7) coordinate (y axis) node[left] {$y$};
\foreach \f in {1.95,2.45,...,5.95} {\pgfmathparse{2*sin(\f r+1)+4} \pgfmathresult
\draw[fill=blue!20] (\f-\L,\pgfmathresult |- x axis) -- (\f-\L,\pgfmathresult) -- (\f,\pgfmathresult) -- (\f,\pgfmathresult |- x axis) -- cycle;}
\node at (\a-\L/2,-5pt) {\footnotesize{$a=x_0$}};
\node at (\b+\L/2+\L,-5pt) {\footnotesize{$b=x_n$}};
\filldraw[blue!50,thick] (\c-\L,0) -- (\c-\L,\Vc) -- (\c,\Vc) -- (\c,0);
\draw[dashed] (\c,0) node[below] {} -- (\c,\Vc) -- (0,\Vc) node[left] {$f(x_{i+1})$};
\node at (\a+5*\L/2,-5pt) {\footnotesize{$x_{i-1}$}};
\node at (\a+7*\L/2,-5pt) {\footnotesize{$x_i$}};
\node at (\a+5*\L,-5pt) {\footnotesize{$x_{i+1}$}};
\draw[blue,thick,smooth,samples=100,domain=1.45:6.2] plot(\x,{2*sin(\x r+1)+4});
\filldraw[black] (\c,\Vc) circle (.03cm);
\end{tikzpicture}
\end{document}