float fun(float x){ if(x < 0){ return fabs(x-1); } else if(x <= 1){ return 1-x; } else if(x > 1){ return (1-x)*(1-x); } }