I think the problem is the multiplication / division operations in the second argument to subs , since the problem disappears as soon as I change the code as follows:
syms Gr Ra Ri AB Gr1 Gr2 cd Gr = 2*c*(Ra^2 - Ri^2) - d*(Ra^4 - Ri^4)/2; Gr1 = subs(Gr, [(Ra^2 - Ri^2),(Ra^4 - Ri^4)], [A/c,-2*B/d]) Gr2 = subs(Gr, [(Ra^2 - Ri^2),(Ra^4 - Ri^4)], [A/c,2*B/d])
and output:
Gr1 = 2*A + B Gr2 = 2*A - B
source share