# Problem with integration with indexed variable

I wonder why I can not have a correct integration form on Mathematica with some indexed variables.

Indeed, when I write :

Integrate[r/Subscript[r, L], {r, 0, Subscript[r, L]}]


I have the following result :

However, when I write :

Integrate[r/Subscript[q, L], {r, 0, Subscript[q, L]}]


I obtain the expected (computed) expression :

Could you explain me where is my error ? and how can I have the expected result with first expression ?

Best,

• @DanielHuber That's not quite the case, though close. In[79]:= Integrate[q*Subscript[r, n], {Subscript[r, n], 0, q}] Out[79]= q^3/2. The issue with the one in this post is that r is the integration variable, and the integrand contains Subscript[r, L] which is viewed as an unknown function of r. So Integrate is flummoxed. May 17, 2023 at 20:07
• Ok, thanks for this remark. But is it possible to prevent the problem ? I would like to use rL as a variable in order to produce more clear formula, rather than using another variable name. To summarize, is-it possible to constrain Mathematica to consider rL not as an unknown function but as a parameter independant from r ? May 17, 2023 at 20:10

One idea is to create an environment where subscripts are rendered inert, and then the expression is evaluated. For example:

SetAttributes[InactivatedSubscripts,HoldAll];

InactivatedSubscripts[expr_]:=Block[{CompressedData},
With[{h=Hold[expr]/.s_Subscript:>RuleCondition@CompressedData[Compress@s]},
ReleaseHold[h]
]
]


Then:

InactivatedSubscripts[
Integrate[r/Subscript[r,L],{r,0,Subscript[r,L]}]
]


Subscript[r, L]/2