Average Error: 7.3 → 6.3
Time: 21.0s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
\[\begin{array}{l} \mathbf{if}\;a \cdot 2.0 \le -8.452560769864224 \cdot 10^{+197}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{elif}\;a \cdot 2.0 \le 1.9902573105400113 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{\left(z \cdot t\right) \cdot 4.5}{a}\\ \mathbf{elif}\;a \cdot 2.0 \le 3.2154246053472375 \cdot 10^{+277}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{t}{\frac{a}{z}} \cdot 4.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}
\begin{array}{l}
\mathbf{if}\;a \cdot 2.0 \le -8.452560769864224 \cdot 10^{+197}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\

\mathbf{elif}\;a \cdot 2.0 \le 1.9902573105400113 \cdot 10^{+77}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{\left(z \cdot t\right) \cdot 4.5}{a}\\

\mathbf{elif}\;a \cdot 2.0 \le 3.2154246053472375 \cdot 10^{+277}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{t}{\frac{a}{z}} \cdot 4.5\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r29677265 = x;
        double r29677266 = y;
        double r29677267 = r29677265 * r29677266;
        double r29677268 = z;
        double r29677269 = 9.0;
        double r29677270 = r29677268 * r29677269;
        double r29677271 = t;
        double r29677272 = r29677270 * r29677271;
        double r29677273 = r29677267 - r29677272;
        double r29677274 = a;
        double r29677275 = 2.0;
        double r29677276 = r29677274 * r29677275;
        double r29677277 = r29677273 / r29677276;
        return r29677277;
}

double f(double x, double y, double z, double t, double a) {
        double r29677278 = a;
        double r29677279 = 2.0;
        double r29677280 = r29677278 * r29677279;
        double r29677281 = -8.452560769864224e+197;
        bool r29677282 = r29677280 <= r29677281;
        double r29677283 = x;
        double r29677284 = y;
        double r29677285 = r29677278 / r29677284;
        double r29677286 = r29677283 / r29677285;
        double r29677287 = 0.5;
        double r29677288 = r29677286 * r29677287;
        double r29677289 = 4.5;
        double r29677290 = z;
        double r29677291 = t;
        double r29677292 = r29677290 * r29677291;
        double r29677293 = r29677292 / r29677278;
        double r29677294 = r29677289 * r29677293;
        double r29677295 = r29677288 - r29677294;
        double r29677296 = 1.9902573105400113e+77;
        bool r29677297 = r29677280 <= r29677296;
        double r29677298 = r29677284 * r29677283;
        double r29677299 = r29677298 / r29677278;
        double r29677300 = r29677287 * r29677299;
        double r29677301 = r29677292 * r29677289;
        double r29677302 = r29677301 / r29677278;
        double r29677303 = r29677300 - r29677302;
        double r29677304 = 3.2154246053472375e+277;
        bool r29677305 = r29677280 <= r29677304;
        double r29677306 = r29677278 / r29677290;
        double r29677307 = r29677291 / r29677306;
        double r29677308 = r29677307 * r29677289;
        double r29677309 = r29677300 - r29677308;
        double r29677310 = r29677305 ? r29677309 : r29677295;
        double r29677311 = r29677297 ? r29677303 : r29677310;
        double r29677312 = r29677282 ? r29677295 : r29677311;
        return r29677312;
}

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.3
Target5.5
Herbie6.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.144030707833976 \cdot 10^{+99}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9.0 \cdot t\right)}{a \cdot 2.0}\\ \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 (* a 2.0) < -8.452560769864224e+197 or 3.2154246053472375e+277 < (* a 2.0)

    1. Initial program 13.7

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

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

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

    if -8.452560769864224e+197 < (* a 2.0) < 1.9902573105400113e+77

    1. Initial program 3.8

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Taylor expanded around 0 3.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/3.8

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

    if 1.9902573105400113e+77 < (* a 2.0) < 3.2154246053472375e+277

    1. Initial program 12.7

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

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \color{blue}{\frac{t}{\frac{a}{z}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification6.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot 2.0 \le -8.452560769864224 \cdot 10^{+197}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{elif}\;a \cdot 2.0 \le 1.9902573105400113 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{\left(z \cdot t\right) \cdot 4.5}{a}\\ \mathbf{elif}\;a \cdot 2.0 \le 3.2154246053472375 \cdot 10^{+277}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - \frac{t}{\frac{a}{z}} \cdot 4.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} \cdot 0.5 - 4.5 \cdot \frac{z \cdot t}{a}\\ \end{array}\]

Reproduce

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

  :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.0 t))) (* a 2.0)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))