Average Error: 20.4 → 5.0
Time: 7.6s
Precision: binary64
\[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
\[\begin{array}{l} t_1 := \frac{b}{z \cdot c}\\ t_2 := \frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\\ t_3 := 4 \cdot \frac{a}{\frac{c}{t}}\\ \mathbf{if}\;t_2 \leq -7.461130439693503 \cdot 10^{-273}:\\ \;\;\;\;\left(t_1 + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - t_3\\ \mathbf{elif}\;t_2 \leq 288384475505851.9:\\ \;\;\;\;\frac{\left(t \cdot a\right) \cdot -4 + \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}}{c}\\ \mathbf{elif}\;t_2 \leq 1.0735366275549439 \cdot 10^{+262}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\left(t_1 + 9 \cdot \frac{y}{\frac{c}{\frac{x}{z}}}\right) - t_3\\ \end{array} \]
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\begin{array}{l}
t_1 := \frac{b}{z \cdot c}\\
t_2 := \frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\\
t_3 := 4 \cdot \frac{a}{\frac{c}{t}}\\
\mathbf{if}\;t_2 \leq -7.461130439693503 \cdot 10^{-273}:\\
\;\;\;\;\left(t_1 + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - t_3\\

\mathbf{elif}\;t_2 \leq 288384475505851.9:\\
\;\;\;\;\frac{\left(t \cdot a\right) \cdot -4 + \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}}{c}\\

\mathbf{elif}\;t_2 \leq 1.0735366275549439 \cdot 10^{+262}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\left(t_1 + 9 \cdot \frac{y}{\frac{c}{\frac{x}{z}}}\right) - t_3\\


\end{array}
(FPCore (x y z t a b c)
 :precision binary64
 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (/ b (* z c)))
        (t_2 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
        (t_3 (* 4.0 (/ a (/ c t)))))
   (if (<= t_2 -7.461130439693503e-273)
     (- (+ t_1 (* 9.0 (/ (* x y) (* z c)))) t_3)
     (if (<= t_2 288384475505851.9)
       (/ (+ (* (* t a) -4.0) (/ (fma x (* 9.0 y) b) z)) c)
       (if (<= t_2 1.0735366275549439e+262)
         t_2
         (- (+ t_1 (* 9.0 (/ y (/ c (/ x z))))) t_3))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = b / (z * c);
	double t_2 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
	double t_3 = 4.0 * (a / (c / t));
	double tmp;
	if (t_2 <= -7.461130439693503e-273) {
		tmp = (t_1 + (9.0 * ((x * y) / (z * c)))) - t_3;
	} else if (t_2 <= 288384475505851.9) {
		tmp = (((t * a) * -4.0) + (fma(x, (9.0 * y), b) / z)) / c;
	} else if (t_2 <= 1.0735366275549439e+262) {
		tmp = t_2;
	} else {
		tmp = (t_1 + (9.0 * (y / (c / (x / z))))) - t_3;
	}
	return tmp;
}

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

Original20.4
Target14.4
Herbie5.0
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} < -1.100156740804105 \cdot 10^{-171}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} < 0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} < 1.1708877911747488 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} < 2.876823679546137 \cdot 10^{+130}:\\ \;\;\;\;\left(\left(9 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} < 1.3838515042456319 \cdot 10^{+158}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(9 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}\\ \end{array} \]

Derivation

  1. Split input into 4 regimes
  2. if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -7.4611304396935027e-273

    1. Initial program 12.1

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
    2. Simplified12.4

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(t, a \cdot -4, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}\right)}{c}} \]
    3. Taylor expanded in t around 0 7.6

      \[\leadsto \color{blue}{\left(\frac{b}{c \cdot z} + 9 \cdot \frac{y \cdot x}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}} \]
    4. Applied associate-/l*_binary647.0

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

    if -7.4611304396935027e-273 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 288384475505851.88

    1. Initial program 18.3

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
    2. Simplified0.6

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(t, a \cdot -4, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}\right)}{c}} \]
    3. Applied fma-udef_binary640.6

      \[\leadsto \frac{\color{blue}{t \cdot \left(a \cdot -4\right) + \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}}}{c} \]
    4. Simplified0.6

      \[\leadsto \frac{\color{blue}{\left(a \cdot t\right) \cdot -4} + \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}}{c} \]

    if 288384475505851.88 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 1.0735366275549439e262

    1. Initial program 0.5

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]

    if 1.0735366275549439e262 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c))

    1. Initial program 55.2

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
    2. Simplified26.2

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(t, a \cdot -4, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}\right)}{c}} \]
    3. Taylor expanded in t around 0 26.7

      \[\leadsto \color{blue}{\left(\frac{b}{c \cdot z} + 9 \cdot \frac{y \cdot x}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}} \]
    4. Applied associate-/l*_binary6421.4

      \[\leadsto \left(\frac{b}{c \cdot z} + 9 \cdot \frac{y \cdot x}{c \cdot z}\right) - 4 \cdot \color{blue}{\frac{a}{\frac{c}{t}}} \]
    5. Applied associate-/l*_binary6414.2

      \[\leadsto \left(\frac{b}{c \cdot z} + 9 \cdot \color{blue}{\frac{y}{\frac{c \cdot z}{x}}}\right) - 4 \cdot \frac{a}{\frac{c}{t}} \]
    6. Simplified9.8

      \[\leadsto \left(\frac{b}{c \cdot z} + 9 \cdot \frac{y}{\color{blue}{\frac{c}{\frac{x}{z}}}}\right) - 4 \cdot \frac{a}{\frac{c}{t}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification5.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \leq -7.461130439693503 \cdot 10^{-273}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - 4 \cdot \frac{a}{\frac{c}{t}}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \leq 288384475505851.9:\\ \;\;\;\;\frac{\left(t \cdot a\right) \cdot -4 + \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \leq 1.0735366275549439 \cdot 10^{+262}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \frac{y}{\frac{c}{\frac{x}{z}}}\right) - 4 \cdot \frac{a}{\frac{c}{t}}\\ \end{array} \]

Reproduce

herbie shell --seed 2021307 
(FPCore (x y z t a b c)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, J"
  :precision binary64

  :herbie-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)))