Average Error: 7.8 → 4.5
Time: 4.6s
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 -9.5426047000982363 \cdot 10^{225} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 5.16846887088953994 \cdot 10^{206}\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 1 \cdot \frac{4.5}{\frac{a}{t \cdot 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 -9.5426047000982363 \cdot 10^{225} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 5.16846887088953994 \cdot 10^{206}\right):\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r583322 = x;
        double r583323 = y;
        double r583324 = r583322 * r583323;
        double r583325 = z;
        double r583326 = 9.0;
        double r583327 = r583325 * r583326;
        double r583328 = t;
        double r583329 = r583327 * r583328;
        double r583330 = r583324 - r583329;
        double r583331 = a;
        double r583332 = 2.0;
        double r583333 = r583331 * r583332;
        double r583334 = r583330 / r583333;
        return r583334;
}

double f(double x, double y, double z, double t, double a) {
        double r583335 = x;
        double r583336 = y;
        double r583337 = r583335 * r583336;
        double r583338 = z;
        double r583339 = 9.0;
        double r583340 = r583338 * r583339;
        double r583341 = t;
        double r583342 = r583340 * r583341;
        double r583343 = r583337 - r583342;
        double r583344 = -9.542604700098236e+225;
        bool r583345 = r583343 <= r583344;
        double r583346 = 5.16846887088954e+206;
        bool r583347 = r583343 <= r583346;
        double r583348 = !r583347;
        bool r583349 = r583345 || r583348;
        double r583350 = 0.5;
        double r583351 = a;
        double r583352 = r583351 / r583336;
        double r583353 = r583335 / r583352;
        double r583354 = r583350 * r583353;
        double r583355 = 4.5;
        double r583356 = r583341 * r583338;
        double r583357 = r583356 / r583351;
        double r583358 = r583355 * r583357;
        double r583359 = r583354 - r583358;
        double r583360 = r583337 / r583351;
        double r583361 = r583350 * r583360;
        double r583362 = 1.0;
        double r583363 = r583351 / r583356;
        double r583364 = r583355 / r583363;
        double r583365 = r583362 * r583364;
        double r583366 = r583361 - r583365;
        double r583367 = r583349 ? r583359 : r583366;
        return r583367;
}

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.8
Herbie4.5
\[\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 2 regimes
  2. if (- (* x y) (* (* z 9.0) t)) < -9.542604700098236e+225 or 5.16846887088954e+206 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 31.0

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 30.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*16.2

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

    if -9.542604700098236e+225 < (- (* x y) (* (* z 9.0) t)) < 5.16846887088954e+206

    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 clear-num1.1

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \color{blue}{\frac{1}{\frac{a}{t \cdot z}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity1.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -9.5426047000982363 \cdot 10^{225} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 5.16846887088953994 \cdot 10^{206}\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 1 \cdot \frac{4.5}{\frac{a}{t \cdot z}}\\ \end{array}\]

Reproduce

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