x + log(1+exp(-y+x)) = -x + 6.1441934777474324e-06įor the denominator you could proceed similarly but obtain that log(1+exp(-z+k)) is already rounded to 0, so that the argument of the exponential function at the denominator is simply rounded to -z=-3000. We have that for the numerator: exp(-x)+exp(-y) = exp(log(exp(-x)+exp(-y))) Here I explain how to do some math manipulation that helps on this problem. go for a tailored scipy/numpy function that does exactly what you want! Check out Weckesser answer.as an alternative to a bigger weapon, do some math manipulation, as detailed below.go for a library for high-precision mathematics, like mpmath.Nan is returned in this case because of the division by zero. This happens because answer1 is the exponential of 2 very large, negative numbers, so that the result is rounded to zero. Simply answer1.sum()=0, and you can't perform a division by zero.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |