On Sun, Jul 7, 2013 at 12:11 PM, Ondřej Čertík <[email protected]>wrote:
> On Sat, Jul 6, 2013 at 12:41 PM, Aaron Meurer <[email protected]> wrote: > > Garbage in garbage out, though, in this case. The integral does not > exist, > > and can't even be thought of as an extended real number like oo. > > > > You can think of sin(oo) and cos(oo) as representing some kind of set of > > limit points on [-1, 1]. In that case, you can see that the limit points > of > > Integral(sin(x), (x, 0, a)) wrt a are also [-1, 1], because 1 - cos(oo) > > gives that set. Probably this formalism will break down at some point, > > because it's not actually what sin(oo) is trying to represent, but it's > > interesting to note that it works in at least this case. > > > I think we should return "integral does not converge", using some kind > of API (e.g. I don't know if we should return just None, > or something else). That's what Wolfram Alpha does: > > > http://www.wolframalpha.com/input/?i=integrate%28sin%28x%29%2C+%28x%2C+0%2C+oo%29%29 > > Ondrej > I agree. We should think about how to represent this. Right now, for the integrals handled by the Meijer G algorithm, it indicates that an integral does not converge for certain values by splitting it into a Piecewise with an unevaluated Integral in the otherwise: In [1]: a = Symbol('a', real=True) In [2]: integrate(exp(-a*x), (x, 0, oo)) Out[2]: ⎧ 1 π ⎪ ─ for │periodic_argument(a, ∞)│ < ─ ⎪ a 2 ⎪ ⎪∞ ⎨⌠ ⎪⎮ -a⋅x ⎪⎮ ℯ dx otherwise ⎪⌡ ⎪0 ⎩ Note that the otherwise doesn't strictly mean that it doesn't converge, just that it isn't known to converge. So another question altogether is how to actually algorithmically determine that an integral doesn't converge. One similar example is the risch_integrate nonelementary integrals. If risch_integrate determines that an integral is nonelementary, it returns a subclass of Integral called NonElementaryIntegral. It looks and prints exactly the same as Integral. In [4]: integrate(exp(-x**2), x, risch=True) Out[4]: ⌠ ⎮ 2 ⎮ -x ⎮ ℯ dx ⌡ In [5]: type(integrate(exp(-x**2), x, risch=True)) Out[5]: sympy.integrals.risch.NonElementaryIntegral This way is nice because it doesn't force the Integral object to know about all the possibilities of its subalgorithms. We could do something like this for nonconvergent integrals too, possibly extending the printer somehow so that people will actually notice it. Aaron Meurer > > -- > You received this message because you are subscribed to the Google Groups > "sympy" 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. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "sympy" 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. For more options, visit https://groups.google.com/groups/opt_out.
