Define a function over an interval?

I need to define a function over a closed interval. I am not sure how to go about this.

Take a look at Piecewise.