Updated code to obtain derivatives of expression with minus