(this negative value of x is what i dont get. If modulus gives positive values,how can f(x) give a negative value)
The definition might seem confusing at first, but it is in fact very logical:
$$|x| = \begin{cases} x & x \ge 0 \\ -x & x< 0\end{cases}$$
You should read this as follows:
The absolute value of $x$, written as $|x|$, is equal to:
- $x$ itself if $x$ is positive;
- $-x$ if $x$ is negative.
Indeed: when $x$ is negative, $-x$ is positive!
Take an example, for $x = -3$ you would get:
$$|\color{red}{-3}| = -(\color{red}{-3}) = 3$$
Or put differently: we probably think of $|-3|=3$ as "dropping the minus sign", but that's hard to put into symbols if we want to write down a symbolical definition. We can however easily add an extra minus and of course this achieves the exact same thing since $-(-x) = x$.