I am trying to make a special substitution which neither
seem to be able to make. I have long polynomials (maybe with 3000 terms), but for the sake of clarity here is an example with a short one:
Now I would like to substitute a by a^2, but only in the terms that have a (to the power of one). (It is important that the a^3 in the original Poly is not changed to a^6 ).
So after substitution the polynomial should become:
Otherwise, the only thing I can think of is a little procedure. Say the original power of a is a^s and we want to change all the terms that contain "a^s" to "a^r".
Then we can do:
s := 1;
r := 2;
for i to nops(Poly) do
P[i] := op(Poly)[i];
if degree(P[i], a) = s then
P[i] := P[i]*a^r/a^s
NewPoly:= add(A[j], j = 1 .. nops(Poly));
But, is there a more efficient way? (especially because I may have to subsitute more than one variable).
Thank you for your help and reading,