RuntimeWarning: invalid value encountered in divide

前端 未结 4 1793
野的像风
野的像风 2021-01-30 06:00

I have to make a program using Euler\'s method for the \"ball in a spring\" model

from pylab import*
from math import*
m=0.1
Lo=1
tt=30
k=200
t=20
g=9.81
dt=0.01         


        
4条回答
  •  不要未来只要你来
    2021-01-30 06:39

    I think your code is trying to "divide by zero" or "divide by NaN". If you are aware of that and don't want it to bother you, then you can try:

    import numpy as np
    np.seterr(divide='ignore', invalid='ignore')
    

    For more details see:

    • http://docs.scipy.org/doc/numpy/reference/generated/numpy.seterr.html

提交回复
热议问题