A generalized derivative for calm and stable functions