Integral $\int \sin({|x|})\,dx$ is this correctly done? $$\int \sin({|x|}) \,dx = ?$$
I know that
$$|x| =
  \begin{cases}
                                   x & \text{if $x \geq 0$  } \\
                                   -x & \text{if $x < 0$} \\
  \end{cases}$$
Now the two cases of $\int \sin({|x|})\,dx$
CASE I
When $|x|$ is positive ($x \geq 0$) therefore $\int \sin({|x|})\,dx$ is changed to $\int \sin({x})\,dx$ and that is equal to $-\cos({x})+C$.
CASE II
When $|x|$ is negative ($x < 0$) therefore $\int \sin({|x|})\,dx$ is changed to $\int \sin({-x})\,dx$ and this will changed to $-\int \sin({x})\,dx = \cos({x})+ C $.
 A: So in summary your splitting in cases (a good idea) shows
$$\int \sin(|x|) dx = \begin{cases} -\cos(x) + C_1 & x >0 \\ \cos(x)+C_2 & x < 0\end{cases}$$
where we have a disagreement on $x=0$, but as we want to find a function that is differentiable and has derivative $\sin(|x|)$ on all of $\Bbb R$ we can take $1+C_2 = -1 + C_1$ to at least have a better behaved (i.e. continuous) function. I 'm not sure if that's what you're meant to do here, but look into it. A priori the constants can be chosen independently of each other on the $x<0$ and $x>0$ parts.
A: Since $f(x)=\sin|x|$ is a continuous function for all $x\in\mathbb{R}$, there is an antiderivative $F(x)$ such that $F'(x)=\sin|x|$ for all $x$.  Here is such a function:
$$F(x)=-\mathop{\rm sgn}(x)(\cos x-1)$$
where $\mathop{\rm sgn}(x)=1$ for $x\gt0$ and $\mathop{\rm sgn}(x)=-1$ for $x\lt0$. (Note, $F(0)=0$ regardless of how one defines $\mathop{\rm sgn}(0)$, but it's fairly standard to define $\mathop{\rm sgn}(0)=0$.) Thus the indefinite integral can be expressed as
$$\int\sin|x|\,dx=-\mathop{\rm sgn}(x)(\cos x-1)+C$$
A: GeoGebra approach:
$$\int \sin \mid x \mid dx = - \frac{\cos (x \operatorname{sgn}(x))}{\operatorname{sgn}(x)}+\operatorname{sgn}(x) + const$$

A: We can address the problem by writing a definite integral one bound of which is zero.

*

*$x\le0\to\displaystyle\int_x^0\sin(-x)\,dx=1-\cos x$,


*$x\ge0\to\displaystyle\int_0^x\sin(x)\,dx=-\cos x+1$.
This can be compacted to
$$\text{sgn}(x)(1-\cos x)$$
to which you can add a constant.
