A language for evaluating derivatives of functionals using automatic differentiation