hasfun - Maple Help

hasfun

test for a specified function

 Calling Sequence hasfun(e, f) hasfun(e, f, x)

Parameters

 e - expression f - function name(s) x - (optional) expression

Description

 • The hasfun command searches an expression e for the function f, or, if f is a list or set of names (of functions), then hasfun searches e for any one of these functions. It returns true if it finds one, false otherwise.
 • If the third optional argument x is specified, the hasfun function tests if the expression e has function(s) f of x, in the sense that x occurs in one or more arguments of the call to f. A typical application is in integration where you might want to test if the integrand has a special function of a variable x.
 For a positive match, x has to occur as an exact subexpression as defined by Maple's op function. See has for examples of what this means.
 If the subexpression x that needs to occur in the arguments to f is a list or set, it needs to be enclosed in a list or set itself, otherwise hasfun will search for the members of x only.

Examples

 > $e≔\mathrm{sin}\left(x\right)+{ⅇ}^{3y}+1$
 ${e}{:=}{\mathrm{sin}}{}\left({x}\right){+}{{ⅇ}}^{{3}{}{y}}{+}{1}$ (1)
 > $\mathrm{hasfun}\left(e,\mathrm{exp}\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{hasfun}\left(e,\mathrm{cos}\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{hasfun}\left(e,\mathrm{exp},y\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{hasfun}\left(e,\mathrm{exp},x\right)$
 ${\mathrm{false}}$ (5)
 > $\mathrm{hasfun}\left(e,\mathrm{exp},\left[x,y\right]\right)$
 ${\mathrm{true}}$ (6)
 > $\mathrm{hasfun}\left(e,\left\{\mathrm{sin},\mathrm{cos}\right\},x\right)$
 ${\mathrm{true}}$ (7)

The function name f can be any expression.

 > $e≔\mathrm{D}\left(x\right)\left(t\right)-x\left(t\right)$
 ${e}{:=}{\mathrm{D}}{}\left({x}\right){}\left({t}\right){-}{x}{}\left({t}\right)$ (8)
 > $\mathrm{hasfun}\left(e,\mathrm{D}\left(x\right),t\right)$
 ${\mathrm{true}}$ (9)

The required subexpression x can also be any expression, but it needs to occur as a subexpression as defined by Maple's op function. Below, $x+y$ is not a subexpression of $x+y+z$.

 > $e≔g\left(2f\left(x+y+z\right)-2\right)$
 ${e}{:=}{g}{}\left({2}{}{f}{}\left({x}{+}{y}{+}{z}\right){-}{2}\right)$ (10)
 > $\mathrm{hasfun}\left(e,f,x+y\right)$
 ${\mathrm{false}}$ (11)

If the subexpression you are looking for is a list or set, you need to enclose it in a list or set itself. The first calling sequence looks for the variables $k$ or $m$ occurring; the second for the list $\left[k,m\right]$; and the third for the list $\left[m,n\right]$:

 > $e≔1+\mathrm{Hypergeom}\left(\left[m,n\right],\left[\right],z\right)$
 ${e}{:=}{1}{+}{\mathrm{Hypergeom}}{}\left(\left[{m}{,}{n}\right]{,}\left[{}\right]{,}{z}\right)$ (12)
 > $\mathrm{hasfun}\left(e,\mathrm{Hypergeom},\left[k,m\right]\right)$
 ${\mathrm{true}}$ (13)
 > $\mathrm{hasfun}\left(e,\mathrm{Hypergeom},\left[\left[k,m\right]\right]\right)$
 ${\mathrm{false}}$ (14)
 > $\mathrm{hasfun}\left(e,\mathrm{Hypergeom},\left[\left[m,n\right]\right]\right)$
 ${\mathrm{true}}$ (15)