Department of Engineering

# Graham Treece

[ Introduction | Teaching | Research | Publications | Software | Videos | Personal ]

## Calc v1.3 Documentation

• Obtaining, installing and running Calc
• Program overview

• ### Obtaining, installing and running Calc

See the revisions page for the new features and fixes in this version.

Calc has been compiled for several environments. If none of the binary executables below are suitable for your platform, please e-mail me - since the software does not have a graphical front end, nor uses any special libraries, it is highly likely that it will compile successfully on your platform.

Once you have downloaded the executable, unzip it using gunzip (except for the Windows executable) - there is only a single file, which does not need a parameter file nor any environment variables. All options are passed to the program as command line parameters.

Please note that Calc is a research tool, and is intended for research / personal use only. Whilst the author would like to think it is fairly well written, it comes with no reliability guarantees - use at your own risk!

### Program overview

The equation to be evaluated is supplied as a text string argument, which can contain logarithmic and trigonometric functions (including 'pi'), standard operations ('+', '-', '*', '/' and '^' for powers) and brackets. Numbers are in floating point format, i.e. -0.001 can be entered as '-0.001' or '-1e-3'. This string is first parsed to ensure priority is given to more important operators, by inserting additional brackets. For instance, the string '-x^2-(y+1)^2-z/3*10' would be replaced by '(((-x)^2)-((y+1)^2))-((z/3)*10)'. This ensures that the actual evaluation of the equation, which runs forwards through the string, will work correctly, i.e. 1-1-1 = (1-1)-1 = -1, rather than 1-1-1 = 1-(1-1) = 1.

Spaces are ignored by the program, with the exception that the equation must be supplied as a single argument (i.e. if spaces are required, enclose the entire equation in quotation marks). Trigonometric and logarithmic functions can be supplied in upper or lower case.

The output of the program is the string with additional spaces removed and brackets inserted, followed by the evaluation of the equation. For example, the input:

calc "COS(10.2*Pi + 2.3)^2 + ln(1.1e-2)"

produces the output:

(cos((10.2*pi)+2.3)^2)+ln(1.1e-2) = -3.55466037248

 | Search | CUED | Cambridge University | © 2005 Cambridge University Engineering Dept and Graham Treece . Information provided by gmt11