# Closed form integral of abs(cos(x))

1. Jul 15, 2014

### zynga

Hi everyone.

Recently, I came across a closed form solution to ∫|cos(x)|dx as
sin(x-∏*floor(x/∏+1/2)) + 2*floor(x/∏+1/2)

I have no idea how to reach this solution but checking this for definite integral from 0 to 3∏/4 or ∏ seems to work. Using |cos(x)| as cos(x)*sgn(cos(x)) doesn't help in reaching at the solution. Does someone know how to get this closed form?

Thanks.

2. Jul 16, 2014

### D H

Staff Emeritus
That is correct as a definite integral,
$$\int_0^x \lvert \cos t \rvert \, dt = \sin\left(x - \pi \left\lfloor \frac x \pi + \frac 1 2\right\rfloor \right) + 2\left\lfloor \frac x \pi + \frac 1 2\right\rfloor$$

As an indefinite integral it's better to write $\int \lvert\cos x\rvert\,dx = \sin x \operatorname{sgn}(\cos x)+C$

How to get that closed form? By being creative. You're not going to find any of the standard integration methods that will yield that nice closed form solution.