Chapter 12Appendix: Formula Functions
This appendix lists all operators, constants, and functions you can use in formulas (Chapter 7). The values in the "Example" columns are results calculated with the sample data sample_endurance_run_en.csv (0–599.9 s, every 0.1 s, 6000 points).
12.1Syntax rules
| Element | Syntax | Description |
|---|---|---|
| Number | 3, 0.25, 1e3, 2.5E-1 |
At most one decimal point. An exponent (e, E) must be followed by digits. Full-width digits cannot be used |
| Series (name) | `Current`, `Current|sample_endurance_run_en` |
Enclose in half-width backquotes |
| Series (symbol) | $1–$10 |
Assign series in Symbol–series mapping |
| Series (unenclosed name) | Base |
Only names that start with a half-width letter or _ and consist only of letters, digits, and _ |
| Time variable | x |
The X value of each point (described later) |
| Separator | , |
Separates function arguments |
| Whitespace | Spaces and line breaks in the expression are ignored |
- Write function names in lowercase.
SIN(x)gives an unknown function error. - The constants
PIandEare uppercase. If you writepi, it is looked up as a series name. - The following full-width and Japanese symbols are read as their half-width equivalents (not inside names enclosed in backquotes).
| Symbol written | Read as |
|---|---|
| ×, ✕, * | * |
| ÷, / | / |
| − (U+2212), - (full-width), –, — | - (the long vowel mark "ー" and the hyphen "‐" are not converted and become invalid characters) |
| ( ), ,, . | ( ), ,, . |
| √( | sqrt( |
12.2Operators
| Operator | Meaning | Example | Result |
|---|---|---|---|
+ - |
Addition, subtraction | 2+3*4 |
14 |
* / |
Multiplication, division | 7/2 |
3.5 |
^ |
Exponentiation | 2^-2 |
0.25 |
- (prefix) |
Negation | -2^2 |
−4 |
( ) |
Evaluates first | (2+3)*4 |
20 |
- The order of evaluation is exponentiation → negation → multiplication and division → addition and subtraction.
- Exponentiation is evaluated from right to left.
2^3^2is 2^9, which is 512. - Negation comes after exponentiation.
-2^2is −(2^2), which is −4, and(-2)^2is 4. Versions before 1.0.11 calculated-2^2as 4. If a saved formula has this form, a notice appears when you open LOGADEC (formulas that use movavg are notified in the same way that the calculation rules changed). - There is no remainder operator (
%). It gives an invalid character error.
12.3Constants and variables
| Name | Meaning | Example | Result |
|---|---|---|---|
PI |
Pi | sin(PI/2) |
1 |
E |
The base of the natural logarithm | log(E) |
1 |
x |
The X value of each point (in X-axis units) | x |
0–599.9 |
An expression that references no series (for example, sin(2*PI*x/60)) is calculated on the X of the data loaded on the screen. The status display shows "Ready (constants/functions only …)". It cannot be saved before data is loaded.
12.4Point-by-point functions
Calculated at each point. Arguments can be series, numbers, or expressions.
| Function | Meaning | Example | Result |
|---|---|---|---|
sqrt(a) |
Square root | sqrt(16) |
4 |
abs(a) |
Absolute value | abs(-3.5) |
3.5 |
log(a) |
Natural logarithm (base e). For the common logarithm, use log(a)/log(10) |
log(100) |
4.60517 |
exp(a) |
e to the power a | exp(1) |
2.71828 |
sin(a) cos(a) tan(a) |
Trigonometric functions (a in radians; for degrees, use a*PI/180) |
cos(PI) |
−1 |
pow(a, b) |
a to the power b (exactly two arguments) | pow(2, 10) |
1024 |
min(a, b, …) |
Point-by-point minimum (two or more arguments) | min(3, 1, 2) |
1 |
max(a, b, …) |
Point-by-point maximum (two or more arguments) | max(3, 1, 2) |
3 |
floor(a) |
To the smaller integer | floor(-2.5) |
−3 |
ceil(a) |
To the larger integer | ceil(-2.5) |
−2 |
round(a) |
To the nearest integer. Exactly half rounds toward the larger | round(2.5), round(-2.5) |
3, −2 |
sign(a) |
Sign (−1 for negative, 0 for 0, 1 for positive) | sign(-7) |
−1 |
- Points that cannot be calculated have no value (NaN). Examples:
sqrt(-1),log(-1),1/0. The graph line breaks there. minandmaxcompare point by point. For the minimum and maximum of a whole series, useminvalandmaxval. Example:max(`Current`, 15)sets points below 15 A to 15.
12.5Aggregate functions
Calculates one value from the whole series and puts the same value at every point. Write one series or expression as the argument.
| Function | Meaning | Example | Result |
|---|---|---|---|
mean(s) |
Mean | mean(`Oil temp`) |
71.8156 |
std(s) |
Standard deviation (divided by the number of points N) | std(`Current`) |
2.00724 |
sum(s) |
Sum | sum(`Current`) |
103944.097 |
minval(s) |
Minimum | minval(`Speed`) |
790.9 |
maxval(s) |
Maximum | maxval(`Speed`) - minval(`Speed`) |
2233.1 |
median(s) |
Median (with an even number of points, the mean of the middle two) | median(`Current`) |
17.0755 |
- Points without a value are excluded from the calculation.
- With X range, only points within the range are used.
- The argument can be an expression.
mean(`Current`*2)is 34.648.sum(1)gives the number of points (6000). - Common forms:
`Oil temp` - mean(`Oil temp`)(deviation from the mean),`Vibration RMS` / maxval(`Vibration RMS`)(normalize the maximum to 1).
12.6Time-series functions
Calculated using the points before and after.
| Function | Meaning | Example | Result |
|---|---|---|---|
diff(s) |
Derivative. (current value − previous value) ÷ (current X − previous X) | diff(`Speed`) |
−97 at 0.1 s (rpm/s) |
integ(s) |
Integral. Accumulates by the trapezoidal rule, with the first point as 0 | integ(`Power`) / 3600 |
38.825 at 599.9 s |
movavg(s, n) |
Moving average. The mean of the last n points including the current point | movavg(`Vibration RMS`, 10) |
0.2072 at 0.9 s |
shift(s, n) |
Shifts by n points. Positive n gives past values, negative n gives future values | shift(`Current`, 1) |
13.768 at 0.1 s (the value at 0 s) |
diff
- The unit is "the unit of the original series ÷ the X unit". If X is in seconds, it is the change per second.
- The first point has no value because there is no previous point.
- Points where X does not increase (the same time or a time going backward), and points where the point before or after has no value, have no value.
integ
- The unit is "the unit of the original series × the X unit". Integrating power (W) over seconds gives J. To get Wh, divide by 3600.
- The first point is 0.
- The following intervals are not added (the integral stays as it is and continues adding from the next interval).
- Intervals where either end has no value
- Intervals where the X spacing exceeds 1.5 times the step (the median interval)
- Intervals where X does not increase
movavg
- n is an integer of 1 or more, written as a number (series and decimals cannot be used). If omitted, it is 5.
- The first n−1 points have no value because not enough points are available.
- If any of the n points being averaged has no value, that point also has no value.
- Example:
movavg(`Current`)is a 5-point average; the value at 0.4 s is 14.0486, the mean of the 5 points from 0 to 0.4 s.
shift
- n is an integer, written as a number. If omitted, it is 1.
- Points that fall outside the data as a result of shifting have no value.
- Example:
`Speed` - shift(`Speed`, 1)is the difference from the adjacent point.
12.7Error messages
If the expression has an error, the reason appears in the status display, and the formula cannot be saved.
| Message | Cause and fix |
|---|---|
| Message about an invalid character | There is a character that cannot be used: a Japanese name not enclosed in backquotes, full-width digits, %, and so on |
| Message about an unknown function | The function name is wrong. Check that it is not written in uppercase |
| Message that (function name)() requires … arguments | The number of arguments is wrong. Examples: pow(2) (two required), min(1) (two or more required) |
| movavg needs n as a constant integer ≥ 1 | The n of movavg is a decimal, 0, a series, or similar |
| shift needs n as a constant integer | The n of shift is a decimal, a series, or similar |
| Message about an unclosed (backquote) | A backquote is not closed |
| Invalid number | A number is written incorrectly. Examples: 1.2.3, 1e+ |
| Syntax error message about an extra token | An operator is missing. Examples: 2 3, $11 |
| Message that $ must be followed by a number from 1 to 10 | The symbol number is wrong. Example: $0 |
| Series "…" was not found. Check the name. | There is no series or saved formula with that name. Check the name |
| Select the item for (symbol). | No series is assigned to a symbol used in the expression |
| Message about a circular reference | Formulas reference each other. This appears not in the status display while you type but when you try to save, and the formula is not saved |