# Different results obtained for $\int e^{-x}\sin x \mathrm dx$ using formula and using by parts.

So I have a very simple integral at hand which can be evaluated by parts directly, and the answer so obtained matches with the correct antiderivative.

$$\int e^{-x}\sin x\mathrm dx$$

My question arises when I try to use the formula for integrals of the type $$\int e^{ax}\sin(bx+c)\mathrm dx$$. Although the formula itself is derived from two applications of by parts technique, the result finally obtained for the said integral differs in sign. Here's how:

\begin{aligned}\int e^{ax}\sin (bx+c)\mathrm dx &= \frac{e^{ax}}{a^2+b^2}\left(a\sin(bx+c)-b\cos(bx+c)\right)\\ & = \frac{e^{ax}}{r}\sin(bx+c-\phi) \ , \ r=\sqrt{a^2+b^2} \ , \ \phi=\arctan\left(\frac{b}{a}\right)\end{aligned}

Plugging in $$a=-1$$, $$b=1$$ and $$c=0$$ for the integral at hand gives $$1/\sqrt{2}\cdot \sin(x+\pi/4)$$ which is negative of the correct antiderivative. What mistake am I making? Any pointers are appreciated. Thanks.

Let's try it with complex numbers:

$$e^{ax} \sin(bx+c)=e^{ax} \frac{e^{i(bx+c)}-e^{-i(bx+c)}}{2i}=\frac{e^{(a+bi)x+ic}-e^{(a-bi)x-ic}}{2i}.$$

Now upon integration you get

$$\frac{\frac{1}{a+bi} e^{(a+bi)x+ic}-\frac{1}{a-bi} e^{(a-bi)x-ic}}{2i} + C \\ = \frac{e^{ax}}{r} \frac{e^{i(bx+c)+i\phi_1} - e^{-i(bx+c)+i\phi_2} }{2i} + C.$$

Here $$\phi_1$$ is an argument of $$a-bi$$ and $$\phi_2$$ is an argument of $$a+bi$$. One can select these arguments to be each other's negative, because the numbers whose arguments are being taken are conjugates of each other. If you do that, then you can define $$\phi:=\phi_1$$ and then you can read off

$$\frac{e^{ax}}{r} \frac{e^{i(bx+c+\phi)}-e^{-i(bx+c+\phi)}}{2i}=\frac{e^{ax}}{r} \sin(bx+c+\phi).$$

Again in my notation $$\phi$$ was an argument of $$a-bi$$, so if you want to use an argument of $$a+bi$$ then you need a minus sign.

So the problem is that you should be using what mathematicians would call the argument of $$a+bi$$ and what programmers call "atan2(b,a)" to obtain the phase shift $$\phi$$. Indeed $$-\pi/4$$ is not a valid argument of $$-1+i$$, but $$3\pi/4$$ is.

• That clarifies it. Thanks. Commented Mar 24, 2021 at 18:47

You are calculating $$\phi=\arctan (-1)=-\pi/4$$. But it could also be $$3\pi/4$$ which I think will give you the answer you want. Check carefully the restrictions on the parameters in whatever source you used for the result.

• But should we not consider the principal branch of the $\arctan()$ function? Commented Mar 24, 2021 at 18:28
• Well I guess not if you are getting the wrong answer! This link defines it slightly differently, so you get the right answer. en.wikipedia.org/wiki/… Commented Mar 24, 2021 at 18:49