When we integrate the double integral $$\int_{0}^{\pi}\int_{0}^{x}x\sin y\; \mathrm{d}y\,\mathrm{d}x$$ we get $2+π^2/2$ as answer. (Please see image)
When we use triangle area formula = $1/2 \cdot \mathrm{base} \cdot \mathrm{height}$, we get $π^2/2$ as answer. Where did the extra 2 come from? as here
When we use the triangle area formula, what we get is the area of the triangle, which is equal to$$\int_0^\pi\int_0^x1\,\mathrm dy\,\mathrm dx.$$But what you are computing is$$\int_0^\pi\int_0^xx\sin y\,\mathrm dy\,\mathrm dx.$$