# Should substitute act on indices?

Hi Folks,

I'm not sure if this expected behaviour but when I run the following code

{p,q,r,s,t,u,v,w}::Indices.

abc := s**2 y^{r} y^{s} A_{r s};

substitute (abc,$s->1$);

the substitute command replaces not only the leading factor s**2 by 1**2 but it also replaces the subscripts s with 1.

Is this correct behaviour?

Cheers, Leo

ps. I'm also curious if factors like 1**2 should be replaced with 1 (though this is easily dealt withy other means)?

This is now fixed on github, the above produces

$$y^{r} y^{s} A_{r s} .$$

If you ever wanted to replace the s index instead (not recommendable, you never know whether the next run still calls this dummy index s), you need to do

substitute (abc,$^{s}->^{1}$);
by (70.9k points)
selected

Hi Kasper, Many thanks for the fix. It works. And I doubt I'd ever have a need to make substitutions on the indices -- down that road lies danger :). Cheers, Leo

 substitute(_, $^{s} -> 1$);