Average Error: 5.9 → 1.0
Time: 1.1m
Precision: 64
Internal Precision: 384
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.6525860513176112 \cdot 10^{-34}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{if}\;a \le 6.557080249188682 \cdot 10^{-33}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{y}{a} \cdot z + \frac{y}{a} \cdot \left(-t\right)\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original5.9
Target0.7
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;y \lt -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{if}\;y \lt 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if a < -1.6525860513176112e-34

    1. Initial program 8.8

      \[x - \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied associate-/l*0.6

      \[\leadsto x - \color{blue}{\frac{y}{\frac{a}{z - t}}}\]

    if -1.6525860513176112e-34 < a < 6.557080249188682e-33

    1. Initial program 0.8

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

    if 6.557080249188682e-33 < a

    1. Initial program 7.9

      \[x - \frac{y \cdot \left(z - t\right)}{a}\]
    2. Taylor expanded around 0 7.9

      \[\leadsto x - \color{blue}{\left(\frac{z \cdot y}{a} - \frac{y \cdot t}{a}\right)}\]
    3. Applied simplify1.6

      \[\leadsto \color{blue}{x - \frac{y}{a} \cdot \left(z - t\right)}\]
    4. Using strategy rm
    5. Applied sub-neg1.6

      \[\leadsto x - \frac{y}{a} \cdot \color{blue}{\left(z + \left(-t\right)\right)}\]
    6. Applied distribute-lft-in1.6

      \[\leadsto x - \color{blue}{\left(\frac{y}{a} \cdot z + \frac{y}{a} \cdot \left(-t\right)\right)}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 1.1m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"

  :herbie-target
  (if (< y -1.0761266216389975e-10) (- x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

  (- x (/ (* y (- z t)) a)))