@Pranavpurkar
There are two ways to do it.
First way like you are trying to do i.e. :
$Y= |-X| \ – \ X^2$
Case 1: when $-X \geq 0$ or $X \leq 0 $ then $Y = -X \ – \ X^2$
Case 2: when $-X \leq 0$ or $X \geq 0 $ then $Y = X \ – \ X^2$
Since, $X$ is positive here, so you have to apply case 2 here.
Another way is to use one of the other definitions of $|X|$ in which you don’t have to consider cases i.e.
$$|X| = \sqrt{X^2}$$
So, Here, $Y= |-X| \ – \ X^2 = \sqrt{(-X)^2} \ – \ X^2 = X \ – \ X^2 $
It will handle both positive and negative values of $X.$