Average Error: 3.4 → 0.4
Time: 1.3m
Precision: 64
Internal Precision: 384
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;z \le -8.643245025974954 \cdot 10^{-54}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\\ \mathbf{if}\;z \le 9.281941309943775 \cdot 10^{-28}:\\ \;\;\;\;x - \frac{0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - 0.3333333333333333 \cdot \frac{y}{z}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.4
Target1.9
Herbie0.4
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{\frac{t}{z \cdot 3.0}}{y}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -8.643245025974954e-54

    1. Initial program 0.5

      \[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
    2. Using strategy rm
    3. Applied associate-/r*0.5

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

    if -8.643245025974954e-54 < z < 9.281941309943775e-28

    1. Initial program 11.8

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

      \[\leadsto \color{blue}{\left(x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\right) - 0.3333333333333333 \cdot \frac{y}{z}}\]
    3. Applied simplify0.2

      \[\leadsto \color{blue}{x - \frac{0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)}\]

    if 9.281941309943775e-28 < z

    1. Initial program 0.5

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

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

Runtime

Time bar (total: 1.3m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, H"

  :herbie-target
  (+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))

  (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))