# Evaluate: Integral of sec(x) with Complex Analysis

I'm trying to better understand how Complex Analysis can offer real solutions. I had seen examples of this with trigonometric identities and I wanted to see how it might do with the integral of $$\mathbf{\sec(x)}$$, given how its solution involves more than trigonometric functions. I'd like to know if my reasoning is correct or if there are improvements that I could make to generate a better/ faster solution using this method.

To start, I began with the exponential form of $$\mathbf{\sec(x)}$$ and a u-substitution.

$$\mathbf{\int{\sec(x)dx}=\int\frac{2}{e^{ix}+e^{-ix}}dx}$$

$$\mathbf{= \frac{2}{i}\tan^{-1}(e^{ix}) + z}$$

On the topic of $$\mathbf{\tan^{-1}(x)}$$ I supposed that I could try finding the inverse of the exponential form of $$\mathbf{\tan(x)}$$ to get my answer to be closer to what it looks like in real space. To do this I switched the x and y positions and solved for y.

$$\mathbf{\tan(x)=\frac{1}{i}\frac{e^{ix}-e^{-ix}}{e^{ix}+e^{-ix}}}$$

$$\mathbf{\tan^{-1}(x) = \frac{1}{2i}\ln(\frac{i-x}{i+x})}$$

Plugging this definition back into what I had solved for earlier, I found that

$$\mathbf{\int{\sec(x)dx}= -\ln(\frac{i-e^{ix}}{i+e^{ix}})+z=\ln(\frac{i+e^{ix}}{i-e^{ix}})+z}$$

At this point it felt like I was getting closer, so I multiplied the numerator and the denominator inside the natural logarithm by the complex conjugate of the denominator.

$$\mathbf{\int{\sec(x)dx}=\ln(\frac{-e^{2ix}-2ie^{ix}+1}{e^{2ix}+1})+z}$$

Multiplying the numerator and denominator by

$$\mathbf{e^{-ix}}$$

I get

$$\mathbf{\int{\sec(x)dx}=\ln(\frac{-e^{ix}+e^{-ix}-2i}{e^{ix}+e^{-ix}})+z}$$

This looked familiar to a certain sum of two trigonometric functions, so I returned from exponential form to trigonometric form.

$$\mathbf{\int{\sec(x)dx}=ln(-i*(\tan(x)+\sec(x)))+z}$$

Having -i within a natural logarithm didn't seem right, but the current form seemed too close to fail at this point since I just needed to the multiply inner expression by i to get the answer in real space. I then remembered the property that $$\mathbf{z = a + bi}$$, and that if $$\mathbf{bi = ln(i)}$$ and $$\mathbf{a = C}$$ then I could use the property of natural logarithms to get to where I wanted to be.

I reasoned that if the real solution contains the point $$\mathbf{(n\pi,C)}$$ where n is any positive odd integer then in the complex equation $$\mathbf{z = \ln(i^{n})=\frac{in\pi}{2}}$$

Recapping what I just did $$\mathbf{\int{\sec(x)dx}=\ln(-i(tan(x)+sec(x)))+\ln(i)+C}$$

$$\mathbf{=\ln(\tan(x)+\sec(x))+C}$$

To get to this point I needed to look at the actual answer to try to force the exponential form to "fit" into place. A lot of my time was spent trying to prove the integral solution rather than evaluate it. There had to have been a better way to think about this, if I'm not already wrong at some step.

I'm also not sure why I didn't get $$\mathbf{\ln|\tan(x)+\sec(x)|+C}$$

rather than $$\mathbf{\ln{(\tan(x)+\sec(x))}+C}$$

Obviously you can't have a negative input for a natural logarithmic function but I don't think I can just claim that my answer involves an absolute value can I? Why is this integral dependent on a particular form of z when the integral of say $$\mathbf{\cos(x)}$$ leads directly to $$\mathbf{\sin(x)+c}$$ using the same method?

• $\ln(\tan x+\sec x)+C$ is indeed a correct result in complex plane, while $\ln|\tan x+\sec x|+C$ is only valid if we consider the integrand a real function. – Kemono Chen Jan 5 at 7:35

Another way to look at that issue involving the logarithm? The most general antiderivative of $$\frac1u$$ can be written as $$\ln(Au)$$, where $$A$$ is a nonzero constant.
In $$\mathbb{R}$$, we'll choose $$A$$ positive on intervals where $$u$$ is positve, and $$A$$ negative on intervals where $$A$$ is negative; this is often abbreviated with an absolute value sign. But that absolute value is deceptive; we can't cross between negative and positive values without going over a singularity, which will produce a divergent integral.
In $$\mathbb{C}$$, we'll allow $$A$$ to be any nonzero complex number, and the only restriction is that we can't use the antiderivative to integrate on a path that circles a singularity. Think of it as a spiral staircase; by going around, we end up on a different level (branch) than we started on, and the integral won't be zero as a line integral around a loop normally should be. Because of this, we can't define that antiderivative as a globally continuous function, and instead we must make a "branch cut" somewhere where the values jump. Traditionally, for the logarithm, this cut is placed on the negative real axis.
Why is this integral dependent on a particular form of z when the integral of say $$\cos(x)$$ leads directly to $$\sin(x)+c$$ using the same method?
Differentiation is predictable. We have rules that always work, and produce an algorithm that can differentiate any elementary function. It's so easy, we can tell a computer how to do it. The inverse operation, integration, is unpredictable. We can write down simple expressions that have complicated antiderivatives, and other simple expressions that don't have elementary antiderivatives at all. This sort of messiness is utterly normal; we just got lucky with $$\sin$$.