Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find parameters to make a given form match a given expression mathematically
ResourceFunction["FindMatchingAlgebraicParameters"][expr,form] gives lists of replacement rules for constants and variables in form so as to match expr mathematically. |
Find values for the parameters of the form that make it match the expression:
In[1]:= | ![]() |
Out[1]= | ![]() |
Perform semantic pattern matching on multivariate forms:
In[2]:= | ![]() |
Out[2]= | ![]() |
By default all symbols are treated as constant parameters:
In[3]:= | ![]() |
Out[3]= | ![]() |
Use the option ''ExpressionVariables'' to designate the parameters in the expression that are to be treated as variables, the option ''FormVariables'' to designate the parameters in the form that are to be treated as variables, and the option ''FormConstants'' to designate the parameters in the form that are to be treated as constants:
In[4]:= | ![]() |
Out[4]= | ![]() |
Nothing is returned here because c is treated as a fixed value as opposed to a constant parameter and therefore cannot equal 2:
In[5]:= | ![]() |
Out[5]= | ![]() |
Here a result is returned because the fixed value c matches up with itself in the expression and form:
In[6]:= | ![]() |
Out[6]= | ![]() |
FindMatchingAlgebraicParameters finds values of parameters to make a given form match a given expression mathematically:
In[7]:= | ![]() |
Out[7]= | ![]() |
MatchQ only matches patterns, without regard for mathematical equivalence:
In[8]:= | ![]() |
Out[8]= | ![]() |
Similarly, ResourceFunction["PatternBindings"] gives a list of elements matching named parts of a pattern, but does not consider mathematical equivalence:
In[9]:= | ![]() |
Out[9]= | ![]() |
FindMatchingAlgebraicParameters considers setting constant parameters equal to 0 or 1 when seeking mathematical equivalence, which limits the solutions found when infinitely many are possible:
In[10]:= | ![]() |
Out[10]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License