compiletable - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


compiletable

create lookup table

tablelook

perform table lookup

insertpattern

append to lookup table

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

compiletable([pattern1=entry1, pattern2=entry2, ...])

tablelook(expr, pattree)

insertpattern(pattern=entry, pattree)

Parameters

pattern, pattern1, pattern2, ...

-

pattern to match

entry, entry1, entry2, ...

-

table entry corresponding to a pattern

expr

-

expression to be matched

pattree

-

pattern match tree returned by compiletable or insertpattern

Description

• 

The compiletable([pattern1=entry1, pattern2=entry2, ...]) calling sequence creates an efficient lookup table by merging patterns (with parameters) into a tree that the pattern matcher (tablelook command) can search in logarithmic time. For example, you can create an integration table in which each pattern is an integrand and the corresponding entry its integral.

  

Each table entry is of the form pattern=entry. For information on the format, see patmatch.

• 

The tablelook(expr, pattree) calling sequence compares expr to patterns in pattree. If tablelook finds a match, it returns the corresponding entry with parameter values substituted. Otherwise, it returns FAIL.

• 

The insertpattern(pattern=entry, pattree) calling sequence appends pattern=entry to the end of pattree.

Examples

tablna::radnum_X+b::radnum=lnax+bx+1alnax+bbx1ab,expa::radnum_X=1aexpax,expa::radnum_X2+b::radnum=12π12a12erfa12xexpb,cosa::radnum_X=1asinax,sina::radnum_X2=12212π12a12FresnelS212π12a12x,sina::radnum_X=1acosax,_X1+sin_X=xcosx+xtanx+lncosx+lnsecx+tanx,_X1sin_X=xcosx+xtanx+lncosxlnsecx+tanx,a::radnum_X+b::radnum=a2x2+bx,_X+a::radnum1=lnx+a,a::radnum_Xn::integer=an+1xn+1:

tabsubs_X=x::name,tab:

pcompiletabletab:

Now we can use the table:

tablelookcos2x,p

sin2x2

(1)

tablelookln2z,p

ln2zzz

(2)

tablelookexp2x23,p

π−2erf−2xⅇ−34

(3)

maptablelook,12x5+3x2x+1x+2,p

x612+x3x22+lnx+2

(4)

See Also

patmatch