Message Boards Message Boards


Wrong answer in integration

Posted 9 years ago
3 Replies
0 Total Likes

When I try to integrate tan^5x in wolfram alpha I get

(1/4) [ secx^4 - 4 secx^2 - 4 ln(cosx) ]

but when I work it out by hand I get

(1/4) tanx^4 - (1/2) tanx^2 - ln|cosx|

I have graphed the two and they are different.

I cannot make sense of this. Other CAS tools give me my answer by hand.

POSTED BY: Dale Callahan
3 Replies

Both are in a sense correct on the real line. The Abs function is not differentiable in the complex plane so the result that uses Abs cannot be an antiderivative in C. The W|A result, on differentiation, gives back the integrand, so it is a correct antiderivative in the complex plane for that integrand.

POSTED BY: Daniel Lichtblau

Well, the result is correct. It all comes down to $\int \tan(x)dx$ which by the substitution $u=\cos(x)$ becomes $-\int \frac{1}{u}du$. When we do this by hand, the answer is $-\log(|u|)+c$ where $c$ is constant of integration. But CAS gives $-\log(u)$ as the general result. i.e. it does not use the absolute value and constant of integration is never given but assumed in the antiderivative, since the derivative of constant is zero.

So Mathematica result is correct, CAS speaking. If you add Abs[] and plot -Log[Abs@Cos[x]] - Sec[x]^2 + Sec[x]^4/4 you'll see it is the same. There is $\frac{1}{4}$ constant offset, which was thrown away from the antiderivative that was returned. Hence, to get the same result as your hand calculation, use 1/4 - Log[Abs[Cos[x]]] - Sec[x]^2 + Sec[x]^4/4 which is also correct, but so is -Log[Abs@Cos[x]] - Sec[x]^2 + Sec[x]^4/4 and also -Log[Cos[x]] - Sec[x]^2 + Sec[x]^4/4 (without the Abs). But if you do not use Abs you'd have to worry about complex values when $\cos(x)$ becomes negative since it is now it is an argument to the $\ln(\cos(x))$

Should CAS return $\ln(|u|)$ as result for $\int \frac{1}{u} du$? Since CAS always returns general results, this is how all CAS systems work that I know about.

POSTED BY: Nasser M. Abbasi

I guess that is a problem of how the systems handle complex numbers.

Let's calculate the difference between your result and Mathematica's for some points:

Table[(-Log[Cos[x]] - Sec[x]^2 + Sec[x]^4/4) - (-Log[Abs[Cos[x]]] - Tan[x]^2/2 + Tan[x]^4/4), {x, 0, 8, 0.2}]

This gives:

{-0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75 - 
  3.14159 I, -0.75 - 3.14159 I, -0.75 - 3.14159 I, -0.75 - 
  3.14159 I, -0.75 - 3.14159 I, -0.75 - 3.14159 I, -0.75 - 
  3.14159 I, -0.75 - 3.14159 I, -0.75 - 3.14159 I, -0.75 - 
  3.14159 I, -0.75 - 3.14159 I, -0.75 - 3.14159 I, -0.75 - 
  3.14159 I, -0.75 - 3.14159 I, -0.75 - 3.14159 I, -0.75 - 
  3.14159 I, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, \
-0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75 - 
  3.14159 I}

That means that the real part differs by a constant (-0.75) only, which is ok. The difference in the complex part comes from the fact that Mathematica's solution has a $-Log[Cos[x]]$ whereas your solution has a $-Log[|Cos[x]|]$, i.e. you have absolute values, where Mathematica has none. When $Cos[x]$ is negative Mathematica needs the complex $Log$.

If you actually integrate the tan, you run into trouble because the function has poles. The integral does not converge in general. You can see that when you try to integrate

Integrate[Tan[x], {x, 0, 2 Pi}]

which does not converge. You can use the Principal Value though:

Integrate[Tan[x], {x, 0, 2 Pi}, PrincipalValue -> True]


Mathematica correctly interprets the integration as integration over the complex numbers and gets complex results.

For details see for example:



POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract