Note a couple things:
- cos2x=2cos^2x-1" "=>" "cos^2x=1/2(1+cos2x)
- d/dxtanx=sec^2x" "=>" "intsec^2xdx=tanx+C
So the integral becomes:
f(x)=intcos^2xdx-intsec^2xdx=1/2int(1+cos2x)dx-tanx
Splitting the remaining integral up:
=1/2intdx+1/2intcos2xdx-tanx
The first integral is simple. For the other, let u=2x so du=2dx. Then:
=1/2x+1/4intcos2x(2dx)-tanx=1/2x+1/2intcosudu-tanx
The integral of cosine is sine:
f(x)=1/2x+1/4sinu-tanx=1/2x+1/4sin2x-tanx+C
We can determine C by using the initial condition f(pi/8)=-1. We could do this with decimals, but for fun we'll do it using identities. Note that tan(x/2)=(1-cosx)/sinx:
-1=1/2(pi/8)+1/4sin(pi/4)-tan(pi/8)+C
-1=pi/16+1/4(1/sqrt2)-(1-cos(pi/4))/sin(pi/4)+C
-1-pi/16-1/(4sqrt2)+(1-1/sqrt2)/(1/sqrt2)=C
C=-1-pi/16-1/(4sqrt2)+(sqrt2-1)
C=sqrt2-2-pi/16-1/(4sqrt2)
Then:
f(x)=1/2x+1/4sin2x-tanx+sqrt2-2-pi/16-1/(4sqrt2)