Average Error: 7.3 → 6.3
Time: 18.3s
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 r31202170 = x;
        double r31202171 = y;
        double r31202172 = r31202170 * r31202171;
        double r31202173 = z;
        double r31202174 = 9.0;
        double r31202175 = r31202173 * r31202174;
        double r31202176 = t;
        double r31202177 = r31202175 * r31202176;
        double r31202178 = r31202172 - r31202177;
        double r31202179 = a;
        double r31202180 = 2.0;
        double r31202181 = r31202179 * r31202180;
        double r31202182 = r31202178 / r31202181;
        return r31202182;
}

double f(double x, double y, double z, double t, double a) {
        double r31202183 = a;
        double r31202184 = 2.0;
        double r31202185 = r31202183 * r31202184;
        double r31202186 = -8.452560769864224e+197;
        bool r31202187 = r31202185 <= r31202186;
        double r31202188 = x;
        double r31202189 = y;
        double r31202190 = r31202183 / r31202189;
        double r31202191 = r31202188 / r31202190;
        double r31202192 = 0.5;
        double r31202193 = r31202191 * r31202192;
        double r31202194 = 4.5;
        double r31202195 = z;
        double r31202196 = t;
        double r31202197 = r31202195 * r31202196;
        double r31202198 = r31202197 / r31202183;
        double r31202199 = r31202194 * r31202198;
        double r31202200 = r31202193 - r31202199;
        double r31202201 = 1.9902573105400113e+77;
        bool r31202202 = r31202185 <= r31202201;
        double r31202203 = r31202189 * r31202188;
        double r31202204 = r31202203 / r31202183;
        double r31202205 = r31202192 * r31202204;
        double r31202206 = r31202197 * r31202194;
        double r31202207 = r31202206 / r31202183;
        double r31202208 = r31202205 - r31202207;
        double r31202209 = 3.2154246053472375e+277;
        bool r31202210 = r31202185 <= r31202209;
        double r31202211 = r31202183 / r31202195;
        double r31202212 = r31202196 / r31202211;
        double r31202213 = r31202212 * r31202194;
        double r31202214 = r31202205 - r31202213;
        double r31202215 = r31202210 ? r31202214 : r31202200;
        double r31202216 = r31202202 ? r31202208 : r31202215;
        double r31202217 = r31202187 ? r31202200 : r31202216;
        return r31202217;
}

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)))