Settings Help
CTAN
Comprehensive TeX Archive Network
Home Upload Browse

Direc­tory tex-archive/macros/latex/contrib/calculator

The calculator and calculus packages: Use \LaTeX as a scientific calculator.

Robert Fuster, 2012


1. Licence
----------
This material is subject to the LaTeX Project Public License. 

See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html 
for the details of that license.


2. About the packages
---------------------

The calculator and calculus packages define several instructions which allow us 
to realize algebraic operations and to evaluate elementary functions and derivatives
in our documents.

My main goal is to define the arithmetic and functional claculations I need in my 
package "xpicture" (http://www.upv.es/~rfuster/xpicture), but the numeric abilities
of "calculator" and "calculus" may be useful in other contexts.

2.1 The calculator package
--------------------------

The operations implemented by the calculator package include
- arithmetical calculations with  real and integer numbers 
- two and three dimensional vectors and matrices arithmetics 
- computation of powers, square roots, trigonometrical, exponential, logarithmic and 
  hyperbolic functions. 

In addition, some important numbers, such as pi, sqrt(2) or e, are predefined.

Some simple examples:

a) Simplify a fraction: if you type

   \FRACTIONSIMPLIFY{252}{2220}{\num}{\den}

    Then, $\num/\den$ equals to 21/186 

b) Compute elementary functions:

   \LOG{2}{\sol}  ---> \sol equals 0.69315

   \LOG[10]{2}{\sol} ---> \sol equals 0.30103

   \SIN{\numberHALFPI}{\sol} ---> \sol equals 1
 
c) More complex calculations:
   You can compute the value of sqrt(7.25)cos(pi/7) by typing

   \SQRT{7.25}{\tempa}
   \DIVIDE{\numberPI}{7}{\tempb}
   \COS{\tempb}{\tempc}
   \MULTIPLY{\tempa}{\tempa}{\sol}

   Then, the value 2.42589 is stored in \sol.

d) Vectors and matrices:

   \SCALARPRODUCT(1,2)(2,1){\sol}  ---> \sol equals 4

   \MATRIXPRODUCT(1,1;-1,2)(0,-1;1,1)(\sola,\solb;\solc,\sold)
        ---> \sola, \solb, \solc, \sold equals 1, 0, 2, 3.


2.2. The calculus package
-------------------------

This package adds to the calculator package several utilities to use and define 
real functions and their derivatives, including elementary functions, 
operations with functions, vector-valuated functions polar coordinates.
When you call a "function", this function ant its derivative are evaluated simultaneously.

Examples:

a) Predefined functions:

   \SINfunction{\numberPI}{\sol}{\Dsol} ---> 
                     \sol equals to 0 (=sin(pi)), and \Dsol equals -1 (=cos(pi)), 
                     because cos(t) is the derivative of sin(t).

b) Defining new functions: You can define the function f(t)=exp(2t)cos(t)-t 
with the following code:

   \SCALEVARIABLEfunction{2}{\EXPfunction}{\functionA}  % A=e^(2t)
   \MULTIPLY{\functionA}{\COSfunction}{\functionB}      % b=e^(2t)cos(t)
   \SUBTRACTfunction{\functionB}{\IDENTITYfunction}{\functionF} % My function

Then, \functionF{num}{\sol}{\Dsol} stores f(num) and f'(num) in \sol and \Dsol. 


3. Installation and documentation
---------------------------------

By compiling the source file "calculator.dtx" in the following sequence 

>> pdflatex calculator.dtx
>> makeindex -s gind.ist -o calculator.ind calculator.idx
>> makeindex -s gglo.ist -o calculator.gls calculator.glo
>> pdflatex calculator.dtx

several files will be generated:

 "calculator.sty" and "calculus.sty" (the packages). 
     Move these two files where LaTeX  search for (typically, in a local texmf tree, 
     at tex/latex/calculator) and refresh the file database.

 "calculator.pdf" (the user manual)

In addition, many small files, named "calculatorNN.tex" are generated.
These files contain the source code of all examples included in the manual.
You can store or discard this files.

---------------------------------------------------
Robert Fuster
rfuster@mat.upv.es

Universitat Polit\`ecnica de Val\`encia, 2012/05/19
---------------------------------------------------





   



Files

Name Size Date Notes
README 3947 2012-06-10 06:31:06
calculator.dtx 155581 2012-06-10 06:14:16
calculator.pdf 593617 2012-06-11 10:31:24

DOWNLOAD Down­load the com­plete con­tents of this di­rec­tory in one zip archive (558.1k).

cal­cu­la­tor – Use LaTeX as a sci­en­tific cal­cu­la­tor

The cal­cu­la­tor and cal­cu­lus pack­ages de­fine sev­eral in­struc­tions which al­low us to re­alise al­ge­braic op­er­a­tions and to eval­u­ate el­e­men­tary func­tions and deriva­tives in our doc­u­ments.
The pack­age’s main goal is to de­fine the arith­metic and func­tional cal­cu­la­tions need in the au­thor’s pack­age xpic­ture, but the nu­meric abil­i­ties of “cal­cu­la­tor” and “cal­cu­lus” may be use­ful in other con­texts.

Doc­u­men­ta­tion Readme
Pack­age doc­u­men­ta­tion
Home pagehttp://XXXX
Ver­sion1.0a
Li­censeThe LaTeX Project Public Li­cense 1.2
Copy­right2012 Robert Fuster
Main­tainerRobert Fuster
Con­tained inTeXLive as cal­cu­la­tor
MiKTeX as cal­cu­la­tor
Topics sup­port for type­set­ting math­e­mat­ics
Guest Book Sitemap Contact 2013-04-08 11:07