Assigning values to subscripted variables

Hi,
I am trying to assign a value to a variable (g). This variable has a subscript composed of two more variables (j,k) separated by an invisible comma. J and k are used for indexing purposes. It seems that Mathematica can’t assign a value (3 for example) to the indexed g. Or did I do something wrong?

 Subscript[g, j\[InvisibleComma]k] /. {j -> 2, k -> 2, 
  Subscript[g, 2\[InvisibleComma]2] -> 3}

Thanks in advance.

Subscripted variables are not “real” variables and users ask again and again why they aren’t working the way the user expects.

Try carefully reading all the advice in SubscriptedVariables101.nb

They are also problems converting them to strings, as the subscript is turned into a line feed.

Thanks for the fast replies. I didn’t find any hint to this in the Mathematica documentations about this issue. And of course, I didn’t know either that I hit a “hot topic” by chance. Anyways, the thing is that I am trying to calculate Christoffel symbols for some coordination conversions. The subscripts and the superscripts are essential in the classical form of the equations and they keeps messing up my calculations. It seems that I have to find away around those trouble makers.

Thank you again

The only problem is that Subscript[] doesn’t accept the invisible comma. (I’ll leave that explanation for the experts). With a “visible” comma the code works as expected.

Subscript[g, j, k] /. {j -> 2, k -> 2, Subscript[g, 2, 2] -> 3}

with a value of 3 for the expression (but you didn’t assign it to anything).
Symbols formatted with visible or invisible commas in the subscript are the same symbol. Your other code should work.

NB: In the documentation section “tutorial/MakingDefinitionsForIndexedObjects” is the statement

You can think of the expression a[i] as being like an “indexed” or “subscripted” variable.

I used matrices instead of Subscript indexing. It worked as it should. Then I read your comment about the subject. And I tried the code with a visible comma as you suggested and it worked perfectly. My formulas should look now like the classical forms.

Thanks for your suggestions.