Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Replace with a new symbol all occurrences of an algebraic subexpression in a given mathematical expression
ResourceFunction["AlgebraicReplace"][expr,reps,repvars] Rewrite expr, replacing each occurrence of an element of reps with the corresponding element of repvars. | |
ResourceFunction["AlgebraicReplace"][expr,reps,repvars,vars] Rewrite expr, burrowing inside any subexpression that is not a polynomial in vars. |
Algebraically replace xy by a new variable z in a bivariate polynomial:
| In[1]:= |
| Out[1]= |
AlgebraicReplace works with non-polynomial expressions:
| In[2]:= | ![]() |
| Out[2]= |
ReplaceAll only replaces literal matches:
| In[3]:= |
| Out[3]= |
AlgebraicReplace rewrites all monomials containing powers of xy to have powers of z:
| In[4]:= |
| Out[4]= |
If the underlying variables are omitted, AlgebraicReplace might not recognize what are the correct ones:
| In[5]:= |
| Out[5]= |
Specify x and y as variables to get the desired replacement:
| In[6]:= |
| Out[6]= |
This work is licensed under a Creative Commons Attribution 4.0 International License