A formula can be any algebraic expression understood by the Emacs
Calc package. Note that calc has the
non-standard convention that ‘/’ has lower precedence than
‘*’, so that ‘a/b*c’ is interpreted as ‘a/(b*c)’. Before
evaluation by calc-eval (see calc-eval),
variable substitution takes place according to the rules described above.
The range vectors can be directly fed into the Calc vector functions
like ‘vmean’ and ‘vsum’.
A formula can contain an optional mode string after a semicolon. This
string consists of flags to influence Calc and other modes during
execution. By default, Org uses the standard Calc modes (precision
12, angular units degrees, fraction and symbolic modes off). The display
format, however, has been changed to (float 5) to keep tables
compact. The default settings can be configured using the variable
org-calc-default-modes.
p20 switch the internal precision to 20 digits n3 s3 e2 f4 normal, scientific, engineering, or fixed display format D R angle modes: degrees, radians F S fraction and symbolic modes N interpret all fields as numbers, use 0 for non-numbers T force text interpretation E keep empty fields in ranges
In addition, you may provide a printf format specifier to
reformat the final result. A few examples:
$1+$2 Sum of first and second field $1+$2;%.2f Same, format result to two decimals exp($2)+exp($1) Math functions can be used $0;%.1f Reformat current cell to 1 decimal ($3-32)*5/9 Degrees F -> C conversion $c/$1/$cm Hz -> cm conversion, using constants.el tan($1);Dp3s1 Compute in degrees, precision 3, display SCI 1 sin($1);Dp3%.1e Same, but use printf specifier for display vmean($2..$7) Compute column range mean, using vector function vmean($2..$7);EN Same, but treat empty fields as 0 taylor($3,x=7,2) taylor series of $3, at x=7, second degree
Calc also contains a complete set of logical operations. For example
if($1<20,teen,string("")) ``teen'' if age $1 less than 20, else empty