# How to make traditional output for derivatives

Hello again after some pause. i have a problem how to present partial derivatives in traditional form, not as Mathematica gave it to me in its notation. So I want to present this

Subscript[S, 1]* (F1^(4,0))[x,y]+Subscript[S, 2]* (F1^(2,2))[x,y]

to have a look $S_1\frac{\partial ^4F_1(x,y)}{\partial x^4}+S_2\frac{\partial ^4F_1(x,y)}{\partial x^2\partial y^2}$

And if I have for example lot of different combination of derivatives terms I want to do this automatically . Is it possible?

-
I posted a solution to this problem as part of my answer here. Its advantage is that it is more compact and that it automatically uses straight derivative symbols (instead of curly ones) when you're not doing partial derivatives. –  Jens Apr 20 '13 at 16:13

Besides of TraditionalForm you should use Defer to stop automatic evaluation of the underlying expression, so it should look like this :

TraditionalForm @ Defer[   Subscript[S, 1] D[F1[x, y], {x, 4}]
+ Subscript[S, 2]*D[F1[x, y], {x, 2}, {y, 2}]]

In order to change the order of terms one could use also undocumented

PolynomialForm[
Defer[ Subscript[S, 1] D[Subscript[F, 1][x, y], {x, 4}] +
Subscript[S, 2] D[Subscript[F, 1][x, y], {x, 2}, {y, 2}]],

For more comprehensive discussion I recommend to read this Wolfram blog post by Vitaliy Kaurov:
Mathematica Q&A Series: Converting to Conventional Mathematical Typesetting.

-
Thank you very much Artes. –  Pipe Apr 20 '13 at 15:12

The problem with using TraditionalForm@Defer is that it won't work as soon as the Defer is gone. So you always need an additional wrapper, different from the simple TraditionalForm wrapper, to get the desired output. It can sometimes be desirable to have the derivative formatted automatically for all TraditionalForm environments, e.g., in Graphics labels etc.

If, as you mention in the question, you have numerous combinations of derivatives, then the output quickly becomes cluttered if you keep writing out all the function arguments in a partial derivative. This is why I formatted the derivative without arguments in this answer.

An additional formatting requirement in traditional form would be to write ordinary derivatives with a straight derivative symbol to distinguish them from partial derivatives. This isn't automatically done by Mathematica in TraditionalForm output, so I added that case distinction in the linked answer.

The downside of the shortened notation in that answer was that you can't copy the formatted output and re-use it as input by pasting it back into a new line.

Here is a way to get the advantages of more readable short-hand notation in the displayed output while at the same time maintaining the ability to evaluate the output later:

Derivative /: MakeBoxes[
Derivative[\[Alpha]__][f1_][vars__Symbol],
] := Module[
{bb, dd, sp},
MakeBoxes[dd, _] ^=
If[Length[{\[Alpha]}] == 1, "\[DifferentialD]", "\[PartialD]"];
MakeBoxes[sp, _] ^= "\[ThinSpace]";
bb /: MakeBoxes[bb[x__], _] := RowBox[Map[ToBoxes[#] &, {x}]];
TemplateBox[{
ToBoxes[bb[dd^Plus[\[Alpha]], f1]],
ToBoxes[
Apply[bb,
Riffle[Map[bb[dd, #] &,
Select[({vars}^{\[Alpha]}), (# =!= 1 &)]], sp]]],
ToBoxes[Derivative[\[Alpha]][f1][vars]]
}, "ShortFraction",
DisplayFunction :> (FractionBox[#1, #2] &),
InterpretationFunction :> (#3 &),
Tooltip -> Automatic
]
]

$\frac{d f}{d x}$

$\frac{\partial^2 f}{\partial x^2}$
Note the absence of arguments $(x)$ and $(x,y)$, respectively, and the different symbols for partial and ordinary derivatives. Also, you can now copy any of the above outputs and paste them into an Input cell. The result is again recognized as the original derivative, without loss of information.