Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
0 votes

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)?

in General questions by (1.8k points)

2 Answers

0 votes
 
Best answer

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 (82.5k points)
selected by

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

0 votes

That probably makes more sense if it only replaces the index if you do

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

Let me see what made me change this when going from 1.x to 2.x...

by (82.5k points)
...