Equation Syntax

Equations are mathematical expressions which can be evaluated to a single “real” magnitude. In pratice, its a lot easier than it sounds. Here’s an example:

Profit = quantity * ( price - cost )

This equation has a name of Profit. The definition of the equation (also referred to as expression) is everything that comes after the equals sign. The variables in this expression are quantity, price, and cost. Formulaic doesn’t care what you call your variables, or how many times you refer to them in your equations, or even how many variables you use. This equation uses two operators; * for multiplication, and - for subtraction. A full list is given below. The parentheses or brackets - ( and ) - are used to group sub-expressions; according to mathematical convention, expressions are evaluated left-to-right, but multiplication and division have a higher precedence, and are thus computed before addition or subtraction. Parentheses or brackets are used to change the default. If you’ve ever used a programming language like "C", all of this will look very familiar.

For details on the operators, functions and constants available in Formulaic, read on:

Formulaic Operators, lowest precendence first
OperatorSampleDescription
?a ? b : ctest - if a equals zero, use the value of c, otherwise use the value of b
+a + bplus - the sum of a and b
-a - bminus - subtract b from a
*a * btimes - multiply a by b
/a / bdivide - divide a by b
^a ^ bpower - a raised to the power of b
Formulaic Functions
FunctionDescription
sin(x)compute sine of angle x (which is given in radians)
cos(x)compute cosine of angle x (which is given in radians)
tan(x)compute tangent of angle x (which is given in radians)
asin(x)compute inverse sine of x
acos(x)compute inverse cosine of x
atan(x)compute inverse tangent of x
atan2(x,y)compute inverse tangent of y/x, with sign chosen for quadrant of (x,y)
exp(x)raise mathematical constant e to the power of x
log(x)compute natural logarithm of x
log10(x)compute base-10 logarithm of x
mod(x,y)compute remainder of the division of x by y with an integral quotient
ceil(x)round up x to the next integral value
floor(x)round down x to the next integral value
round(x)round x to the nearest integral value
max(x,y)return the greater of x and y
min(x,y)return the lesser of x and y
abs(x)return the absolute value of x
sqrt(x)return square root of x
cbrt(x)return cube root of x
hypot(x,y)return the value of sqrt(x*x + y*y)
Formulaic Constants
NameValue
E2.78...
PI3.14...
Copyright © 2008-2010 Hoy Moon Limited. All rights reserved.
All trademarks and registered trademarks are the property of their respective owners.