suggestion: replace \newcommand{\dd}[3][]{\frac{\mbox{d}{#1}}{\mbox{d}{#2}}} by \newcommand{\dd}[3][]{\frac{\mbox{d}^{#1}{#2}}{\mbox{d}{#3}^{#1}}} to allow e.g. d^n E / dx^n by typing \dd[n]{E}{x}