Evaluate $\int \dfrac{\cos^2x}{1+\tan x}dx$
Here are my various unsuccessful attempts:-
Attempt $1$:
$$\tan x=t$$ $$\sec^2 x=\dfrac{dt}{dx}$$
$$\int \dfrac{dt}{(1+t^2)^2(1+t)}$$ $$\ln(1+t)=y$$ $$\dfrac{1}{1+t}=\dfrac{dy}{dt}$$
$$\int \dfrac{dy}{\left(1+(e^y-1)^2\right)^2}$$ $$\int \dfrac{dy}{(1+e^{2y}+1-2e^y)^2}$$ $$\int \dfrac{dy}{(e^{2y}+2-2e^y)^2}$$ $$\int \dfrac{dy}{e^4y+4+4e^{2y}+4e^{2y}-4e^y(e^{2y}+2)}$$ $$\int \dfrac{dy}{e^4y-4e^{3y}+8e^{2y}-8e^y+4}$$
From here I gave up on this method.
Attempt $2$:
$$\int \dfrac{\cos^3x}{\cos x+\sin x}$$ $$\int\dfrac{3\cos x+\cos 3x}{4(\cos x+\sin x)}$$ $$\dfrac{1}{4}\left(3\cdot\int\dfrac{\cos x}{\cos x+\sin x}+\int \dfrac{\cos 3x}{\cos x+\sin x}\right)$$
Solving the first integral
$$\cos x=A(\cos x+\sin x)+B(-\sin x+\cos x)+C$$ $$A+B=1$$ $$A-B=0$$ $$A=\dfrac{1}{2},B=\dfrac{1}{2}$$
$$\dfrac{1}{4}\left(\dfrac{3}{2}\left(x+\ln|\sin x+\cos x|\right)+\int \dfrac{\cos 3x}{\cos x+\sin x}\right)$$
I was not understanding how to proceed for second integration.
Attempt $3$:
For @mvpq
$$\tan x=t$$ $$\sec^2 x=\dfrac{dt}{dx}$$
$$\int \dfrac{dt}{(1+t^2)^2(1+t)}$$
Trying to write expression as $$\dfrac{1}{(1+t^2)^2(1+t)}=\dfrac{A}{1+t}+\dfrac{B}{1+t^2}+\dfrac{C}{(1+t^2)^2}$$
$$\dfrac{1}{(1+t^2)^2(1+t)}=\dfrac{A(1+t^2)^2+B(1+t^2)+C(1+t)}{(1+t)(1+t^2)^2}$$ $$\dfrac{1}{(1+t^2)^2(1+t)}=(A+B+C)+Ct+(B+2A)t^2+At^4$$ $$A+B+C=1\tag{1}$$
$$A=0$$ $$A+2B=0$$ $$B=0$$ $$C=0$$
But $A+B+C=1$, hence no solution, so cannot be solved by partial fractions.
Attempt $4$:
For @heropup
$$\tan x=t$$ $$\sec^2 x=\dfrac{dt}{dx}$$
$$\int \dfrac{dt}{(1+t^2)^2(1+t)}$$
Trying to write expression as $$\dfrac{1}{(1+t^2)^2(1+t)}=\dfrac{A}{1+t}+\dfrac{Bt+C}{1+t^2}+\dfrac{Dt+E}{(1+t^2)^2}$$
$$\dfrac{1}{(1+t^2)^2(1+t)}=\dfrac{A(1+t^2)^2+(Bt+C)(1+t^2)(1+t)+(Dt+E)(1+t)}{(1+t)(1+t^2)^2}$$
$$1=A(1+t^2)^2+(Bt+C)(1+t^2)(1+t)+(Dt+E)(1+t)$$
Placing $t=-1$ in the equation
$$4A=1, A=\dfrac{1}{4}$$ $$1=(Bt+C)(1+t+t^2+t^3)+(Dt+Dt^2+E+Et)$$ $$1=Bt+Bt^2+Bt^3+Bt^4+C+Ct+Ct^2+Ct^3+Dt+Dt^2+E+Et$$
$$1=Bt^4+(B+C)t^3+(B+C+D)t^2+(B+C+D+E)t+(C+E)$$ $$B=0$$ $$B+C=0$$ $$C=0$$ $$B+C+D=0$$ $$D=0$$ $$B+C+D+E=0$$ $$E=0$$ $$C+E=1$$ $$E=1$$
This is contradiction right?
Any hints?
Your partial fraction decomposition fails because the appropriate choice for numerators are not constants, but instead $$\frac{1}{(1+t^2)^2(1+t)} = \frac{A}{1+t} + \frac{Bt + C}{1+t^2} + \frac{Dt + E}{(1+t^2)^2}.$$ When the denominator is an integer power of a quadratic polynomial, the numerator is a linear function of $t$.
In order to solve for the coefficients in a correct manner, you need to first collect all of the terms on the RHS over a common denominator; this you have done:
$$\frac{1}{(1+t^2)^2(1+t)} = \frac{A(1+t^2)^2 + (Bt+C)(1+t)(1+t^2) + (Dt+E)(1+t)}{(1+t^2)^2(1+t)}.$$
Next, you need to equate the numerator on the LHS with the numerator on the RHS:
$$1 = A(1+t^2)^2 + (Bt+C)(1+t)(1+t^2) + (Dt+E)(1+t).$$
Here is where you make a mistake: You need to expand the RHS as a polynomial in $t$ and then collect like terms in $t$:
$$1 = (A+B) t^4 + (B+C) t^3 + (2A + B + C + D) t^2 + (B + C + D + E)t + (A + C + E).$$
After this, you equate corresponding coefficients to obtain the system $$\begin{cases} 1 &= A + C + E \\ 0 &= B + C + D + E \\ 0 &= 2A + B + C + D \\ 0 &= B + C \\ 0 &= A + B \end{cases}$$
Moreover, your substitution trick was performed incorrectly. When $t = -1$, you would get $$1 = A(1 + (-1)^2)^2 = 4A,$$ hence $A = 1/4$. I do not understand how you got $A = 0$.