Average Error: 8.0 → 0.9
Time: 16.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 - \left(z \cdot 9\right) \cdot t \le -3.397261068180268733517436164043746284167 \cdot 10^{288} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 3.753404758648867148597172224071890067461 \cdot 10^{280}\right):\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(x \cdot y\right) \cdot \frac{1}{a}\right) - 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 -3.397261068180268733517436164043746284167 \cdot 10^{288} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 3.753404758648867148597172224071890067461 \cdot 10^{280}\right):\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r488119 = x;
        double r488120 = y;
        double r488121 = r488119 * r488120;
        double r488122 = z;
        double r488123 = 9.0;
        double r488124 = r488122 * r488123;
        double r488125 = t;
        double r488126 = r488124 * r488125;
        double r488127 = r488121 - r488126;
        double r488128 = a;
        double r488129 = 2.0;
        double r488130 = r488128 * r488129;
        double r488131 = r488127 / r488130;
        return r488131;
}

double f(double x, double y, double z, double t, double a) {
        double r488132 = x;
        double r488133 = y;
        double r488134 = r488132 * r488133;
        double r488135 = z;
        double r488136 = 9.0;
        double r488137 = r488135 * r488136;
        double r488138 = t;
        double r488139 = r488137 * r488138;
        double r488140 = r488134 - r488139;
        double r488141 = -3.397261068180269e+288;
        bool r488142 = r488140 <= r488141;
        double r488143 = 3.753404758648867e+280;
        bool r488144 = r488140 <= r488143;
        double r488145 = !r488144;
        bool r488146 = r488142 || r488145;
        double r488147 = 0.5;
        double r488148 = a;
        double r488149 = r488133 / r488148;
        double r488150 = r488132 * r488149;
        double r488151 = r488147 * r488150;
        double r488152 = 4.5;
        double r488153 = r488148 / r488135;
        double r488154 = r488138 / r488153;
        double r488155 = r488152 * r488154;
        double r488156 = r488151 - r488155;
        double r488157 = 1.0;
        double r488158 = r488157 / r488148;
        double r488159 = r488134 * r488158;
        double r488160 = r488147 * r488159;
        double r488161 = r488138 * r488135;
        double r488162 = r488161 / r488148;
        double r488163 = r488152 * r488162;
        double r488164 = r488160 - r488163;
        double r488165 = r488146 ? r488156 : r488164;
        return r488165;
}

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.5
Herbie0.9
\[\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) (* (* z 9.0) t)) < -3.397261068180269e+288 or 3.753404758648867e+280 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 52.7

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

      \[\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 *-un-lft-identity26.1

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

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

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

    if -3.397261068180269e+288 < (- (* x y) (* (* z 9.0) t)) < 3.753404758648867e+280

    1. Initial program 1.0

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

      \[\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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \le -3.397261068180268733517436164043746284167 \cdot 10^{288} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 3.753404758648867148597172224071890067461 \cdot 10^{280}\right):\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(x \cdot y\right) \cdot \frac{1}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019235 
(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)))