Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

result that comes with warning from giac integrator

Using Giac/Xcas 1.7 on Linux. (via sagemath 9.3)

giac sometimes results an actual antiderivative from a call to int but because it issues warnings, sagemath is not able to parse what giac returned back, it throws an exception.

Is it possible to handle such cases, so that one can get the anti derivative returned, but have the warning message be separated and may be just printed on the screen in addition, as separate output? Here are two examples.

Example 1

   var('x')
   anti=integrate(1/(2*x^(1/2)+(1+x)^(1/2))^2,x, algorithm="giac")
/usr/lib/python3.9/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1134 
   1135             except Exception:
-> 1136                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1137         else:
   1138             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, ....

And because an exception is thrown, this is counted as failed.

Example 2

 var('a x')
 integrate(sec(2*a*x),x, algorithm="giac")

usr/lib/python3.9/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1134 
   1135             except Exception:
-> 1136                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1137         else:
   1138             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Unable to check sign:...

Here are the examples done inside giac directly

0>> integrate(sec(2*a*x),x)
Unable to check sign: (pi/x/2)>(-pi/x/2)
Unable to check sign: (pi/x/2)>(-pi/x/2)
2/(2*a)*(-1/8*ln(abs(sin(2*a*x)+1/sin(2*a*x)-2))+1/8*ln(abs(sin(2*a*x)+1/sin(2*a*x)+2)))
// Time 0.02

And

2>> integrate(1/(2*x^(1/2)+(1+x)^(1/2))^2,x)
Warning, choosing root of [1,0,%%%{-4,[1]%%%}+%%%{-2,[0]%%%},0,1] at parameters values [-27]
Warning, choosing root of [1,0,%%%{-4,[1]%%%}+%%%{-2,[0]%%%},0,1] at parameters values [26]
2*((-5*x-1)/6/(3*x-1)+5/18*ln(abs(3*x-1))+2*(2/9*ln(sqrt(x+1)-sqrt(x))+5/36*ln(abs((sqrt(x+1)-sqrt(x))^2-3))-5/36*ln(abs(3*(sqrt(x+1)-sqrt(x))^2-1))-(10*(sqrt(x+1)-sqrt(x))^2-6)/9/(3*(sqrt(x+1)-sqrt(x))^4-10*(sqrt(x+1)-sqrt(x))^2+3)))
// Time 0.06
3>>

The above output from giac shows it does gives a result for the integrate command, but it follows some warning messages. Even if the result might not be correct, it is still a result. But now it is not possible to capture this returned result, since sagemath throws an exception and this is taken right away as failed call.

May be if these warning lines could be filtered out or handled somehow differently, this will allow one to see giac result?

There are many such examples.