Start by performing color(blue)(" Integration by parts") using the formula
color(blue)(int u dv=uv-int v du )
the solution is quite long because it consists of two terms.
from the given:
int (x sin x - sec 2x) dx
color (red)("First part:")
int (x sinx) dx
Let u=x, and dv=sin x dx
and v=-cos x and du=dx
so that int (x sinx) dx=-x*cos x-int -cos x dx
then color (blue)(int (x sinx) dx=-x*cos x+sin x)
color (red)(" second part:")
Use the formula: int (sec u) du=ln (sec u+tan u)+C
so that
color(blue)(int sec 2x dx=1/2*ln(sec 2x+tan 2x))
Now , combine the first and second parts
color (magenta)(f(x)=int (x sin x - sec 2x) dx=
color(magenta)(-x*cos x+sin x-1/2*ln(sec 2x+tan 2x)+C)
Solve for C: using f(pi/12)=-2 and then
-2=-(pi/12)*cos (pi/12)+sin (pi/12)-1/2*lnabs(sec 2*(pi/12)+tan 2*(pi/12))+C
-2=-(pi/12)*1/2*sqrt(2+sqrt3)+1/2*sqrt(2-sqrt3)-1/2*lnabs(2/sqrt3+1/sqrt3)+C
C=1/2 ln sqrt3+pi/24*sqrt(2+sqrt3)-1/2*sqrt(2-sqrt3)-2
The final answer is
color (magenta)(f(x)=-x*cos x+sin x-1/2 ln (sec 2x+tan 2x) + 1/2 ln sqrt3+pi/24*sqrt(2+sqrt3)-1/2*sqrt(2-sqrt3)-2)
simplifying the square roots we have the following
color (magenta)(f(x)=-x*cos x+sin x-1/2 ln (sec 2x+tan 2x) -1.73129)