Average Error: 7.2 → 4.4
Time: 20.1s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
\[\begin{array}{l} \mathbf{if}\;\left(z \cdot 9.0\right) \cdot t \le -2.7852718339082345 \cdot 10^{+160}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le 1.0499883925908476 \cdot 10^{+281}:\\ \;\;\;\;\frac{y \cdot x - 9.0 \cdot \left(t \cdot z\right)}{2.0} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}
\begin{array}{l}
\mathbf{if}\;\left(z \cdot 9.0\right) \cdot t \le -2.7852718339082345 \cdot 10^{+160}:\\
\;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\

\mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le 1.0499883925908476 \cdot 10^{+281}:\\
\;\;\;\;\frac{y \cdot x - 9.0 \cdot \left(t \cdot z\right)}{2.0} \cdot \frac{1}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r32941135 = x;
        double r32941136 = y;
        double r32941137 = r32941135 * r32941136;
        double r32941138 = z;
        double r32941139 = 9.0;
        double r32941140 = r32941138 * r32941139;
        double r32941141 = t;
        double r32941142 = r32941140 * r32941141;
        double r32941143 = r32941137 - r32941142;
        double r32941144 = a;
        double r32941145 = 2.0;
        double r32941146 = r32941144 * r32941145;
        double r32941147 = r32941143 / r32941146;
        return r32941147;
}

double f(double x, double y, double z, double t, double a) {
        double r32941148 = z;
        double r32941149 = 9.0;
        double r32941150 = r32941148 * r32941149;
        double r32941151 = t;
        double r32941152 = r32941150 * r32941151;
        double r32941153 = -2.7852718339082345e+160;
        bool r32941154 = r32941152 <= r32941153;
        double r32941155 = y;
        double r32941156 = x;
        double r32941157 = r32941155 * r32941156;
        double r32941158 = a;
        double r32941159 = r32941157 / r32941158;
        double r32941160 = 0.5;
        double r32941161 = r32941159 * r32941160;
        double r32941162 = 4.5;
        double r32941163 = r32941162 * r32941151;
        double r32941164 = r32941148 / r32941158;
        double r32941165 = r32941163 * r32941164;
        double r32941166 = r32941161 - r32941165;
        double r32941167 = 1.0499883925908476e+281;
        bool r32941168 = r32941152 <= r32941167;
        double r32941169 = r32941151 * r32941148;
        double r32941170 = r32941149 * r32941169;
        double r32941171 = r32941157 - r32941170;
        double r32941172 = 2.0;
        double r32941173 = r32941171 / r32941172;
        double r32941174 = 1.0;
        double r32941175 = r32941174 / r32941158;
        double r32941176 = r32941173 * r32941175;
        double r32941177 = r32941168 ? r32941176 : r32941166;
        double r32941178 = r32941154 ? r32941166 : r32941177;
        return r32941178;
}

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.2
Target5.0
Herbie4.4
\[\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 2 regimes
  2. if (* (* z 9.0) t) < -2.7852718339082345e+160 or 1.0499883925908476e+281 < (* (* z 9.0) t)

    1. Initial program 29.6

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

      \[\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-identity29.3

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

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

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

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

    if -2.7852718339082345e+160 < (* (* z 9.0) t) < 1.0499883925908476e+281

    1. Initial program 4.1

      \[\frac{x \cdot y - \left(z \cdot 9.0\right) \cdot t}{a \cdot 2.0}\]
    2. Using strategy rm
    3. Applied fma-neg4.1

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, -\left(z \cdot 9.0\right) \cdot t\right)}}{a \cdot 2.0}\]
    4. Taylor expanded around 0 4.1

      \[\leadsto \frac{\mathsf{fma}\left(x, y, -\color{blue}{9.0 \cdot \left(t \cdot z\right)}\right)}{a \cdot 2.0}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity4.1

      \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(x, y, -9.0 \cdot \left(t \cdot z\right)\right)}}{a \cdot 2.0}\]
    7. Applied times-frac4.2

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \frac{\mathsf{fma}\left(x, y, -9.0 \cdot \left(t \cdot z\right)\right)}{2.0}}\]
    8. Simplified4.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(z \cdot 9.0\right) \cdot t \le -2.7852718339082345 \cdot 10^{+160}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;\left(z \cdot 9.0\right) \cdot t \le 1.0499883925908476 \cdot 10^{+281}:\\ \;\;\;\;\frac{y \cdot x - 9.0 \cdot \left(t \cdot z\right)}{2.0} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{a} \cdot 0.5 - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \end{array}\]

Reproduce

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