Average Error: 3.4 → 1.4
Time: 22.8s
Precision: 64
\[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;y \cdot 9.0 \le -3.90363473546571 \cdot 10^{-141}:\\ \;\;\;\;\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \left(\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \sqrt[3]{\left(27.0 \cdot a\right) \cdot b}\right) + \left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(t \cdot z\right)\right)\\ \mathbf{elif}\;y \cdot 9.0 \le 3.577414942380431 \cdot 10^{+108}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(y \cdot \left(z \cdot 9.0\right)\right) \cdot t\right)\\ \mathbf{elif}\;y \cdot 9.0 \le 1.1110052012410984 \cdot 10^{+292}:\\ \;\;\;\;\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \left(\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \sqrt[3]{\left(27.0 \cdot a\right) \cdot b}\right) + \left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2.0 + \left(27.0 \cdot \left(a \cdot b\right) - \left(9.0 \cdot \left(t \cdot y\right)\right) \cdot z\right)\\ \end{array}\]
\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b
\begin{array}{l}
\mathbf{if}\;y \cdot 9.0 \le -3.90363473546571 \cdot 10^{-141}:\\
\;\;\;\;\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \left(\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \sqrt[3]{\left(27.0 \cdot a\right) \cdot b}\right) + \left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(t \cdot z\right)\right)\\

\mathbf{elif}\;y \cdot 9.0 \le 3.577414942380431 \cdot 10^{+108}:\\
\;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(y \cdot \left(z \cdot 9.0\right)\right) \cdot t\right)\\

\mathbf{elif}\;y \cdot 9.0 \le 1.1110052012410984 \cdot 10^{+292}:\\
\;\;\;\;\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \left(\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \sqrt[3]{\left(27.0 \cdot a\right) \cdot b}\right) + \left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(t \cdot z\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot 2.0 + \left(27.0 \cdot \left(a \cdot b\right) - \left(9.0 \cdot \left(t \cdot y\right)\right) \cdot z\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r34817242 = x;
        double r34817243 = 2.0;
        double r34817244 = r34817242 * r34817243;
        double r34817245 = y;
        double r34817246 = 9.0;
        double r34817247 = r34817245 * r34817246;
        double r34817248 = z;
        double r34817249 = r34817247 * r34817248;
        double r34817250 = t;
        double r34817251 = r34817249 * r34817250;
        double r34817252 = r34817244 - r34817251;
        double r34817253 = a;
        double r34817254 = 27.0;
        double r34817255 = r34817253 * r34817254;
        double r34817256 = b;
        double r34817257 = r34817255 * r34817256;
        double r34817258 = r34817252 + r34817257;
        return r34817258;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r34817259 = y;
        double r34817260 = 9.0;
        double r34817261 = r34817259 * r34817260;
        double r34817262 = -3.90363473546571e-141;
        bool r34817263 = r34817261 <= r34817262;
        double r34817264 = 27.0;
        double r34817265 = a;
        double r34817266 = r34817264 * r34817265;
        double r34817267 = b;
        double r34817268 = r34817266 * r34817267;
        double r34817269 = cbrt(r34817268);
        double r34817270 = r34817269 * r34817269;
        double r34817271 = r34817269 * r34817270;
        double r34817272 = x;
        double r34817273 = 2.0;
        double r34817274 = r34817272 * r34817273;
        double r34817275 = t;
        double r34817276 = z;
        double r34817277 = r34817275 * r34817276;
        double r34817278 = r34817261 * r34817277;
        double r34817279 = r34817274 - r34817278;
        double r34817280 = r34817271 + r34817279;
        double r34817281 = 3.577414942380431e+108;
        bool r34817282 = r34817261 <= r34817281;
        double r34817283 = r34817276 * r34817260;
        double r34817284 = r34817259 * r34817283;
        double r34817285 = r34817284 * r34817275;
        double r34817286 = r34817274 - r34817285;
        double r34817287 = r34817268 + r34817286;
        double r34817288 = 1.1110052012410984e+292;
        bool r34817289 = r34817261 <= r34817288;
        double r34817290 = r34817265 * r34817267;
        double r34817291 = r34817264 * r34817290;
        double r34817292 = r34817275 * r34817259;
        double r34817293 = r34817260 * r34817292;
        double r34817294 = r34817293 * r34817276;
        double r34817295 = r34817291 - r34817294;
        double r34817296 = r34817274 + r34817295;
        double r34817297 = r34817289 ? r34817280 : r34817296;
        double r34817298 = r34817282 ? r34817287 : r34817297;
        double r34817299 = r34817263 ? r34817280 : r34817298;
        return r34817299;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.4
Target2.5
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + a \cdot \left(27.0 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27.0\right) \cdot b\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (* y 9.0) < -3.90363473546571e-141 or 3.577414942380431e+108 < (* y 9.0) < 1.1110052012410984e+292

    1. Initial program 5.9

      \[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*1.4

      \[\leadsto \left(x \cdot 2.0 - \color{blue}{\left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27.0\right) \cdot b\]
    4. Using strategy rm
    5. Applied add-cube-cbrt1.6

      \[\leadsto \left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)\right) + \color{blue}{\left(\sqrt[3]{\left(a \cdot 27.0\right) \cdot b} \cdot \sqrt[3]{\left(a \cdot 27.0\right) \cdot b}\right) \cdot \sqrt[3]{\left(a \cdot 27.0\right) \cdot b}}\]

    if -3.90363473546571e-141 < (* y 9.0) < 3.577414942380431e+108

    1. Initial program 1.0

      \[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*1.1

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

    if 1.1110052012410984e+292 < (* y 9.0)

    1. Initial program 16.3

      \[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
    2. Using strategy rm
    3. Applied sub-neg16.3

      \[\leadsto \color{blue}{\left(x \cdot 2.0 + \left(-\left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right)\right)} + \left(a \cdot 27.0\right) \cdot b\]
    4. Applied associate-+l+16.3

      \[\leadsto \color{blue}{x \cdot 2.0 + \left(\left(-\left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\right)}\]
    5. Simplified12.9

      \[\leadsto x \cdot 2.0 + \color{blue}{\left(27.0 \cdot \left(b \cdot a\right) - \left(\left(t \cdot y\right) \cdot 9.0\right) \cdot z\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 9.0 \le -3.90363473546571 \cdot 10^{-141}:\\ \;\;\;\;\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \left(\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \sqrt[3]{\left(27.0 \cdot a\right) \cdot b}\right) + \left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(t \cdot z\right)\right)\\ \mathbf{elif}\;y \cdot 9.0 \le 3.577414942380431 \cdot 10^{+108}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(y \cdot \left(z \cdot 9.0\right)\right) \cdot t\right)\\ \mathbf{elif}\;y \cdot 9.0 \le 1.1110052012410984 \cdot 10^{+292}:\\ \;\;\;\;\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \left(\sqrt[3]{\left(27.0 \cdot a\right) \cdot b} \cdot \sqrt[3]{\left(27.0 \cdot a\right) \cdot b}\right) + \left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2.0 + \left(27.0 \cdot \left(a \cdot b\right) - \left(9.0 \cdot \left(t \cdot y\right)\right) \cdot z\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))

  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))