crsa ml 4: cost fctn (not vectorized)