I am looking at the following mathematica code

Subscript[ff, r1_, r2_, CC_][x_, y_] := (r1 x + r2 y) (1 - (x + y)/CC)
Subscript[gg, r1_, r2_, CC_][x_, y_] := x

enter image description here

and am wondering why the $r1,r2,CC$ variables are written as subscripts instead of being included as []'s. What does putting a variable as subscript do? I tried looking for this information here but didn't find my answer.

  • 2
    $\begingroup$ See here (18395) $\endgroup$
    – Sektor
    Commented Mar 19, 2016 at 7:34
  • $\begingroup$ By writing it this way the author is separating parameters from variables. Using Subscript is a big no-no in Mathematica programming (as Sektor's link indicates). While it is possible to use it, it leads to problems more often than not. Please resist the temptation to use it. $\endgroup$ Commented Mar 19, 2016 at 14:52

1 Answer 1


It's a matter of notation.

I'd have written the functions as

ff[r1_,r2_,CC_,x_,y_]:= (r1*x + r2*y)(1 - (x + y)/CC)
gg[r1_,r2_,CC_,x_,y_]:= x

And would have gotten the same results if I called them to calculate

Input: Print[ff[1,2,3,4,5],",",gg[1,2,3,4,5]]
Output: -28,4


Input: Print[Subscript[ff,1,2,3][4,5],",",Subscript[gg,1,2,3][4,5]]
Output: -28,4

My guess is that the author of the code snippet wishes to keep seperate the subscript variables from the (x,y) variables for his own (aesthetic or not) reasons.

You can also see from here that the Subscript[] function is used just for formatting purposes.

  • 1
    $\begingroup$ If you read the post I linked to you will see that this behaviour is not always consistent. $\endgroup$
    – Sektor
    Commented Mar 19, 2016 at 10:22
  • $\begingroup$ Unfortunately I've read your very informative link after my post. Thanks ! $\endgroup$
    – milia
    Commented Mar 20, 2016 at 23:05

Your Answer

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

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