# Finding $\int \sec^2 x \tan x \, dx$, I get $\frac12\sec^2x+C$, but an online calculator gets $\frac12\tan^2x+C$.

I tried to find a generic antiderivative for

$$\displaystyle \int \sec^2x \tan x \mathop{dx}$$

but I think there is something wrong with my solution because it doesn't match what I got through an online calculator.

What am I doing wrong?

Below is my solution.

We will use substitution:

$$u = \sec x \qquad du = \sec x \tan x \, dx$$

We substitute and apply the power rule:

$$\int (\sec x) (\sec x \tan x \, dx) = \int u \, du = \frac{1}{2} u^2 + C = \frac{\sec^2x}{2} + C$$

The solution I found with the online calculator is:

$$\frac{\tan ^2 x}{2} + C$$

The steps in the online solution make sense also, so I'm not sure what's going on.

The one thing I have some doubts about is whether I derived the $$du$$ from $$u = \sec x$$ correctly. But it seems okay to me. I used implicit differentiation with $$x$$.

• $\sec^2{(x)}=1+\tan^2{(x)}=\tan^2{(x)}+C$ hence these functions differ by a constant... – Peter Foreman Jul 23 at 18:23
• What happens if you try $u=\tan \theta?$ – Chris Leary Jul 23 at 18:25

$$\frac{\sec^{2}(x)}{2} + C = \frac{1+\tan^{2}(x)}{2} + C = \frac{1}{2} + \frac{\tan^{2}(x)}{2} + C$$

$$\frac{1}{2}$$ is just another constant, in indefinite integral constant doesn't really matter unless you're asked for the integrand original function so you can just kind of "combine" $$\frac{1}{2}$$ into C, you can also differentiate the answer to know that there's nothing wrong at all with your answer

The difference between your answer and the answer given is that they differ by a constant value.

You can see this by using the identity

$$1+\tan^2(x) = \sec^2(x)$$

Hence your answer can be converted to the given answer by subtracting $$-1/2$$, which is a constant.

As mentioned in the comments and in another answer you can also directly get the form in the answer by using the substitution

$$u = \tan x$$

• I modified your answer a bit to use MathJax. Going forward, please use MathJax for mathematical typesetting for ease of readability. Good answer though! – Cameron Williams Jul 23 at 18:29
• Thanks for editing the expressions – StackUpPhysics Jul 23 at 18:29

Try differentiating both of them and see that nothing has gone wrong at all.

Let $$u = \tan x$$.

Then $$du = \sec^{2} x dx$$.

Hence, the integral becomes

$$\int u du = \frac{u^{2}}{2} + C = \frac{\tan^{2}x}{2} + C.$$