ubsuny / 23-Homework6G5

MIT License
0 stars 8 forks source link

How I dealt with singularities #31

Open AhmedCode99 opened 10 months ago

AhmedCode99 commented 10 months ago

In order to avoid dividing by zero, I used the following:

def f(x):
# Replace zero values in x with a small positive value to avoid division by zero
x_safe = np.where(x == 0, np.finfo(float).eps, x)
return np.exp(-1 / x_safe)

It works perfectly. Feel free to use it.

sharmistharanit commented 10 months ago

See the work that Tirth has done. Hope it helps.

AhmedCode99 commented 10 months ago

@sharmistharanit what do you mean? Are you confused about something?

uarif commented 10 months ago

Did you find the answer?