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.
numboccur⁡x3+x−1,x
2
big_expr≔expand⁡sin⁡7⁢x
big_expr≔64⁢sin⁡x⁢cos⁡x6−80⁢sin⁡x⁢cos⁡x4+24⁢sin⁡x⁢cos⁡x2−sin⁡x
numboccur⁡big_expr,sin⁡x
4
numboccur⁡a+b⁢a+b+1a+b+c,a+b
1
numboccur⁡a⁢x+x2+b,a,x,x2,b
5
numboccur⁡a⁢x+x2+b,a,a,x,x2,b
6
numboccur⁡1,3,2,3,3
See Also
has
ListTools:-Occurrences
Download Help Document