2
$\begingroup$

Is there a way to declare that subscripted letters are not functions of the letter? By default, this happens:

In[5]:= D[Subscript[t, 0], t]
Out[5]= (Subscript^(1,0))[t,0]

which I can understand but is slightly eye-roll-inducing. Mathematical practice would like this t_0 to be constant.

$\endgroup$
5
  • 3
    $\begingroup$ You can use Symbolize. There are already a few questions about this. $\endgroup$
    – Domen
    Jan 23 at 16:26
  • 2
    $\begingroup$ Point 3: "Avoid subscripted symbols." That said, try setting Attributes[Subscript] = {Constant, NHoldAll}. $\endgroup$
    – Goofy
    Jan 23 at 16:43
  • 1
    $\begingroup$ Instead of using Subscript[t, 0] use t0 and format it to look like Subscript[t, 0], i.e., Format[t0] = Subscript["t", 0]; Then D[t0, t] evaluates to 0 $\endgroup$
    – Bob Hanlon
    Jan 23 at 17:55
  • 1
    $\begingroup$ Does this answer your question? Solve with v9 (issues with Subscript, Overscript, Superscript etc) $\endgroup$
    – xzczd
    Jan 24 at 2:59
  • $\begingroup$ This is a simple mistake? $\endgroup$ Jan 24 at 18:31

1 Answer 1

4
$\begingroup$

You can use a variation of the following idea where I fix a similar issue with Solve:

$Notations = Alternatives[
    Subscript, Superscript, Subsuperscript, SubPlus, SubMinus, SubStar, SuperPlus,
    SuperMinus, SuperStar, SuperDagger, Overscript, Underscript, Underoverscript, 
    OverBar, OverVector, OverTilde, OverHat, OverDot, UnderBar
];

Unprotect[D];
D[a__] /; !FreeQ[{a}, $Notations[__]] := Block[{CompressedData},
With[{z=Unevaluated[D[a]] /. s:$Notations[__] :> CompressedData[Compress[s]]},
        z /; !MatchQ[z,_D]
    ]
]
Protect[D];

Then:

D[t Subscript[t,0] + t^2, t]

2 t + Subscript[t, 0]

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.