_  _ ____ ___ _  _    ___  ____ ___ ___ ____ ____ _  _    _  _ _  _ _  _ ___ ____ ____
|\/| |__|  |  |__|    |__] |__|  |   |  |___ |__/ |\ |    |__| |  | |\ |  |  |___ |__/
|  | |  |  |  |  |    |    |  |  |   |  |___ |  \ | \|    |  | |__| | \|  |  |___ |  \
Function Templates / Types:

When Math Pattern Hunter runs the program uses function templates, or types, to create potential matching functions. An example of this would be a number of rational functions multiplied together. This document describes the setup of the different types available to use when running the program and give examples of how to configure the options associated with each type. The templates / types in the program are defined in the source code file fntemplates-types.h. The following are the sections for this page:


Fn_Terms:

The fn_term type is the only type that is enabled by default. All of the other templates are based on this type. The fn_term type represents (mostly) rational functions, or at least functions that can be described by multiplied fractions and fractional exponents. The diagrams at this page are examples of fn_terms.

Each fn_term has a set of nodes and pointers to each of the three other fn_terms: the numerator (num_term), the denominator (denom_term), and the exponent (exp_term) (in the source code this type is setup as a linked-list-like structure). For a given depth, d, the maximum number of non-NULL fn_terms attached to a given start term is d. For example, if 1 <= d <= 2 the following templates will be generated by the program (the format of each fn_term is n/d*(given fn_term)^e):

f, n*f, 1/d*f, and f^e

The depth can be set by the "--depth" option (the default is two).

Each fn_term node is filled in with a function and variables for each of the function's indices. When evaluating the overall functions each node value is computed and placed in the overall formula to compute the value of the total fn_term (as opposed to the individual fn_terms at each node).

Fn_Term_Sums:

Fn_Term_Sums represent sums of fn_terms. For this type the depth option describes the maximum number of fn_terms that can be summed for a given fn_term_sum. The following example enables this type an sets the related parameters for it:

$ pattern_hunter {1,3,5,7} --use-fnterm-sums --fnterm-sum-max-depth 2
Fn_Term Linear Combos:
This type is used to describe linear combinations of fn_terms. It is possible to duplicate the functionality of the fn_term_sums with this type, so care should be used when chosing what types to run. The depth for this type is the maximum number of fn_terms that can be summed (with an appropriate constant multiplied) for a given linear combo. It is also possible to set the interval that the integer coefficients in the linear combos are generated from. The following example demonstrates how to enable this feature:


$ pattern_hunter {5,18,118,1550} --use-fnterm-linear-combos --fnterm-lc-max-depth 3 --fnterm-lc-coeff-start 2 --fnterm-lc-coeff-end 3
Fn_Term Multiplications:

The next type allows for multiplications of fn_terms. All of the forms of fn_terms that can be produced by enabling this type can be covered by fn_terms themselves with a higher depth setting. This type basically remains in the program since it has always been in the program (...). In this case the depth setting corresponds to the maximum number of fn_terms that can be multiplied together in a given fterm_multiply. The following demonstrates how to enable the type:

$ pattern_hunter {0,2,20,294} --depth 2 --use-fnterm-mult --fnterm-mult-max-depth 2
Fn_Term_Sum Multiplications:

This type should be considered experimental until it has been suficiently tested an debugged so that the segfaults arising from use of this type are far and few between.

That being noted, this type represents multiplications of fn_term_sums. The depth option for this type corresponds to the maximum number of fn_term_sums that can be multiplied together for a given object of this type. Note that since this type relies on another type (where that type is stacked against the fn_terms) the number of cases to check when brute-forcing through all potentially matching functions grows quickly. With this in mind a user should expect that a run of the Pattern Hunter including this type may run for hours, or days (this is also why this form has not been debugged to the point that the experimental label can be removed). The following gives an example of the usage:

$ pattern_hunter {0,9,36,81} --use-fts-mults --output-file all_night_run.txt --use-console-progress-bar
$ less -r all_night_run.txt
Fn_Term Linear Combos Multiplications (TODO):
Sum_Terms:

The last type gives an interesting form for matching functions. This type has the same properties as the fn_terms with the numerator fn_terms, and the denominator and exponent terms, except that instead of having a function to evaluate at each node, there is a fn_term_sum to evaluate at each node. The depth has the same meaning for this type as it did for the fn_terms. Note that this type will likely be more stable than some of the types with the experimental tag, but a considerable amount of testing still needs to be done to guarantee that use of this type will produce the results intended (...). As was the case for previous types, since this type depends on other intermediate types the number of cases to check will quickly grow large, so again expect that a test run could literally take days to complete. The following shows how to enable this type:

$ pattern_hunter {1/3,1/5,1/7,1/9} --use-sum-terms --sum-term-max-depth 3