Average Error: 3.5 → 1.0
Time: 18.7s
Precision: 64
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;t \le -9.181292183295369782473870231071122258393 \cdot 10^{99}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(z \cdot y\right) \cdot t\right) \cdot 9\right) + \left(27 \cdot a\right) \cdot b\\ \mathbf{elif}\;t \le 4.723997013909106823422754055447391420667 \cdot 10^{137}:\\ \;\;\;\;\left(27 \cdot a\right) \cdot b + \left(x \cdot 2 - 9 \cdot \left(\left(z \cdot t\right) \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{27} \cdot \left(a \cdot b\right)\right) \cdot \sqrt{27} + \left(x \cdot 2 - \left(\left(z \cdot 9\right) \cdot y\right) \cdot t\right)\\ \end{array}\]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
\mathbf{if}\;t \le -9.181292183295369782473870231071122258393 \cdot 10^{99}:\\
\;\;\;\;\left(x \cdot 2 - \left(\left(z \cdot y\right) \cdot t\right) \cdot 9\right) + \left(27 \cdot a\right) \cdot b\\

\mathbf{elif}\;t \le 4.723997013909106823422754055447391420667 \cdot 10^{137}:\\
\;\;\;\;\left(27 \cdot a\right) \cdot b + \left(x \cdot 2 - 9 \cdot \left(\left(z \cdot t\right) \cdot y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt{27} \cdot \left(a \cdot b\right)\right) \cdot \sqrt{27} + \left(x \cdot 2 - \left(\left(z \cdot 9\right) \cdot y\right) \cdot t\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r32819808 = x;
        double r32819809 = 2.0;
        double r32819810 = r32819808 * r32819809;
        double r32819811 = y;
        double r32819812 = 9.0;
        double r32819813 = r32819811 * r32819812;
        double r32819814 = z;
        double r32819815 = r32819813 * r32819814;
        double r32819816 = t;
        double r32819817 = r32819815 * r32819816;
        double r32819818 = r32819810 - r32819817;
        double r32819819 = a;
        double r32819820 = 27.0;
        double r32819821 = r32819819 * r32819820;
        double r32819822 = b;
        double r32819823 = r32819821 * r32819822;
        double r32819824 = r32819818 + r32819823;
        return r32819824;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r32819825 = t;
        double r32819826 = -9.18129218329537e+99;
        bool r32819827 = r32819825 <= r32819826;
        double r32819828 = x;
        double r32819829 = 2.0;
        double r32819830 = r32819828 * r32819829;
        double r32819831 = z;
        double r32819832 = y;
        double r32819833 = r32819831 * r32819832;
        double r32819834 = r32819833 * r32819825;
        double r32819835 = 9.0;
        double r32819836 = r32819834 * r32819835;
        double r32819837 = r32819830 - r32819836;
        double r32819838 = 27.0;
        double r32819839 = a;
        double r32819840 = r32819838 * r32819839;
        double r32819841 = b;
        double r32819842 = r32819840 * r32819841;
        double r32819843 = r32819837 + r32819842;
        double r32819844 = 4.723997013909107e+137;
        bool r32819845 = r32819825 <= r32819844;
        double r32819846 = r32819831 * r32819825;
        double r32819847 = r32819846 * r32819832;
        double r32819848 = r32819835 * r32819847;
        double r32819849 = r32819830 - r32819848;
        double r32819850 = r32819842 + r32819849;
        double r32819851 = sqrt(r32819838);
        double r32819852 = r32819839 * r32819841;
        double r32819853 = r32819851 * r32819852;
        double r32819854 = r32819853 * r32819851;
        double r32819855 = r32819831 * r32819835;
        double r32819856 = r32819855 * r32819832;
        double r32819857 = r32819856 * r32819825;
        double r32819858 = r32819830 - r32819857;
        double r32819859 = r32819854 + r32819858;
        double r32819860 = r32819845 ? r32819850 : r32819859;
        double r32819861 = r32819827 ? r32819843 : r32819860;
        return r32819861;
}

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.5
Target2.5
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811188954625810696587370427881 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -9.18129218329537e+99

    1. Initial program 0.7

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Taylor expanded around inf 0.6

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

    if -9.18129218329537e+99 < t < 4.723997013909107e+137

    1. Initial program 4.4

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Taylor expanded around inf 4.3

      \[\leadsto \left(x \cdot 2 - \color{blue}{9 \cdot \left(t \cdot \left(z \cdot y\right)\right)}\right) + \left(a \cdot 27\right) \cdot b\]
    3. Using strategy rm
    4. Applied associate-*r*1.0

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

    if 4.723997013909107e+137 < t

    1. Initial program 0.7

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*0.6

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot \left(9 \cdot z\right)\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    4. Taylor expanded around 0 0.6

      \[\leadsto \left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \color{blue}{27 \cdot \left(a \cdot b\right)}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt0.6

      \[\leadsto \left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \color{blue}{\left(\sqrt{27} \cdot \sqrt{27}\right)} \cdot \left(a \cdot b\right)\]
    7. Applied associate-*l*0.6

      \[\leadsto \left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \color{blue}{\sqrt{27} \cdot \left(\sqrt{27} \cdot \left(a \cdot b\right)\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -9.181292183295369782473870231071122258393 \cdot 10^{99}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(z \cdot y\right) \cdot t\right) \cdot 9\right) + \left(27 \cdot a\right) \cdot b\\ \mathbf{elif}\;t \le 4.723997013909106823422754055447391420667 \cdot 10^{137}:\\ \;\;\;\;\left(27 \cdot a\right) \cdot b + \left(x \cdot 2 - 9 \cdot \left(\left(z \cdot t\right) \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{27} \cdot \left(a \cdot b\right)\right) \cdot \sqrt{27} + \left(x \cdot 2 - \left(\left(z \cdot 9\right) \cdot y\right) \cdot t\right)\\ \end{array}\]

Reproduce

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