Average Error: 7.6 → 4.1
Time: 6.6s
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 -2.21834298495767539 \cdot 10^{236}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le -1.3603949856993749 \cdot 10^{34}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{elif}\;x \cdot y \le 2.9090994917840058 \cdot 10^{187}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{1}{\frac{a}{t \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 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 -2.21834298495767539 \cdot 10^{236}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\

\mathbf{elif}\;x \cdot y \le -1.3603949856993749 \cdot 10^{34}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\

\mathbf{elif}\;x \cdot y \le 2.9090994917840058 \cdot 10^{187}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{1}{\frac{a}{t \cdot z}}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r109000 = x;
        double r109001 = y;
        double r109002 = r109000 * r109001;
        double r109003 = z;
        double r109004 = 9.0;
        double r109005 = r109003 * r109004;
        double r109006 = t;
        double r109007 = r109005 * r109006;
        double r109008 = r109002 - r109007;
        double r109009 = a;
        double r109010 = 2.0;
        double r109011 = r109009 * r109010;
        double r109012 = r109008 / r109011;
        return r109012;
}

double f(double x, double y, double z, double t, double a) {
        double r109013 = x;
        double r109014 = y;
        double r109015 = r109013 * r109014;
        double r109016 = -2.2183429849576754e+236;
        bool r109017 = r109015 <= r109016;
        double r109018 = 0.5;
        double r109019 = a;
        double r109020 = r109019 / r109014;
        double r109021 = r109013 / r109020;
        double r109022 = r109018 * r109021;
        double r109023 = 4.5;
        double r109024 = t;
        double r109025 = z;
        double r109026 = r109024 * r109025;
        double r109027 = r109026 / r109019;
        double r109028 = r109023 * r109027;
        double r109029 = r109022 - r109028;
        double r109030 = -1.360394985699375e+34;
        bool r109031 = r109015 <= r109030;
        double r109032 = r109015 / r109019;
        double r109033 = r109018 * r109032;
        double r109034 = cbrt(r109019);
        double r109035 = r109034 * r109034;
        double r109036 = r109024 / r109035;
        double r109037 = r109023 * r109036;
        double r109038 = r109025 / r109034;
        double r109039 = r109037 * r109038;
        double r109040 = r109033 - r109039;
        double r109041 = 2.9090994917840058e+187;
        bool r109042 = r109015 <= r109041;
        double r109043 = 1.0;
        double r109044 = r109019 / r109026;
        double r109045 = r109043 / r109044;
        double r109046 = r109023 * r109045;
        double r109047 = r109033 - r109046;
        double r109048 = r109042 ? r109047 : r109029;
        double r109049 = r109031 ? r109040 : r109048;
        double r109050 = r109017 ? r109029 : r109049;
        return r109050;
}

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.6
Target5.6
Herbie4.1
\[\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.14403070783397609 \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 3 regimes
  2. if (* x y) < -2.2183429849576754e+236 or 2.9090994917840058e+187 < (* x y)

    1. Initial program 31.3

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

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

    if -2.2183429849576754e+236 < (* x y) < -1.360394985699375e+34

    1. Initial program 5.1

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
    5. Applied times-frac2.0

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \color{blue}{\left(\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\right)}\]
    6. Applied associate-*r*2.1

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

    if -1.360394985699375e+34 < (* x y) < 2.9090994917840058e+187

    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.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 clear-num4.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -2.21834298495767539 \cdot 10^{236}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le -1.3603949856993749 \cdot 10^{34}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{elif}\;x \cdot y \le 2.9090994917840058 \cdot 10^{187}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{1}{\frac{a}{t \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 +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)))