compute cost