Integrate by parts to find some useful recurrences relating Iₙ and Jₙ.
![\displaystyle I_n = \int_(-\pi)^\pi x^n \cos(x) \, dx = uv \bigg|_(x=-\pi)^(x=\pi) - \int_(-\pi)^\pi v\, du \\\\ \implies I_n = -n \int_(-\pi)^\pi x^(n-1) \sin(x) \, dx \\\\ \implies I_n = -n J_(n-1)](https://img.qammunity.org/2023/formulas/mathematics/high-school/tq6tz0gdtgxc2f1pc2hxgdulndk8zmg9lt.png)
where u = xⁿ and dv = cos(x) dx.
![\displaystyle J_n = \int_(-\pi)^\pi x^n \sin(x) \, dx = uv \bigg|_(x=-\pi)^(x=\pi) + \int_(-\pi)^\pi v\, du \\\\ \implies J_n = \pi^n - (-\pi)^n + n \int_(-\pi)^\pi x^(n-1) \cos(x) \, dx \\\\ \implies J_n = \pi^n - (-\pi)^n + n I_(n-1)](https://img.qammunity.org/2023/formulas/mathematics/high-school/th2sg4mv8qbtf6y0qn4lid8ygonbzs7739.png)
The integrals for n = 0 are trivial:
![\displaystyle I_0 = \int_(-\pi)^\pi \cos(x) \, dx = \sin(\pi) - \sin(-\pi) = 0](https://img.qammunity.org/2023/formulas/mathematics/high-school/1df83kbu6rzl1gak6y4lqyf66ld0vjhj9k.png)
![\displaystyle J_0 = \int_(-\pi)^\pi \sin(x) \, dx = -\cos(\pi) - (-\cos(-\pi)) = 0](https://img.qammunity.org/2023/formulas/mathematics/high-school/1l057dskahovof7hjbyayaq201baxwwbwu.png)
Now, the integral we're interested in is
![\displaystyle \int_(-\pi)^\pi x^n f(x) \cos(x) \, dx](https://img.qammunity.org/2023/formulas/mathematics/high-school/1bbgxifjhhkyrkn8d38083omegdugyna5z.png)
but we know f(x) is quadratic, and we want to find its coefficients a, b, and c such that
![\displaystyle \int_(-\pi)^\pi x^n (ax^2+bx+c) \cos(x) \, dx](https://img.qammunity.org/2023/formulas/mathematics/high-school/1sypwqbxtxkzbsefztyy41dq4ud9u4169m.png)
But this is simply
![\displaystyle \int_(-\pi)^\pi (ax^(n+2)+bx^(n+1)+cx^n) \cos(x) \, dx = aI_(n+2) + bI_(n+1) + cI_n](https://img.qammunity.org/2023/formulas/mathematics/high-school/s7odaeh6dxab7qx5xzibvfhg7ay641mnzt.png)
Using the recurrences above and the initial values we've computed, we find
• I₁ = -J₀ = 0
• J₁ = π - (-π) + I₀ = 2π
• I₂ = -2 J₁ = -4π
• J₂ = π² - (-π)² + 2 I₁ = 0
• I₃ = -3 J₂ = 0
• J₃ = π³ - (-π)³ + 3 I₂ = 2π³ - 12π
• I₄ = -4 J₃ = -8π³ + 48π
When n = 0, the integral we care about is
![aI_2 + bI_1 + cI_0 = -4\pi a + 0 + 0 = 4\pi \implies a = -1](https://img.qammunity.org/2023/formulas/mathematics/high-school/8ywtxc2zbuqhayq9bwrh89jlf5jtl5kgf0.png)
When n = 1,
![aI_3 + bI_2 + cI_1 = 0 - 4\pi b + 0 = 4\pi \implies b = -1](https://img.qammunity.org/2023/formulas/mathematics/high-school/1pkdf425y02jfpdibi4q65qec27s9rket7.png)
When n = 2,
![aI_4 + bI_3 + cI_2 = (48\pi - 8\pi^3)a + 0 - 4\pi c = 4\pi \implies c = 2\pi^2 - 13](https://img.qammunity.org/2023/formulas/mathematics/high-school/42kl6rhuumraz14p7kr489d98x8chmq4g7.png)
so that
![f(x) = \boxed{-x^2 - x + 2\pi^2 - 13}](https://img.qammunity.org/2023/formulas/mathematics/high-school/j082u54jzrxn1yqaa05jb65cbneklvpoi9.png)