Average Error: 20.2 → 9.4
Time: 22.4s
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}\;t \le -5.317803398975145198026138615390142277316 \cdot 10^{-135}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + \frac{x}{\frac{z \cdot c}{y}} \cdot 9\right) - 4 \cdot \frac{a}{\frac{c}{t}}\\ \mathbf{elif}\;t \le 1.249237249674777600849992317874825942798 \cdot 10^{-250}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + \left(\frac{x \cdot y}{z \cdot c} \cdot \sqrt{9}\right) \cdot \sqrt{9}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \mathbf{elif}\;t \le 1.891461409896939803176803699826823134415 \cdot 10^{-179}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right)\right) - 4 \cdot \left(\frac{a}{\sqrt[3]{c}} \cdot \frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}}\right)\\ \mathbf{elif}\;t \le 1.861603601865103942031928256975014473322 \cdot 10^{-89}:\\ \;\;\;\;\frac{1}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - 4 \cdot \left(t \cdot a\right)}{\sqrt[3]{c}}\\ \mathbf{elif}\;t \le 3.444271540187472204041842233420156897756 \cdot 10^{71}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - 4 \cdot \frac{t}{\frac{c}{a}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + \frac{x}{\frac{z \cdot c}{y}} \cdot 9\right) - 4 \cdot \frac{a}{\frac{c}{t}}\\ \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}\;t \le -5.317803398975145198026138615390142277316 \cdot 10^{-135}:\\
\;\;\;\;\left(\frac{b}{z \cdot c} + \frac{x}{\frac{z \cdot c}{y}} \cdot 9\right) - 4 \cdot \frac{a}{\frac{c}{t}}\\

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

\mathbf{elif}\;t \le 1.891461409896939803176803699826823134415 \cdot 10^{-179}:\\
\;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right)\right) - 4 \cdot \left(\frac{a}{\sqrt[3]{c}} \cdot \frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}}\right)\\

\mathbf{elif}\;t \le 1.861603601865103942031928256975014473322 \cdot 10^{-89}:\\
\;\;\;\;\frac{1}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - 4 \cdot \left(t \cdot a\right)}{\sqrt[3]{c}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r26387349 = x;
        double r26387350 = 9.0;
        double r26387351 = r26387349 * r26387350;
        double r26387352 = y;
        double r26387353 = r26387351 * r26387352;
        double r26387354 = z;
        double r26387355 = 4.0;
        double r26387356 = r26387354 * r26387355;
        double r26387357 = t;
        double r26387358 = r26387356 * r26387357;
        double r26387359 = a;
        double r26387360 = r26387358 * r26387359;
        double r26387361 = r26387353 - r26387360;
        double r26387362 = b;
        double r26387363 = r26387361 + r26387362;
        double r26387364 = c;
        double r26387365 = r26387354 * r26387364;
        double r26387366 = r26387363 / r26387365;
        return r26387366;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r26387367 = t;
        double r26387368 = -5.317803398975145e-135;
        bool r26387369 = r26387367 <= r26387368;
        double r26387370 = b;
        double r26387371 = z;
        double r26387372 = c;
        double r26387373 = r26387371 * r26387372;
        double r26387374 = r26387370 / r26387373;
        double r26387375 = x;
        double r26387376 = y;
        double r26387377 = r26387373 / r26387376;
        double r26387378 = r26387375 / r26387377;
        double r26387379 = 9.0;
        double r26387380 = r26387378 * r26387379;
        double r26387381 = r26387374 + r26387380;
        double r26387382 = 4.0;
        double r26387383 = a;
        double r26387384 = r26387372 / r26387367;
        double r26387385 = r26387383 / r26387384;
        double r26387386 = r26387382 * r26387385;
        double r26387387 = r26387381 - r26387386;
        double r26387388 = 1.2492372496747776e-250;
        bool r26387389 = r26387367 <= r26387388;
        double r26387390 = r26387375 * r26387376;
        double r26387391 = r26387390 / r26387373;
        double r26387392 = sqrt(r26387379);
        double r26387393 = r26387391 * r26387392;
        double r26387394 = r26387393 * r26387392;
        double r26387395 = r26387374 + r26387394;
        double r26387396 = r26387367 * r26387383;
        double r26387397 = r26387396 / r26387372;
        double r26387398 = r26387382 * r26387397;
        double r26387399 = r26387395 - r26387398;
        double r26387400 = 1.8914614098969398e-179;
        bool r26387401 = r26387367 <= r26387400;
        double r26387402 = r26387376 / r26387372;
        double r26387403 = r26387375 / r26387371;
        double r26387404 = r26387402 * r26387403;
        double r26387405 = r26387379 * r26387404;
        double r26387406 = r26387374 + r26387405;
        double r26387407 = cbrt(r26387372);
        double r26387408 = r26387383 / r26387407;
        double r26387409 = r26387407 * r26387407;
        double r26387410 = r26387367 / r26387409;
        double r26387411 = r26387408 * r26387410;
        double r26387412 = r26387382 * r26387411;
        double r26387413 = r26387406 - r26387412;
        double r26387414 = 1.861603601865104e-89;
        bool r26387415 = r26387367 <= r26387414;
        double r26387416 = 1.0;
        double r26387417 = r26387416 / r26387409;
        double r26387418 = r26387376 * r26387379;
        double r26387419 = fma(r26387418, r26387375, r26387370);
        double r26387420 = r26387419 / r26387371;
        double r26387421 = r26387382 * r26387396;
        double r26387422 = r26387420 - r26387421;
        double r26387423 = r26387422 / r26387407;
        double r26387424 = r26387417 * r26387423;
        double r26387425 = 3.444271540187472e+71;
        bool r26387426 = r26387367 <= r26387425;
        double r26387427 = r26387379 * r26387391;
        double r26387428 = r26387374 + r26387427;
        double r26387429 = r26387372 / r26387383;
        double r26387430 = r26387367 / r26387429;
        double r26387431 = r26387382 * r26387430;
        double r26387432 = r26387428 - r26387431;
        double r26387433 = r26387426 ? r26387432 : r26387387;
        double r26387434 = r26387415 ? r26387424 : r26387433;
        double r26387435 = r26387401 ? r26387413 : r26387434;
        double r26387436 = r26387389 ? r26387399 : r26387435;
        double r26387437 = r26387369 ? r26387387 : r26387436;
        return r26387437;
}

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.2
Target14.2
Herbie9.4
\[\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 5 regimes
  2. if t < -5.317803398975145e-135 or 3.444271540187472e+71 < t

    1. Initial program 26.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. Simplified16.4

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

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

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

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

      \[\leadsto \left(9 \cdot \color{blue}{\frac{x}{\frac{z \cdot c}{y}}} + \frac{b}{z \cdot c}\right) - 4 \cdot \left(\frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}\right)\]
    9. Using strategy rm
    10. Applied *-un-lft-identity7.9

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

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

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

    if -5.317803398975145e-135 < t < 1.2492372496747776e-250

    1. Initial program 12.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.3

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

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

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

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

    if 1.2492372496747776e-250 < t < 1.8914614098969398e-179

    1. Initial program 11.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. Simplified9.6

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

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

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

      \[\leadsto \left(9 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4 \cdot \color{blue}{\left(\frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}\right)}\]
    7. Using strategy rm
    8. Applied times-frac13.2

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

    if 1.8914614098969398e-179 < t < 1.861603601865104e-89

    1. Initial program 12.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. Simplified8.2

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4}{c}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt9.0

      \[\leadsto \frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4}{\color{blue}{\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}}}\]
    5. Applied *-un-lft-identity9.0

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

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

    if 1.861603601865104e-89 < t < 3.444271540187472e+71

    1. Initial program 17.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. Simplified10.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.317803398975145198026138615390142277316 \cdot 10^{-135}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + \frac{x}{\frac{z \cdot c}{y}} \cdot 9\right) - 4 \cdot \frac{a}{\frac{c}{t}}\\ \mathbf{elif}\;t \le 1.249237249674777600849992317874825942798 \cdot 10^{-250}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + \left(\frac{x \cdot y}{z \cdot c} \cdot \sqrt{9}\right) \cdot \sqrt{9}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \mathbf{elif}\;t \le 1.891461409896939803176803699826823134415 \cdot 10^{-179}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right)\right) - 4 \cdot \left(\frac{a}{\sqrt[3]{c}} \cdot \frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}}\right)\\ \mathbf{elif}\;t \le 1.861603601865103942031928256975014473322 \cdot 10^{-89}:\\ \;\;\;\;\frac{1}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - 4 \cdot \left(t \cdot a\right)}{\sqrt[3]{c}}\\ \mathbf{elif}\;t \le 3.444271540187472204041842233420156897756 \cdot 10^{71}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \frac{x \cdot y}{z \cdot c}\right) - 4 \cdot \frac{t}{\frac{c}{a}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + \frac{x}{\frac{z \cdot c}{y}} \cdot 9\right) - 4 \cdot \frac{a}{\frac{c}{t}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019170 +o rules:numerics
(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)))