19
$\begingroup$

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?

$\endgroup$
16
$\begingroup$

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 "_"

$\endgroup$
4
$\begingroup$

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:

enter image description here

$\endgroup$
  • $\begingroup$ 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." $\endgroup$ – Brian Moths Sep 14 '16 at 14:37
  • 1
    $\begingroup$ @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`. $\endgroup$ – xzczd Sep 14 '16 at 14:44
  • $\begingroup$ Thanks. I have been looking through the documentation since I posted the comment, and I just now stumbled upon that. $\endgroup$ – Brian Moths Sep 14 '16 at 14:47
0
$\begingroup$

You can also use the input form in the definition

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

$\endgroup$
  • 2
    $\begingroup$ 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. $\endgroup$ – Mr.Wizard Mar 13 '12 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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