Changed algorithm for finding y at x