Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13921

Python Error: RuntimeWarning: overflow encountered in double_scalars

$
0
0

I am running into the error in the title with the code below:

from scipy import special as spdef func(x, n):coefs = [[0] * (n+1) for _ in range(n+1)]for i in range(n+1):        for j in range(i+1):                if j <=x:                        coefs[i][j] = sp.binom(i, j)                else:                        sumation = 0                        for k in range(x+1):                                sumation = sumation + coefs[i - k - 1][j - k]                        coefs[i][j] = sumation

Running this with

print(func(10, 1500))

returns the error:

RuntimeWarning: overflow encountered in double_scalarssum = sum + list[i - k - 1][j - k]

It works up until just past n = 1000.

I am using Python 3.6. I thought that numbers could be any size in this version of Python but I am new to it so I might just be missing something.

Any help with overcoming this would be appreciated.

Thank you


Viewing all articles
Browse latest Browse all 13921

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>