Function Repository Resource:

FindMatchingAlgebraicParameters

Source Notebook

Find parameters to make a given form match a given expression mathematically

Contributed by: Daniel McDonald

ResourceFunction["FindMatchingAlgebraicParameters"][expr,form]

gives lists of replacement rules for constants and variables in form so as to match expr mathematically.

Details and Options

ResourceFunction["FindMatchingAlgebraicParameters"] accounts for parameters that may disappear when certain constant parameters are set equal to zero or one.
Parameters can be treated as either variables or constants.
The option ''ExpressionVariables'' designates the parameters in expr that are to be treated as variables.
The option ''FormVariables'' designates the parameters in form that are to be treated as variables.
The option ''FormConstants'' designates the parameters in form that are to be treated as constants.
ResourceFunction["FindMatchingAlgebraicParameters"] is a way of performing semantic pattern matching.

Examples

Basic Examples (1) 

Find values for the parameters of the form that make it match the expression:

In[1]:=
ResourceFunction["FindMatchingAlgebraicParameters"][2 z^2 + 3, a*x^2 + b*x + c, "ExpressionVariables" -> {z}, "FormVariables" -> {x},
  "FormConstants" -> {a, b, c}]
Out[1]=

Scope (1) 

Perform semantic pattern matching on multivariate forms:

In[2]:=
ResourceFunction["FindMatchingAlgebraicParameters"][(2 w)^2 Sin[z], Sin[d*x] (a + b*y)^c, "ExpressionVariables" -> {z, w}, "FormVariables" -> {x, y}, "FormConstants" -> {a, b, c, d}]
Out[2]=

Options (4) 

By default all symbols are treated as constant parameters:

In[3]:=
ResourceFunction[
 "FindMatchingAlgebraicParameters"][(3 z)^2 + 3, (b*x)^c + b]
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]:=
ResourceFunction[
 "FindMatchingAlgebraicParameters"][(3 z)^2 + 3, (b*x)^c + b, "ExpressionVariables" -> {z}, "FormVariables" -> {x}, "FormConstants" -> {b, c}]
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]:=
ResourceFunction[
 "FindMatchingAlgebraicParameters"][(3 z)^2 + 3, (b*x)^c + b, "ExpressionVariables" -> {z}, "FormVariables" -> {x}, "FormConstants" -> {b}]
Out[5]=

Here a result is returned because the fixed value c matches up with itself in the expression and form:

In[6]:=
ResourceFunction[
 "FindMatchingAlgebraicParameters"][(3 z)^c + 3, (b*x)^c + b, "ExpressionVariables" -> {z}, "FormVariables" -> {x}, "FormConstants" -> {b}]
Out[6]=

Properties and Relations (3) 

FindMatchingAlgebraicParameters finds values of parameters to make a given form match a given expression mathematically:

In[7]:=
ResourceFunction["FindMatchingAlgebraicParameters"][x^2, u^a + b, "ExpressionVariables" -> {x}, "FormVariables" -> {u}, "FormConstants" -> {a, b}]
Out[7]=

MatchQ only matches patterns, without regard for mathematical equivalence:

In[8]:=
{MatchQ[x^2, u_^a_], MatchQ[x^2, u_^a_ + b_]}
Out[8]=

Similarly, ResourceFunction["PatternBindings"] gives a list of elements matching named parts of a pattern, but does not consider mathematical equivalence:

In[9]:=
{ResourceFunction["PatternBindings"][x^2, u_^a_], ResourceFunction["PatternBindings"][x^2, u_^a_ + b_]}
Out[9]=

Possible Issues (1) 

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]:=
ResourceFunction["FindMatchingAlgebraicParameters"][100, a*b]
Out[10]=

Publisher

Daniel McDonald

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 15 August 2025

Related Resources

License Information