Sponsored links: Algebra eBooks ### The Maxima on-line user's manual

Algebra Calculator

#### Search: #### Defrule

Function: defrule (<rulename>, <pattern>, <replacement>) Defines and names a replacement rule for the given pattern. If the rule named <rulename> is applied to an expression (by `apply1`, `applyb1`, or `apply2`), every subexpression matching the pattern will be replaced by the replacement. All variables in the replacement which have been assigned values by the pattern match are assigned those values in the replacement which is then simplified.

The rules themselves can be treated as functions which transform an expression by one operation of the pattern match and replacement. If the match fails, the rule function returns `false`.

```(%o1)                                true
(%i2) ```

### Related Examples

##### defrule-factor-false-matchdeclare-maxapplydepth-simp-tellsimp-tellsimpafter-true

1/(a*b), simp:true;

1/(a*b), simp:false;

matchdeclare(a, true);

Calculate

##### defrule-factor-false-matchdeclare-maxapplydepth-simp-tellsimp-tellsimpafter-true

1/(a*b), simp:true;

1/(a*b), simp:false;

matchdeclare(a, true);

Calculate

##### defrule-denom-expandwrt_denom-factor-false-matchdeclare-maxapplydepth-simp-tellsimp-tellsimpafter-true

1/(a*b), simp:true;

1/(a*b), simp:false;

matchdeclare(a, true);

Calculate

##### defrule-false-maxapplydepth-simp-tellsimp-tellsimpafter-true

1/(a*b), simp:true;

1/(a*b), simp:false;

tellsimp(1/(a*b), sim...

Calculate

##### defrule-denom-expandwrt_denom-factor-false-matchdeclare-maxapplydepth-ratexpand-simp-tellsimp-tellsimpafter-true

1/(a*b), simp:true;

1/(a*b), simp:false;

matchdeclare(a, true);

Calculate

##### defrule-disprule-matchdeclare-true

matchdeclare(n, integ...

defrule(fnx, f(n*x), ...

disprule(all);

Calculate

matchdeclare(n, integ...

defrule(fnx, f(nx), n...

disprule(all);

Calculate

matchdeclare(n, integ...

defrule(fnx, f(nx), n...

disprule(all);

Calculate

matchdeclare(n, integ...

defrule(fnx, f(nx), n...

disprule(all);

Calculate

##### defrule-false-maxapplydepth-simp-tellsimp-tellsimpafter-true

1/(a*b), simp:true;

1/(a*b), simp:false;

tellsimp(1/(a*b), sim...

Calculate 