%%
%% This is file `calculus.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% calculator.dtx  (with options: `calculus')
%% ------------------------------------------------------------------
%% The calculator and calculus packages
%% Copyright (C) 2012 by Robert Fuster <rfuster@mat.upv.es>
%% All rights reserved
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in:
%% 
%%     http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%% ------------------------------------------------------------------
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}




\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{calculus}
   [2012/06/10 v.1.0a]
\RequirePackage{calculator}
\def\ccls@ErrorFuncDef#1{%
      \PackageError{calculus}%
        {\noexpand#1 command already defined}
        {The \noexpand#1 control sequence is already defined\MessageBreak
         If you want to redefine the \noexpand#1 command as a
         function\MessageBreak
         please, use the \noexpand\renewfunction command}}
\def\ccls@ErrorFuncUnDef#1{%
      \PackageError{calculus}%
        {\noexpand#1 command undefined}
        {The \noexpand#1 control sequence is not currently defined\MessageBreak
         If you want to define the \noexpand#1 command as a function\MessageBreak
         please, use the \noexpand\newfunction command}}
\def\ccls@InfoFuncEns#1{%
      \PackageInfo{calculus}%
      {\noexpand#1 command already defined\MessageBreak
       the \noexpand\ensurefunction command will not redefine it}}
\def\ccls@ErrorPFuncDef#1{%
      \PackageError{calculus}%
        {\noexpand#1 command already defined}
        {The \noexpand#1 control sequence is already defined\MessageBreak
         If you want to redefine the \noexpand#1
         command as a polar function\MessageBreak
         please, use the \noexpand\renewpolarfunction command}}

\def\ccls@ErrorPFuncUnDef#1{%
      \PackageError{calculus}%
        {\noexpand#1 command undefined}
        {The \noexpand#1 control sequence
         is not currently defined.\MessageBreak
         If you want to define the \noexpand#1 command as a polar
         function\MessageBreak
         please, use the \noexpand\newpolarfunction command}}

\def\ccls@InfoPFuncEns#1{%
      \PackageInfo{calculus}%
      {\noexpand#1 command already defined\MessageBreak
       the \noexpand\ensurepolarfunction command does not redefine it}}
\def\ccls@ErrorVFuncDef#1{%
      \PackageError{calculus}%
        {\noexpand#1 command already defined}
        {The \noexpand#1 control sequence is already defined\MessageBreak
         If you want to redefine the \noexpand#1 command as a vector
         function\MessageBreak
         please, use the \noexpand\renewvectorfunction command}}

\def\ccls@ErrorVFuncUnDef#1{%
      \PackageError{calculus}%
        {\noexpand#1 command undefined}
        {The \noexpand#1 control sequence is not currently
         defined.\MessageBreak
         If you want to define the \noexpand#1 command as a vector
         function\MessageBreak
         please, use the \noexpand\newvectorfunction command}}

\def\ccls@InfoVFuncEns#1{%
      \PackageInfo{calculus}%
      {\noexpand#1 command already defined\MessageBreak
       the \noexpand\ensurevectorfunction command does not redefine it}}
\def\newfunction#1#2{%
       \ifx #1\undefined
         \ccls@deffunction{#1}{#2}
       \else
          \ccls@ErrorFuncDef{#1}
       \fi}
\def\renewfunction#1#2{%
       \ifx #1\undefined
          \ccls@ErrorFuncUnDef{#1}
       \else
          \ccls@deffunction{#1}{#2}
       \fi}
\def\ensurefunction#1#2{%
       \ifx #1\undefined\ccls@deffunction{#1}{#2}
       \else
          \ccls@InfoFuncEns{#1}
       \fi}
\def\forcefunction#1#2{%
       \ccls@deffunction{#1}{#2}}
\def\ccls@deffunction#1#2{%
    \def#1##1##2##3{%
             \begingroup
             \def\t{##1}%
                  #2
                 \xdef##2{\y}%
                 \xdef##3{\Dy}%
             \endgroup}\ignorespaces}
\def\newpolarfunction#1#2{%
       \ifx #1\undefined
         \ccls@defpolarfunction{#1}{#2}
       \else
          \ccls@ErrorPFuncDef{#1}
       \fi}
\def\renewpolarfunction#1#2{%
       \ifx #1\undefined
          \ccls@ErrorPFuncUnDef{#1}
       \else
          \ccls@defpolarfunction{#1}{#2}
       \fi}
\def\ensurepolarfunction#1#2{%
       \ifx #1\undefined\ccls@defpolarfunction{#1}{#2}
       \else
          \ccls@InfoPFuncEns{#1}
       \fi}
\def\forcepolarfunction#1#2{%
       \ccls@defpolarfunction{#1}{#2}}
\def\ccls@defpolarfunction#1#2{%
       \def#1##1##2##3##4##5{%
       \begingroup
         \def\t{##1}
       #2
       \COS{\t}\ccls@cost
       \MULTIPLY\r\ccls@cost{\x}
       \SIN{\t}\ccls@sint
       \MULTIPLY\r\ccls@sint{\y}
       \MULTIPLY\ccls@cost\Dr\Dx
       \SUBTRACT{\Dx}{\y}{\Dx}
       \MULTIPLY\ccls@sint\Dr\Dy
       \ADD{\Dy}{\x}{\Dy}
       \xdef##2{\x}
       \xdef##3{\Dx}
       \xdef##4{\y}
       \xdef##5{\Dy}
       \endgroup}\ignorespaces}
\def\newvectorfunction#1#2{%
       \ifx #1\undefined
         \ccls@defvectorfunction{#1}{#2}
       \else
          \ccls@ErrorVFuncDef{#1}
       \fi}
\def\renewvectorfunction#1#2{%
       \ifx #1\undefined
          \ccls@ErrorVFuncUnDef{#1}
       \else
          \ccls@defvectorfunction{#1}{#2}
       \fi}
\def\ensurevectorfunction#1#2{%
       \ifx #1\undefined\ccls@defvectorfunction{#1}{#2}
       \else
          \ccls@InfoVFuncEns{#1}
       \fi}
\def\forcevectorfunction#1#2{%
       \ccls@defvectorfunction{#1}{#2}}
\def\ccls@defvectorfunction#1#2{%
       \def#1##1##2##3##4##5{%
       \begingroup
         \def\t{##1}
       #2
       \xdef##2{\x}
       \xdef##3{\Dx}
       \xdef##4{\y}
       \xdef##5{\Dy}
       \endgroup}\ignorespaces}
\def\newlpoly#1#2#3{%
    \newfunction{#1}{%
        \ccls@lpoly{#2}{#3}}}
\def\renewlpoly#1#2#3{%
    \renewfunction{#1}{%
        \ccls@lpoly{#2}{#3}}}
\def\ensurelpoly#1#2#3{%
    \ensurefunction{#1}{%
        \ccls@lpoly{#2}{#3}}}
\def\forcelpoly#1#2#3{%
    \forcefunction{#1}{%
        \ccls@lpoly{#2}{#3}}}
\def\ccls@lpoly#1#2{%
        \MULTIPLY{#2}{\t}{\y}
        \ADD{\y}{#1}{\y}
        \COPY{#2}{\Dy}}
\def\newqpoly#1#2#3#4{%
    \newfunction{#1}{%
        \ccls@qpoly{#2}{#3}{#4}}}
\def\renewqpoly#1#2#3#4{%
    \renewfunction{#1}{%
        \ccls@qpoly{#2}{#3}{#4}}}
\def\ensureqpoly#1#2#3#4{%
    \ensurefunction{#1}{%
        \ccls@qpoly{#2}{#3}{#4}}}
\def\forceqpoly#1#2#3#4{%
    \forcefunction{#1}{%
        \ccls@qpoly{#2}{#3}{#4}}}
\def\ccls@qpoly#1#2#3{%
        \MULTIPLY{\t}{#3}{\y}
           \MULTIPLY{2}{\y}{\Dy}
           \ADD{#2}{\Dy}{\Dy}
        \ADD{#2}{\y}{\y}
        \MULTIPLY{\t}{\y}{\y}
        \ADD{#1}{\y}{\y}}
\def\newcpoly#1#2#3#4#5{%
    \newfunction{#1}{%
        \ccls@cpoly{#2}{#3}{#4}{#5}}}
\def\renewcpoly#1#2#3#4#5{%
    \renewfunction{#1}{%
        \ccls@cpoly{#2}{#3}{#4}{#5}}}
\def\ensurecpoly#1#2#3#4#5{%
    \ensurefunction{#1}{%
        \ccls@cpoly{#2}{#3}{#4}{#5}}}
\def\forcecpoly#1#2#3#4#5{%
    \forcefunction{#1}{%
        \ccls@cpoly{#2}{#3}{#4}{#5}}}
\def\ccls@cpoly#1#2#3#4{%
        \MULTIPLY{\t}{#4}{\y}
           \MULTIPLY{3}{\y}{\Dy}
        \ADD{#3}{\y}{\y}
           \MULTIPLY{2}{#3}{\ccls@temp}
           \ADD{\ccls@temp}{\Dy}{\Dy}
        \MULTIPLY{\t}{\y}{\y}
           \MULTIPLY{\t}{\Dy}{\Dy}
        \ADD{#2}{\y}{\y}
           \ADD{#2}{\Dy}{\Dy}
        \MULTIPLY{\t}{\y}{\y}
        \ADD{#1}{\y}{\y}
        }
\newfunction{\ONEfunction}{%
      \COPY{1}{\y}
      \COPY{0}{\Dy}}
\newfunction{\ZEROfunction}{%
      \COPY{0}{\y}
      \COPY{0}{\Dy}}
\newfunction{\IDENTITYfunction}{%
      \COPY{\t}{\y}
      \COPY{1}{\Dy}}
\newfunction{\RECIPROCALfunction}{%
      \DIVIDE{1}{\t}{\y}
      \SQUARE{\y}{\Dy}
      \MULTIPLY{-1}{\Dy}{\Dy}}
\newfunction{\SQUAREfunction}{%
      \SQUARE{\t}{\y}
      \MULTIPLY{2}{\t}{\Dy}}
\newfunction{\CUBEfunction}{%
      \SQUARE{\t}{\Dy}
      \MULTIPLY{\t}{\Dy}{\y}
      \MULTIPLY{3}{\Dy}{\Dy}}
\newfunction{\SQRTfunction}{%
      \SQRT{\t}{\y}
      \DIVIDE{0.5}{\y}{\Dy}}
\newfunction{\EXPfunction}{%
     \EXP{\t}{\y}
     \COPY{\y}{\Dy}}
\newfunction{\COSfunction}{%
     \COS{\t}{\y}
     \SIN{\t}{\Dy}
     \MULTIPLY{-1}{\Dy}{\Dy}}
\newfunction{\SINfunction}{%
     \SIN{\t}{\y}
     \COS{\t}{\Dy}}
\newfunction{\TANfunction}{%
     \TAN{\t}{\y}
     \COS{\t}{\Dy}
     \SQUARE{\Dy}{\Dy}
     \DIVIDE{1}{\Dy}{\Dy}}
\newfunction{\COTfunction}{%
     \COTAN{\t}{\y}
     \SIN{\t}{\Dy}
     \SQUARE{\Dy}{\Dy}
     \DIVIDE{-1}{\Dy}{\Dy}}
\newfunction{\COSHfunction}{%
     \COSH{\t}{\y}
     \SINH{\t}{\Dy}}
\newfunction{\SINHfunction}{%
     \SINH{\t}{\y}
     \COSH{\t}{\Dy}}
\newfunction{\TANHfunction}{%
     \TANH{\t}{\y}
     \COSH{\t}{\Dy}
     \SQUARE{\Dy}{\Dy}
     \DIVIDE{1}{\Dy}{\Dy}}
\newfunction{\COTHfunction}{%
     \COTANH{\t}{\y}
     \SINH{\t}{\Dy}
     \SQUARE{\Dy}{\Dy}
     \DIVIDE{-1}{\Dy}{\Dy}}
\newfunction{\LOGfunction}{%
     \LOG{\t}{\y}
     \DIVIDE{1}{\t}{\Dy}}
\newfunction{\HEAVISIDEfunction}{%
     \ifdim \t\p@<\z@ \COPY{0}{\y}\else\COPY{1}{\y}\fi
      \COPY{0}{\Dy}}
\def\CONSTANTfunction#1#2{%
              \def#2##1##2##3{%
                          \xdef##2{#1}%
                          \xdef##3{0}}}
\def\SUMfunction#1#2#3{%
            \def#3##1##2##3{%
             \begingroup
                    #1{##1}{\ccls@SUMf}{\ccls@SUMDf}%
                    #2{##1}{\ccls@SUMg}{\ccls@SUMDg}%
                    \ADD{\ccls@SUMf}{\ccls@SUMg}{\ccls@SUMfg}
                    \ADD{\ccls@SUMDf}{\ccls@SUMDg}{\ccls@SUMDfg}
                         \xdef##2{\ccls@SUMfg}%
                         \xdef##3{\ccls@SUMDfg}%
             \endgroup}\ignorespaces}
\def\SUBTRACTfunction#1#2#3{%
            \def#3##1##2##3{%
             \begingroup
                    #1{##1}{\ccls@SUBf}{\ccls@SUBDf}%
                    #2{##1}{\ccls@SUBg}{\ccls@SUBDg}%
                    \SUBTRACT{\ccls@SUBf}{\ccls@SUBg}{\ccls@SUBfg}
                    \SUBTRACT{\ccls@SUBDf}{\ccls@SUBDg}{\ccls@SUBDfg}
                         \xdef##2{\ccls@SUBfg}%
                         \xdef##3{\ccls@SUBDfg}%
             \endgroup}\ignorespaces}
\def\PRODUCTfunction#1#2#3{%
            \def#3##1##2##3{%
             \begingroup
                    #1{##1}{\ccls@PROf}{\ccls@PRODf}%
                    #2{##1}{\ccls@PROg}{\ccls@PRODg}%
                    \MULTIPLY{\ccls@PROf}{\ccls@PROg}{\ccls@PROfg}
                    \MULTIPLY{\ccls@PROf}{\ccls@PRODg}{\ccls@PROfDg}
                    \MULTIPLY{\ccls@PRODf}{\ccls@PROg}{\ccls@PRODfg}
                    \ADD{\ccls@PROfDg}{\ccls@PRODfg}{\ccls@PRODfg}
                         \xdef##2{\ccls@PROfg}%
                         \xdef##3{\ccls@PRODfg}%
             \endgroup}\ignorespaces}
\def\QUOTIENTfunction#1#2#3{%
            \def#3##1##2##3{%
             \begingroup
                    #1{##1}{\ccls@QUOf}{\ccls@QUODf}%
                    #2{##1}{\ccls@QUOg}{\ccls@QUODg}%
                    \DIVIDE{\ccls@QUOf}{\ccls@QUOg}{\ccls@QUOfg}
                    \MULTIPLY{\ccls@QUOf}{\ccls@QUODg}{\ccls@QUOfDg}
                    \MULTIPLY{\ccls@QUODf}{\ccls@QUOg}{\ccls@QUODfg}
                    \SUBTRACT{\ccls@QUODfg}{\ccls@QUOfDg}{\ccls@QUOnum}
                    \SQUARE{\ccls@QUOg}{\ccls@qsquaretempg}
                    \DIVIDE{\ccls@QUOnum}{\ccls@qsquaretempg}{\ccls@QUODfg}
                         \xdef##2{\ccls@QUOfg}%
                         \xdef##3{\ccls@QUODfg}%
             \endgroup}\ignorespaces}
\def\COMPOSITIONfunction#1#2#3{%  #3=#1(#2)
            \def#3##1##2##3{%
             \begingroup
                    #2{##1}{\ccls@COMg}{\ccls@COMDg}%
                    #1{\ccls@COMg}{\ccls@COMf}{\ccls@COMDf}%
                    \MULTIPLY{\ccls@COMDg}{\ccls@COMDf}{\ccls@COMDf}
                         \xdef##2{\ccls@COMf}%
                         \xdef##3{\ccls@COMDf}%
             \endgroup}\ignorespaces}
\def\SCALEfunction#1#2#3{%
            \def#3##1##2##3{%
             \begingroup
                    #2{##1}{\ccls@SCFf}{\ccls@SCFDf}%
                    \MULTIPLY{#1}{\ccls@SCFf}{\ccls@SCFaf}
                    \MULTIPLY{#1}{\ccls@SCFDf}{\ccls@SCFDaf}
                         \xdef##2{\ccls@SCFaf}%
                         \xdef##3{\ccls@SCFDaf}%
             \endgroup}\ignorespaces}
\def\SCALEVARIABLEfunction#1#2#3{%
            \def#3##1##2##3{%
             \begingroup%
                    \MULTIPLY{#1}{##1}{\ccls@SCVat}
                    #2{\ccls@SCVat}{\ccls@SCVf}{\ccls@SCVDf}%
                    \MULTIPLY{#1}{\ccls@SCVDf}{\ccls@SCVDf}
                         \xdef##2{\ccls@SCVf}%
                         \xdef##3{\ccls@SCVDf}%
             \endgroup}\ignorespaces}
\def\POWERfunction#1#2#3{%
            \def#3##1##2##3{%
             \begingroup
                    #1{##1}{\ccls@POWf}{\ccls@POWDf}%
                    \POWER{\ccls@POWf}{#2}{\ccls@POWfn}
                   \SUBTRACT{#2}{1}{\ccls@nminusone}
                   \POWER{\ccls@POWf}{\ccls@nminusone}{\ccls@POWDfn}
                  \MULTIPLY{#2}{\ccls@POWDfn}{\ccls@POWDfn}
                  \MULTIPLY{\ccls@POWDfn}{\ccls@POWDf}{\ccls@POWDfn}
                         \xdef##2{\ccls@POWfn}%
                         \xdef##3{\ccls@POWDfn}%
             \endgroup}\ignorespaces}

\def\LINEARCOMBINATIONfunction#1#2#3#4#5{%
            \def#5##1##2##3{%
             \begingroup
                    #2{##1}{\ccls@LINf}{\ccls@LINDf}%
                    #4{##1}{\ccls@LINg}{\ccls@LINDg}%
                    \MULTIPLY{#1}{\ccls@LINf}{\ccls@LINf}
                    \MULTIPLY{#3}{\ccls@LINg}{\ccls@LINg}
                    \MULTIPLY{#1}{\ccls@LINDf}{\ccls@LINDf}
                    \MULTIPLY{#3}{\ccls@LINDg}{\ccls@LINDg}
                    \ADD{\ccls@LINf}{\ccls@LINg}{\ccls@LINafbg}
                    \ADD{\ccls@LINDf}{\ccls@LINDg}{\ccls@LINDafbg}
                         \xdef##2{\ccls@LINafbg}%
                         \xdef##3{\ccls@LINDafbg}%
             \endgroup}\ignorespaces}
\def\POLARfunction#1#2{%
       \PRODUCTfunction{#1}{\COSfunction}{\ccls@polarx}
       \PRODUCTfunction{#1}{\SINfunction}{\ccls@polary}
       \PARAMETRICfunction{\ccls@polarx}{\ccls@polary}{#2}}
\def\PARAMETRICfunction#1#2#3{%
       \def#3##1##2##3##4##5{%
                #1{##1}{##2}{##3}
                #2{##1}{##4}{##5}}}
\let\VECTORfunction\PARAMETRICfunction
%% 
%%
%% End of file `calculus.sty'.
