Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1938 maxima can not integrate x*exp(-1/2*(x-m)^2)

closed
nobody
5
2010-07-09
2010-03-26
Anonymous
No

Maxima can not integrate the function x*exp(-1/2*(x-m)^2)

Maxima 5.20.1 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) integrate(x*exp(-1/2*(x-m)^2),x);
2
(x - m)
/ - --------
[ 2
(%o1) I x %e dx
]
/

The correct solution would be

(%i2) diff(-exp(-1/2*x^2+m*x-1/2*m^2)+1/2*m*sqrt(%pi)*sqrt(2)*erf(1/2*sqrt(2)*x-1/2*m*sqrt(2)),x);
2 2
x m 2 x m
- (------- - -------) - -- + m x - --
sqrt(2) sqrt(2) 2 2
(%o2) m %e - (m - x) %e

Discussion

  • (%i1) S:'integrate(x*exp(-1/2*(x-m)^2),x);
    (%o1) integrate(x*%e^(-(x-m)^2/2),x)
    (%i2) changevar(S, y=x-m, y, x);
    (%o2) integrate((y+m)*%e^(-y^2/2),y)
    (%i3) ev(%, nouns);
    (%o3) (sqrt(%pi)*m*erf(y/sqrt(2)))/sqrt(2)-%e^(-y^2/2)
    Solution:
    (%i4) sol:subst(y=x-m,%),rootscontract;
    (%o4) sqrt(%pi/2)*m*erf((x-m)/sqrt(2))-%e^(-(x-m)^2/2)
    Test:
    (%i5) diff(sol,x)-first(S)$
    (%i6) expand(%);
    (%o6) 0

     
  • uhlst
    uhlst
    2010-03-27

    Thank you for showing this "trick" with changevar.

    Is there a way that Maxima automatically does the correct substitution without giving it a hint with changevar? If e.g. the "-1/2" in the exponent is removed, then Maxima has no problem to do the integration. Does Maxima not try itself some substitutions if integrate is called?

     
  • Robert Dodier
    Robert Dodier
    2010-06-05

    Wow, that's pretty surprising. Maxima can solve integrate(exp(-(1/2)*(x - m)^2), x) so why not this one?

     
  • Robert Dodier
    Robert Dodier
    2010-06-05

    • labels: --> Lisp Core - Integration
     
  • Dieter Kaiser
    Dieter Kaiser
    2010-07-09

    Fixed in sin.lisp revision 1.67.

    Maxima can now calculate the integral of this bug report. 'The result is not as nice as the expected result, but can be shown to be equivalent up to a constant:

    (%i48) multthru(integrate(x*exp(-1/2*(x-m)^2),x)),gamma_expand:true,erf_representation:erf;
    (%o48) sqrt(%pi)*m*(m-x)*(1-erf(abs(x-m)/sqrt(2)))/(sqrt(2)*abs(x-m))
    -(m-x)^2*%e^-((m-x)^2/2)/(x-m)^2

    Closing this bug report as fixed.

    Dieter Kaiser

     
  • Dieter Kaiser
    Dieter Kaiser
    2010-07-09

    • status: open --> closed