Skip to main content
Skip table of contents

Exponential Variable Usage

Some formulas may result in an error like “Exponential variable usage detected on $x”. This generally results from an expression like

CODE
$i0 = $x.setUnits('')
$i1 = $i0 - ($i0 - 0.02) * constant.E^(0.2)
$i2 = $i1 - ($i1 - 0.02) * constant.E^(0.2)
$i3 = $i2 - ($i2 - 0.02) * constant.E^(0.2)
$i4 = $i3 - ($i3 - 0.02) * constant.E^(0.2)

In this case, $x is actually referenced 16 times (explained below).

Workaround

This kind of recursive or iterative expression doesn’t work well on time-series data. These calculations are best done in DataLab or an external ML system, not Seeq Formula.

Why is this happening?

This is a consequence of the design of Seeq Formula and the optimization to only calculate time series on-demand.

May programmers are familiar with language features that contrast pass-by-value vs pass-by-reference. In a pass-by-value language design an expression like

CODE
$a = $b + 2*$b

will compute the result of that expression and store its value in $a. Subsequent uses of $a don’t have to recompute anything because it passes the value to future uses. $b is only used twice.

Seeq Formula is more like compute-by-reference. There is no value stored in $a, only a reference to its underlying calculation. Each use of $a will compute its result relative to the desired time range.

It’s easier to understand when we think of when these variables referencing time series:

CODE
$a = $signal1 + $signal2
$b = $a + $a.move(2d)

$a isn’t a static value, it’s a description of what to do with $signal1 and $signal2. If your view range is Thursday, it needs a slice of each signal on Thursday for the first part of line 2, but then the move() needs a slice of the signals from Tuesday. This is why we can’t just store a value in $a.

Because these are references to calculations, the expression

CODE
$b = $a + $a + $a
return $b + $b + $b 

is going to fetch $a 9 times, 3 for each reference to $b

Now it’s possible to understand why the introductory formula uses $x 16 times: 2 for $i1, and $i2 uses $i1 twice, so $x is used 4 times. Then $i3 uses $i2 twice, so $x is used 8 times. And so on.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.