I am having trouble implementing a function numerically. It suffers from the fact that at large input values the result is a very large number times a very small number. I am not sure if catastrophic cancellation is the correct term so please correct me if it is. Evidence of something going awry:
How can I avoid the oscillations and the assigment of 0.0 for larger inputs of 6?
Here is my function:
import numpy as np def func(x): t = np.exp(-np.pi*x) return 1/t*(1-np.sqrt(1-t**2))