Continuous evaluation
N.B.
x^y
is "x XOR y", not "x to the power y". Use
Math.pow(x,y)
.