match
pattern matching
Calling Sequence
Parameters
Description
Examples
match(expr = pattern, v, 's')
match(expr = pattern, {v1, v2, ..., vN}, 's')
expr
-
expression of type algebraic to be matched
pattern
pattern (also of type algebraic) to match
v
name of the main variable
's'
name of the return argument
{v1, v2, ..., vN}
names of the main variables
The match(expr = pattern, v, 's') calling sequence returns true if it can match expr to pattern for some values of the variables (excluding the main variable, v). Otherwise, it returns false.
The match(expr = pattern, {v1, v2, ..., vN}, 's') calling sequence returns true if it can match expr to pattern for some values of the variables (excluding the main variables, {v1, v2, ..., vN}). Otherwise, it returns false.
Note: In the multiple main variable case, the pattern specified must be a polynomial in all, or all but one of, the main variables. That is, type(pattern, polynom(anything, vI)) must be true for (N - 1) values of I in the range 1, 2, ..., N. Otherwise, the match command returns false.
If the match is successful, s is assigned a substitution set such that subs⁡s,pattern=expr.
The main variables must be matched exactly in the pattern. In other words, the main variables cannot be substituted for any value.
The match command attempts to compute expressions to satisfy the pattern, as opposed to the typematch command that matches the form of the objects.
match⁡ln⁡kk12=A⁢ln⁡kP⁢kQ,k,s
true
s
A=1,P=1,Q=−12
match⁡5⁢x2−3⁢x+z⁢x+y=a⁢x+b2+c,x,s
a=5,b=z10−310,c=−120⁢z2+y+310⁢z−920
In the multiple main variable case, if the pattern is not a polynomial in (all but one of) the main variables, the match command always returns false.
match⁡sin⁡x+y=sin⁡a⁢x+y,x,y,s
false
match⁡5⁢x2−3⁢x+z⁢x+y=a⁢x+b2+c⁢x⁢z+d,x,z,s
a=5,b=−310,c=1,d=y−920
match⁡5⁢x2−3⁢x+z⁢x+y=a⁢x+b2+f⁢x−c⁢x⁢z+d⁢y,x,y,z,s
a=5,b=0,c=−1,d=1,f=−3
The pattern is polynomial in one of the two main variables, and suitable values can be found for all non-main variables in the following example.
match⁡sin⁡x+4⁢y=sin⁡a⁢x+b⁢y,x,y,s
a=1,b=4
Take care that the pattern (containing the variables to be matched) appears on the right hand side of the first argument to match.
match⁡2⁢x+3=a⁢x+b,x,s
match⁡a⁢x+b=2⁢x+3,x,s
See Also
patmatch
solve[identity]
subs
type/polynom
typematch
Download Help Document