Average Error: 5.4 → 1.6
Time: 2.5m
Precision: 64
Internal precision: 128
\[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.389688531466505 \cdot 10^{+21}:\\ \;\;\;\;\left(b \cdot c - 4.0 \cdot \left(i \cdot x + a \cdot t\right)\right) + \left(\left(\left(y \cdot 18.0\right) \cdot \left(x \cdot t\right)\right) \cdot z - \left(27.0 \cdot j\right) \cdot k\right)\\ \mathbf{if}\;z \le 8.34671733747768 \cdot 10^{-19}:\\ \;\;\;\;\left(\left(\left(z \cdot y\right) \cdot x\right) \cdot \left(t \cdot 18.0\right) + b \cdot c\right) - \left(\left(x \cdot i + t \cdot a\right) \cdot 4.0 + \left(j \cdot 27.0\right) \cdot k\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot c - 4.0 \cdot \left(i \cdot x + a \cdot t\right)\right) + \left(\left(\left(y \cdot 18.0\right) \cdot \left(x \cdot t\right)\right) \cdot z - \left(27.0 \cdot j\right) \cdot k\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus i

Bits error versus j

Bits error versus k

Target

Original5.4
Comparison1.4
Herbie1.6
\[ \begin{array}{l} \mathbf{if}\;t \lt -1.6210815397541398 \cdot 10^{-69}:\\ \;\;\;\;\left(\left(18.0 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) - \left(\left(k \cdot j\right) \cdot 27.0 - c \cdot b\right)\\ \mathbf{if}\;t \lt 165.68027943805222:\\ \;\;\;\;\left(\left(18.0 \cdot y\right) \cdot \left(x \cdot \left(z \cdot t\right)\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) + \left(c \cdot b - 27.0 \cdot \left(k \cdot j\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(18.0 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) - \left(\left(k \cdot j\right) \cdot 27.0 - c \cdot b\right)\\ \end{array} \]

Derivation

  1. Split input into 2 regimes.
  2. if z < -9.389688531466505e+21 or 8.34671733747768e-19 < z

    1. Initial program 6.6

      \[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
    2. Applied simplify 6.0

      \[\leadsto \color{blue}{\left(b \cdot c - 4.0 \cdot \left(i \cdot x + a \cdot t\right)\right) + \left(\left(y \cdot 18.0\right) \cdot \left(\left(x \cdot t\right) \cdot z\right) - \left(27.0 \cdot j\right) \cdot k\right)}\]
    3. Using strategy rm
    4. Applied associate-*r* 2.2

      \[\leadsto \left(b \cdot c - 4.0 \cdot \left(i \cdot x + a \cdot t\right)\right) + \left(\color{blue}{\left(\left(y \cdot 18.0\right) \cdot \left(x \cdot t\right)\right) \cdot z} - \left(27.0 \cdot j\right) \cdot k\right)\]

    if -9.389688531466505e+21 < z < 8.34671733747768e-19

    1. Initial program 4.6

      \[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
    2. Applied simplify 3.3

      \[\leadsto \color{blue}{\left(b \cdot c - 4.0 \cdot \left(i \cdot x + a \cdot t\right)\right) + \left(\left(y \cdot 18.0\right) \cdot \left(\left(x \cdot t\right) \cdot z\right) - \left(27.0 \cdot j\right) \cdot k\right)}\]
    3. Applied taylor 3.3

      \[\leadsto \left(c \cdot b - \left(4.0 \cdot \left(x \cdot i\right) + 4.0 \cdot \left(t \cdot a\right)\right)\right) + \left(\left(y \cdot 18.0\right) \cdot \left(\left(x \cdot t\right) \cdot z\right) - \left(27.0 \cdot j\right) \cdot k\right)\]
    4. Taylor expanded around inf 3.3

      \[\leadsto \color{blue}{\left(c \cdot b - \left(4.0 \cdot \left(x \cdot i\right) + 4.0 \cdot \left(t \cdot a\right)\right)\right)} + \left(\left(y \cdot 18.0\right) \cdot \left(\left(x \cdot t\right) \cdot z\right) - \left(27.0 \cdot j\right) \cdot k\right)\]
    5. Applied simplify 1.2

      \[\leadsto \color{blue}{\left(\left(\left(z \cdot y\right) \cdot x\right) \cdot \left(t \cdot 18.0\right) + b \cdot c\right) - \left(\left(x \cdot i + t \cdot a\right) \cdot 4.0 + \left(j \cdot 27.0\right) \cdot k\right)}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 2.5m) Debug log

Please include this information when filing a bug report:

herbie --seed '#(1356412610 2788747310 2361053618 1554242241 2684529597 48943163)'
(FPCore (x y z t a b c i j k)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, E"

  :target
  (if (< t -1.6210815397541398e-69) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b))) (if (< t 165.68027943805222) (+ (- (* (* 18.0 y) (* x (* z t))) (* (+ (* a t) (* i x)) 4.0)) (- (* c b) (* 27.0 (* k j)))) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b)))))

  (- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))