0
$\begingroup$

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

$\endgroup$
5
  • 1
    $\begingroup$ But then, why do you need to do this? $\endgroup$ Commented Jan 15, 2017 at 19:22
  • $\begingroup$ I just prefer the notion style for readability. $\endgroup$
    – user27119
    Commented Jan 15, 2017 at 19:29
  • 4
    $\begingroup$ The best advice about working with Subscripts is: don't use them. See here, here, and here. $\endgroup$
    – corey979
    Commented Jan 15, 2017 at 19:41
  • 1
    $\begingroup$ @corey979 Duly noted. It can be done, its just probably not worth it. Lesson of the day don't use subscripts. $\endgroup$
    – user27119
    Commented Jan 15, 2017 at 20:01
  • 1
    $\begingroup$ @ 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? $\endgroup$ Commented Jan 16, 2017 at 7:42

0

Your Answer

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

Browse other questions tagged or ask your own question.