Average Error: 7.8 → 4.3
Time: 3.7s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{elif}\;x \cdot y \le -5.7260618197076615 \cdot 10^{109}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y \le 2.19718171022247432 \cdot 10^{260}:\\ \;\;\;\;\left(x \cdot y - z \cdot \left(9 \cdot t\right)\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y = -\infty:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\

\mathbf{elif}\;x \cdot y \le -5.7260618197076615 \cdot 10^{109}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

\mathbf{elif}\;x \cdot y \le 2.19718171022247432 \cdot 10^{260}:\\
\;\;\;\;\left(x \cdot y - z \cdot \left(9 \cdot t\right)\right) \cdot \frac{1}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r798141 = x;
        double r798142 = y;
        double r798143 = r798141 * r798142;
        double r798144 = z;
        double r798145 = 9.0;
        double r798146 = r798144 * r798145;
        double r798147 = t;
        double r798148 = r798146 * r798147;
        double r798149 = r798143 - r798148;
        double r798150 = a;
        double r798151 = 2.0;
        double r798152 = r798150 * r798151;
        double r798153 = r798149 / r798152;
        return r798153;
}

double f(double x, double y, double z, double t, double a) {
        double r798154 = x;
        double r798155 = y;
        double r798156 = r798154 * r798155;
        double r798157 = -inf.0;
        bool r798158 = r798156 <= r798157;
        double r798159 = 0.5;
        double r798160 = a;
        double r798161 = r798155 / r798160;
        double r798162 = r798154 * r798161;
        double r798163 = r798159 * r798162;
        double r798164 = 4.5;
        double r798165 = t;
        double r798166 = z;
        double r798167 = r798165 * r798166;
        double r798168 = r798164 * r798167;
        double r798169 = r798168 / r798160;
        double r798170 = r798163 - r798169;
        double r798171 = -5.7260618197076615e+109;
        bool r798172 = r798156 <= r798171;
        double r798173 = r798156 / r798160;
        double r798174 = r798159 * r798173;
        double r798175 = r798160 / r798166;
        double r798176 = r798165 / r798175;
        double r798177 = r798164 * r798176;
        double r798178 = r798174 - r798177;
        double r798179 = 2.1971817102224743e+260;
        bool r798180 = r798156 <= r798179;
        double r798181 = 9.0;
        double r798182 = r798181 * r798165;
        double r798183 = r798166 * r798182;
        double r798184 = r798156 - r798183;
        double r798185 = 1.0;
        double r798186 = 2.0;
        double r798187 = r798160 * r798186;
        double r798188 = r798185 / r798187;
        double r798189 = r798184 * r798188;
        double r798190 = r798180 ? r798189 : r798170;
        double r798191 = r798172 ? r798178 : r798190;
        double r798192 = r798158 ? r798170 : r798191;
        return r798192;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.8
Target5.5
Herbie4.3
\[\begin{array}{l} \mathbf{if}\;a \lt -2.090464557976709 \cdot 10^{86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \lt 2.14403070783397609 \cdot 10^{99}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right) - \frac{t}{a} \cdot \left(z \cdot 4.5\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (* x y) < -inf.0 or 2.1971817102224743e+260 < (* x y)

    1. Initial program 50.9

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 50.8

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    3. Using strategy rm
    4. Applied associate-*r/50.9

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\frac{4.5 \cdot \left(t \cdot z\right)}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity50.9

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\]
    7. Applied times-frac6.3

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{1} \cdot \frac{y}{a}\right)} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\]
    8. Simplified6.3

      \[\leadsto 0.5 \cdot \left(\color{blue}{x} \cdot \frac{y}{a}\right) - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\]

    if -inf.0 < (* x y) < -5.7260618197076615e+109

    1. Initial program 5.9

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 5.6

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    3. Using strategy rm
    4. Applied associate-/l*1.3

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \color{blue}{\frac{t}{\frac{a}{z}}}\]

    if -5.7260618197076615e+109 < (* x y) < 2.1971817102224743e+260

    1. Initial program 4.4

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Using strategy rm
    3. Applied associate-*l*4.4

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

      \[\leadsto \color{blue}{\left(x \cdot y - z \cdot \left(9 \cdot t\right)\right) \cdot \frac{1}{a \cdot 2}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{elif}\;x \cdot y \le -5.7260618197076615 \cdot 10^{109}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y \le 2.19718171022247432 \cdot 10^{260}:\\ \;\;\;\;\left(x \cdot y - z \cdot \left(9 \cdot t\right)\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< a -2.090464557976709e+86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.144030707833976e+99) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9) t)) (* a 2)))