I am interested in drawing the following figure with tikz
I (think) I know how to do this with Bézier curves using \draw with filling, but I want the top curve to be an exact graph of a function that depends on a parameter, like f(x)=cos(kx) or f(x)=exp(kx), where I can adjust the parameter k to later animate my tikz figure. My problem is that I do not know how to use \draw to connect everything together, along with plotting the top curve using an actual function along with the green filling underneath. I would appreciate all help on this.
\draw plot (\x,<your function>)
. Of course, for plot you can define function domain and number of samples too. See TikZ & PGF manual, 22.5 Plotting a Function, page 344