count occurrences of an expression - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Expressions : Structure : numboccur

numboccur - count occurrences of an expression

Calling Sequence

numboccur(f, x)

Parameters

f

-

expression

x

-

expression

Description

• 

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.

Thread Safety

• 

The numboccur command is thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

Examples

numboccurx3+x1,x

2

(1)

big_expr:=expandsin7x

big_expr:=64sinxcosx680sinxcosx4+24sinxcosx2sinx

(2)

numboccurbig_expr,sinx

4

(3)

numboccura+ba+b+1a+b+c,a+b

1

(4)

numboccurax+x2+b,a,x,x2,b

5

(5)

numboccurax+x2+b,a,a,x,x2,b

6

(6)

numboccur1,2,3,3,3

2

(7)

numboccur1,2,3,3,3

1

(8)

See Also

has


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam