Cost function without gradiant