I get error message <string>: 149: RuntimeWarning: invalid value encountered in sqrt when generating a list
def ellipse(numPoints, genX=np.linspace, HALF_WIDTH=10, HALF_HEIGHT=6.5): xs = 10.*genX(-1,1,numPoints) ys = 6.5*np.sqrt(1-(xs**2)) return(xs, ys, "-") I am getting an error indicating an invalid value in squareroot. I donβt understand what it is.
sqrt(0) = 0 6.5*sqrt(1- (-1**2)) = 0 They should work, but y values ββhave problems, they return "nan"
+8
Bob Unger
source share1 answer
maybe xs**2 returns a number > 1 sqrt with a negative number will return nan (not a number)
>>> import numpy as np >>> np.sqrt(-1) nan If I correctly numpy provides complex number functions, which I think is the only way to represent sqrt (x), where x <0
+6
Foo bar user
source share