## #2693 integrate(x^n * exp(-x^2/2)/sqrt(2*%pi), x, minf, inf ) Gives Wrong Answer

None
closed
nobody
None
5
2014-05-11
2014-03-04
Sean Lake
No

First system info:
Maxima 5.32.1 http://maxima.sourceforge.net
using Lisp SBCL 1.1.14
on Mac OS X 10.8.5

The input with incorrect output is:

```(%i1) integrate( x^n * exp(-x^2/2)/sqrt(2*%pi), x, minf, inf );
Is n + 1 positive, negative or zero?

pos;
Is n an integer?

yes;
(%o1)                                  0
```

The correct output can be obtained by answering "no" to whether n is an integer:

```(%i3) integrate( x^n * exp(-x^2/2)/sqrt(2*%pi), x, minf, inf );
Is n + 1 positive, negative or zero?

pos;
Is n an integer?

no;
Is n positive, negative or zero?

pos;
n/2 - 1/2      n       n + 1          n   1   n/2 - 1/2
2          (- 1)  gamma(-----) + gamma(- + -) 2
2            2   2
(%o3)      --------------------------------------------------------
sqrt(2) sqrt(%pi)
(%i4) %, factor;
n/2 - 1       n            n + 1
2        ((- 1)  + 1) gamma(-----)
2
(%o4)                 ----------------------------------
sqrt(%pi)
```

## Discussion

• Dan Gildea - 2014-03-05

Problem seems to be that clearsign is called during
and assume database forgets that n+1>0

Works OK if you assume(n+1>0) before doing the integral,
or even if you just do the same integral twice in a row.

• Rupert Swarbrick - 2014-05-11

It looks like this was fixed by the patch I just pushed to fix [#2726]:

```Maxima branch_5_33_base_36_g202e3e9_dirty http://maxima.sourceforge.net
using Lisp SBCL 1.1.15.debian
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) integrate( x^n * exp(-x^2/2)/sqrt(2*%pi), x, minf, inf );
Is n + 1 positive, negative or zero?

pos;
Is n an integer?

y;
n   1      n/2 - 1/2      n
(%o1) (gamma_incomplete(- + -, 0) 2          (- 1)
2   2
n   1      n/2 - 1/2
+ gamma_incomplete(- + -, 0) 2         )/(sqrt(2) sqrt(%pi))
2   2
(%i2) %, factor;
n/2 - 1       n                       n + 1
2        ((- 1)  + 1) gamma_incomplete(-----, 0)
2
(%o2)          ------------------------------------------------
sqrt(%pi)
```

The `gamma_incomplete((n+1)/2, 0)` is a bit ugly, but otherwise it looks good.

#### Related

• Rupert Swarbrick - 2014-05-11
• status: open --> closed

No, thanks