# Writing partial differentiation in a subscript

I would like to represent partial derivatives in Mathematica as subscripts. e.g. $\frac{\partial f}{\partial x}(x,y) = f_x(x,y)$.

Mathematica instead produces the output $f^{(1,0)}(x,y)$. Is there any way to make the partial derivative appear as a subscript?

On another note, is there a way to suppress arguments in the output? For me it would be even better if the output would read $f_x$.

• What do you want $f^{(2,3)}(x, y)$ to look like? Or $f^{(n, m)}(x, y)$? Or $f^{(1, 0)}(2, 3)$? – Carl Woll Jun 5 '18 at 0:40
• I would like $f^{(n,m)}(x,y)$ to appear as $f_{x\dots xy\dots y}$ (where $x$ appears $n$ times and $y$ appears $m$ times). I won't be evaluating the derivatives of $f$ at a point, so the last consideration isn't strictly necessary. – Fishy Jun 5 '18 at 0:44

## 1 Answer

You could write a MakeBoxes rule to do what you want:

Derivative /: MakeBoxes[
Derivative[n_Integer?NonNegative, m_Integer?NonNegative][f_], form_
] := SubscriptBox[
MakeBoxes[f, form],
TemplateBox[Join[ConstantArray["x", n], ConstantArray["y", m]],"RowDefault"]
]


For example:

Derivative[1, 0][f][x, y]
% // TeXForm


Subscript[f, x][x,y]

$f_x(x,y)$

Derivative[3, 2][g] //TeXForm


$g_{xxxyy}$

D[f[x, y], x, x] • Thank you for your response! It doesn't seem to work for me. Can you please explain how to implement the MakeBoxes rule? (I am new to Mathematica; Do I just evaluate it in an input cell?) Also, if possible, I would like this to apply globally to the output of all functions with partial derivatives (say there are f, g, h, ...). The point is to make the notation in deriving equations visually compact. – Fishy Jun 5 '18 at 1:06
• @Fishy Yes, just evaluate it in an input cell. I generalized it to work with all function heads. – Carl Woll Jun 5 '18 at 1:40
• Carl-- Thank you so much, it works now! The only remaining problem is an error message which appears when I use TexForm: TeXForm::unspt: TeXForm of TemplateSlotSequence[1,] is not supported. After googling, it seems to be a bug in mathematica itself (e.g. here ). Anyway, I consider the problem solved. Cheers! – Fishy Jun 5 '18 at 16:13
• @Fishy If you think the answer has resolved your problem, you may click on the check mark to accept it. – xzczd Jun 6 '18 at 12:18