Open AhmedCode99 opened 10 months ago
I have used this for preventing division by zero issues, and calculating the exponential only for non-zero elements.
def exp_minus_one_over_x(x): x = np.asarray(x, dtype=float) mask = x != 0 # Avoid division by zero result = np.zeros_like(x, dtype=float)
# Calculate the exponential only where x is not zero
result[mask] = np.exp(-1 / x[mask])
return result
still I have got these results. Simpson's rule result: 3.742912580939198e+214 Trapezoidal rule result: 2.8071844357043985e+214 Adaptive trapezoidal result: inf I am getting infinity for the adaptive trapezoidal result. What to do for removing it?
I answered this question here https://github.com/ubsuny/23-Homework6G1/issues/18