I just did the absolute value two days ago on this site.

see http://www.mathhelpforum.com/math-he...-function.html

the square can be found in many places, including in older threads at this forum

but the technique is very similar to the absolute value problem