$g(x)=|\sin{x}-1|+|3-\cos{x}-\sin{x}|+2\sin{x}$
Answer: Above equality is simplified to $$1-\sin{x}+3-\cos{x}-\sin{x}+2\sin{x}=4-\cos{x}$$
$$-1 \le\sin{x}\le1$$
So , I know that $f(x)=|\sin{x}-1|$ will be equal to $1-\sin{x}$ when $-1 \le\sin{x}\lt1$.
But what if $\sin{x}$ is exactly $1$, then wouldn't the expression be $\sin{x}-1$?
I always considered $|x|=x$, whenever $x$ is equal to or greater than $0$.
$\vert \sin x - 1 \vert = \vert 1 - \sin x \vert, \; \forall x \in \Bbb R; \tag 1$
since
$1 - \sin x \ge 0, \; \forall x \in \Bbb R, \tag 2$
$\vert \sin x - 1 \vert = \vert 1 - \sin x \vert = 1 - \sin x, \; \forall x \in \Bbb R. \tag 3$