Wouldn’t this approach run into issues if at some point x[i] == y[i] == 0?
x[i] == y[i] == 0
There is a solution without division at all.