applyrule - Maple Programming Help

Home : Support : Online Help : Programming : Operations : Substitution : applyrule

applyrule

applying rules

 Calling Sequence applyrule(rule, expr) applyrule([rule1, rule2, ...], expr)

Parameters

 expr - expression the rules are applied to rule - rule

Description

 • With applyrule a rule or a list of rules can be applied to a given expression. applyrule computes the fix point, it applies the rules until no rule can be applied any more. It is more powerful than the command subs, but does not do mathematical transformations as algsubs does.
 • Rules are given as equations or in the syntax of the pattern matcher with parameters. See patmatch.

Examples

 > $\mathrm{applyrule}\left(a+b=x,f\left(a+b+c\right)\right)$
 ${f}{}\left({x}{+}{c}\right)$ (1)
 > $\mathrm{applyrule}\left(x=y,{x}^{2}\right)$
 ${{y}}^{{2}}$ (2)
 > $\mathrm{applyrule}\left({x}^{2}=y,f\left({x}^{2},{ⅇ}^{\mathrm{sin}\left(x\right)+2{x}^{2}}\right)\right)$
 ${f}{}\left({y}{,}{{ⅇ}}^{{\mathrm{sin}}{}\left({x}\right){+}{2}{}{y}}\right)$ (3)
 > $\mathrm{applyrule}\left(f\left(a::\mathrm{integer}x\right)=af\left(x\right),f\left(2x\right)+g\left(x\right)-f\left(px\right)\right)$
 ${2}{}{f}{}\left({x}\right){+}{g}{}\left({x}\right){-}{f}{}\left({p}{}{x}\right)$ (4)
 > $\mathrm{applyrule}\left(\left[a::\mathrm{even}=\mathrm{even},a::\mathrm{prime}=\mathrm{prime}\right],\left[1,2,4,3,5,6,4,8,15,21\right]\right)$
 $\left[{1}{,}{\mathrm{even}}{,}{\mathrm{even}}{,}{\mathrm{prime}}{,}{\mathrm{prime}}{,}{\mathrm{even}}{,}{\mathrm{even}}{,}{\mathrm{even}}{,}{15}{,}{21}\right]$ (5)
 > $\mathrm{applyrule}\left(\mathrm{sin}\left(2x\right)=2\mathrm{sin}\left(x\right)\mathrm{cos}\left(x\right),\mathrm{sin}\left(x\right)+\mathrm{sin}\left(2x\right)-\mathrm{cos}\left(x\right)\right)$
 ${\mathrm{sin}}{}\left({x}\right){+}{2}{}{\mathrm{sin}}{}\left({x}\right){}{\mathrm{cos}}{}\left({x}\right){-}{\mathrm{cos}}{}\left({x}\right)$ (6)