2
$\begingroup$

I prefer to enter mathematical expressions using typography that closely mirrors traditional mathematical typography... as for instance is found in a scientific paper or textbook. Thus if I see the term $t^2$ in a printed equation, I type as input

t^2

rather than, say,

Power[t,2]

(Actually, the best version is t CNTRL^ 2, which sets the exponent elevated and smaller.)

I find this helps me (and students) more accurately translate printed equations into Input form and non-incidentally think more like a mathematician, see the structure of equations, ensure proper syntax, and so forth (even if it might require a few extra keystrokes).

To this end I'd like to find the most "mathematical style" input for a derivative, such as $\frac{d t^2}{dt}$ or $\frac{d}{dt} t^2$, rather than the "computer style" of D[t^2,t].

One can use the Basic math palette and insert a partial derivative symbol with subscript, ESC pd ESC CNTRL-, and then enter, t in the subscript box and t^2 in the line to get the equivalent of $\partial_t t^2$. Indeed, when this term is entered (interpreted), the proper solution, 2 t is computed. Fine.

But I'd prefer an even more "mathematical" typography for input. One that uses (\[DifferentialD]/\[DifferentialD]t)t^2 (properly rendered), something visually equivalent to $\frac{d t^2}{dt}$ or $\frac{d}{dt} t^2$, as mentioned above.

Alas, all my efforts to typeset an input with a "traditional" ratio may appear proper, but none get interpreted so that the derivative is actually computed. Even clicking on the nice ratio version in the Basic math palette fails to be interpreted.

In short: How do I typeset a traditional ratio form of a derivative and later have it properly interpreted (and thus computed)?

Moreover, I don't want to write a term in text form and then convert it to TraditionalForm. For instance, I don't want to type Power[t,2] and then convert it using TraditionalForm. That defeats the whole point.

To clarify using a more complex example: The following are two computationally equivalent inputs of a complex term:

equivalent terms

I find it much easier to interpret the bottom input. A single character missing in the upper, text-based input is hard to find.

So it is clear how to do this with integrals (and summations...). How to do it with a derivative expressed in the traditional form of a ratio?

Clear?

(Note that the "mathematical typography" of an integral is interpreted properly.)

$\endgroup$
7
  • $\begingroup$ Convert the expressions you are writing to TraditionalForm and evaluate. e.g. \!\( \*SubscriptBox[\(\[PartialD]\), \(t\)]\(( \*SuperscriptBox[\(t\), \(2\)])\)\) $\endgroup$
    – Syed
    Aug 31, 2022 at 4:33
  • $\begingroup$ Sorry, I don't understand. D[t^2,t] //TraditionalForm or TraditionalForm[D[t^2,t] evaluates to the solution directly ($2t$), but I want instead to see the input in the proper "mathematical" form before I enter/interpret it. (Am I missing something here?). And your version does not give the ratio form (just the partial derivative sign with subscript I mentioned in my question.) $\endgroup$ Aug 31, 2022 at 4:37
  • $\begingroup$ This doesn't fix the desired input part of your question but it will display (pretty much) what you want: Inactivate[D[t^2, t]] // TraditionalForm. Then you just have to use Activate at some point to have it evaluated. Maybe that could be a function placed into a palette. $\endgroup$
    – JimB
    Aug 31, 2022 at 5:57
  • $\begingroup$ @JimB: Thanks, but as I pointed out in my comment, having the student type D[t^2,t] is precisely what I want to AVOID. It defeats the whole purpose of exploiting the syntax constraints and such. Example: enter a definite integral sign from the Basic math palette. You see the slots and such. You enter the variables accordingly. Your approach demands the user type text perfectly, in order to see the mathematical term. THAT is what is to be avoided. Clear? $\endgroup$ Aug 31, 2022 at 6:12
  • 2
    $\begingroup$ I looked at all the pallettes and you are right, there does not seem to be one to enter $\frac{d f(t)}{dt}$ type of input. It will be nice to have one. $\endgroup$
    – Nasser
    Aug 31, 2022 at 7:34

1 Answer 1

3
$\begingroup$

Use Notation Package.

The code below looks huge because it is written with box forms so that you can copy&paste it correctly (without interpretation) to the notebook.

Cell[BoxData[{
 RowBox[{"Notation", "[", 
  RowBox[{
   TemplateBox[{
     RowBox[{
       FractionBox["\[DifferentialD]", 
        RowBox[{"\[DifferentialD]", "x_"}]], "y_"}]},
    "NotationTemplateTag"], " ", "⟹", " ", 
   TemplateBox[{
     RowBox[{"D", "[", 
       RowBox[{"y_", ",", "x_"}], "]"}]},
    "NotationTemplateTag"]}], "]"}], "\[IndentingNewLine]", 
 RowBox[{"Notation", "[", 
  RowBox[{
   TemplateBox[{
     RowBox[{
       FractionBox[
        SuperscriptBox["\[DifferentialD]", "n_"], 
        RowBox[{"\[DifferentialD]", 
          SuperscriptBox["x_", "n_"]}]], "y_"}]},
    "NotationTemplateTag"], " ", "⟹", " ", 
   TemplateBox[{
     RowBox[{"D", "[", 
       RowBox[{"y_", ",", 
         RowBox[{"{", 
           RowBox[{"x_", ",", "n_"}], "}"}]}], "]"}]},
    "NotationTemplateTag"]}], "]"}], "\[IndentingNewLine]", 
 RowBox[{"Notation", "[", 
  RowBox[{
   TemplateBox[{
     FractionBox[
      RowBox[{"\[DifferentialD]", "y_"}], 
      RowBox[{"\[DifferentialD]", "x_"}]]},
    "NotationTemplateTag"], " ", "⟹", " ", 
   TemplateBox[{
     RowBox[{"D", "[", 
       RowBox[{"y_", ",", "x_"}], "]"}]},
    "NotationTemplateTag"]}], "]"}], "\[IndentingNewLine]", 
 RowBox[{"Notation", "[", 
  RowBox[{
   TemplateBox[{
     FractionBox[
      RowBox[{
        SuperscriptBox["\[DifferentialD]", "n_"], " ", "y_"}], 
      RowBox[{"\[DifferentialD]", 
        SuperscriptBox["x_", "n_"]}]]},
    "NotationTemplateTag"], " ", "⟹", " ", 
   TemplateBox[{
     RowBox[{"D", "[", 
       RowBox[{"y_", ",", 
         RowBox[{"{", 
           RowBox[{"x_", ",", "n_"}], "}"}]}], "]"}]},
    "NotationTemplateTag"]}], "]"}]}], "Input"
]

enter image description here

$\endgroup$
1
  • $\begingroup$ Oh perfect... perfect! I didn't know about the Notation package, and see it is very helpful. ($+1, \checkmark$). I just hope WRI incorporates this trick into subsequent versions of Mathematica as it is so valuable. $\endgroup$ Apr 3, 2023 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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