Why Pair Sine and Cosine Integrals?
Integration by parts applied to a polynomial times sine produces a cosine integral; applied to a polynomial times cosine, it produces a sine integral. These two calculations are linked. Treating them as a pair makes the alternating pattern easier to follow and gives a reliable way to reduce the polynomial degree until the calculation stops.
For example, integrating \(x^n\sin x\) by parts leaves an integral involving \(x^{n-1}\cos x\). Integrating that cosine integral by parts returns to a sine integral, now with a polynomial of still lower degree. The trigonometric functions cycle, but the polynomial degree decreases. That decrease is what makes the method terminate.
The Paired Recurrences
For a nonnegative integer \(n\), write \(S_n\) for an antiderivative of \(x^n\sin x\), and \(C_n\) for an antiderivative of \(x^n\cos x\). These antiderivatives are understood up to an additive constant. For \(n\geq 1\), integration by parts gives the paired recurrences below. The starting cases follow by direct integration.
For the first recurrence, take \(u=x^n\) and \(dv=\sin x\,dx\). Then \(du=nx^{n-1}\,dx\) and \(v=-\cos x\), giving \(S_n=-x^n\cos x+nC_{n-1}\). For the second, take \(u=x^n\) and \(dv=\cos x\,dx\). Then \(v=\sin x\), giving \(C_n=x^n\sin x-nS_{n-1}\).
Each recurrence lowers the polynomial degree by one, while alternating between sine and cosine. Substituting one recurrence into the other can lower the degree by two at a time. This is the key stopping mechanism: after finitely many substitutions, only the starting cases remain.
Worked Example: Integrating \(x^3\sin x\)
Worked Example: Integrating \(x^3\sin x\)
Use \(S_3=-x^3\cos x+3C_2\). The cosine recurrence gives \(C_2=x^2\sin x-2S_1\), and \(S_1=-x\cos x+C_0=-x\cos x+\sin x\). Substitution, shown one step at a time, yields $$ \begin{aligned} S_1&=-x\cos x+\sin x,\\ C_2&=x^2\sin x-2(-x\cos x+\sin x)\\ &=x^2\sin x+2x\cos x-2\sin x,\\ S_3&=-x^3\cos x+3(x^2\sin x+2x\cos x-2\sin x)\\ &=-x^3\cos x+3x^2\sin x+6x\cos x-6\sin x. \end{aligned} $$ Therefore an antiderivative is \(-x^3\cos x+3x^2\sin x+6x\cos x-6\sin x+C\). Differentiating the nonconstant terms gives $$ \begin{aligned} \frac{d}{dx}(-x^3\cos x+3x^2\sin x+6x\cos x-6\sin x) &=(-3x^2\cos x+x^3\sin x)\\ &\quad +(6x\sin x+3x^2\cos x)\\ &\quad +(6\cos x-6x\sin x)-6\cos x\\ &=x^3\sin x. \end{aligned} $$ The derivative equals the integrand, as required.
Resolving the Cycle for a General Polynomial
The paired recurrences can be used directly, as in the example. A second approach makes the alternating pattern explicit by seeking polynomial coefficients for the sine and cosine terms. This approach also shows the algebraic step that resolves the cycle without leaving an unknown integral on either side.
Let \(P\) be a polynomial and seek an antiderivative of \(P(x)\sin x\) in the form \(A(x)\sin x+B(x)\cos x\), where \(A\) and \(B\) are polynomials. Differentiating gives $$ \frac{d}{dx}(A\sin x+B\cos x) =(A'-B)\sin x+(A+B')\cos x. $$ For this derivative to equal \(P\sin x\), the coefficients must satisfy $$ A'-B=P,\qquad A+B'=0. $$ The first equation gives \(B=A'-P\). Differentiating it and substituting into the second equation produces $$ A+A''=P'. $$ This is the algebraic cycle: the coefficient \(A\) is related to its second derivative. Because \(P\) is a polynomial, repeated differentiation eventually gives zero, so this equation can be resolved by a finite sum.
To justify the sine formula, set \(A=P'-P'''+P^{(5)}-\cdots\) and \(B=-P+P''-P^{(4)}+\cdots\). The alternating terms cancel in \(A+A''\), leaving \(P'\). Since \(B=A'-P\), we have \(A'-B=P\), and \(A+A''=P'\) implies \(A+B'=0\). The differentiated expression is therefore \(P\sin x\).
For the cosine formula, use the same derivative identity and require \(A'-B=0\) and \(A+B'=P\). These equations give \(B=A'\) and \(A+A''=P\). The finite choice \(A=P-P''+P^{(4)}-\cdots\) satisfies this equation, and \(B=A'=P'-P'''+P^{(5)}-\cdots\). Substitution into the derivative identity gives \(P\cos x\). This proves both formulas.
Worked Example: Resolving the Polynomial Cycle for \(x^3\sin x\)
Worked Example: Resolving the Polynomial Cycle for \(x^3\sin x\)
Take \(P(x)=x^3\). The coefficient equation is \(A+A''=P'=3x^2\). Since \(P'''=6\) and the next derivative is zero, the finite alternating sum gives $$ A=P'-P'''=3x^2-6. $$ Then \(B=A'-P=6x-x^3\). Thus a proposed antiderivative is $$ F(x)=(3x^2-6)\sin x+(6x-x^3)\cos x. $$ Differentiate each term: $$ \begin{aligned} F'(x) &=6x\sin x+(3x^2-6)\cos x\\ &\quad +(6-3x^2)\cos x-(6x-x^3)\sin x\\ &=x^3\sin x. \end{aligned} $$ The cosine terms cancel, and \(6x\sin x-(6x-x^3)\sin x=x^3\sin x\). The derivative check confirms the antiderivative.
Worked Example: Integrating \(x^4\cos x\)
Worked Example: Integrating \(x^4\cos x\)
Start with \(C_4=x^4\sin x-4S_3\), using the already established recurrence for \(S_3\). Substituting that expression gives $$ \begin{aligned} C_4 &=x^4\sin x-4(-x^3\cos x+3x^2\sin x+6x\cos x-6\sin x)\\ &=x^4\sin x+4x^3\cos x-12x^2\sin x-24x\cos x+24\sin x. \end{aligned} $$ To check, differentiate: $$ \begin{aligned} \frac{d}{dx}(&x^4\sin x+4x^3\cos x-12x^2\sin x-24x\cos x+24\sin x)\\ &=4x^3\sin x+x^4\cos x\\ &\quad +12x^2\cos x-4x^3\sin x\\ &\quad -24x\sin x-12x^2\cos x\\ &\quad -24\cos x+24x\sin x+24\cos x\\ &=x^4\cos x. \end{aligned} $$ All terms other than \(x^4\cos x\) cancel.
When the Recurrences Are Useful
The paired recurrences are especially useful when a polynomial weight makes repeated integration by parts manageable and a clear stopping rule is needed. They tell you which lower-degree integral appears next, and they make the alternating signs visible. For indefinite integrals, the result is a polynomial combination of sine and cosine plus a constant. For definite integrals, apply the same recurrences to antiderivatives and then evaluate the resulting boundary terms at the specified endpoints.
For a general polynomial \(P\), the finite-sum formulas can be quicker than repeatedly writing the recurrences. The recurrence is often easier to derive and apply when the polynomial is a simple power; the finite-sum form can make the overall pattern clearer for a higher-degree polynomial. Both methods rely on polynomial derivatives eventually vanishing.
A Common Sign Error
The cosine recurrence has a minus sign: \(C_n=x^n\sin x-nS_{n-1}\). Losing that sign changes terms in the final answer. For instance, the expression $$ -x^3\cos x+3x^2\sin x-6x\cos x+6\sin x $$ is not an antiderivative of \(x^3\sin x\). Differentiation gives $$ x^3\sin x+12x\sin x, $$ not \(x^3\sin x\). The correct recurrence calculation gives \(+6x\cos x-6\sin x\) in place of \(-6x\cos x+6\sin x\). Differentiating the corrected expression cancels the extra terms and leaves exactly \(x^3\sin x\).
A practical safeguard is to keep each recurrence on its own line, preserve the minus sign when substituting, and differentiate the final expression. This checks both the algebra and the trigonometric signs.
Check Your Understanding
Use the paired recurrences or the finite polynomial formulas to answer these questions. Check each antiderivative by differentiation.
- Write the recurrences for \(S_2\) and \(C_2\) in terms of lower-degree antiderivatives.
- Find an antiderivative of \(x^2\cos x\).
- For a polynomial \(P\), what equation does the sine coefficient \(A\) satisfy when seeking an antiderivative \(A\sin x+B\cos x\) of \(P\sin x\)?
- Why do the finite alternating sums for polynomial-weighted sine and cosine integrals terminate?
- Differentiate your answer for \(\int x^3\cos x\,dx\) and verify that it returns \(x^3\cos x\).