Math¶

Evaluates a mathematical expression

The action supports all common mathematical operators, parentheses, and a couple of functions that you would typically find in a scientific calculator.

• Input: Can be used in the Expression parameter
• Output: The calculated output

Parameters¶

• Expression: The mathematical expression to evaluate

For evaluating the expression, the DDMathParser library is used. Below is an overview of the supported operators and functions.

Some other actions that have numeric parameters (e.g. Extend Selection and Move Caret) support the same expressions as this action.

Operators¶

Operator Function Description
Standard Operators
`+` `add` addition and unary positive
`-` or `−` `subtract` and `negate` subtraction and negation
`*` or `×` `multiply` multiplication
`/` or `÷` `divide` division
`%` `mod` or `percent` modulus or a percentage of a value
`!` `factorial` factorial
`**` `pow` exponentiation
`º` or `°` `dtor` converts the value to radians
Bitwise Operators
`&` `and` bitwise and
`|` `or` bitwise or
`^` `xor` bitwise xor
`~` `not` bitwise not
`<<` `lshift` bitwise left shift
`>>` `rshift` bitwise right shift
Comparison Operators
`==` or `=` `l_eq` equal
`!=` `l_neq` not equal
`<` `l_lt` less than
`>` `l_gt` greater than
`<=` or `≤` `l_ltoe` less than or equal
`>=` or `≥` `l_gtoe` greater than or equal
Logical Operators
`&&` or `∧` `l_and` logical and
`||` or `∨` `l_or` logical or
`!` or `¬` `l_not` logical not

Functions¶

Functions that take > 1 parameter¶

• sum() - returns a sum of the passed parameters
• count() - returns the number of passed parameters
• min() - returns the minimum of the passed parameters
• max() - returns the maximum of the passed parameters
• median() - returns the median of the passed parameters
• stddev() - returns the standard deviation of the passed parameters
• average() - returns the average of the passed parameters
• random() - returns a random integer. Can take 0, 1, or 2 parameters. The first parameter (if given) is the lower bound of the random integer. The second parameter (if given) is the upper bound of the random integer.
• nthroot() - returns the n<sup>th</sup> root of a number. For example, nthroot(27,3) returns the cube root of 27, or 3.

Functions that take 1 parameter¶

• sqrt() - returns the square root of the passed parameter
• log() - returns the base 10 log of the passed parameter
• ln() - returns the base e log of the passed parameter
• log2() - returns the base 2 log of the passed parameter
• exp() - returns e raised to the power of the passed parameter
• ceil() - returns the passed parameter rounded up
• floor() - returns the passed parameter rounded down

Trigonometric functions¶

• sin(), cos(), tan()
• Their inverses (asin, acos, atan)
• Their reciprocals (csc, sec, cotan)
• The reciprocals of the inverses (acsc, asec, acotan)
• The hyperbolic variations of all the above functions (sinh, cosh, tanh, asinh, acosh, atanh, csch, sech, cotanh, acsch, asech, acotanh)
• The versine functions (versin, vercosin, coversin, covercosin, haversin, havercosin, hacoversin, hacovercosin, exsec, excsc, crd)
• dtor() - converts the passed parameter from degrees to radians
• rtod() - converts the passed parameter from radians to degrees

Functions that take no parameters (“constant functions”)¶

• phi() - returns the value of ϕ (the Golden Ratio). Also recognized as ϕ()
• pi() - returns the value of π. Also recognized as π()
• pi_2() - returns the value of π/2
• pi_4() - returns the value of π/4
• tau() - returns the value of τ. Also recognized as τ()
• sqrt2() - returns the value of the square root of 2
• e() - returns the value of e
• log2e() - returns the value of the log base 2 of e
• log10e() - returns the value of the log base 10 of e
• ln2() - returns the value of the log base e of 2
• ln10() - returns the value of the log base e of 10