MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Trying for better partials notation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18204] Re: Trying for better partials notation
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Mon, 21 Jun 1999 22:50:44 -0400
  • Organization: Universitaet Leipzig
  • References: <7khp2p$qub@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Patrick,

try the attached package.


Regards
  Jens

Patrick Reany wrote:
> 
> I'm trying to get partials to look better in version 3. I've tried all
> kinds of tricks, including using the Notation package to do this, but to
> no avail so far.
> 
> I want a form that currently displays as
> 
>   h^(0,1) [u,x]   to display as    \partial_x  h[u,x]
> 
> where \partial is the del symbol and "_x" means subscript x.
> 
> One thing I tried was
> 
> h^(a_) [b_] :=  \partial_a.b  h[b]
> 
> Matching this to the previous example was to give
> 
>   a.b = {0,1}.{u,x} = x
> 
> Thanks
> 
> Patrick
 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[]



  • Prev by Date: Re: Automatic numbered captions for figures (plots)
  • Next by Date: Re: problem with Part function
  • Previous by thread: Trying for better partials notation
  • Next by thread: Automatic numbered captions for figures (plots)