compute cost with multi variables