Within the for
loops you assign single values to both E_y1
and y1
, one after the other, each new value overriding the previous one. What you want is them representing ranges, or lists. The syntax looks like this:
E_y1 = range(21)
y1 = [tan(sqrt(w**2*m*x/2*h**2)) for x in E_y1]
x1 = E_y1
plot(x1,y1)
show()
Now Ey1
is a range of numbers, and y1
is a list.
And about that domain error: You are taking the square root of a negative number, so the problem is hardly surprising.