Adding the optional parameter, implicitmultiply, or implicitmultiply=true will cause the parser to interpret some situations as implied multiplication.
•
|
An explicit space, such as in the expressions "2 x", or "x y", or "x 2", or "(x+4) y", is interpreted by Parse as multiplication.
|
•
|
A number followed by a variable or open parenthesis with no space, such as "2x", or "2(x-4)" is interpreted as multiplication between the number and subsequent expression.
|
•
|
Two back-to-back expressions surrounded by parentheses, such as "(x-1)(x+1)" is interpreted as multiplication between expressions.
|
•
|
Multi-letter variable names, if not otherwise specified by either the names or corenames options are interpreted as single letter variables multiplied together. Thus "xy" is parsed as "x*y", but "norm(x)" is also interpreted as "n*o*r*m*x".
|
The names option lets you specify which additional variable and function names should be accepted as a single entity. The additional names should be combined in set brackets, { } and denoted as strings. Calling Parse("norm(x)",implicitmultiply,names={"norm"}) will now be interpreted as a single function call, %norm(x) as opposed to multiplication of single-letter variables as in the previous paragraph.
names="all" can be used to specify that all multi-letter names should be interpreted as single entities instead of a multiplication of single-letter variables.
The corenames option works in conjunction with the names option to build a complete list of recognized multi-letter names. The union of corenames and names constitutes the full set of recognized names. corenames is predefined to include standard special functions like sin, cos, log, and Pi. For a complete definition, execute Describe(InertForm:-Parse).
By setting corenames={} you can override and eliminate all known names.
There is some ambiguity in identifying which names should be kept in the expression. Consider the case where expr = phi2, and names = {phi,phi2}. This could be interpreted as `%*`(phi,2) or as phi2. This command will return the latter. It matches the longest names first.
Related to names and corenames, the variables option lets you specify additional names that should always be treated as variables. For example, "x(y+1)" is normally interpreted as the function x called with arguments y+1. The other interpretation would be x multiplied by y+1. By specifying x in the set of variables, it will not be interpreted as a function name. See Describe(InertForm:-Parse) for the default list of variables (which includes x).
When implicitmultiply is enabled, the input should be restricted to mathematical expressions. Constructs like procedures and modules are not supported, and will likely trigger a syntax error.