Is this extensible to arrays of symbolic variables someway?
Ideally, I have a complex expression (a polynomial in the x[i], where x is an array of symbolic variables and the coefficients can be either floats or other symbolic variables) and a list of “monomials” that I want to replace, e.g. c*x*x => c*y, d*x^2 => d*y, etc…
The goal is:
set to zero all monomials of order greater than 2, e.g. x^3 or x*x*x
replace all second-order expressions with a simpler one, e.g. c*x^2 => c*y or d*x*x => d*y
Write down all the rules and interpolate when you refer to an array element.
Example: r = [@acrule(*($(x), $(x), $(x)) => 0)]
If you work with polynomials the polynomial_coeffs function may be useful.
Example: d, rem = polynomial_coeffs(f, [x...])