Question: Building a piecewise function

Hello,

I would like to build this piecewise function :

 

I try this manner :

f:=x->piecewise(x=>0 and x <= 1, x^2,x > 1 and x<=2, (2-x)^2);

But, it doesn't work. I receive the following error message :

Error, `>` unexpected

Do you have some ideas about my mistake?

Thank you for your help.

Please Wait...