# Bug in integration of sqrt functions?

I have been experiencing a problem integrating a function with several terms. I have managed to narrow it down to a problem with integration.

When I type the following command I get 1 as I should

```
integrate(cos(x),x,0,pi/2)
```

However, when I write the same integral in the form

```
integrate((sqrt(1-sin(x)*sin(x))),x,0,pi/2)
```

I get an error "RuntimeError: ECL says: Error executing code in Maxima: atanh: argument 1 isn't in the domain of atanh."

I guess it is a result of the fact that

```
integrate((sqrt(1-sin(x)*sin(x))),x,0,pi/2)
```

gives $\tan(x)/\sqrt{(\tan(x)^2 + 1)}$ and sage is trying to substitute $x=\pi/2$ without trying to simplify the expression first or taking the limit of x to $\pi/2$. Is there a way to avoid this problem when the function I wrote is a part of a bigger function and I can't simplify by hand.

Both integrals are identical and I don't understand why I am getting an error in one case. Is this a bug or am I doing something wrong?

This has been reported upstream - http://www.math.utexas.edu/pipermail/maxima/2013/034222.html - thanks, Dima!