Re: Output format of partial derivatives
- To: mathgroup at smc.vnet.net
- Subject: [mg16886] Re: Output format of partial derivatives
- From: Jens-Peer Kuska <v-jkuska>
- Date: Mon, 5 Apr 1999 02:24:24 -0400
- Organization: Wolfram Research, Inc.
- References: <7e1amq$b7u@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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[]