fixed sign error in search direction calculation

Bug in the direction calculation.