Suppose P(x,y) a polynomial in the variables x,y.
For example, x4 or x3y2+3xy+1.
Is there a general method which allows us to evaluate the indefinite integral
∫P(sinx,cosx)dx
What about the case when P(x,y) is a rational function (i.e. a ratio of two polynomials)?
Example of a rational function: x2y+y3x+y.
This is being asked in an effort to cut down on duplicates, see here: Coping with *abstract* duplicate questions.
Answer
There are several general approaches to integrals that involve expressions with sines and cosines, polynomial expressions being the simplest ones.
Weierstrass Substitution
A method that always works is Weierstrass substitution, which will turn such an integral into an integral of rational functions, which in turn can always be solved, at least in principle, by the method of partial fractions. This works even for rational functions of sine and cosine, as well as functions that involve the other trigonometric functions.
Weierstrass substitution replaces sines and cosines (and by extension, tangents, cotangents, secants, and cosecants) by rational functions of a new variable. The identities begin by the trigonometric substitution t=tanx2, with −π<x<π, which yields
sinx=2t1+t2cosx=1−t21+t2dx=2dt1+t2.
For example, if we have
∫sinx−cosxsinx+cosxdx
using the substitution above we obtain:
∫sinx−cosxsinx+cosxdx=∫(2t1+t2−1−t21+t22t1+t2+1−t21+t2)(21+t2)dt=∫(2t−1+t21+t21+2t−t21+t2)(21+t2)dt=∫(2t−1+t22t+1−t2)(21+t2)dt=2∫2t−1+t2(1+t2)(2t+1−t2)dt
which can then be integrated by the method of partial fractions.
Substitutions and Reduction formulas
However, there are usually faster methods, particularly for polynomial expressions. By breaking up the integral into a sum of integrals corresponding to the monomials, the problem reduces to solving integrals of the form
∫(sinx)n(cosx)mdx
with n and m nonnegative integers. The standard methods then are:

If n is odd, then “reserve” one sine, and transform the others into cosines by using the identity sin2x=1−cos2x. Then do the change of variable u=cosx to transform the integral into the integral of a polynomial. For example,
∫(sinx)5(cosx)2dx,
then take (sinx)5, and write it as
sinx(sinx)4=sinx(sin2x)2=sinx(1−cos2x)2.
Then setting u=cosx and du=−sinxdx, we get
∫(sinx)4(cosx)2dx=∫sinx(1−cos2x)2(cosx)2dx=−∫(1−u2)2u2du,
which can be solved easily. 
If m is odd, then do the same trick by by “reserving” one cosine and using the substitution u=sinx. For example,
∫sin2xcos3xdx=∫sin2x(cos2x)cosxdx=∫(sin2x)(1−sin2x)cosxdx
and then setting u=sinx, du=cosxdx, we get
∫sin2xcos3xdx=∫u2(1−u2)du,
which can be solved easily again. 
If n and m are both even, then either replace all the sines with cosines or vice versa, using sin2x=1−cos2x or cos2x=1−sin2x, and expand. This will leave integrals of the form
∫sinnxdxor∫cosmxdx
with n and m even positive and even. In that situation, one can use the reduction formulas, which can be obtained by using integration by parts:
∫sinnxdx=−1nsinn−1xcosx+n−1n∫sinn−2xdx,∫cosmxdx=1mcosm−1xsinx+n−1n∫cosn−2xdx.
By repeated application of these formulas, one eventually ends up with an integral of the form ∫dx which can be solved directly.
The process can be shortened if you happen to spot or know some trigonometric identities; for example, the power reduction formulas allow you to replace powers of sines or cosines by expressions of multiple angles, e.g.,
sin4θ=3−4cos(2θ)+cos(4θ)8
could replace a single integral with three integrals that can be done fairly easily via substitution.
Other methods
If you are comfortable enough integrating functions with a complex variable in it, then the method described by Qiaochu will transform any integral that involves sines and cosines in any way into an integral that involves exponential functions instead.
Attribution
Source : Link , Question Author : Community , Answer Author :
5 revs, 3 users 94%