Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, this looks like a bug and your explanation of the problem seems correct. It is not possible to recover from a crash. If you expect a computation to crash, the only way to deal with this is by starting Sage in a separate process. For example, you can call Sage externally in a loop from some script.

Or, internally in Sage, you can use the interface for parallel computations, which starts multiple processes of Sage in the background. This also has the advantage that you can run several integration problems in parallel and can set a timeout. Use it like this:

@parallel(ncpus=1)
def myintegrate(f, v):
    from sage.libs.giac import libgiac
    return libgiac.integrate(f, v).sage()

To run a computation in parallel, and thus in a different process, pass a list of arguments, of possibly several integration problems. The result is an iterator over (inputs, outputs) in arbitrary order. In this example, we only have one problem, so the lists have length one.

sage: integrand=(x+(1+x)^(1/2))^(1/2)/(x^2+1)/(1+x)^(1/2)
sage: results = list(myintegrate([(integrand, x)]))
sage: input, output = results[0]

If the process crashed or an exception was raised, then output is a str with some error message (this is not documented very well), otherwise it contains the result of the computation. So check the type of the output in order to test if the computation was successful:

sage: type(output) == str
True
sage: output
NO DATA