Average Error: 8.0 → 4.6
Time: 3.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 -4.03283629370113762 \cdot 10^{287}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 6.15442072676607707 \cdot 10^{270}:\\ \;\;\;\;\frac{x \cdot y - 9 \cdot \left(t \cdot z\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{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 - \left(z \cdot 9\right) \cdot t \le -4.03283629370113762 \cdot 10^{287}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r616571 = x;
        double r616572 = y;
        double r616573 = r616571 * r616572;
        double r616574 = z;
        double r616575 = 9.0;
        double r616576 = r616574 * r616575;
        double r616577 = t;
        double r616578 = r616576 * r616577;
        double r616579 = r616573 - r616578;
        double r616580 = a;
        double r616581 = 2.0;
        double r616582 = r616580 * r616581;
        double r616583 = r616579 / r616582;
        return r616583;
}

double f(double x, double y, double z, double t, double a) {
        double r616584 = x;
        double r616585 = y;
        double r616586 = r616584 * r616585;
        double r616587 = z;
        double r616588 = 9.0;
        double r616589 = r616587 * r616588;
        double r616590 = t;
        double r616591 = r616589 * r616590;
        double r616592 = r616586 - r616591;
        double r616593 = -4.0328362937011376e+287;
        bool r616594 = r616592 <= r616593;
        double r616595 = 0.5;
        double r616596 = a;
        double r616597 = r616586 / r616596;
        double r616598 = r616595 * r616597;
        double r616599 = 4.5;
        double r616600 = r616590 * r616599;
        double r616601 = r616587 / r616596;
        double r616602 = r616600 * r616601;
        double r616603 = r616598 - r616602;
        double r616604 = 6.154420726766077e+270;
        bool r616605 = r616592 <= r616604;
        double r616606 = r616590 * r616587;
        double r616607 = r616588 * r616606;
        double r616608 = r616586 - r616607;
        double r616609 = 2.0;
        double r616610 = r616596 * r616609;
        double r616611 = r616608 / r616610;
        double r616612 = r616596 / r616585;
        double r616613 = r616584 / r616612;
        double r616614 = r616595 * r616613;
        double r616615 = r616606 / r616596;
        double r616616 = r616599 * r616615;
        double r616617 = r616614 - r616616;
        double r616618 = r616605 ? r616611 : r616617;
        double r616619 = r616594 ? r616603 : r616618;
        return r616619;
}

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

Original8.0
Target5.8
Herbie4.6
\[\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)) < -4.0328362937011376e+287

    1. Initial program 54.9

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

      \[\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 *-un-lft-identity54.2

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{\color{blue}{1 \cdot a}}\]
    5. Applied times-frac29.4

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

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

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

    if -4.0328362937011376e+287 < (- (* x y) (* (* z 9.0) t)) < 6.154420726766077e+270

    1. Initial program 0.8

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

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

    if 6.154420726766077e+270 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 48.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -4.03283629370113762 \cdot 10^{287}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le 6.15442072676607707 \cdot 10^{270}:\\ \;\;\;\;\frac{x \cdot y - 9 \cdot \left(t \cdot z\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

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