An approach that is amenable to algebraic calculation by computer algebra methods is to differentiate in log space. Since the elasticity can be defined logarithmically, that is:
differentiating in log space is an obvious approach. Logarithmic differentiation is particularly convenient in algebra software such as Mathematica or Maple, where logarithmic differentiation rules can be defined.
A more detailed examination and the rules differentiating in log space can be found at Elasticity of a function.