Average Error: 20.3 → 5.0
Time: 9.0s
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 := \left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b\\ t_2 := \frac{t_1}{z \cdot c}\\ t_3 := \frac{b}{z \cdot c}\\ t_4 := t_3 + 9 \cdot \left(\frac{y}{z} \cdot \frac{x}{c}\right)\\ \mathbf{if}\;t_2 \leq -2.7094793051114516 \cdot 10^{+212}:\\ \;\;\;\;t_4 - 4 \cdot \frac{t}{\frac{c}{a}}\\ \mathbf{elif}\;t_2 \leq -3.161582993753441 \cdot 10^{-141}:\\ \;\;\;\;\left(t_3 + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - 4 \cdot \left(a \cdot \frac{t}{c}\right)\\ \mathbf{elif}\;t_2 \leq 4.163744982269748 \cdot 10^{-105}:\\ \;\;\;\;\frac{t_1}{z} \cdot \frac{1}{c}\\ \mathbf{elif}\;t_2 \leq 7.726641705823416 \cdot 10^{+282}:\\ \;\;\;\;\frac{b + \mathsf{fma}\left(x, 9 \cdot y, a \cdot \left(t \cdot \left(z \cdot -4\right)\right)\right)}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;t_4 - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\ \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 (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b))
        (t_2 (/ t_1 (* z c)))
        (t_3 (/ b (* z c)))
        (t_4 (+ t_3 (* 9.0 (* (/ y z) (/ x c))))))
   (if (<= t_2 -2.7094793051114516e+212)
     (- t_4 (* 4.0 (/ t (/ c a))))
     (if (<= t_2 -3.161582993753441e-141)
       (- (+ t_3 (* 9.0 (/ (* x y) (* z c)))) (* 4.0 (* a (/ t c))))
       (if (<= t_2 4.163744982269748e-105)
         (* (/ t_1 z) (/ 1.0 c))
         (if (<= t_2 7.726641705823416e+282)
           (/ (+ b (fma x (* 9.0 y) (* a (* t (* z -4.0))))) (* z c))
           (- t_4 (* 4.0 (* t (/ a c))))))))))
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 = (((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b;
	double t_2 = t_1 / (z * c);
	double t_3 = b / (z * c);
	double t_4 = t_3 + (9.0 * ((y / z) * (x / c)));
	double tmp;
	if (t_2 <= -2.7094793051114516e+212) {
		tmp = t_4 - (4.0 * (t / (c / a)));
	} else if (t_2 <= -3.161582993753441e-141) {
		tmp = (t_3 + (9.0 * ((x * y) / (z * c)))) - (4.0 * (a * (t / c)));
	} else if (t_2 <= 4.163744982269748e-105) {
		tmp = (t_1 / z) * (1.0 / c);
	} else if (t_2 <= 7.726641705823416e+282) {
		tmp = (b + fma(x, (9.0 * y), (a * (t * (z * -4.0))))) / (z * c);
	} else {
		tmp = t_4 - (4.0 * (t * (a / c)));
	}
	return tmp;
}
function code(x, y, z, t, a, b, c)
	return Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c))
end
function code(x, y, z, t, a, b, c)
	t_1 = Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b)
	t_2 = Float64(t_1 / Float64(z * c))
	t_3 = Float64(b / Float64(z * c))
	t_4 = Float64(t_3 + Float64(9.0 * Float64(Float64(y / z) * Float64(x / c))))
	tmp = 0.0
	if (t_2 <= -2.7094793051114516e+212)
		tmp = Float64(t_4 - Float64(4.0 * Float64(t / Float64(c / a))));
	elseif (t_2 <= -3.161582993753441e-141)
		tmp = Float64(Float64(t_3 + Float64(9.0 * Float64(Float64(x * y) / Float64(z * c)))) - Float64(4.0 * Float64(a * Float64(t / c))));
	elseif (t_2 <= 4.163744982269748e-105)
		tmp = Float64(Float64(t_1 / z) * Float64(1.0 / c));
	elseif (t_2 <= 7.726641705823416e+282)
		tmp = Float64(Float64(b + fma(x, Float64(9.0 * y), Float64(a * Float64(t * Float64(z * -4.0))))) / Float64(z * c));
	else
		tmp = Float64(t_4 - Float64(4.0 * Float64(t * Float64(a / c))));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(z * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(b / N[(z * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + N[(9.0 * N[(N[(y / z), $MachinePrecision] * N[(x / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2.7094793051114516e+212], N[(t$95$4 - N[(4.0 * N[(t / N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3.161582993753441e-141], N[(N[(t$95$3 + N[(9.0 * N[(N[(x * y), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(4.0 * N[(a * N[(t / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4.163744982269748e-105], N[(N[(t$95$1 / z), $MachinePrecision] * N[(1.0 / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 7.726641705823416e+282], N[(N[(b + N[(x * N[(9.0 * y), $MachinePrecision] + N[(a * N[(t * N[(z * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], N[(t$95$4 - N[(4.0 * N[(t * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\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 := \left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b\\
t_2 := \frac{t_1}{z \cdot c}\\
t_3 := \frac{b}{z \cdot c}\\
t_4 := t_3 + 9 \cdot \left(\frac{y}{z} \cdot \frac{x}{c}\right)\\
\mathbf{if}\;t_2 \leq -2.7094793051114516 \cdot 10^{+212}:\\
\;\;\;\;t_4 - 4 \cdot \frac{t}{\frac{c}{a}}\\

\mathbf{elif}\;t_2 \leq -3.161582993753441 \cdot 10^{-141}:\\
\;\;\;\;\left(t_3 + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - 4 \cdot \left(a \cdot \frac{t}{c}\right)\\

\mathbf{elif}\;t_2 \leq 4.163744982269748 \cdot 10^{-105}:\\
\;\;\;\;\frac{t_1}{z} \cdot \frac{1}{c}\\

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

\mathbf{else}:\\
\;\;\;\;t_4 - 4 \cdot \left(t \cdot \frac{a}{c}\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

Original20.3
Target14.6
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 5 regimes
  2. if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -2.70947930511145165e212

    1. Initial program 31.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. Taylor expanded in x around 0 15.9

      \[\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}} \]
    3. Applied egg-rr14.6

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

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

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

    if -2.70947930511145165e212 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -3.16158299375344073e-141

    1. Initial program 0.6

      \[\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. Taylor expanded in x around 0 1.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}} \]
    3. Applied egg-rr1.2

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

    if -3.16158299375344073e-141 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 4.16374498226974795e-105

    1. Initial program 23.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. Applied egg-rr1.7

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

    if 4.16374498226974795e-105 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 7.7266417058234163e282

    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. Applied egg-rr0.8

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

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

    1. Initial program 59.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. Taylor expanded in x around 0 30.4

      \[\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}} \]
    3. Applied egg-rr23.9

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

      \[\leadsto \left(\frac{b}{c \cdot z} + 9 \cdot \color{blue}{\left(\frac{y}{z} \cdot \frac{x}{c}\right)}\right) - 4 \cdot \left(\frac{a}{c} \cdot t\right) \]
  3. Recombined 5 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 -2.7094793051114516 \cdot 10^{+212}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \left(\frac{y}{z} \cdot \frac{x}{c}\right)\right) - 4 \cdot \frac{t}{\frac{c}{a}}\\ \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.161582993753441 \cdot 10^{-141}:\\ \;\;\;\;\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{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 4.163744982269748 \cdot 10^{-105}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z} \cdot \frac{1}{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 7.726641705823416 \cdot 10^{+282}:\\ \;\;\;\;\frac{b + \mathsf{fma}\left(x, 9 \cdot y, a \cdot \left(t \cdot \left(z \cdot -4\right)\right)\right)}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \left(\frac{y}{z} \cdot \frac{x}{c}\right)\right) - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\ \end{array} \]

Reproduce

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