Math::Symbolic::Custom::DefaultTests(3)

NAME
Math::Symbolic::Custom::DefaultTests - Default Math::Symbolic tree tests

SYNOPSIS
  use Math::Symbolic;

DESCRIPTION
This is a class of default tests for Math::Symbolic trees. Likewise, Math::Symbolic::Custom::DefaultMods defines default tree transformation routines. For details on how the custom method delegation model works, please have a look at the Math::Symbolic::Custom and Math::Symbolic::Custom::Base classes.

  EXPORT
Please see the docs for Math::Symbolic::Custom::Base for details, but you should not try to use the standard Exporter semantics with this class.

SUBROUTINES

  is_zero()
Returns true (1) of the tree is a constant and '0'. Returns false (0) otherwise.

  is_one()
Returns true (1) of the tree is a constant and '1'. Returns false (0) otherwise.

  is_zero_or_one()
Returns true ('1' for 1, '0E0' for 0) of the tree is a constant and '1' or '0'. Returns false (0) otherwise.

  is_integer()
is_integer() returns a boolean.

It returns true (1) if the tree is a constant object representing an integer value. It does not compute the value of the tree. (eg. '5*10' is not considered an integer, but '50' is.)

It returns false (0) otherwise.

  is_simple_constant()
is_simple_constant() returns a boolean.

It returns true if the tree consists of only constants and operators. As opposed to is_constant(), is_simple_constant() does not apply derivatives if necessary.

It returns false (0) otherwise.

  is_constant()
is_constant() returns a boolean.

It returns true (1) if the tree consists of only constants and operators or if it becomes a tree of only constants and operators after application of derivatives.

It returns false (0) otherwise.

If you need not pay the price of applying derivatives, you should use the is_simple_constant() method instead.

  is_identical()
is_identical() returns a boolean.

It compares the tree it is called on to its first argument. If the first argument is not a Math::Symbolic tree, it is sent through the parser.

is_identical() returns true (1) if the trees are completely identical. That includes operands of commutating operators having the same order, etc. This does not test of mathematical equivalence! (Which is much, much harder to test for. If you know how to, please let me know!)

It returns false (0) otherwise.

  is_identical_base
is_identical_base() returns a boolean.

It compares the tree it is called on to its first argument. If the first argument is not a Math::Symbolic tree, it is sent through the parser.

is_identical_base() returns true (1) if the trees are identical or if they are exponentiations with the same base. The same gotchas that apply to is_identical apply here, too.

For example, 'x*y' and '(x*y)^e' result in a true return value because 'x*y' is equal to '(x*y)^1' and this has the same base as '(x*y)^e'.

It returns false (0) otherwise.

  is_sum()
(beta)

is_constant() returns a boolean.

It returns true (1) if the tree contains no variables (because it can then be evaluated to a single constant which is a sum). It also returns true if it is a sum or difference of constants and variables. Furthermore, it is true for products of integers and constants because those products are really sums of variables. If none of the above cases match, it applies all derivatives and tries again.

It returns false (0) otherwise.

Please contact the author in case you encounter bugs in the specs or implementation. The heuristics aren't all that great.

  test_num_equiv()
Takes another Math::Symbolic tree or a code ref as first argument. Tests the tree it is called on and the one passed in as first argument for equivalence by sampling random numbers for their parameters and evaluating them.

This is no guarantee that the functions are actually similar. The computation required for this test may be very high for large numbers of tests.

In case of a subroutine reference passed in, the values of the parameters of the Math::Symbolic tree are passed to the sub ref sorted by the parameter names.

Following the test-tree, there may be various options as key/value pairs:

  limits: A hash reference with parameter names as keys and code refs
          as arguments. A code ref for parameter 'x', will be executed
          for every number of 'x' that is generated. If the code
          returns false, the number is discarded and regenerated.
  tests:  The number of tests to carry out. Default: 20
  epsilon: The accuracy of the numeric comparison. Default: 1e-7
  retries: The number of attempts to make if a function evaluation
           throws an error.
  upper:   Upper limit of the random numbers. Default: 10
  lower:   Lower limit of the random numbers. Default: -10

AUTHOR
Please send feedback, bug reports, and support requests to the Math::Symbolic support mailing list: math-symbolic-support at lists dot sourceforge dot net. Please consider letting us know how you use Math::Symbolic. Thank you.

If you're interested in helping with the development or extending the module's functionality, please contact the developers' mailing list: math-symbolic-develop at lists dot sourceforge dot net.

List of contributors:

  Steffen Mueller, symbolic-module at steffen-mueller dot net
  Stray Toaster, mwk at users dot sourceforge dot net
  Oliver Ebenhoeh

SEE ALSO
New versions of this module can be found on http://steffen-mueller.net or CPAN. The module development takes place on Sourceforge at http://sourceforge.net/projects/math-symbolic/

Math::Symbolic::Custom Math::Symbolic::Custom::DefaultDumpers Math::Symbolic::Custom::DefaultMods Math::Symbolic