# Integration by parts question: why does the constant of integration get swallowed up?

To integrate $$e^x\cos x$$ we can use integration by parts twice: \begin{align} \int e^x \cos x \, dx &= e^x\sin x - \int e^x\sin x \, dx \\ &= e^x\sin x - \left(-e^x\cos x + \int e^x\cos x \, dx\right) \\ &= e^x\sin x + e^x\cos x - \int e^x \cos x \, dx \\ 2 \int e^x\cos x \, dx &= e^x(\sin x + \cos x) \\ \int e^x \cos x \, dx &= \frac{e^x(\sin x + \cos x)}{2} \end{align} But this solution is incomplete: there should be a constant of integration at the end. Why does this happen? I think it might have something to do that you are adding a family of functions to itself, but I can’t quite pin down what the problem is.

• Bringing the integral from the right to the left side. – marty cohen Jan 17 at 23:42

Strictly speaking, you have something more like $$F(x)=e^x \sin(x) - G(x)$$ then $$F(x)=e^x \sin(x) + e^x \cos(x) - H(x)$$, where $$F$$ and $$H$$ are both some antiderivatives of $$e^x \cos(x)$$ (not necessarily the same ones) and $$G$$ is some antiderivative of $$e^x \sin(x)$$. Now $$F$$ and $$H$$ differ only by a constant, so $$2F(x)=e^x \sin(x) + e^x \cos(x) + C$$ and then you divide.

In practice if you want to take derivations seriously, you're better off with definite integrals with variable limits, i.e. working with $$\int_a^x f(y) dy$$ instead of $$\int f(x) dx$$.

• Hi Ian. Thanks for this answer. It does make more sense to look at things from this angle. However, if we want to define the notation $\int f(x) \, dx$ precisely, then can it refer to a set of antiderivatives? In other words, can we define $\int f(x) \, dx$ as $\{F(x) \mid F' = f\}$? And if so, where would the error in this proof be? – Joe Mar 3 at 17:03
• @Joe Sure, but this way of doing things has mildly annoying algebraic properties. For example $\int f(x) dx + \left ( -\int f(x) dx \right )$ is $\{ x \mapsto c : c \in \mathbb{R} \}$ rather than $x \mapsto 0$ as you would initially expect. Missing this fact is what led to your question in the first place. – Ian Mar 3 at 17:20
• I'm not overly familiar with set notation, but I presume that $\{ x \mapsto c \mid c \in \mathbb{R} \}$ refers to the family of constant functions. You've convinced me that defining the indefinite integral this way is not easy and/or desirable, but if we do take this approach, then how would we define the addition of two indefinite integrals? In other words, is there a sensible way of defining $\{F(x) \mid F' = f\} + \{G(x) \mid G' = g\}$, for instance? – Joe Mar 3 at 17:29
• @Joe Yes, $\{ x \mapsto c : c \in \mathbb{R} \}$ is the set of all real-valued constant functions. And sure, there is an addition operation: it's $\{ x \mapsto F_0(x) + G_0(x) + c : c \in \mathbb{R} \}$ where $F_0$ and $G_0$ are any particular elements of the two sets you're trying to add. When you get used to it, this isn't that bad, but if you aren't used to it, you get confused when, for example, subtracting an indefinite integral from itself doesn't "really" result in $0$. – Ian Mar 3 at 17:39
• @Joe Note that this is the same as $A+B=\{ x \mapsto F(x) + G(x) : F \in A,G \in B \}$, which is maybe the more obvious way to write it, but one should keep in mind that given $f \in A+B$ there is not a unique decomposition of $f$ as $g+h$ where $g \in A$ and $h \in B$. – Ian Mar 3 at 18:02

In order to find $$\int f(x)\,dx$$ (on an interval $$I$$), all one needs is to find one differentiable function $$F:I\to\mathbb{R}$$ such that $$F'(x)=f(x)$$ for every $$x\in I$$. Then $$\int f(x)\, dx=F(x)+C$$

This is the definition of indefinite integrals. This definition is based on the observations that

• If $$F:I\to\mathbb{R}$$ is such that $$F'=f$$ on I, then for any constant $$K$$, $$(F+K)'=f$$ on $$I$$;

• If $$G:I\to\mathbb{R}$$ and $$F:I\to\mathbb{R}$$ are such that $$G'=F'$$ on $$I$$, then there exists a constant $$K$$ with $$G=F+K$$. (This is why it is important that $$I$$ is "connected", i.e., an interval on $$\mathbb{R}$$.)

Now go back to your integral where $$f(x)= \int e^x\cos x$$, $$I=\mathbb{R}$$. The formal$$\dagger$$ calculation just gives you one $$F$$ such that $$F'=f$$ on $$I$$, which give you the answer: $$\int e^x\cos x\,dx=\frac{1}{2}e^x(\sin x+\cos x)+C.$$

$$\dagger$$ The reason it is "formal" is that by definition, $$\int f(x)\,dx$$ means a family (set) of functions (on $$I$$); but in the calculation, one uses only one "instance" of the set. This is OK since one can eventually add the "arbitrary constant" $$C$$ to get the answer.

Whenever you have an indefinite integral, there is a constant of integration.

When you make the limits definite, the constant is subtracted away since it occurs in both the lower and upper limit.

This solution to your problem makes use of a very basic fact. Note that $$\int f(x)~dx=\int f(x)+0~dx$$ \begin{align}\int e^x \cos x \, dx&= e^x\sin x - \left(-e^x\cos x + \int e^x\cos x \, dx\right)\\ &=e^x\sin x+e^x\cos x-\int e^x\cos x \, dx\\ &=e^x\sin x+e^x\cos x-\int e^x\cos x \, dx+\int0~dx\end{align} Hence, $$2\int e^x\cos x \, dx=e^x\sin x+e^x\cos x+C$$