in Maxima, let y: x*signum(x^2-4);
integrate(y,x,0,3) returns -9/2 integrate(y,x,0,2) + integrate(y,x,2,3) returns 1/2 if you want to see the large amount of work that goes into this, do trace(sign) in Maxima. Is there a bug in this, someone can look for a hint. In general, the algorithms in Maxima for symbolically computing integrals are aimed at analytic functions that have integrals in terms of elementary functions. They may also work on discontinuous functions, but this is not what the writers of the programs set out to do. The task, to integrate "anything you might type in" is not complicated or intractable, It is not computable. Any solution you offer is at best a partial solution. There are other techniques including numerical quadrature, that can be tried. There are 6 routines that can be called as quad_qag() quad_qag(y,x,0,3,k) where k is 1,2, ...6. They all return 0.5 or so (to 12 digits at least). So where does that leave us? My guess is that the integration package could say -- hey, you have a numerical function in the place of an integrand. Nothing symbolic about it. Why don't you use quad_qag? Whether this should be done by Sage or Maxima --- perhaps both. It would require a change in Sage to accept the result form from quad_qag and the possibility of an error return. Regarding the comment from Nils -- I was not intending to criticize Dima in particular. It is good that some members of the Sage community are better at reporting bugs and maybe tracking them down. And maybe making ECL a more compatible / loadable/ Lisp for Sage . Understanding the interface to program X (where X might be singular, gap, maxima) so that a Sage program can be used as a front end, does not, in my opinion, constitute a contribution to program X, nor does it mean that the person writing the interface understands the program X in anything but a superficial way. It is not a bad thing to be able to do this, it is just not something that really contributes to the computational capability of program X. There is nothing preventing a random person from the Sage community from looking at the open source for Maxima and (say) contributing to the code that might detect discontinuities and adapt the definite integrate program to do the right thing (more often). It is just that the drumbeat is directed in quite different directions. It is irrelevant whether python is easy to learn or not. It is irrelevant to many of the thousands (100,000s) of Maxima users that there is a python interface from Sage. There are at least 3 non-Sage front ends. At least one of them may also be a front-end to other Sage components, or maybe all of Sage (I'm thinking of texmacs) but I don't know. While I only know Sage from reading about it -- I have not used gap or singular or magma for any serious purpose ever, just to try out. And not recently. But I do suspect that many of the components are incompatible at the edges. For instance, how many of them have a notion of floating-point overflow? How many have extended the Reals to include infinity (or complex with complex infinity)? How about indeterminate like 0/0? I know that Maxima deals with these concepts in an ad hoc way; Or several ways, because there is "inf" as well as "floating-point-double-positive-infinity" And there are some implementations of Maxima that might signal an exception. Does the Sage interface know what to tell the user if that happens? (I don't know, and it's possible you have this all figured out. It seems a little unlikely since just using Maxima already gets you into trouble, I think. But maybe you (and by this I mean "all Sage people") have solved this, Please direct me to the relevant documentation in that case. I am sure that people are well-intentioned in providing access to a variety of programs from a single front end. When the knowledge "inside" the various systems in relatively shallow -- as, perhaps plotting, or even bigfloats, there may be a better chance for success than if you are trying to make sense out of rather deep programs (with possible bugs, and less obvious design objectives).. I would count among these the Maxima "assumption" database, "equation solving", and symbolic (contour) definite integration. These are not new thoughts, I'm not sure where you can go with this. You can call me mean if you like. I have thick skin. RJF On Monday, April 11, 2016 at 10:22:06 AM UTC-7, Sergey V Kozlukov wrote: > > Actually, i was doing crappy thing > Several times I accidentally got correct output, > which made me think, sage handles discontinuity&c in such cases > It doesn't. > > Btw, i'd like to see this info in ```help(integrate)``` > It's, probably, complicated or intractable to determine every such case, > in order to throw exception (because maxima can return wrong answer), > or split integral > But notice in docstring would make it less confusing > > понедельник, 11 апреля 2016 г., 19:41:44 UTC+3 пользователь Sergey V > Kozlukov написал: >> >> > It looks to me like you reported a discrepancy which everyone else >> would startby considering a bug >> Well, at the time of writing, title and post itself seemed to me rather >> neutral. My fault >> >> > Demo is hardly the simplest >> I admit, i should have reported it in more readable form. >> I don't have time to find the MWE right now, but i think it would be >> better, if i at least post there purified version of the code i provided >> before. >> The simplest form i found right now is: >> >> f(x) = sign(x^2 - 4) >> v = (x*f).integrate(x, 0, 3) >> show(v) >> Which yields (wrong) answer $\frac{-9}{2}$, derived by directly applying >> Newton-Leibnitz >> That's what Maxima returns >> >> And then we can apply same technique as before >> (multiply $x^2$ by $cos^2+sin^2$) >> to make SAGE magically return correct answer: >> f(x) = sign(x^2*cos(x)^2 + x^2*sin(x)^2 - 4) >> v = (x*f).integrate(x, 0, 3).simplify_full() >> show(v) >> Evaluates to $\frac{1}{2}$ (correct). >> NB: in this case ```integrate``` returns integral expression, which is >> then simplified into number >> >> понедельник, 11 апреля 2016 г., 17:16:43 UTC+3 пользователь rjf написал: >>> >>> [snipped] >>> >> -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.