Average Error: 20.2 → 8.8
Time: 21.9s
Precision: 64
\[\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} \mathbf{if}\;z \le -4.402350092041883275668460169588838453823 \cdot 10^{-72}:\\ \;\;\;\;\frac{\frac{1}{z} \cdot \left(b + y \cdot \left(x \cdot 9\right)\right) - \left(4 \cdot t\right) \cdot a}{c}\\ \mathbf{elif}\;z \le 2.285273688348913568491691630401286761171 \cdot 10^{-97}:\\ \;\;\;\;\frac{b + \left(y \cdot \left(x \cdot 9\right) - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right)}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z} \cdot \left(b + y \cdot \left(x \cdot 9\right)\right) - \left(4 \cdot t\right) \cdot a}{c}\\ \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}
\mathbf{if}\;z \le -4.402350092041883275668460169588838453823 \cdot 10^{-72}:\\
\;\;\;\;\frac{\frac{1}{z} \cdot \left(b + y \cdot \left(x \cdot 9\right)\right) - \left(4 \cdot t\right) \cdot a}{c}\\

\mathbf{elif}\;z \le 2.285273688348913568491691630401286761171 \cdot 10^{-97}:\\
\;\;\;\;\frac{b + \left(y \cdot \left(x \cdot 9\right) - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right)}{z \cdot c}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z} \cdot \left(b + y \cdot \left(x \cdot 9\right)\right) - \left(4 \cdot t\right) \cdot a}{c}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r34856053 = x;
        double r34856054 = 9.0;
        double r34856055 = r34856053 * r34856054;
        double r34856056 = y;
        double r34856057 = r34856055 * r34856056;
        double r34856058 = z;
        double r34856059 = 4.0;
        double r34856060 = r34856058 * r34856059;
        double r34856061 = t;
        double r34856062 = r34856060 * r34856061;
        double r34856063 = a;
        double r34856064 = r34856062 * r34856063;
        double r34856065 = r34856057 - r34856064;
        double r34856066 = b;
        double r34856067 = r34856065 + r34856066;
        double r34856068 = c;
        double r34856069 = r34856058 * r34856068;
        double r34856070 = r34856067 / r34856069;
        return r34856070;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r34856071 = z;
        double r34856072 = -4.4023500920418833e-72;
        bool r34856073 = r34856071 <= r34856072;
        double r34856074 = 1.0;
        double r34856075 = r34856074 / r34856071;
        double r34856076 = b;
        double r34856077 = y;
        double r34856078 = x;
        double r34856079 = 9.0;
        double r34856080 = r34856078 * r34856079;
        double r34856081 = r34856077 * r34856080;
        double r34856082 = r34856076 + r34856081;
        double r34856083 = r34856075 * r34856082;
        double r34856084 = 4.0;
        double r34856085 = t;
        double r34856086 = r34856084 * r34856085;
        double r34856087 = a;
        double r34856088 = r34856086 * r34856087;
        double r34856089 = r34856083 - r34856088;
        double r34856090 = c;
        double r34856091 = r34856089 / r34856090;
        double r34856092 = 2.2852736883489136e-97;
        bool r34856093 = r34856071 <= r34856092;
        double r34856094 = r34856071 * r34856084;
        double r34856095 = r34856094 * r34856085;
        double r34856096 = r34856095 * r34856087;
        double r34856097 = r34856081 - r34856096;
        double r34856098 = r34856076 + r34856097;
        double r34856099 = r34856071 * r34856090;
        double r34856100 = r34856098 / r34856099;
        double r34856101 = r34856093 ? r34856100 : r34856091;
        double r34856102 = r34856073 ? r34856091 : r34856101;
        return r34856102;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.2
Target14.2
Herbie8.8
\[\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} \lt -1.100156740804104887233830094663413900721 \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} \lt -0.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} \lt 1.170887791174748819600820354912645756062 \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} \lt 2.876823679546137226963937101710277849382 \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} \lt 1.383851504245631860711731716196098366993 \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 2 regimes
  2. if z < -4.4023500920418833e-72 or 2.2852736883489136e-97 < z

    1. Initial program 24.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. Simplified9.5

      \[\leadsto \color{blue}{\frac{\frac{b + \left(x \cdot 9\right) \cdot y}{z} - \left(t \cdot 4\right) \cdot a}{c}}\]
    3. Using strategy rm
    4. Applied div-inv9.5

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

    if -4.4023500920418833e-72 < z < 2.2852736883489136e-97

    1. Initial program 6.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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.402350092041883275668460169588838453823 \cdot 10^{-72}:\\ \;\;\;\;\frac{\frac{1}{z} \cdot \left(b + y \cdot \left(x \cdot 9\right)\right) - \left(4 \cdot t\right) \cdot a}{c}\\ \mathbf{elif}\;z \le 2.285273688348913568491691630401286761171 \cdot 10^{-97}:\\ \;\;\;\;\frac{b + \left(y \cdot \left(x \cdot 9\right) - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right)}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z} \cdot \left(b + y \cdot \left(x \cdot 9\right)\right) - \left(4 \cdot t\right) \cdot a}{c}\\ \end{array}\]

Reproduce

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

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