Reputation: 13
First post, please be gentle!
I am trying to do root finding on an exponential function 1/(np.exp((j-w)/x)-1)
, and I find I keep getting the RuntimeWarning: overflow encountered in exp
.
I understand this comes from the limitations on float64, but I can't seem to insert code to help understand where this is coming from. I have tried to include some try...except OverflowError
blocks to give me a peek inside where this keeps happening, but it never seems to catch this.
I have ideas on how to handle it, as long as I can get my code to do something different when it encounters overflows.
Thanks in advance!
Upvotes: 1
Views: 782
Reputation: 998
I'm guessing the problem is that you cannot figure out when warning happens. To do that use try
/except
but in slightly modified way:
import warnings
warnings.filterwarnings("error")
...
try:
1/(np.exp((j-w)/x)-1)
except RuntimeWarning:
print(j)
print(w)
print(x)
print((j-w)/x)
This should give a hint, there the problem lies
Upvotes: 1