3

$$\int \tan^2 x dx$$ the question isn't behind on how to do it but rather on its solution, let me go through my solution quickly:

If we do a substitution $u=\tan(x)$ then $du=\sec^2 x dx=(u^2+1)dx$ hence we get $$\int \frac{u^2}{1+u^2}du=\int\left(1-\frac{1}{1+u^2}\right)du=\tan x-\arctan(\tan x)+C$$ so no problem until here. The solution from the book or WolframAlpha is: $\tan x-x+C$ so it raised a question, since $\tan $ isn't injective and only has an inverse for $x\in(-\frac{\pi}{2},\frac{\pi}{2})$, for which then $\arctan(\tan(x))=x$ is only true for $x\in(-\frac{\pi}{2},\frac{\pi}{2})$. But then why if we do $\arctan(\tan x)=x$ in my solution we then get $$\tan x-x+C$$ which is the same as the correct solution the book or WolframAlpha shows, while we have only just considered the $x\in(-\frac{\pi}{2},\frac{\pi}{2})$ in my method? Isn't the indefinite integral considering $\forall x\in \mathbb{R}$? Why is this happening?

Note: Not looking at all for an alternative solution or how to get there, rather why I get the correct solution by considering $x\in(-\frac{\pi}{2},\frac{\pi}{2})$ while an integral should be $\forall x\in \mathbb{R}$

J. W. Tanner
  • 60,406
Aley20
  • 111
  • 1
    The result in your textbook/Wolfram arises since $\tan^2 x = \sec^2 x - 1$, so the integral becomes $\int \tan^2 x dx = \int (\sec^2 x - 1) dx = \tan x - x + C$. – homie o'morphic Dec 09 '22 at 00:10
  • 1
    @moofasa I really appreciate you but that's totally out of the scope of my question that was raised. What I'm asking is in the very last paragraphs – Aley20 Dec 09 '22 at 00:15
  • I'm not sure if this answers your question, but indefinite integration tends to be loose, IMO. I wouldn't worry about it. The notation $\int f$ just means "all antiderivatives of $f$ on some subdomain of the domain of $f$". There's nothing wrong with using u-subs for indefinite integrals, but without any bounds of integration, your u-sub might not be valid. But as far as indefinite integration cares, it's fine. There is a domain involved, sure, but that's because functions naturally have a domain by definition. Your main goal is to just find the antiderivative and put that $+C$ at the end. – Accelerator Dec 09 '22 at 01:24
  • You might be interested in looking at this, https://math.stackexchange.com/a/2992231/399263, for an interesting technique to make the C "disappear", or rather on how to express the $C$ from possibly $\arctan(\tan(x))$ itself (I didn't solve it, so I cannot be sure) without going for the floor function as shown in Ninad Mushi's answer. – zwim Dec 09 '22 at 02:05
  • @Aley20, I understand that you were asking about something different - hence the comment rather than posting it as an answer. My point is that you don't need to do $u$-substitution to get the antiderivative of $\tan^2 x$. In fact, you use the same exact trig identity to perform the change of variables anyway. – homie o'morphic Dec 09 '22 at 17:36

3 Answers3

5

This is a phenomenon that happens with all indefinite integrals. The original integral

$$\int \tan^2 x\:dx$$

has singularities at $\frac{\pi}{2} + \pi k$ for $k\in\Bbb{Z}$, therefore, no, the original integral was not for all $x\in\Bbb{R}$. Whenever you have discontinuities like that, they are tucked away in the $+C$. For example, take the textbook case of

$$\int \frac{dx}{x} = \log|x| + C$$

but this answer is a little misleading misleading. Consider the function

$$f(x)=\begin{cases}\log( -x) +7 & x<0 \\ \log (x )-2 & x>0\end{cases}$$

Taking the derivative, we see that it is still $\frac{1}{x}$. That is because $f$ can still be written as

$$f(x) = \log|x| + C$$

but in this case, the constant $C$ changes values across the discontinuity

$$C = \begin{cases}7 & x<0 \\ -2 & x>0\end{cases}$$

and that is allowed for $+C$. In your answer, we have that

$$x = \arctan(\tan x) + C$$

where the $+C$ hides the arbitrary constant (s)

$$C = \pi\left\lfloor\frac{x+\frac{\pi}{2}}{\pi}\right\rfloor$$

which makes the two answers equivalent, since they are only off by an arbitrary constant.

Ninad Munshi
  • 34,407
  • that sounds good but still is unclear to me how $\arctan(\tan(x))$ and $x$ differ by an arbitrary constant, will plotting into a graph help me see it? – Aley20 Dec 09 '22 at 00:32
  • @Aley20 It is as you say. One graph is a triangle wave, and the other is a triangle wave but with the beginning of each triangle lined up with the end of the previous (aka a sloped line) – Ninad Munshi Dec 09 '22 at 00:32
  • the thing is that I already did and it confused me because the $C$ then varies for each different $x$, but now I remember that you said it is true for the $C$, isn't it? So then it should be fine? And as a second last question, does this phenomena ocurr also with the $\arcsin(\sin x)$ and $\arccos(\cos x)$ with $x$ as well? – Aley20 Dec 09 '22 at 00:37
  • @Aley20 why don't you plot those and find out – Ninad Munshi Dec 09 '22 at 00:48
  • I'm... asking you because it's not clear by looking at the graph as it is with $\arctan(\tan x)$. Also still asking for the confirmation as if $C$ can vary for each different $x$, I know you said it in your post but I want to be sure. – Aley20 Dec 09 '22 at 01:00
  • 1
    In general, $\arctan(\tan(x)) = x + k\pi$ where $k$ is some integer. That $k\pi$ is a constant, so that's why you can just say $\tan(x) - (x+k\pi) + C = \tan(x) - x + C$. I'm not sure what you mean when you ask if $C$ can vary for each $x$. No matter what $x$ is, the $C$ is just some constant. @Aley20 – Accelerator Dec 09 '22 at 01:32
  • @Aley20 there is no sign ambiguity with the derivative of $\arctan(\tan x)$ which is why the function always has a positive slope. But what happens with the derivative of $\arcsin(\sin x)$? (Hint: $\sqrt{\cos^2 x} \neq \cos x$) – Ninad Munshi Dec 09 '22 at 01:39
  • 1
    I am deeply uncomfortable with a "constant" which seems to depend on $x$. I get that you have structured things so that on any connected subset of the domain of $\tan$, the expression will evaluate to a constant, but this seems notationally dangerous. – Xander Henderson Dec 09 '22 at 01:45
  • @XanderHenderson in a distributional sense, the constant's only dependence on $x$ occurs at a point mass at the discontinuities. In my view the point of the $+C$ is not to be a "constant" in the English sense of the word but to be a function in the kernel of the derivative operator on the domain we care about. This was done in an effort to conform with every integral table on the planet which states $\int dx/x = \log |x| +C$. I disagree with that notation, but if we have to keep it this seems like an acceptable work around. – Ninad Munshi Dec 09 '22 at 01:48
  • @NinadMunshi I'm not really arguing with it (though I think that introducing distributions in this context is a bit of a challenge). Just describing my own discomfort. – Xander Henderson Dec 09 '22 at 01:52
1

Elementary Explanation

Most elementary textbook authors are fairly careful to define things in such a way that the situation you are describing is not an issue. Because I have been teaching out of it recently, here is what Thomas' Calculus (instructor's 13th ed) has to say:

Definition: (p. 232) a function $F$ is an antiderivative of $f$ on an interval $I$ if $F'(x) = f(x)$ for all $x$ in $I$.

and

Definition: (p. 237) The collection of all antiderivatives of $f$ is called the indefinite integral of $f$ with respect to $x$, and is denoted by $$ \int f(x)\,\mathrm{d}x. $$

Notice that the indefinite integral of $f$ is defined in terms of antiderivatives of $f$, and the antiderivative of $f$ is only defined if $f$ is defined on an interval.

This implies that before you even start to ask what the indefinite integral of a function is, you first have to be clear about the definition of that function. What does the collection of symbols $\tan(x)^2$ represent?[1]

Barring any other information, I would assume that $\tan$ represents the tangent function, which is defined on the domain $\mathbb{R}\setminus \{\pi/2 + k\pi : k\in\mathbb{Z}\}$ (that is, the tangent function is defined everywhere that the cosine is not zero). BUT there is a problem here, since the question is about the antiderivative of the square of the tangent function, and the tangent function is naturally defined on a set which is not an interval.

This implies that $$\int \tan(x)^2\,\mathrm{d}x$$ does not, in fact, refer to the square of the tangent function on its natural domain, but only on some connected component of that domain, say $(-\pi/2,\pi/2)$, or $(\pi/2, 3\pi/2)$. Before you can evaluate the indefinite integral, you must first specify the domain of the function which you are integrating.

But...

In their answer, Ninad Munshi argues that one can discuss antiderivatives of functions which are defined on disconnected domains, and that the "disconnection" is swallowed by the constant of integration. I will not argue that they are wrong, but I do think that this is a wrongheaded approach, which could, potentially, lead to pain later on—being able to "split out" the behaviour of a function across singularities is often helpful.

Looking at the example of $x \mapsto 1/x$, we have two facts:

  1. if we assume that $x > 0$, then $$ \int \frac{1}{x}\, \mathrm{d}x = \log(x) + C, $$ where $C$ is an arbitrary constant of integration, and
  2. if we assume that $x < 0$, then $$ \int \frac{1}{x}\, \mathrm{d}x = \log(-x) + C, $$ where $C$ is an arbitrary constant of integration.

If we want to talk about an "antiderivative"[2] or "indefinite integral"[3] of $x \mapsto 1/x$ on the set $\mathbb{R}\setminus \{0\}$, then I think that it is wise to keep track of the various domains of definition. Hence I would argue that the "correct" antiderivative is something like $$ \int \frac{1}{x} \,\mathrm{d}x = \begin{cases} \log(x) + C & \text{if $x > 0$, and} \\ \log(-x) + D & \text{if $x < 0$,} \end{cases} $$ where both $C$ and $D$ are arbitrary constants of integration.

In the case of $\tan(x)^2$, it would not be unreasonable to write $$\int \tan(x)^2 \,\mathrm{d}x = \begin{cases} \tan(x) + x + C_k & \text{if $x \in \left(\dfrac{\pi}{2} + (k-1)\pi, \dfrac{\pi}{2} + k\pi\right)$,} \end{cases} $$ where $C_k$ is an arbitrary constant of integration for each $k\in \mathbb{Z}$.


[1] Minor pet peeve: I work in an area of mathematics where $f^2$ means $f \circ f$, i.e. $f$ composed with itself. Because of this, I find the notation $\tan^2(x)$ somewhat ambiguous. Yes, it is common notation, and no, you aren't going to be misunderstood if you use it. But my choice is to use $\tan(x)^2$, as I think that it is less ambiguous. This explains my choice above. Please make your own choices when writing.

[2] "Antiderivative" is in quotes because, per the definition at the top, an antiderivative is only defined on an interval, and we are about to talk about a function which is not defined on an interval, so the definition we are working with doesn't really apply.

[3] Ditto.

0

When you apply a substitution u=f(x) for an integral, the function f(x) must be bijective so that the inverse $f^{-1}$ exists. In your case, you should let $u=\tan x$ for $x\in \left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$ so that $\arctan(\tan x)=x.$

For otherwise, if we fix an integer $n$ and let $u=\tan x$ for $x \in\left( n \pi-\frac{\pi}{2}, n \pi+\frac{\pi}{2}\right)$,

then $$\arctan(\tan x)=n \pi+x$$

and $$I=\tan x-\arctan(\tan x)+C= \tan x-(n \pi+x)+C=\tan-x+C’,$$

where $C’=C-n\pi$ absorbs $-n\pi$ despite of the choice of principal values for the function $\arctan x$.

Wish it helps :-)

Lai
  • 20,421