I have an expression of the form:
expression = A1*x + A2*x^2 + ...
and I would like to replace A1
by F1[y]
, A2
by F2[y]
, etc.
Regular expressions would seem to be the thing to use, but since the above is not a string, I'm not sure how to do this. Would like the solution to be something simple like
expression /. A* :> F*[y]
but of course this doesn't work.
How do I accomplish the above?
expression
? It might be easier to replaceA1
,A2
,… byA[1]
,A[2]
,…. Then, replacement becomes as simple asexpression /. A[i_] :> F[i][y]
. As a general rule i try to keep any information that I might need again out of symbol names - most function have no issue with composite heads, and it makes extracting the information so much easier $\endgroup$