Average Error: 19.0 → 6.5
Time: 15.7s
Precision: 64
\[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
\[\begin{array}{l} \mathbf{if}\;c \le -1.8411746432829907 \cdot 10^{-69}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9.0 \cdot \left(\frac{x}{\frac{c}{y}} \cdot \frac{1}{z}\right)\right) - 4.0 \cdot \left(\frac{t}{c} \cdot a\right)\\ \mathbf{elif}\;c \le 5.385830162594913 \cdot 10^{-79}:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{b + \left(9.0 \cdot x\right) \cdot y}{z} - \left(4.0 \cdot t\right) \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{x}{\frac{c}{y}} \cdot \frac{1}{z}\right) + \frac{b}{c} \cdot \frac{1}{z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \end{array}\]
\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\begin{array}{l}
\mathbf{if}\;c \le -1.8411746432829907 \cdot 10^{-69}:\\
\;\;\;\;\left(\frac{b}{z \cdot c} + 9.0 \cdot \left(\frac{x}{\frac{c}{y}} \cdot \frac{1}{z}\right)\right) - 4.0 \cdot \left(\frac{t}{c} \cdot a\right)\\

\mathbf{elif}\;c \le 5.385830162594913 \cdot 10^{-79}:\\
\;\;\;\;\frac{1}{\frac{c}{\frac{b + \left(9.0 \cdot x\right) \cdot y}{z} - \left(4.0 \cdot t\right) \cdot a}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r15274573 = x;
        double r15274574 = 9.0;
        double r15274575 = r15274573 * r15274574;
        double r15274576 = y;
        double r15274577 = r15274575 * r15274576;
        double r15274578 = z;
        double r15274579 = 4.0;
        double r15274580 = r15274578 * r15274579;
        double r15274581 = t;
        double r15274582 = r15274580 * r15274581;
        double r15274583 = a;
        double r15274584 = r15274582 * r15274583;
        double r15274585 = r15274577 - r15274584;
        double r15274586 = b;
        double r15274587 = r15274585 + r15274586;
        double r15274588 = c;
        double r15274589 = r15274578 * r15274588;
        double r15274590 = r15274587 / r15274589;
        return r15274590;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r15274591 = c;
        double r15274592 = -1.8411746432829907e-69;
        bool r15274593 = r15274591 <= r15274592;
        double r15274594 = b;
        double r15274595 = z;
        double r15274596 = r15274595 * r15274591;
        double r15274597 = r15274594 / r15274596;
        double r15274598 = 9.0;
        double r15274599 = x;
        double r15274600 = y;
        double r15274601 = r15274591 / r15274600;
        double r15274602 = r15274599 / r15274601;
        double r15274603 = 1.0;
        double r15274604 = r15274603 / r15274595;
        double r15274605 = r15274602 * r15274604;
        double r15274606 = r15274598 * r15274605;
        double r15274607 = r15274597 + r15274606;
        double r15274608 = 4.0;
        double r15274609 = t;
        double r15274610 = r15274609 / r15274591;
        double r15274611 = a;
        double r15274612 = r15274610 * r15274611;
        double r15274613 = r15274608 * r15274612;
        double r15274614 = r15274607 - r15274613;
        double r15274615 = 5.385830162594913e-79;
        bool r15274616 = r15274591 <= r15274615;
        double r15274617 = r15274598 * r15274599;
        double r15274618 = r15274617 * r15274600;
        double r15274619 = r15274594 + r15274618;
        double r15274620 = r15274619 / r15274595;
        double r15274621 = r15274608 * r15274609;
        double r15274622 = r15274621 * r15274611;
        double r15274623 = r15274620 - r15274622;
        double r15274624 = r15274591 / r15274623;
        double r15274625 = r15274603 / r15274624;
        double r15274626 = r15274594 / r15274591;
        double r15274627 = r15274626 * r15274604;
        double r15274628 = r15274606 + r15274627;
        double r15274629 = r15274611 * r15274609;
        double r15274630 = r15274629 / r15274591;
        double r15274631 = r15274608 * r15274630;
        double r15274632 = r15274628 - r15274631;
        double r15274633 = r15274616 ? r15274625 : r15274632;
        double r15274634 = r15274593 ? r15274614 : r15274633;
        return r15274634;
}

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

Original19.0
Target13.6
Herbie6.5
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -1.100156740804105 \cdot 10^{-171}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -0.0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.1708877911747488 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 2.876823679546137 \cdot 10^{+130}:\\ \;\;\;\;\left(\left(9.0 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.3838515042456319 \cdot 10^{+158}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if c < -1.8411746432829907e-69

    1. Initial program 20.2

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified14.6

      \[\leadsto \color{blue}{\frac{\frac{\left(x \cdot 9.0\right) \cdot y + b}{z} - \left(4.0 \cdot t\right) \cdot a}{c}}\]
    3. Taylor expanded around 0 12.0

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

      \[\leadsto \left(9.0 \cdot \color{blue}{\frac{x}{\frac{z \cdot c}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity10.9

      \[\leadsto \left(9.0 \cdot \frac{x}{\frac{z \cdot c}{\color{blue}{1 \cdot y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    8. Applied times-frac10.0

      \[\leadsto \left(9.0 \cdot \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{c}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    9. Applied *-un-lft-identity10.0

      \[\leadsto \left(9.0 \cdot \frac{\color{blue}{1 \cdot x}}{\frac{z}{1} \cdot \frac{c}{y}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    10. Applied times-frac9.8

      \[\leadsto \left(9.0 \cdot \color{blue}{\left(\frac{1}{\frac{z}{1}} \cdot \frac{x}{\frac{c}{y}}\right)} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    11. Simplified9.8

      \[\leadsto \left(9.0 \cdot \left(\color{blue}{\frac{1}{z}} \cdot \frac{x}{\frac{c}{y}}\right) + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    12. Using strategy rm
    13. Applied *-un-lft-identity9.8

      \[\leadsto \left(9.0 \cdot \left(\frac{1}{z} \cdot \frac{x}{\frac{c}{y}}\right) + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{\color{blue}{1 \cdot c}}\]
    14. Applied times-frac6.8

      \[\leadsto \left(9.0 \cdot \left(\frac{1}{z} \cdot \frac{x}{\frac{c}{y}}\right) + \frac{b}{z \cdot c}\right) - 4.0 \cdot \color{blue}{\left(\frac{a}{1} \cdot \frac{t}{c}\right)}\]
    15. Simplified6.8

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

    if -1.8411746432829907e-69 < c < 5.385830162594913e-79

    1. Initial program 13.7

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified2.3

      \[\leadsto \color{blue}{\frac{\frac{\left(x \cdot 9.0\right) \cdot y + b}{z} - \left(4.0 \cdot t\right) \cdot a}{c}}\]
    3. Using strategy rm
    4. Applied clear-num2.4

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

    if 5.385830162594913e-79 < c

    1. Initial program 20.6

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified14.8

      \[\leadsto \color{blue}{\frac{\frac{\left(x \cdot 9.0\right) \cdot y + b}{z} - \left(4.0 \cdot t\right) \cdot a}{c}}\]
    3. Taylor expanded around 0 12.5

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

      \[\leadsto \left(9.0 \cdot \color{blue}{\frac{x}{\frac{z \cdot c}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity11.2

      \[\leadsto \left(9.0 \cdot \frac{x}{\frac{z \cdot c}{\color{blue}{1 \cdot y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    8. Applied times-frac10.2

      \[\leadsto \left(9.0 \cdot \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{c}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    9. Applied *-un-lft-identity10.2

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

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

      \[\leadsto \left(9.0 \cdot \left(\color{blue}{\frac{1}{z}} \cdot \frac{x}{\frac{c}{y}}\right) + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}\]
    12. Using strategy rm
    13. Applied *-un-lft-identity9.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \le -1.8411746432829907 \cdot 10^{-69}:\\ \;\;\;\;\left(\frac{b}{z \cdot c} + 9.0 \cdot \left(\frac{x}{\frac{c}{y}} \cdot \frac{1}{z}\right)\right) - 4.0 \cdot \left(\frac{t}{c} \cdot a\right)\\ \mathbf{elif}\;c \le 5.385830162594913 \cdot 10^{-79}:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{b + \left(9.0 \cdot x\right) \cdot y}{z} - \left(4.0 \cdot t\right) \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{x}{\frac{c}{y}} \cdot \frac{1}{z}\right) + \frac{b}{c} \cdot \frac{1}{z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \end{array}\]

Reproduce

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