Average Error: 7.8 → 1.1
Time: 4.8s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -6.82000317957228026 \cdot 10^{177}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.60899996071580589 \cdot 10^{305}:\\ \;\;\;\;\frac{0.5 \cdot \left(x \cdot y\right) - 4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \left(4.5 \cdot t\right) \cdot \frac{1}{\frac{a}{z}}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -6.82000317957228026 \cdot 10^{177}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\

\mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.60899996071580589 \cdot 10^{305}:\\
\;\;\;\;\frac{0.5 \cdot \left(x \cdot y\right) - 4.5 \cdot \left(t \cdot z\right)}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r651195 = x;
        double r651196 = y;
        double r651197 = r651195 * r651196;
        double r651198 = z;
        double r651199 = 9.0;
        double r651200 = r651198 * r651199;
        double r651201 = t;
        double r651202 = r651200 * r651201;
        double r651203 = r651197 - r651202;
        double r651204 = a;
        double r651205 = 2.0;
        double r651206 = r651204 * r651205;
        double r651207 = r651203 / r651206;
        return r651207;
}

double f(double x, double y, double z, double t, double a) {
        double r651208 = x;
        double r651209 = y;
        double r651210 = r651208 * r651209;
        double r651211 = z;
        double r651212 = 9.0;
        double r651213 = r651211 * r651212;
        double r651214 = t;
        double r651215 = r651213 * r651214;
        double r651216 = r651210 - r651215;
        double r651217 = -6.82000317957228e+177;
        bool r651218 = r651216 <= r651217;
        double r651219 = 0.5;
        double r651220 = a;
        double r651221 = r651220 / r651209;
        double r651222 = r651208 / r651221;
        double r651223 = r651219 * r651222;
        double r651224 = 4.5;
        double r651225 = r651214 / r651220;
        double r651226 = r651225 * r651211;
        double r651227 = r651224 * r651226;
        double r651228 = r651223 - r651227;
        double r651229 = 2.608999960715806e+305;
        bool r651230 = r651216 <= r651229;
        double r651231 = r651219 * r651210;
        double r651232 = r651214 * r651211;
        double r651233 = r651224 * r651232;
        double r651234 = r651231 - r651233;
        double r651235 = r651234 / r651220;
        double r651236 = r651224 * r651214;
        double r651237 = 1.0;
        double r651238 = r651220 / r651211;
        double r651239 = r651237 / r651238;
        double r651240 = r651236 * r651239;
        double r651241 = r651223 - r651240;
        double r651242 = r651230 ? r651235 : r651241;
        double r651243 = r651218 ? r651228 : r651242;
        return r651243;
}

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.6
Herbie1.1
\[\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) (* (* z 9.0) t)) < -6.82000317957228e+177

    1. Initial program 25.4

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

      \[\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*14.3

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    7. Using strategy rm
    8. Applied associate-/r/1.9

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

    if -6.82000317957228e+177 < (- (* x y) (* (* z 9.0) t)) < 2.608999960715806e+305

    1. Initial program 0.9

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

      \[\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/0.9

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\frac{4.5 \cdot \left(t \cdot z\right)}{a}}\]
    5. Applied associate-*r/0.9

      \[\leadsto \color{blue}{\frac{0.5 \cdot \left(x \cdot y\right)}{a}} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\]
    6. Applied sub-div0.9

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

    if 2.608999960715806e+305 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 62.7

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

      \[\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*34.0

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x}{\frac{a}{y}}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    7. Using strategy rm
    8. Applied div-inv0.8

      \[\leadsto 0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \color{blue}{\left(t \cdot \frac{1}{\frac{a}{z}}\right)}\]
    9. Applied associate-*r*1.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -6.82000317957228026 \cdot 10^{177}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \left(\frac{t}{a} \cdot z\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 2.60899996071580589 \cdot 10^{305}:\\ \;\;\;\;\frac{0.5 \cdot \left(x \cdot y\right) - 4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \left(4.5 \cdot t\right) \cdot \frac{1}{\frac{a}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020033 +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)))