The integration by parts formula is
∫ a b u d v = u v | a b − ∫ a b v d u . {\displaystyle \int _{a}^{b}u\,dv=\left.uv\right|_{a}^{b}-\int _{a}^{b}v\,du.}
Set
u = x ⟹ d u = d x d v = cos ( x ) d x ⟹ v = sin ( x ) . {\displaystyle {\begin{aligned}u&=x&&\implies du&&=dx\\dv&=\cos(x)\,dx&&\implies v&&=\sin(x).\end{aligned}}}
Hence by the formula,
∫ 0 π / 2 x cos ( x ) d x = x sin ( x ) | 0 π / 2 − ∫ 0 π / 2 sin ( x ) d x = ( π 2 sin ( π 2 ) − 0 ) − ( − cos ( x ) | 0 π / 2 ) = π 2 − ( − cos ( π 2 ) + cos ( 0 ) ) = π 2 − ( 0 + 1 ) = π 2 − 1. {\displaystyle {\begin{aligned}\int _{0}^{\pi /2}x\cos(x)\,dx&=\left.x\sin(x)\right|_{0}^{\pi /2}-\int _{0}^{\pi /2}\sin(x)\,dx\\&=\left({\frac {\pi }{2}}\sin \left({\frac {\pi }{2}}\right)-0\right)-\left(\left.-\cos(x)\right|_{0}^{\pi /2}\right)\\&={\frac {\pi }{2}}-\left(-\cos \left({\frac {\pi }{2}}\right)+\cos(0)\right)\\&={\frac {\pi }{2}}-(0+1)\\&=\color {blue}{\frac {\pi }{2}}-1.\end{aligned}}}