Skip to content

Unnecessary Maxima interactions in integration #3732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
williamstein opened this issue Jul 28, 2008 · 10 comments
Open

Unnecessary Maxima interactions in integration #3732

williamstein opened this issue Jul 28, 2008 · 10 comments

Comments

@williamstein
Copy link
Contributor

Here are a variety of integrals for which Maxima should not have to interact to ask about assumptions, but does.

Component: calculus

Issue created by migration from https://trac.sagemath.org/ticket/3732

@williamstein
Copy link
Contributor Author

Attachment: testintfailscases.py.gz

@sagetrac-aginiewicz
Copy link
Mannequin

sagetrac-aginiewicz mannequin commented Sep 1, 2008

comment:1

There's another example (that's with 3.1.2.alpha2), here it shouldn't need assumption on a:

sage: var('a')
a
sage: integrate((x-a)^2*exp(-(x-a)^2), x, -Infinity, +Infinity)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/giniu/<ipython console> in <module>()

/opt/sage/local/lib/python2.5/site-packages/sage/calculus/functional.py in integral(f, *args, **kwds)
    252     """
    253     try:
--> 254         return f.integral(*args, **kwds)
    255     except ValueError, err:
    256         raise err

/opt/sage/local/lib/python2.5/site-packages/sage/calculus/calculus.py in integral(self, v, a, b)
   2532                     raise ValueError, "Integral is divergent."
   2533                 else:
-> 2534                     raise TypeError, error
   2535                     
   2536 

TypeError: Computation failed since Maxima requested additional constraints (use assume):
Is  a  positive or negative?

@sagetrac-gnprice
Copy link
Mannequin

sagetrac-gnprice mannequin commented Oct 24, 2008

another failing integral

@sagetrac-gnprice
Copy link
Mannequin

sagetrac-gnprice mannequin commented Oct 24, 2008

comment:2

Attachment: gaussian-integral-testcase.py.gz

I added a testcase for another integral, namely integral( s^2 * exp(- (a + b) * s^2 ), s), that fails to integrate. This is reproduced on Sage 3.1.1.

@kcrisman
Copy link
Member

comment:3

Added clearer summary. The second attachment is not relevant to this ticket, though certainly we should be able to integrate arbitrary functions!

What is the purpose of this ticket long-term? These could be added, complete with their error messages, to calculus.py examples - but we already have several of those. Or one could say this is just a reminder of what we would eventually like Sage to be able to use Maxima to do, and put them in but not test them.

Otherwise this is in some sense related to solving #780 (among several others), which is a thornier problem.

@kcrisman kcrisman changed the title calculus -- some examples of sage integration failing Additional examples of maxima interactions in calculus leading to errors Jan 29, 2009
@kcrisman
Copy link
Member

comment:4

With the latest Maxima upgrade and Pynac conversion, the last two integrals are correct - the penultimate one is, of course,

1/2*sqrt(pi)

and the last one is

1/2*(a+b)^(3/2)*s^3*gamma_incomplete(-3/2,(a+b)/s^2)/(s^2)^(3/2)

@kcrisman

This comment has been minimized.

@kcrisman
Copy link
Member

kcrisman commented Oct 2, 2009

comment:5

Here is the current state of this ticket. Of the examples in the first attached file, the following are legitimate bugs of this type.

The first example has unnecessary questions.

sage: integrate(1/sqrt(x-q), x, 1, 2)
2 sqrt(2 - q) - 2 sqrt(1 - q) # should be this always

The third example is definitely a case for this, as of Maxima 5.19.1:

(%i19) integrate(log(q-x), x, a, b);
Is  b - a  positive, negative, or zero?

positive;
(%o19)          (b - q) log(q - b) - (a - q) log(q - a) - b + a
(%i20) integrate(log(q-x), x, a, b);
Is  b - a  positive, negative, or zero?

negative;
(%o20)          (b - q) log(q - b) - (a - q) log(q - a) - b + a
(%i21) integrate(log(q-x), x, a, b);
Is  b - a  positive, negative, or zero?

zero;
(%o21)          (b - q) log(q - b) - (a - q) log(q - a) - b + a

The fifth example has MANY questions to ask, always the same answer:

(%i36) integrate(1/sqrt(q^2-x^2),x, a, b);
Is  b - a  positive, negative, or zero?

negative;
Is  q - a  positive, negative, or zero?

zero;
Is  q + a  positive, negative, or zero?

zero;
Is  q + b  positive, negative, or zero?

positive;
                                 b              a
(%o36)                    asin(------) - asin(------)
                               abs(q)         abs(q)

++++++++++++++++++++++++++++++++

The following should not be considered bugs, at least not for the reason given.

The second example is okay:

sage: integrate(1/(x-q),x,1,2)

Maxima adds pi*I and/or switches q-2 to 2-q as appropriate. If we don't like those differences, that should be on a different ticket.

The fourth example is:

sage: integrate(1/(q-x^2), x)

The answers given are a constant away from each other, but look very different. This probably should be considered a bug (Maxima can't connect between logs and arctan/h stuff), but is likely to not be resolved soon, or by questions.

The last example is definitely not a bug, as for q=-1 you should get a different answer!

@kcrisman kcrisman changed the title Additional examples of maxima interactions in calculus leading to errors Unnecessary Maxima interactions in integration Oct 2, 2009
@kcrisman
Copy link
Member

comment:6

Update: these (the three remaining ones above) are still in Maxima 5.20.1.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@DaveWitteMorris
Copy link
Member

comment:11

Here is a particularly easy one (that sympy and giac can do, of course):

sage: var("a");
sage: integrate(cos(x), x, 0, a)
    <snip>
ValueError: ...
Is a positive, negative or zero?

sage: integrate(cos(x), x, 0, a, algorithm="sympy")
sin(a)

sage: integrate(cos(x), x, 0, a, algorithm="giac")
sin(a)

@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants