To begin, let's first apply the sum rule to break intcosx-sec^2xdx into intcosxdx-intsec^2xdx. Now we can evaluate these integrals one by one:
intcosxdx=sinx+C-> (the derivative of sine is cosine, so the antiderivative of cosine is sine)
intsec^2xdx=tanx+C-> (same logic)
The whole solution is: f(x)=sinx+C-tanx+C. Because C is just some constant, C+C is just another constant, so we can write: f(x)=sinx-tanx+C. To solve for C, we use the given initial condition that f(pi/8)=-1:
-1=sin(pi/8)-tan(pi/8)+C
-1=(sqrt(2-sqrt(2)))/2-(sqrt(2)-1)+C
0=(sqrt(2-sqrt(2)))/2-sqrt(2)+2+C
C=-(sqrt(2-sqrt(2))-2sqrt(2)+4)/2~~-0.968
Thus, f(x)=sinx-tanx-(sqrt(2-sqrt(2))-2sqrt(2)+4)/2, or, using an approximation, f(x)=sinx-tanx-0.968.