TikZ-PGF – How to Draw Area Under Arbitrary Curve

tikz-pgf

I'm using tikz to create two arbitrary curves and fill the area between them. What I'm trying to do is:

enter image description here

This is my approach:

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[line join=round]
\draw [-latex,thick] (-0.5,0)  -- (4.5,0) node[below]{$x$};
\draw [-latex,thick] (0,-0.5)  -- (0,3.5) node[left]{$y$};

\draw [fill=white!50!blue,opacity=0.3, smooth,samples=100,domain=0.5:3.5] plot(\x, {sin(\x*200)*0.25+0.5}) -- plot(\x, {sin(\x*200)*0.25+2.5}) -- cycle; 

\draw (0,0) node[below left]{$0$} ;
\draw (2,1.5) node[]{$D$} ;
\draw [blue, domain=-0.25:4, smooth, variable=\x] plot (\x, {sin(\x*200)*0.25+0.5});
\draw [blue, domain=-0.25:4, smooth, variable=\x] plot (\x, {sin(\x*200)*0.25+2.5});
\draw [blue] (0.5,-0.25) -- (0.5,3) ;
\draw [blue] (3.5,-0.25) -- (3.5,3);
\draw (0.5,0) node[below left]{$a$} ;
\draw (3.5,0) node[below right]{$b$};
\draw (4,3) node[right]{$y=\psi(x)$} ;
\draw (4,1) node[right]{$y=\varphi(x)$};
\end{tikzpicture}

\end{document}

And what I get:

enter image description here

I don't know how to fix these crossed lines.

I'm also having trouble to define the sin(\x*200)*0.25+2.5 in the y axis, to get something very similar:

enter image description here

Best Answer

\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw [fill=white!50!blue, opacity=0.3, smooth, samples=100, domain=0.5:3.5] plot(\x, {sin(\x*200)*0.25+0.5}) -- plot[domain=3.5:0.5] (\x, {sin(\x*200)*0.25+2.5}) -- cycle; 
\draw[yshift=-3cm, fill=white!50!red, opacity=0.3, smooth, samples=100, domain=0.5:3.5] plot({sin(\x*200)*0.25+0.5},\x) -- plot[domain=3.5:0.5] ({sin(\x*200)*0.25+2.5},\x) -- cycle; 
\end{tikzpicture}
\end{document}

Two shaded regions