Why $f(x)=|\sin{x}-1|=1-\sin{x}$? What if $\sin{x}-1$ is zero?

$$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$$.

• If sine is exactly 1, then their difference is zero and it doesn't matter which order you write it in since either way the difference will be zero. – Cameron Williams Mar 3 at 4:38
• $$|0|=+0=-0~~$$ – learner Mar 3 at 4:39
• Yes, that's true. But in the problem I've been given, it is a crucial point since they would result in different answers. Can you please see edit? – Eldar Rahimli Mar 3 at 4:48
• You should have "above inequality is simplified to $1-\sin x+3-\cdots$". – Lord Shark the Unknown Mar 3 at 5:32

Usually, we hear that $$x=|x|$$ is $$x$$ is "positive" and $$x=-|x|$$ if $$x$$ is "negative," and often the case of $$x=0$$ isn't really discussed. In fact, as

$$|0|=0=-0,$$

we can include $$0$$ in either case above. In particular, we can say the following:

If $$x\leq 0$$, then $$|x|=-x$$.

As $$\sin x\leq 1$$, we know $$\sin x - 1 \leq 0$$, so...

• So does it mean that given answer is only one of two "simplifications"( we could also say $|\sin{x}-1|=\sin{x}-1$ and get $2+2\sin{x}-\cos{x}$)? – Eldar Rahimli Mar 3 at 6:01
• No. If you write $|\sin x - 1| = \sin x - 1$ then that is only valid if $\sin x = 1$, so your "simplification" would only be valid at those points $x$ with $\sin x = 1$. A simplification has to be valid at all points. $|\sin x - 1| = 1 - \sin x$ is valid at all points. – Ted Mar 3 at 6:07
• @Ted It makes sense, now. This actually answered my question, that the simplified equation has to be valid at all points. Thanks – Eldar Rahimli Mar 3 at 7:42

$$\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$$

Yes, usually, the absolute value is defined as (see Wikipedia): $$|x|=\begin{cases}\ \ \ x,\ x\ge 0\\ -x,\ x<0\end{cases}$$ However, it can be adjusted (see the opening paragraph in the above article): $$|x|=\begin{cases}\ \ \ x,\ x>0\\ -x,\ x<0 \\ \ \ \ 0, \ x=0\end{cases}$$ So, using the adjusted form: $$|\sin x-1|=\begin{cases}\ \ \ \ \sin x-1,\ \ \sin x-1>0\\ -(\sin x-1),\ \sin x-1<0 \\ \ \qquad \qquad \ 0, \ \ \sin x-1=0\end{cases} = \\ \begin{cases}\ \ \ \ \ \ \ \ \sin x-1,\ \ \sin x-1\not>0 \ (\emptyset)\\ \qquad \ 1-\sin x,\ \sin x-1<0 \\ \ 0=1-\sin x, \ \ \sin x-1=0\end{cases} = 1-\sin x, \sin x-1\le 0.$$