Average Error: 7.7 → 5.1
Time: 18.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 -4.566826615749695196924573814616312015843 \cdot 10^{195}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{a} \cdot y\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le -1.409471842933517829629004567440056948219 \cdot 10^{-54}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y \le -7.881150033831729975395028746011437642375 \cdot 10^{-181}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{elif}\;x \cdot y \le 7.171891915826975815362349199038023134459 \cdot 10^{232}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{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 \le -4.566826615749695196924573814616312015843 \cdot 10^{195}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{a} \cdot y\right) - 4.5 \cdot \frac{t \cdot z}{a}\\

\mathbf{elif}\;x \cdot y \le -1.409471842933517829629004567440056948219 \cdot 10^{-54}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\

\mathbf{elif}\;x \cdot y \le -7.881150033831729975395028746011437642375 \cdot 10^{-181}:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\

\mathbf{elif}\;x \cdot y \le 7.171891915826975815362349199038023134459 \cdot 10^{232}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{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 r465145 = x;
        double r465146 = y;
        double r465147 = r465145 * r465146;
        double r465148 = z;
        double r465149 = 9.0;
        double r465150 = r465148 * r465149;
        double r465151 = t;
        double r465152 = r465150 * r465151;
        double r465153 = r465147 - r465152;
        double r465154 = a;
        double r465155 = 2.0;
        double r465156 = r465154 * r465155;
        double r465157 = r465153 / r465156;
        return r465157;
}

double f(double x, double y, double z, double t, double a) {
        double r465158 = x;
        double r465159 = y;
        double r465160 = r465158 * r465159;
        double r465161 = -4.566826615749695e+195;
        bool r465162 = r465160 <= r465161;
        double r465163 = 0.5;
        double r465164 = a;
        double r465165 = r465158 / r465164;
        double r465166 = r465165 * r465159;
        double r465167 = r465163 * r465166;
        double r465168 = 4.5;
        double r465169 = t;
        double r465170 = z;
        double r465171 = r465169 * r465170;
        double r465172 = r465171 / r465164;
        double r465173 = r465168 * r465172;
        double r465174 = r465167 - r465173;
        double r465175 = -1.4094718429335178e-54;
        bool r465176 = r465160 <= r465175;
        double r465177 = r465160 / r465164;
        double r465178 = r465163 * r465177;
        double r465179 = r465169 * r465168;
        double r465180 = r465170 / r465164;
        double r465181 = r465179 * r465180;
        double r465182 = r465178 - r465181;
        double r465183 = -7.88115003383173e-181;
        bool r465184 = r465160 <= r465183;
        double r465185 = 9.0;
        double r465186 = r465185 * r465169;
        double r465187 = r465170 * r465186;
        double r465188 = r465160 - r465187;
        double r465189 = 2.0;
        double r465190 = r465164 * r465189;
        double r465191 = r465188 / r465190;
        double r465192 = 7.171891915826976e+232;
        bool r465193 = r465160 <= r465192;
        double r465194 = r465169 * r465180;
        double r465195 = r465168 * r465194;
        double r465196 = r465178 - r465195;
        double r465197 = r465159 / r465164;
        double r465198 = r465158 * r465197;
        double r465199 = r465163 * r465198;
        double r465200 = r465199 - r465173;
        double r465201 = r465193 ? r465196 : r465200;
        double r465202 = r465184 ? r465191 : r465201;
        double r465203 = r465176 ? r465182 : r465202;
        double r465204 = r465162 ? r465174 : r465203;
        return r465204;
}

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.7
Target5.4
Herbie5.1
\[\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 5 regimes
  2. if (* x y) < -4.566826615749695e+195

    1. Initial program 28.3

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

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

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

    if -4.566826615749695e+195 < (* x y) < -1.4094718429335178e-54

    1. Initial program 3.9

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

      \[\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-identity3.9

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

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

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

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

    if -1.4094718429335178e-54 < (* x y) < -7.88115003383173e-181

    1. Initial program 3.4

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Using strategy rm
    3. Applied associate-*l*3.4

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

    if -7.88115003383173e-181 < (* x y) < 7.171891915826976e+232

    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 *-un-lft-identity4.1

      \[\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.5

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

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

    if 7.171891915826976e+232 < (* x y)

    1. Initial program 36.4

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

      \[\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-identity36.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -4.566826615749695196924573814616312015843 \cdot 10^{195}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{a} \cdot y\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le -1.409471842933517829629004567440056948219 \cdot 10^{-54}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y \le -7.881150033831729975395028746011437642375 \cdot 10^{-181}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{elif}\;x \cdot y \le 7.171891915826975815362349199038023134459 \cdot 10^{232}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

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

  :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 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

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