Linear.V2:$cdot from linear-1.19.1.3, A

Percentage Accurate: 99.1% → 99.5%
Time: 1.7s
Alternatives: 4
Speedup: 2.3×

Specification

?
\[x \cdot y + z \cdot t \]

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Alternative 1: 99.5% accurate, 0.1× speedup?

\[\mathsf{fma}\left(x, y, z \cdot t\right) \]
Derivation
  1. Initial program 98.4%

    \[x \cdot y + z \cdot t \]
  2. Step-by-step derivation
    1. fma-def99.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right)} \]
  3. Simplified99.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right)} \]
  4. Final simplification99.2%

    \[\leadsto \mathsf{fma}\left(x, y, z \cdot t\right) \]

Alternative 2: 66.5% accurate, 0.6× speedup?

\[\begin{array}{l} \mathbf{if}\;t \leq -7.7 \cdot 10^{-84} \lor \neg \left(t \leq 7.8 \cdot 10^{-61}\right) \land \left(t \leq 2.3 \cdot 10^{+46} \lor \neg \left(t \leq 1.5 \cdot 10^{+133}\right)\right):\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if t < -7.7000000000000001e-84 or 7.80000000000000065e-61 < t < 2.3000000000000001e46 or 1.50000000000000003e133 < t

    1. Initial program 97.2%

      \[x \cdot y + z \cdot t \]
    2. Taylor expanded in x around 0 74.7%

      \[\leadsto \color{blue}{t \cdot z} \]

    if -7.7000000000000001e-84 < t < 7.80000000000000065e-61 or 2.3000000000000001e46 < t < 1.50000000000000003e133

    1. Initial program 100.0%

      \[x \cdot y + z \cdot t \]
    2. Taylor expanded in x around inf 71.9%

      \[\leadsto \color{blue}{y \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -7.7 \cdot 10^{-84} \lor \neg \left(t \leq 7.8 \cdot 10^{-61}\right) \land \left(t \leq 2.3 \cdot 10^{+46} \lor \neg \left(t \leq 1.5 \cdot 10^{+133}\right)\right):\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 3: 99.1% accurate, 1.0× speedup?

\[z \cdot t + x \cdot y \]
Derivation
  1. Initial program 98.4%

    \[x \cdot y + z \cdot t \]
  2. Final simplification98.4%

    \[\leadsto z \cdot t + x \cdot y \]

Alternative 4: 51.7% accurate, 2.3× speedup?

\[z \cdot t \]
Derivation
  1. Initial program 98.4%

    \[x \cdot y + z \cdot t \]
  2. Taylor expanded in x around 0 56.2%

    \[\leadsto \color{blue}{t \cdot z} \]
  3. Final simplification56.2%

    \[\leadsto z \cdot t \]

Reproduce

?
herbie shell --seed 2023167 
(FPCore (x y z t)
  :name "Linear.V2:$cdot from linear-1.19.1.3, A"
  :precision binary64
  (+ (* x y) (* z t)))