Status: Valid
Owner: ----
Labels: Type-Defect Priority-High WrongResult Integration

New issue 4031 by [email protected]: Definite integral returns an answer with indefinite integrals
http://code.google.com/p/sympy/issues/detail?id=4031

In [1]: var("i L a b")
Out[1]: (i, L, a, b)

In [2]: integrand =  cos(pi*i*x/L)**2/(a + b*x)

In [3]: integrand = integrand.rewrite(exp)

In [4]: integrate(integrand, (x, 0, L))
Out[4]:
           ⌠
  ⌠        ⎮    4⋅ⅈ⋅π⋅i      2⋅ⅈ⋅π⋅i
  ⎮ 1      ⎮   ℯ        + 2⋅ℯ        + 1
- ⎮ ─ dx + ⎮ ───────────────────────────── dx
  ⎮ a      ⎮        2⋅ⅈ⋅π⋅i        2⋅ⅈ⋅π⋅i
  ⌡        ⎮ 4⋅L⋅b⋅ℯ        + 4⋅a⋅ℯ
           ⌡

The answer is obviously wrong (it should not depend on x).

Also, I don't know if this is related, but integrate seems to be quite inefficient. I put a print statement at the top of integrate() to print the args, and I got

In [4]: integrate(integrand, (x, 0, L))
((exp(I*pi*i*x/L)/2 + exp(-I*pi*i*x/L)/2)**2/(a + b*x), (x, 0, L))
(4/(4*a + 4*b*x) - 1/(2*a + 2*b*x), x)
(1/(2*a + 2*b*x), x)
(1/(4*a + 4*b*x), x)
(1/(4*a + 4*b*x), x)
(0, x)
(1/(4*a + 4*b*x), x)
(1/(4*a + 4*b*x), x)
(1/(4*a + 4*b*x), x)
Out[4]:
           ⌠
  ⌠        ⎮    4⋅ⅈ⋅π⋅i      2⋅ⅈ⋅π⋅i
  ⎮ 1      ⎮   ℯ        + 2⋅ℯ        + 1
- ⎮ ─ dx + ⎮ ───────────────────────────── dx
  ⎮ a      ⎮        2⋅ⅈ⋅π⋅i        2⋅ⅈ⋅π⋅i
  ⌡        ⎮ 4⋅L⋅b⋅ℯ        + 4⋅a⋅ℯ
           ⌡

In other words, it is computing that same integral (1/(4*a + 4*b*x)) six times.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to