I am currently taking a Calculus II course and working through some practice questions in the textbook by Adams. I could not figure out the following question and have a contradictory answer to what Wolfram|Alpha says, yet I do not know where I am going wrong.

Determine whether $\int\limits_{0}^{\frac{\pi}{2}} \tan(x) dx$ converges or diverges. If it does not diverge, give the value it converges to.

The following is my attempt to solve this problem, I am clearly wrong since Wolfram|Alpha disagrees with me, so a sufficient answer would just be to point out where my mistake was/what misconception I have about evaluating improper integrals.

At $x=\frac{\pi}{2}$ there is a vertical asymptote since $\tan(\frac{\pi}{2})$ is undefined. Thus, this integral is vertically improper at $x=\frac{\pi}{2}$. We then convert the improper integral to a limit of a proper integral as follows,

$$\int\limits_{0}^{\frac{\pi}{2}} \tan(x) dx = \lim\limits_{c \rightarrow (\frac{\pi}{2})^-} \int\limits_{0}^{c} \tan(x) dx = \lim\limits_{c \rightarrow (\frac{\pi}{2})^-} -\ln(\cos(x))|_{0}^{c}$$

We can then evaluate the resulting limit as follows,

$$\lim\limits_{c \rightarrow (\frac{\pi}{2})^-} -\ln(\cos(x))|_{0}^{c} = \lim\limits_{c \rightarrow (\frac{\pi}{2})^-} (-\ln(\cos(c)) + \ln(\cos(0)))$$ Since $\ln(\cos(0))=0$ we have then reduced the problem to,

$$\lim\limits_{c \rightarrow (\frac{\pi}{2})^-} -\ln(\cos(c)) = \infty$$ Therefore, the integral diverges to infinity.

Yet, Wolfram|Alpha states that the integral converges to a finite value, namely, around $38$, so I'm at a loss of what is going on.

If anyone would be able to clear this up for me that would be helpful.

  • 1
    $\begingroup$ If you add $\large\tt\mbox{PricipalValue->True}$ to the Wolfram-Alpha input, it yields $\large\infty$. $\endgroup$ Commented Jul 18, 2014 at 8:04
  • 1
    $\begingroup$ Now Wolfram Alpha says it does not converge. $\endgroup$
    – Anixx
    Commented May 17, 2017 at 9:52

2 Answers 2


Your working is perfectly correct, the only incorrect logic is the following:

I am clearly wrong since Wolfram|Alpha disagrees with me

To compute the integral Wolfram|Alpha has used a numerical method to estimate the value and the method it is using is not sophisticated enough to handle this integral near the asymptote.

This is not uncommon. I can't remember specific instances off the top of my head, but several times I've been able to work out simpler expressions than the forms returned in WA. Humans are still usually better mathematicians than computers (13/02/12) .

  • $\begingroup$ Oh, I thought Wolfram|Alpha would be correct about any sort of well-formed question such as "evaluate this integral". So, let me just clarify... it is divergent? Is there any way for me to check my answer for questions like these then if I can't ask Wolfram|Alpha? $\endgroup$ Commented Feb 13, 2012 at 4:45
  • 2
    $\begingroup$ Well, one has to use one's sense to determine whether a computer would definitely be correct in a particular evaluation. I know Wolfram|Alpha will return the value I want if I tell it to multiply 10 digit integers, but around divergent integrals things can get a bit messy. If you the computer does not agree with you and it is of the second case, you can ask us right here. $\endgroup$ Commented Feb 13, 2012 at 4:51

Remember that computers are stupid. They only calculate, they don't think. Your work is correct.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .