Average Error: 19.8 → 8.0
Time: 1.2m
Precision: 64
Internal precision: 128
\[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \le -2.1533033503554896 \cdot 10^{-227}:\\ \;\;\;\;\left(9.0 \cdot \frac{y}{\frac{c \cdot z}{x}} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}\\ \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \le 0.0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \left(\frac{t}{c} \cdot a\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

Target

Original19.8
Comparison13.8
Herbie8.0
\[ \begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -1.100156740804105 \cdot 10^{-171}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -0.0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.1708877911747488 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 2.876823679546137 \cdot 10^{+130}:\\ \;\;\;\;\left(\left(9.0 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.3838515042456319 \cdot 10^{+158}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes.
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -2.1533033503554896e-227

    1. Initial program 12.0

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Applied taylor 7.3

      \[\leadsto \left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}\]
    3. Taylor expanded around 0 7.3

      \[\leadsto \color{blue}{\left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}}\]
    4. Using strategy rm
    5. Applied associate-/l* 7.4

      \[\leadsto \left(9.0 \cdot \color{blue}{\frac{y}{\frac{c \cdot z}{x}}} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}\]

    if -2.1533033503554896e-227 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 0.0

    1. Initial program 35.7

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

      \[\leadsto \color{blue}{\frac{\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z}}{c}}\]

    if 0.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 22.3

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Applied taylor 11.8

      \[\leadsto \left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}\]
    3. Taylor expanded around 0 11.8

      \[\leadsto \color{blue}{\left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}}\]
    4. Using strategy rm
    5. Applied associate-/l* 10.8

      \[\leadsto \left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \color{blue}{\frac{t}{\frac{c}{a}}}\]
    6. Using strategy rm
    7. Applied associate-/r/ 10.1

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

Runtime

Time bar (total: 1.2m) Debug log

Please include this information when filing a bug report:

herbie --seed '#(724045636 2503216985 2112021327 2271983714 3388563250 1713609638)'
(FPCore (x y z t a b c)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, J"

  :target
  (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -1.100156740804105e-171) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -0.0) (/ (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.1708877911747488e-53) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 2.876823679546137e+130) (- (+ (* (* 9.0 (/ y c)) (/ x z)) (/ b (* c z))) (* 4.0 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.3838515042456319e+158) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (- (+ (* 9.0 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4.0 (/ (* a t) c))))))))

  (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))