 functional operators examples - Maple Help

Home : Support : Online Help : Programming : Operations : Operators : functional operators examples

Examples of Functional Operators

A functional operator in Maple is a special form of a procedure. Functional operators are written using arrow notation:

For basic information, see Functional Operators.  The following examples demonstrate the different types of functional operators that you can use in Maple. Examples

First, define a basic operator on a single variable $x$ and apply it using function notation.

 > $F:=x→\mathrm{sin}\left(x\right)$
 ${F}{:=}{x}{→}{\mathrm{sin}}{}\left({x}\right)$ (1.1)
 > $F\left(t\right)$
 ${\mathrm{sin}}{}\left({t}\right)$ (1.2)

In this example, empty parentheses denote that the operator returns $1$, no matter what the input.

 > $A:=\left(\right)→1$
 ${A}{:=}\left({}\right){→}{1}$ (1.3)
 > $A\left(x\right)$
 ${1}$ (1.4)

Note that in 1-D Math input, an operator can always be applied by using function notation.  However, in 2-D Math input, when the operator is also of type atomic, you must use the apply command.  This is because $1\left(x\right)$ is interpreted as multiplication in 2-D math rather than function application.  For more information, including how to change this default behavior, see 2DMathDetails.

 > 1(x);
 ${1}$ (1.5)
 > $1\left(x\right)$
 ${x}$ (1.6)
 >
 ${1}$ (1.7)

Similarly, this multivariate operator returns $3.14$, no matter what the input.

 > $B:=\left(\right)→3.14$
 ${B}{:=}\left({}\right){→}{3.14}$ (1.8)
 > $\mathrm{B}\left(\mathrm{x},\mathrm{y}\right)$
 ${3.14}$ (1.9)
 > 3.14(x,y);
 ${3.14}$ (1.10)
 >
 ${3.14}$ (1.11)

Operators can be applied without assigning them a name.

 > $\left(x→x\right)\left(t\right)$
 ${t}$ (1.12)
 > $\left(x\to {x}^{2}\right)\left(4\right)$
 ${16}$ (1.13)

Operators are distributive.

 > $\left(a+b\right)\left(t\right)$
 ${a}{}\left({t}\right){+}{b}{}\left({t}\right)$ (1.14)
 > $\left(a+1\right)\left(t\right)$
 ${a}{}\left({t}\right){+}{1}$ (1.15)

Use the composition operator @ to perform operator composition.  That is, $f@g$ means $f\circ g$.

 > $f≔x\to x+2;g≔y\to \sqrt{y}$
 ${f}{:=}{x}{→}{x}{+}{2}$
 ${g}{:=}{y}{→}\sqrt{{y}}$ (1.16)
 > $\left(\mathrm{f}@\mathrm{g}\right)\left(\mathrm{t}\right);\left(g@f\right)\left(t\right)$
 $\sqrt{{t}}{+}{2}$
 $\sqrt{{t}{+}{2}}$ (1.17)
 > $\left(\left(x\to \mathrm{sin}\left(x\right)\right)@\left(x\to \mathrm{arcsin}\left(x\right)\right)\right)\left(t\right)$
 ${t}$ (1.18)

Repeated composition is entered with the @@ operator.  Here, a function is composed with itself.

 > $\left(\left(x→\mathrm{ln}\left(x\right)+1\right)@@2\right)\left(t\right)$
 ${\mathrm{ln}}{}\left({\mathrm{ln}}{}\left({t}\right){+}{1}\right){+}{1}$ (1.19) See Also