Ask Your Question

rbw's profile - activity

2019-03-12 17:31:49 -0500 received badge  Supporter (source)
2019-03-12 17:30:13 -0500 commented answer How can I detect failure of analytical integration?

Ouch, this is so much better it hurts...

Many thanks!

2019-03-09 15:04:34 -0500 received badge  Nice Question (source)
2019-03-08 14:51:48 -0500 received badge  Student (source)
2019-03-08 14:51:05 -0500 asked a question How can I detect failure of analytical integration?

I want to check whether an analytical integration worked, and to try numerical integration in case it failed. I'd like to know when this happened. I'm very inexperienced with sagemath, but I know my way around python.

I did this:

g(x) = integrate(f(x), x)
w0 = SR.wild(0)
w1 = SR.wild(1)
s=integrate(w0,w1,hold=True)
if(len(g.find(s)) : print('failed')
else: print('worked')

This worked for my one test case, but I'd like to know if this is correct and somewhat general, and also, it looked a bit convoluted to me. There probably is a better solution that I could not find.

Apologies if the above is too gross to contemplate!