login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for #199 integrate(exp(-x^2)+exp(x)/x,x) revision 1 of 3

1 2 3
Editor: page
Time: 2007/11/29 03:24:26 GMT-8
Note:

changed:
-
For some reason, the following forgets about one summand:

\begin{axiom}
integrate(exp(-x^2)+exp(x)/x,x)
\end{axiom}

From kratt6 Sat Aug 20 15:16:16 -0500 2005
From: kratt6
Date: Sat, 20 Aug 2005 15:16:16 -0500
Subject: 
Message-ID: <20050820151616-0500@page.axiom-developer.org>

The problem is in 'expintegratepoly$INTTR'. There you find the following definition::

  -- returns either
  --   (q in GP, a in F)  st p = q' + a, and a=0 or a has no integral in F
  -- or (q in GP, r in GP) st p = q' + r, and r has no integral elem/UP
      expintegratepoly(p, FRDE) ==
        coef0:F := 0
        notelm := answr := 0$GP
        while p ^= 0 repeat
          ans1 := FRDE(n := degree p, a := leadingCoefficient p)
          answr := answr + monomial(ans1.ans, n)
          if ~ans1.sol? then         -- Risch d.e. has no complete solution
               missing := a - ans1.right
               if zero? n then coef0 := missing
                          else notelm := notelm + monomial(missing, n)
          p   := reductum p
        zero? notelm => [answr, coef0]
      [answr, notelm]

In principle, this function takes a polynomial 'p' and tries to integrate every coefficient. If it finds an answer, it adds it to 'answr', otherwise to 'notelm'. Note however, that the constant term of the 'p' will never get added to 'notelm', even if it was not possible to integrate it. So maybe the last line should read::

      [answr, notelm+monomial(coef0, 0)]

This seems to "work", i.e., the integrals are then returned unevaluated. However, I'd rather have axiom to use the linearity of the integral...
Note that

\begin{axiom}
integrate(exp(-x^2)+sin(x),x)
\end{axiom}

is an example for an integral where 'coef0' does not vanish but 'notelm' does. So the more drastic change::

          if ~ans1.sol? then         -- Risch d.e. has no complete solution
               missing := a - ans1.right
               if zero? n then coef0 := missing
               notelm := notelm + monomial(missing, n)
          p   := reductum p
        zero? notelm => [answr, coef0]
      [answr, notelm]

is not necessary - but does not produce wrong results either.

By the way, here are some other - strange - manifestation of the same bug:

\begin{axiom}
integrate(exp(-x^2)+1/x,x)
integrate(exp(x)/x+1/x,x)
\end{axiom}

Although $1/x$ is certainly elementary, and so is its integral, the bug manifests itself.

Martin

From kratt6 Sat Aug 20 15:17:25 -0500 2005
From: kratt6
Date: Sat, 20 Aug 2005 15:17:25 -0500
Subject: property change
Message-ID: <20050820151725-0500@page.axiom-developer.org>

Status: open => fix proposed 


From page Thu Nov 29 03:24:02 -0800 2007
From: page
Date: Thu, 29 Nov 2007 03:24:02 -0800
Subject: 
Message-ID: <20071129032402-0800@axiom-wiki.newsynthesis.org>

Name: '#199 integratee^(x^2)' => '#199 #199 integrate(exp(-x^2)+exp(x)/x,x)' 


Submitted by : (unknown) at: 2007-11-17T22:06:58-08:00 (16 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

For some reason, the following forgets about one summand:

axiom
integrate(exp(-x^2)+exp(x)/x,x)

\label{eq1}\int^{
\displaystyle
x}{{{{e^\%A}+{\%A \ {e^{\left(-{\%A^2}\right)}}}}\over \%A}\ {d \%A}}(1)
Type: Union(Expression(Integer),...)

The problem is in expintegratepoly$INTTR. There you find the following definition:
  -- returns either
  --   (q in GP, a in F)  st p = q' + a, and a=0 or a has no integral in F
  -- or (q in GP, r in GP) st p = q' + r, and r has no integral elem/UP
      expintegratepoly(p, FRDE) ==
        coef0:F := 0
        notelm := answr := 0$GP
        while p ^= 0 repeat
          ans1 := FRDE(n := degree p, a := leadingCoefficient p)
          answr := answr + monomial(ans1.ans, n)
          if ~ans1.sol? then         -- Risch d.e. has no complete solution
               missing := a - ans1.right
               if zero? n then coef0 := missing
                          else notelm := notelm + monomial(missing, n)
          p   := reductum p
        zero? notelm => [answr, coef0]
      [answr, notelm]

In principle, this function takes a polynomial p and tries to integrate every coefficient. If it finds an answer, it adds it to answr, otherwise to notelm. Note however, that the constant term of the p will never get added to notelm, even if it was not possible to integrate it. So maybe the last line should read:

      [answr, notelm+monomial(coef0, 0)]

This seems to "work", i.e., the integrals are then returned unevaluated. However, I'd rather have axiom to use the linearity of the integral... Note that

axiom
integrate(exp(-x^2)+sin(x),x)

\label{eq2}{{{\erf \left({x}\right)}\ {\sqrt{\pi}}}-{2 \ {\cos \left({x}\right)}}}\over 2(2)
Type: Union(Expression(Integer),...)

is an example for an integral where coef0 does not vanish but notelm does. So the more drastic change:

          if ~ans1.sol? then         -- Risch d.e. has no complete solution
               missing := a - ans1.right
               if zero? n then coef0 := missing
               notelm := notelm + monomial(missing, n)
          p   := reductum p
        zero? notelm => [answr, coef0]
      [answr, notelm]

is not necessary - but does not produce wrong results either.

By the way, here are some other - strange - manifestation of the same bug:

axiom
integrate(exp(-x^2)+1/x,x)

\label{eq3}\int^{
\displaystyle
x}{{{{\%A \ {e^{\left(-{\%A^2}\right)}}}+ 1}\over \%A}\ {d \%A}}(3)
Type: Union(Expression(Integer),...)
axiom
integrate(exp(x)/x+1/x,x)

\label{eq4}\int^{
\displaystyle
x}{{{{e^\%A}+ 1}\over \%A}\ {d \%A}}(4)
Type: Union(Expression(Integer),...)

Although 1/x is certainly elementary, and so is its integral, the bug manifests itself.

Martin

property change --kratt6, Sat, 20 Aug 2005 15:17:25 -0500 reply
Status: open => fix proposed

Name: #199 integratee^(x^2) => #199 #199 integrate(exp(-x^2)+exp(x)/x,x)