Calchemy Syntax

Basic Calchemy equations are of the form:

expression ? unit

Where expression is the arithmetic expression you want evaluated, and unit is the unit you want the result expressed in.


Operators and Precedence

Equations may contain the following binary operators (listed in decreasing order of precedence):
^   ... exponentiation
    ... implied multiplication
* / ... multiplication, division
+ - ... addition, subtraction
;   ... solve by dimensional analysis
All operators except "^" are left associative; "^" is right associative. "+" and "-" can also be used as high-precedence unary operators (sign).

Side-by-side operands (with no intervening punctuation) are evaluated with an implied multiplication. The precedence of the implied multiplication is just higher than that of "*" and "/".

Calchemy evaluates higher precedence operators before lower precedence operators. Left associative operators of the same precedence are evaluated from left to right; right associative operators of the same precedence are evaluated from right to left.

Parentheses, braces, or brackets can be used to explicitly override the default precedence. You can use the "Show Interpretations" function in Calchemy to find out exactly how Calchemy evaluated your equation.

When in doubt it is always best to parenthesize!
Precedence is very important and of course applies to units as well as numbers. Using parenthesis is an easy way to make sure you and Calchemy are speaking the same language.


Functions

Calchemy also supports the following high-precedence functions:
sqrt(x) ... square root of x
log(x   ... log base 10 of x
exp(x)  ... e to the x
ln(x)   ... natural log of x
sin(x)  ... sine of x (radians)
cos(x)  ... cosine of x (radians)
tan(x)  ... tangent of x (radians)
asn(x)  ... arc-sine (radians) of x
acs(x)  ... arc-cosine (radians) of x
atn(x)  ... arc-tangent (radians) of x
Note that the arguments to these functions should always be parenthesized to avoid precedence confusion.

The default base unit for trig and inverse-trig functions is the radian. To enter argument in or convert results to any other unit (e.g. degrees), you must explicitly specify the unit. For example:

sin(90 degrees)
The square root function can work on arguments with any dimensions with even exponents. Note also that "square root" is the same as exponentiation to the 1/2 power; similarly, "cube root" is the same as exponentiation to the 1/3 power. All other functions work only on dimensionless arguments and return dimensionless results.

Calchemy also understands the modifiers square and cubic to allow you to enter units in a more natural format. For example the following are both equivalent:

3 meters^2
3 square meters

Calchemy Software Inc.
Fort Collins, CO

[Calchemy Logo]

Last Updated 6/21/2009
© Copyright 1996-2009 Calchemy Software Inc.