Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B

Percentage Accurate: 99.9% → 99.9%
Time: 4.1s
Alternatives: 6
Speedup: TODO×

Specification

?
\[\frac{\left(x + y\right) - z}{t \cdot 2} \]

Your Program's Arguments

Results

Enter valid numbers for all inputs

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 6 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?

\[\frac{\left(x + y\right) - z}{t \cdot 2} \]
Derivation
  1. Initial program 100.0%

    \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
  2. Final simplification100.0%

    \[\leadsto \frac{\left(x + y\right) - z}{t \cdot 2} \]

Alternative 2?

\[\begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{+159} \lor \neg \left(z \leq -5.6 \cdot 10^{+75}\right) \land \left(z \leq -7.1 \cdot 10^{+28} \lor \neg \left(z \leq 2.9 \cdot 10^{+170}\right)\right):\\ \;\;\;\;\frac{z}{t} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if z < -2.90000000000000014e159 or -5.60000000000000023e75 < z < -7.0999999999999999e28 or 2.9000000000000001e170 < z

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in z around inf 87.1%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{t}} \]
    3. Step-by-step derivation
      1. *-commutative87.1%

        \[\leadsto \color{blue}{\frac{z}{t} \cdot -0.5} \]
    4. Simplified87.1%

      \[\leadsto \color{blue}{\frac{z}{t} \cdot -0.5} \]

    if -2.90000000000000014e159 < z < -5.60000000000000023e75 or -7.0999999999999999e28 < z < 2.9000000000000001e170

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in z around 0 86.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{y + x}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{+159} \lor \neg \left(z \leq -5.6 \cdot 10^{+75}\right) \land \left(z \leq -7.1 \cdot 10^{+28} \lor \neg \left(z \leq 2.9 \cdot 10^{+170}\right)\right):\\ \;\;\;\;\frac{z}{t} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \end{array} \]

Alternative 3?

\[\begin{array}{l} t_1 := \frac{z}{t} \cdot -0.5\\ t_2 := 0.5 \cdot \frac{x}{t}\\ \mathbf{if}\;y \leq -8 \cdot 10^{-262}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-294}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-233}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if y < -8.0000000000000001e-262 or 2.7000000000000001e-294 < y < 6.49999999999999989e-233

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in x around inf 47.4%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t}} \]

    if -8.0000000000000001e-262 < y < 2.7000000000000001e-294 or 6.49999999999999989e-233 < y < 1.5e39

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in z around inf 57.1%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{t}} \]
    3. Step-by-step derivation
      1. *-commutative57.1%

        \[\leadsto \color{blue}{\frac{z}{t} \cdot -0.5} \]
    4. Simplified57.1%

      \[\leadsto \color{blue}{\frac{z}{t} \cdot -0.5} \]

    if 1.5e39 < y

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in y around inf 74.5%

      \[\leadsto \color{blue}{0.5 \cdot \frac{y}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification55.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{-262}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-294}:\\ \;\;\;\;\frac{z}{t} \cdot -0.5\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-233}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+39}:\\ \;\;\;\;\frac{z}{t} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]

Alternative 4?

\[\begin{array}{l} \mathbf{if}\;y \leq 3.9 \cdot 10^{+15}:\\ \;\;\;\;0.5 \cdot \frac{x - z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if y < 3.9e15

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in y around 0 79.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x - z}{t}} \]

    if 3.9e15 < y

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in z around 0 92.3%

      \[\leadsto \color{blue}{0.5 \cdot \frac{y + x}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.9 \cdot 10^{+15}:\\ \;\;\;\;0.5 \cdot \frac{x - z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \end{array} \]

Alternative 5?

\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+47}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -2.79999999999999988e47

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in x around inf 58.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t}} \]

    if -2.79999999999999988e47 < x

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in y around inf 40.1%

      \[\leadsto \color{blue}{0.5 \cdot \frac{y}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+47}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]

Alternative 6?

\[0.5 \cdot \frac{x}{t} \]
Derivation
  1. Initial program 100.0%

    \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
  2. Taylor expanded in x around inf 42.8%

    \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t}} \]
  3. Final simplification42.8%

    \[\leadsto 0.5 \cdot \frac{x}{t} \]

Reproduce

?
herbie shell --seed 2023166 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
  :precision binary64
  (/ (- (+ x y) z) (* t 2.0)))