I am solving the differential equation $$(D-1)^2y=e^x\sec^2(x)\tan (x)$$ The particular solution is the following $$y=e^x\frac{1}D\int \sec^2(x)\tan(x)dx$$ This can be done in two ways. $$y=e^x\frac{1}{D}(\sec^2(x)/2); \qquad y=e^x\frac1D(\tan^2(x)/2)$$ Depending on whether you substitute $\sec(x)=t$ or $\tan(x)=t$. The next integral gives different final answers which one of them is correct or both are correct?
First solution using the first integral $$y=e^x\tan(x)/2$$ Second solution using second integral $$y=\frac{e^x}2(\tan(x)-x)$$
For the particular solution $$y_p=\frac{e^x}2(\tan(x)-x)$$ But since we have the homogeneous solution $$y_h=c_1e^x+c_2xe^x$$ Therefore the general solution is $$\implies y(x)=c_1e^x+c_2xe^x+\frac 12e^x\tan(x)$$ The $xe^x$ term is absorbed by the homogenous solution
For the first particular solution we have
$$y=e^x\frac{1}D\int \sec^2(x)\tan(x)dx$$ $$y=e^x\frac{1}D\int \frac { \sin(x)}{\cos^3(x)}dx$$ Substitute $u=\cos x \implies du=-\sin x dx$ $$y=-e^x\frac{1}D\int \frac { du}{u^3}$$ $$y=\frac 12e^x\int \frac { dx}{\cos^2x}$$ $$y_p=\frac 12e^x\tan(x)$$ $$\implies y(x)=c_1e^x+c_2xe^x+\frac 12e^x\tan(x)$$ Which is the same answer
Edit
You get extra terms because we didint pay attention to the constant of integration but both methods give the same answers
$$y=-e^x\frac{1}D\int \frac { du}{u^3}$$ $$y=-e^x\frac{1}D(-\frac12u^{-2}+K_1)$$ $$y=-e^x \int(-\frac12 \frac 1 {\cos^2 x}+K_1)$$ $$y=\frac 12e^x \int( \frac 1 {\cos^2 x}+K_1)$$ $$\boxed {y=\frac 12e^x( \tan x+K_1x+K_2)}$$
If you pay attention to both constant of integration you end with the same value for the integral..but note that it will just give you the homogeneous part of the solution which we already have...So we dont pay attention to the constant of integration to get the particular solution