Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Output format of partial derivatives

47 views
Skip to first unread message

Christian Zemlin

unread,
Apr 1, 1999, 3:00:00 AM4/1/99
to
Hi all,

I am working with expressions that contain MANY partial derivatives, and
they would be much easier to read if instead of Mathematica's notation,

(1,1)
f (x,y)

I could get something like

f
xy

Does anybody know how to get such output?

Thanks,

Christian

P.J. Hinton

unread,
Apr 5, 1999, 3:00:00 AM4/5/99
to

Change the low-level formatting rules for a derivative expressed in
TraditionalForm.

MakeBoxes[Derivative[indices__][f_][vars__], TraditionalForm] :=
SubscriptBox[MakeBoxes[f, TraditionalForm],
RowBox[Map[ToString,
Flatten[Thread[dummyhead[{vars}, Partition[{indices}, 1]]] /.
dummyhead -> Table]]]]™

Here is how you exploit this formatting code.

TraditionalForm[Derivative[1, 1][f][x, y]]

This should yield output as you describe.

--
P.J. Hinton
Mathematica Programming Group pa...@wolfram.com
Wolfram Research, Inc. http://www.wolfram.com/~paulh/
Disclaimer: Opinions expressed herein are those of the author alone.


Jens-Peer Kuska

unread,
Apr 5, 1999, 3:00:00 AM4/5/99
to

Hi Christian,

I append a Mathematica 3.x package that does what you want

Regards
Jens

Christian Zemlin wrote:
>
> Hi all,


>
> I am working with expressions that contain MANY partial derivatives, and
> they would be much easier to read if instead of Mathematica's notation,
>
> (1,1)
> f (x,y)
>
> I could get something like
>
> f
> xy
>
> Does anybody know how to get such output?
>

> Thanks,
>
> Christian

filename="FormatPDiff.m"

BeginPackage["FormatPDiff`"]

FormatPDiff::usage="FormatPDiff.m defines the format for traditional partial derivatives."

Begin["`Private`"]

protected=Unprotect[Derivative]

MakeBoxes[Derivative[dorder__][f_][args__Symbol] /; Length[{args}]>1, form_:StandardForm]:=
Module[{sm,num,den,arglst,lbr,rbr},
Switch[form,
TraditionalForm, lbr="(";rbr=")",
StandardForm, lbr="[";rbr="]",
_,lbr="[";rbr="]"
];
sm=Plus @@ {dorder};
If[sm>1,
num=RowBox[{SuperscriptBox["\[PartialD]",sm],MakeBoxes[f,form]}],
num=RowBox[{"\[PartialD]",MakeBoxes[f,form]}]
];
den={"\[PartialD]",SuperscriptBox[#[[2]],#[[1]]] }& /@
Transpose[{{dorder},MakeBoxes[#,form] & /@ {args}}];
den=Select[den,MatchQ[#,{_,SuperscriptBox[_,n_ /; n>0]}] &] //.
SuperscriptBox[a_,1] :> a;
den=RowBox[Flatten[den]];
arglst=Drop[
Flatten[
Transpose[
{#,Table[",",{i,Length[#]}]}
]& [{args}]],
-1
];
RowBox[
{FractionBox[num,den],RowBox[{lbr,Sequence @@ arglst,rbr}]}
]
]

Format[Derivative[dorder__][f_][args__Symbol] /; Length[{args}]>1,TeXForm]:=
MakeBoxes[Derivative[dorder][f][args],TraditionalForm]

Protect[Evaluate[protected]]

End[] (* private context *)

EndPackage[]


0 new messages