# Using sub-scripted variables in functions

Is it possible to use subscripts in Mathematica functions, for example

  f[Subscript[x, a] _] := x^2


However this doesn't seem to work, is there a way to allow indexed variables to behave in the same way as non-indexed variables?

Cheers

• But then, why do you need to do this? – J. M.'s torpor Jan 15 '17 at 19:22
• I just prefer the notion style for readability. – Q.P. Jan 15 '17 at 19:29
• The best advice about working with Subscripts is: don't use them. See here, here, and here. – corey979 Jan 15 '17 at 19:41
• @corey979 Duly noted. It can be done, its just probably not worth it. Lesson of the day don't use subscripts. – Q.P. Jan 15 '17 at 20:01
• @ corey979 This has been the common opinion for many years. However, recently I started to notice that the expressions with subscripts work in situations they have not work before, and started to use subscripts, especially in tensor expressions, being very careful in cross-checking the results with and without subscripts. It seems to work. May it be an improvement of the latest Mma version? – Alexei Boulbitch Jan 16 '17 at 7:42