Average Error: 7.9 → 4.0
Time: 15.4s
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 r517018 = x;
        double r517019 = y;
        double r517020 = r517018 * r517019;
        double r517021 = z;
        double r517022 = 9.0;
        double r517023 = r517021 * r517022;
        double r517024 = t;
        double r517025 = r517023 * r517024;
        double r517026 = r517020 - r517025;
        double r517027 = a;
        double r517028 = 2.0;
        double r517029 = r517027 * r517028;
        double r517030 = r517026 / r517029;
        return r517030;
}

double f(double x, double y, double z, double t, double a) {
        double r517031 = x;
        double r517032 = y;
        double r517033 = r517031 * r517032;
        double r517034 = -3.2487071020495243e+187;
        bool r517035 = r517033 <= r517034;
        double r517036 = 1.1649817974422874e+58;
        bool r517037 = r517033 <= r517036;
        double r517038 = !r517037;
        bool r517039 = r517035 || r517038;
        double r517040 = 0.5;
        double r517041 = a;
        double r517042 = r517041 / r517032;
        double r517043 = r517031 / r517042;
        double r517044 = r517040 * r517043;
        double r517045 = 4.5;
        double r517046 = t;
        double r517047 = z;
        double r517048 = r517041 / r517047;
        double r517049 = r517046 / r517048;
        double r517050 = r517045 * r517049;
        double r517051 = r517044 - r517050;
        double r517052 = r517040 * r517033;
        double r517053 = 1.0;
        double r517054 = r517053 / r517041;
        double r517055 = r517052 * r517054;
        double r517056 = r517046 * r517047;
        double r517057 = r517056 / r517041;
        double r517058 = r517045 * r517057;
        double r517059 = r517055 - r517058;
        double r517060 = r517039 ? r517051 : r517059;
        return r517060;
}

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