GNU.WIKI: The GNU/Linux Knowledge Base

  [HOME] [PHP Manual] [HowTo] [ABS] [MAN1] [MAN2] [MAN3] [MAN4] [MAN5] [MAN6] [MAN7] [MAN8] [MAN9]

  [0-9] [Aa] [Bb] [Cc] [Dd] [Ee] [Ff] [Gg] [Hh] [Ii] [Jj] [Kk] [Ll] [Mm] [Nn] [Oo] [Pp] [Qq] [Rr] [Ss] [Tt] [Uu] [Vv] [Ww] [Xx] [Yy] [Zz]


NAME

       Math::Calculus::Differentiate - Algebraic Differentiation Engine

SYNOPSIS

         use Math::Calculus::Differentiate;

         # Create an object.
         my $exp = Math::Calculus::Differentiate->new;

         # Set a variable and expression.
         $exp->addVariable('x');
         $exp->setExpression('x^2 + 5*x') or die $exp->getError;

         # Differentiate and simplify.
         $exp->differentiate or die $exp->getError;;
         $exp->simplify or die $exp->getError;;

         # Print the result.
         print $exp->getExpression; # Prints 2*x + 5

DESCRIPTION

       This module can take an algebraic expression, parse it into a tree
       structure, modify the tree to give a representation of the
       differentiated function, simplify the tree and turn the tree back into
       an output of the same form as the input.

       It supports differentiation of expressions including the +, -, *, / and
       ^ (raise to power) operators, bracketed expressions to enable correct
       precedence and the functions ln, exp, sin, cos, tan, sec, cosec, cot,
       sinh, cosh, tanh, sech, cosech, coth, asin, acos, atan, asinh, acosh
       and atanh.

EXPORT

       None by default.

METHODS

       new
             $exp = Math::Calculus::Differentiate->new;

           Creates a new instance of the differentiation engine, which can
           hold an individual expression.

       addVariable
             $exp->addVariable('x');

           Sets a certain named value in the expression as being a variable. A
           named value must be an alphabetic chracter.

       setExpression
             $exp->setExpression('x^2 + 5*x);

           Takes an expression in human-readable form and stores it internally
           as a tree structure, checking it is a valid expression that the
           module can understand in the process. Note that the engine is
           strict about syntax. For example, note above that you must write
           5*x and not just 5x. Whitespace is allowed in the expression, but
           does not have any effect on precedence.  If you require control of
           precedence, use brackets; bracketed expressions will always be
           evaluated first, as you would normally expect. The module follows
           the BODMAS precedence convention. Returns undef on failure and a
           true value on success.

       getExpression
             $expr = $exp->getExpression;

           Returns a textaul, human readable representation of the expression
           that is being stored.

       differentiate
             $exp->differentiate('x');

           Differentiates the expression that was stored with setExpression
           with respect to the variable passed as a parameter. Returns undef
           on failure and a true value on success.

       simplify
             $exp->simplify;

           Attempts to simplify the expression that is stored internally. It
           is a very good idea to call this after calling differentiate, as
           the tree will often not be in the most compact possible form, and
           this will affect the readability of output from getExpression and
           the performance of future calls to differentiate if you are
           intending to obtain higher derivatives. Returns undef on failure
           and a true value on success.

       getTraceback
             $exp->getTraceback;

           When setExpression and differentiate are called, a traceback is
           generated to describe what these functions did. If an error occurs,
           this traceback can be extremely useful in helping track down the
           source of the error.

       getError
             $exp->getError;

           When any method other than getTraceback is called, the error
           message stored is cleared, and then any errors that occur during
           the execution of the method are stored. If failure occurs, call
           this method to get a textual representation of the error.

SEE ALSO

       The author of this module has a website at
       <http://www.jwcs.net/~jonathan/>, which has the latest news about the
       module and a web-based frontend to allow you to test the module out for
       yourself.

AUTHOR

       Jonathan Worthington, <jonathan@jwcs.net>

COPYRIGHT AND LICENSE

       Copyright (C) 2004 by Jonathan Worthington

       This library is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself, either Perl version 5.8.1 or, at
       your option, any later version of Perl 5 you may have available.

POD ERRORS

       Hey! The above document had some coding errors, which are explained
       below:

       Around line 55:
           '=item' outside of any '=over'

       Around line 150:
           You forgot a '=back' before '=head1'



  All copyrights belong to their respective owners. Other content (c) 2014-2018, GNU.WIKI. Please report site errors to webmaster@gnu.wiki.
Page load time: 0.185 seconds. Last modified: November 04 2018 12:49:43.