I don't know enough math to fully understand your question but theses lines seems suspicious:
x = np.linspace(0, 10, 100)
[...]
x_train, x_test = x[:80], x[80:]
y_train, y_test = y[:80], y[80:]
This is the only place where you can get an error that gives a dimension of 20.