Hi all,
I am new to Maxima (using it since yesterday), but thanks to the good documentation and many examples on the web, I could finish some tasks which were not too easy surprisingly fast. But in turn, I now can't find a solution for a very simple problem although I have put a significant amount of time into reading the manual and searching for examples.
I am trying to replace parts of a product within an expression by another expression. For example, given the expression
(i*j*k + i*k*l)^2,
I would like to replace i*k by s, so that the expression becomes
(s*j + s*l)^2.
I have tried subst, but of course it did not work (i*k is not a complete subexpression in the example expression). Then I read a hint regarding ratsubst, but this does the wrong thing as well. Below is a transcription showing the problem:
(%i7) test: (i*k*l + i*k*h)^2;
2
(%o7) (i k l + h i k)
(%i8) subst(s, (i*k), test);
2
(%o8) (i k l + h i k)
(%i9) ratsubst(s, (i*k), test);
2 2 2 2 2
(%o9) l s + 2 h l s + h s
Is there any way to achieve what I want?
Thank you very much in advance,
Peter