# How to use subscript in pattern names?

For example I want to define a function with parameters σx and σy, that is, the function will be declared as:

f[σx_,σy_] := . . .

I tried Symbolize but it doesn't work. How can I use Subscript in pattern names?

You can use Symbolize, from the Notation package following the tutorial as you did.

Then, just take the precaution of writing the pattern with its head explicit, such as:

Pattern[xr, _]

The problem is that Mathematica can't interpret the short notation for patterns (xr_ for example) if it has a box structure before the "_"

As mentioned by Rojo in the answer above,

xr_
can't be interpreted as desired even after Symbolize is used, but one doesn't need to write Pattern in its FullForm to circumvent the problem, actually you just need one more : i.e.

xr:_

Example:

• I am using mathematica 11.0, and after loading the Notation package and entering Symbolize[<keystrokes>], where <keystrokes> was Shift+_ then Control+_ then Shift +_, I got the error message "Symbolize::noboxtag: The Symbolize boxes Subscript[ _ , _ ] do not have an embedded TemplateBox with tag NotationTemplateTag. The Symbolize statement Symbolize[Subscript[ _ , _ ]] may not have been entered using the palette, or the embedded TemplateBox may have been deleted. The embedded TemplateBox ensures correct parsing and retention of proper styling and grouping information." – Brian Moths Sep 14 '16 at 14:37
• @NowIGetToLearnWhatAHeadIs As mentioned in the document: When defining your own notations it is critically important to use the notation templates. So don't type Symbolize directly, use the Notation Palette popping up when you execute <<Notation. – xzczd Sep 14 '16 at 14:44
• Thanks. I have been looking through the documentation since I posted the comment, and I just now stumbled upon that. – Brian Moths Sep 14 '16 at 14:47
• Thanks for this answer, it really saved me. – mattos Apr 11 '20 at 6:20

You can also use the input form in the definition

f[Subscript[σ, x_], Subscript[σ, y_]] := ...`

• CarloB, welcome to the site. I don't believe this works in the way the OP wants. It would require entering your values as subscripts to sigma for each argument. – Mr.Wizard Mar 13 '12 at 14:26