. Advertisement .

..3..

. Advertisement .

..4..

I’m trying to run a new project. I do a couple of things like this:

```
import numpy
d = numpy.array([[1089, 1093]])
e = numpy.array([[1000, 4443]])
answer = numpy.exp(-3 * d)
answer1 = numpy.exp(-3 * e)
res = answer.sum()/answer1.sum()
print res
```

but in my program, I am getting the warning:

```
nan
C:\Users\Desktop\test.py:16: RuntimeWarning: invalid value encountered in double_scalars
res = answer.sum()/answer1.sum()
```

Can someone explain to me why the issue of the runtimewarning: invalid value encountered in double_scalars happened? Where have I gone wrong? Thank you!

This is how I solve this problem using math manipulation. That is for the numerator.

Where

`x=3* 1089`

and`y=3* 1093`

are respectively. The argument for this exponential is`-x + log(1+exp(-y+x)) = -x + 6.1441934777474324e-06`

You could also use the same procedure for the denominator, but

`log(1+exp(-z+k))`

has already been rounded up to`0`

. This means that the argument to the exponential function at denominator can be simply rounded up to`-z=-3000`

. Now you have your result.This is very close to what you would get if only the two leading terms were kept (i.e. The numerator’s first number

`1089`

and the denominator’s first number`1000`

are the`1089`

codes.Let’s take a look at how close we are to the solution to Wolfram alpha ( Link).

This difference is

`+1.7053025658242404e-13`

. The approximation that we made at denominator was therefore fine.The final result is

From Wolfram Alpha is ( Link).

It is also safe to use numpy.

You can solve your problem now by:

`scipy/numpy`

function that is tailored to your needs