# \[?\] Avoid getting easy integral wrong?

**URL:** <https://community.wolfram.com/t/avoid-getting-easy-integral-wrong/11730>\
**Category:** Questions\
**Tags:** calculus, numerical-computation\
**Created:** [December 30, 2017, 4:00pm UTC](https://community.wolfram.com/t/avoid-getting-easy-integral-wrong/11730 "2017-12-30T16:00:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![schandler](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/schandler/32/38011_2.png) [@schandler](https://community.wolfram.com/u/schandler)\
**Post date:** [December 30, 2017, 4:00pm UTC](https://community.wolfram.com/t/avoid-getting-easy-integral-wrong/11730/1 "2017-12-30T16:00:58Z")

</div>

Seems impossible and so either we have user error (most likely) or Mathematica has an integration bug. Here’s the integral:

```
 Integrate[(1 - Exp[(-k)*x^a])/(1 - Exp[-k]), {x, 0, 1}, Assumptions -> {k > 0, a > 0}]

```

And here’s the answer I get.

```
 (E^k*(a*k^a^(-1) - Gamma[a^(-1)] + Gamma[a^(-1), k]))/(a*(-1 + E^k)*k^a^(-1))

```

Let’s evaluate this expression at a=0.1 and k=0.1 We get zero! But this can’t be. If we plot the function, we see that it is non-negative on the interval from 0 to 1 and assumes positive values in lots of places. And if I do numerical integration on the original expression, I get 0.912835, which looks about right.

What’s going on? Is there a fix? Am I missing something?

By the way, there are other integrals similar to this, which also yield results that do not seem possible. Here’s the integral on which I discovered what sure looks like a problem. I believe this integral should never be greater than 1/2. And, yet, when I evaluate it for various values of k and a I get values well over 1/2.

```
Integrate[(1 - Exp[(-k)*x^a])/(1 - Exp[-k]) - x, {x, 0, 1}, Assumptions -> {k > 0, a > 0}]

```

---

<div class="post-metadata">

**Author:** ![iliang](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/iliang/32/11263_2.png) [@iliang](https://community.wolfram.com/u/iliang)\
**Post date:** [December 30, 2017, 4:48pm UTC](https://community.wolfram.com/t/avoid-getting-easy-integral-wrong/11730/2 "2017-12-30T16:48:21Z")

</div>

It’s floating point cancellation, we can use arbitrary precision or exact values:

```
In[7]:= (E^k k^(-1/a) (a k^(1/a) - Gamma[1/a] + Gamma[1/a, k]))/(
 a (-1 + E^k)) /. {a -> 1/10, k -> 1/10}

Out[7]= (100000000000 (-(36287999999999999/100000000000) + 
   401044422751291/(1000000000 E^(1/10))) E^(1/10))/(-1 + E^(1/10))

In[8]:= N[%, 20]

Out[8]= 0.91283470967626027646

In[9]:= N[%7]

Out[9]= 0.

```
