Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
1- If the integral call breaks (and this often occurs), the old_assumptions are not restored .. 
ok, this one should be easy and dealt with some exception handling but I don't know the Sage     
coding guideline here.

Yes, this is because you didn't include a try/except clause in your code. Luckily, this is pretty easy to do; you could put it around

assume(extra_assumptions)
result = integral(f, var, lbound, ubound)
forget()
assume(old_assumptions)

and that would work pretty well.

The second issue is also present in Maxima.

(%i1) assume(x>0);
(%o1)                               [x > 0]
(%i2) assume(x>1);
(%o2)                               [x > 1]
(%i5) facts();
(%o5)                           [x > 0, x > 1]
(%i6) is(x>1);
(%o6)                                true
(%i7) is(x>0);
(%o7)                                true

Maxima's deduction mechanism is not very strong; there are many obvious consequences which cannot be determined by is.

As for the rest, such local assumptions are called contexts, I believe. Maxima does support this, but we haven't integrated it in Sage yet. There is a ticket for this, however, though it has languished.


By the way, if you are almost always using only functionality from Maxima, it wouldn't be the worst idea to see if just using Maxima is better for you, or using the .maxima_methods() method. You would get the fine-grained control over all sorts of things that Maxima excels in. Sage is great, but for some people doing group theory, it has more overhead than they need, and they would just use GAP; maybe this is the case for your specific use case.