Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using Displaying index as subscript on output: e.g. C[i] -> C_i with Notation[...] or Interpretation[..]? I have often ended up wanting to define functions of annotated variables to better match my whiteboard mathematics. Naively, I would want to do things like:

f[z[bar]_] := z[bar]^2;
relativez[z_, z[bar]_] := z / z[bar];

However, this doesn't work. Obviously, I can do things like

f[zbar_] := zbar^2;

But I would prefer to have it map to my math better if a simple variation of this pattern works.

share|improve this question
Which is more important: the entry of this function definition, or the way the definition displays with e.g. Definition[f]? – Mr.Wizard Sep 19 '13 at 19:38
If it isn't possible to do both at the same time, then I think that current answer gives a possible tradeoff where I can choose as appropriate. – jlperla Sep 19 '13 at 20:46

You are close to the truth

f[z_[bar_]] := z[bar]^2;
share|improve this answer
So close. Also note that the following works: f2[z_, z_[bar_]] := z/z[bar]; f2[a, a[bar]] – jlperla Sep 19 '13 at 17:58
Just a confirmation though, in your original version the following does not work f[zb], presumably because it needs to match a pattern with a [_]. In this sense, I am not getting exactly what I am want (which is z[bar] as a complete placeholder on its own. However, for my purposes this may be sufficient. – jlperla Sep 19 '13 at 18:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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