The pattern 'symbpat' and replacement 'symbrepl' can be normal expressions; for example, you can replace .5 with 'SIN(π/6)'. You can also use a “wildcard” in the pattern (to match any subexpression) and in the replacement (to represent that expression). A wildcard is a name that begins with &, such as the name '&A', used in replacing 'SIN(&A+&B)' with 'SIN(&A)*COS(&B)+COS(&A)*SIN(&B)'. Multiple occurrences of a particular wildcard in a pattern must match identical subexpressions.

↓MATCH works from top down; that is, it checks the entire expression first. This approach works well for expansion. An expression expanded during one execution of ↓MATCH will contain additional subexpressions, and those subexpressions can be expanded by another execution of ↓MATCH. Several expressions can be expanded by one execution of ↓MATCH provided none is a subexpression of any other.

Access: …µMATCH

Input/Output:

 

 

Level 2/Argument 1

Level 1/Argument 2

 

 

Level 2/Item 1

Level 1/Item

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

'

pat

 

 

repl

' }

 

2

'

0/1

 

 

'symb

{ 'symb ' 'symb

 

 

'symb

 

 

1

'

pat

repl

' 'symb

cond

' }

2

'

0/1

 

 

'symb

{ 'symb ' 'symb

 

 

 

'symb

 

.5 {

 

Example 1:

.5 'SIN(π/6)' } ↓MATCH returns 'SIN(π/6)' to level 2 and 1 to level

 

1.

 

 

 

 

 

 

 

 

 

 

 

 

 

Example 2: 'SIN(U+V)' { 'SIN(&A+&B)'

'SIN(&A)*COS(&B)+COS(&A)*SIN(&B)' } ↓MATCH returns 'SIN(U)*COS(V)+COS(U)*SIN(V)' to level 2 and 1 to level 1.

Example 3: This sequence: 'SIN(5*Z)' { 'SIN(&A+&B)'

'Σ(K=0,&A,COMB(&A,K)*SIN(K*π)*COS(&B^(&AK)*SIN(&B) ^K)' 'ABS(IP(&A))==&A' } ↓MATCH returns 'Σ(K=0,5,COMB(5,K)*SIN(K*π)*COS(Z^(5K)*SIN(Z)^K)' to level 2 and 1 to level 1.

See also:

MATCH

↑MATCH

Type: Command

Description: BottomUp Match and Replace Command: Rewrites an e xpression.

↑MATCH rewrites expressions or subexpressions that match a specified pattern 'symbpat'. An optional condition, 'symbcond', can further restrict whether a rewrite occurs. A test result is also returned to indicate if command execution produced a rewrite; 1 if it did, 0 if it did not.

The pattern 'symbpat' and replacement 'symbrepl' can be normal expressions; for example, you can replace 'SIN(π/6)' with '1/2'. You can also use a “wildcard” in the pattern (to match any subexpression) and in the replacement (to represent that expression). A wildcard is a name that begins with &, such as the name '&A', used in replacing 'SIN(&A+π)' with '–SIN(&A)'. Multiple occurrences of a particular wildcard in a pattern must match identical subexpressions.

↑MATCH works from bottom up; that is, it checks the lowest level (most deeply nested) subexpressions first. This approach works well for simplification. A subexpression simplified during one execution of ↑MATCH will be a simpler argument of its parent expression, so the parent expression can be simplified by another execution of ↑MATCH.

Several subexpressions can be simplified by one execution of ↑MATCH provided none is a subexpression of any other.

Access: …µMATCH

3142 Full Command and Function Reference

Page 262
Image 262
HP 50g Graphing, 48gII Graphing manual ↑Match, Access …µ↓MATCH Input/Output, Symb Symb symb, Access …µ↑MATCH