Average Error: 7.9 → 4.0
Time: 15.7s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -3.248707102049524282663682277335964122111 \cdot 10^{187} \lor \neg \left(x \cdot y \le 1.164981797442287361051324591328157653864 \cdot 10^{58}\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \left(x \cdot y\right)\right) \cdot \frac{1}{a} - 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 \le -3.248707102049524282663682277335964122111 \cdot 10^{187} \lor \neg \left(x \cdot y \le 1.164981797442287361051324591328157653864 \cdot 10^{58}\right):\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r1221065 = x;
        double r1221066 = y;
        double r1221067 = r1221065 * r1221066;
        double r1221068 = z;
        double r1221069 = 9.0;
        double r1221070 = r1221068 * r1221069;
        double r1221071 = t;
        double r1221072 = r1221070 * r1221071;
        double r1221073 = r1221067 - r1221072;
        double r1221074 = a;
        double r1221075 = 2.0;
        double r1221076 = r1221074 * r1221075;
        double r1221077 = r1221073 / r1221076;
        return r1221077;
}

double f(double x, double y, double z, double t, double a) {
        double r1221078 = x;
        double r1221079 = y;
        double r1221080 = r1221078 * r1221079;
        double r1221081 = -3.2487071020495243e+187;
        bool r1221082 = r1221080 <= r1221081;
        double r1221083 = 1.1649817974422874e+58;
        bool r1221084 = r1221080 <= r1221083;
        double r1221085 = !r1221084;
        bool r1221086 = r1221082 || r1221085;
        double r1221087 = 0.5;
        double r1221088 = a;
        double r1221089 = r1221088 / r1221079;
        double r1221090 = r1221078 / r1221089;
        double r1221091 = r1221087 * r1221090;
        double r1221092 = 4.5;
        double r1221093 = t;
        double r1221094 = z;
        double r1221095 = r1221088 / r1221094;
        double r1221096 = r1221093 / r1221095;
        double r1221097 = r1221092 * r1221096;
        double r1221098 = r1221091 - r1221097;
        double r1221099 = r1221087 * r1221080;
        double r1221100 = 1.0;
        double r1221101 = r1221100 / r1221088;
        double r1221102 = r1221099 * r1221101;
        double r1221103 = r1221093 * r1221094;
        double r1221104 = r1221103 / r1221088;
        double r1221105 = r1221092 * r1221104;
        double r1221106 = r1221102 - r1221105;
        double r1221107 = r1221086 ? r1221098 : r1221106;
        return r1221107;
}

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.9
Target5.8
Herbie4.0
\[\begin{array}{l} \mathbf{if}\;a \lt -2.090464557976709043451944897028999329376 \cdot 10^{86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \lt 2.144030707833976090627817222818061808815 \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) < -3.2487071020495243e+187 or 1.1649817974422874e+58 < (* x y)

    1. Initial program 20.3

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \color{blue}{\frac{t}{\frac{a}{z}}}\]
    5. Using strategy rm
    6. Applied associate-/l*3.7

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

    if -3.2487071020495243e+187 < (* x y) < 1.1649817974422874e+58

    1. Initial program 4.2

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

      \[\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 div-inv4.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -3.248707102049524282663682277335964122111 \cdot 10^{187} \lor \neg \left(x \cdot y \le 1.164981797442287361051324591328157653864 \cdot 10^{58}\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \left(x \cdot y\right)\right) \cdot \frac{1}{a} - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 
(FPCore (x y z t a)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, I"
  :precision binary64

  :herbie-target
  (if (< a -2.090464557976709e86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.14403070783397609e99) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9) t)) (* a 2)))