Average Error: 20.7 → 6.3
Time: 26.7s
Precision: binary64
\[[x, y]=\mathsf{sort}([x, y])\]
\[[t, a]=\mathsf{sort}([t, a])\]
\[\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 := 4 \cdot \frac{t \cdot a}{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}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\left(\frac{\sqrt[3]{b} \cdot \sqrt[3]{b}}{\frac{c}{\frac{\sqrt[3]{b}}{z}}} + 9 \cdot \frac{x \cdot \frac{y}{c}}{z}\right) - t_1\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \frac{b}{z \cdot c}\\ t_4 := t_3 + 9 \cdot \frac{x \cdot y}{z \cdot c}\\ \mathbf{if}\;t_2 \leq -3.6590373263643594 \cdot 10^{-177}:\\ \;\;\;\;t_4 - t_1\\ \mathbf{elif}\;t_2 \leq 1.2723756627530677 \cdot 10^{+31}:\\ \;\;\;\;\frac{\mathsf{fma}\left(t, a \cdot -4, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}\right)}{c}\\ \mathbf{elif}\;t_2 \leq 5.254822180873033 \cdot 10^{+305}:\\ \;\;\;\;t_4 - 4 \cdot \left(a \cdot \frac{t}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_3 + \left(9 \cdot \frac{y}{c}\right) \cdot \frac{x}{z}\right) - t_1\\ \end{array}\\ \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 := 4 \cdot \frac{t \cdot a}{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}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\left(\frac{\sqrt[3]{b} \cdot \sqrt[3]{b}}{\frac{c}{\frac{\sqrt[3]{b}}{z}}} + 9 \cdot \frac{x \cdot \frac{y}{c}}{z}\right) - t_1\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \frac{b}{z \cdot c}\\
t_4 := t_3 + 9 \cdot \frac{x \cdot y}{z \cdot c}\\
\mathbf{if}\;t_2 \leq -3.6590373263643594 \cdot 10^{-177}:\\
\;\;\;\;t_4 - t_1\\

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

\mathbf{elif}\;t_2 \leq 5.254822180873033 \cdot 10^{+305}:\\
\;\;\;\;t_4 - 4 \cdot \left(a \cdot \frac{t}{c}\right)\\

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


\end{array}\\


\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 (* 4.0 (/ (* t a) c)))
        (t_2 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))))
   (if (<= t_2 (- INFINITY))
     (-
      (+
       (/ (* (cbrt b) (cbrt b)) (/ c (/ (cbrt b) z)))
       (* 9.0 (/ (* x (/ y c)) z)))
      t_1)
     (let* ((t_3 (/ b (* z c))) (t_4 (+ t_3 (* 9.0 (/ (* x y) (* z c))))))
       (if (<= t_2 -3.6590373263643594e-177)
         (- t_4 t_1)
         (if (<= t_2 1.2723756627530677e+31)
           (/ (fma t (* a -4.0) (/ (fma x (* 9.0 y) b) z)) c)
           (if (<= t_2 5.254822180873033e+305)
             (- t_4 (* 4.0 (* a (/ t c))))
             (- (+ t_3 (* (* 9.0 (/ y c)) (/ x z))) t_1))))))))
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 = 4.0 * ((t * a) / c);
	double t_2 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = (((cbrt(b) * cbrt(b)) / (c / (cbrt(b) / z))) + (9.0 * ((x * (y / c)) / z))) - t_1;
	} else {
		double t_3 = b / (z * c);
		double t_4 = t_3 + (9.0 * ((x * y) / (z * c)));
		double tmp_1;
		if (t_2 <= -3.6590373263643594e-177) {
			tmp_1 = t_4 - t_1;
		} else if (t_2 <= 1.2723756627530677e+31) {
			tmp_1 = fma(t, (a * -4.0), (fma(x, (9.0 * y), b) / z)) / c;
		} else if (t_2 <= 5.254822180873033e+305) {
			tmp_1 = t_4 - (4.0 * (a * (t / c)));
		} else {
			tmp_1 = (t_3 + ((9.0 * (y / c)) * (x / z))) - t_1;
		}
		tmp = tmp_1;
	}
	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.7
Target15.0
Herbie6.3
\[\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 5 regimes
  2. if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -inf.0

    1. Initial program 64.0

      \[\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.5

      \[\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 30.8

      \[\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-/r*_binary6433.1

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

      \[\leadsto \left(\frac{b}{c \cdot z} + 9 \cdot \frac{\color{blue}{x \cdot \frac{y}{c}}}{z}\right) - 4 \cdot \frac{a \cdot t}{c} \]
    6. Applied add-cube-cbrt_binary6425.0

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

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

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

    if -inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -3.65903732636435944e-177

    1. Initial program 0.8

      \[\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. Simplified10.0

      \[\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 2.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}} \]

    if -3.65903732636435944e-177 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 1.2723756627530677e31

    1. Initial program 17.4

      \[\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.8

      \[\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 *-un-lft-identity_binary640.8

      \[\leadsto \frac{\mathsf{fma}\left(t, a \cdot -4, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}\right)}{\color{blue}{1 \cdot c}} \]
    4. Applied associate-/r*_binary640.8

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

    if 1.2723756627530677e31 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 5.25482218087303271e305

    1. Initial program 0.7

      \[\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. Simplified14.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 3.8

      \[\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 *-un-lft-identity_binary643.8

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

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

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

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

    1. Initial program 63.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} \]
    2. Simplified28.1

      \[\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 31.5

      \[\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 times-frac_binary6417.4

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

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

    \[\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 -\infty:\\ \;\;\;\;\left(\frac{\sqrt[3]{b} \cdot \sqrt[3]{b}}{\frac{c}{\frac{\sqrt[3]{b}}{z}}} + 9 \cdot \frac{x \cdot \frac{y}{c}}{z}\right) - 4 \cdot \frac{t \cdot a}{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 -3.6590373263643594 \cdot 10^{-177}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{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.2723756627530677 \cdot 10^{+31}:\\ \;\;\;\;\frac{\mathsf{fma}\left(t, a \cdot -4, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}\right)}{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 5.254822180873033 \cdot 10^{+305}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - 4 \cdot \left(a \cdot \frac{t}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + \left(9 \cdot \frac{y}{c}\right) \cdot \frac{x}{z}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \end{array} \]

Reproduce

herbie shell --seed 2021275 
(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)))