numboccur
count occurrences of an expression
Calling Sequence
Parameters
Description
Thread Safety
Examples
numboccur(f, x)
f
-
expression
x
The numboccur(f, x) function returns the number of times that x is found in f.
If x is a sum or a product, the counted expressions are those where the sum or product appear with no extra terms or factors in f. If x is a list or a set, then every element in the list or set is counted.
If x is a list or set, numboccur counts and adds together the number of times each member of the list or set occurs in f. In other words, numboccur(f,{x,y}) is equivalent to numboccur(f,x) + numboccur(f,y). Note that if x is a list and contains a given element more than once, it is counted more than once each time it appears in f.
If the item that you want numboccur to count is itself a list or set, you must enclose it in a list or set. Otherwise, numboccur will count occurrences of the items in the list or set as described above.
The numboccur command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
numboccurx3+x−1,x
2
big_expr≔expandsin7x
big_expr≔64sinxcosx6−80sinxcosx4+24sinxcosx2−sinx
numboccurbig_expr,sinx
4
numboccura+ba+b+1a+b+c,a+b
1
numboccurax+x2+b,a,x,x2,b
5
numboccurax+x2+b,a,a,x,x2,b
6
numboccur1,3,2,3,3
See Also
has
ListTools:-Occurrences
Download Help Document