Average Error: 7.7 → 5.1
Time: 8.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 -8.1516548360793441 \cdot 10^{300}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 5.1798943199914996 \cdot 10^{-242}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y \le 6.2688458872086312 \cdot 10^{203}:\\ \;\;\;\;\frac{x \cdot y - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot z\right)\right)}{a \cdot 2}\\ \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 -8.1516548360793441 \cdot 10^{300}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\

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

\mathbf{elif}\;x \cdot y \le 6.2688458872086312 \cdot 10^{203}:\\
\;\;\;\;\frac{x \cdot y - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot z\right)\right)}{a \cdot 2}\\

\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 r745662 = x;
        double r745663 = y;
        double r745664 = r745662 * r745663;
        double r745665 = z;
        double r745666 = 9.0;
        double r745667 = r745665 * r745666;
        double r745668 = t;
        double r745669 = r745667 * r745668;
        double r745670 = r745664 - r745669;
        double r745671 = a;
        double r745672 = 2.0;
        double r745673 = r745671 * r745672;
        double r745674 = r745670 / r745673;
        return r745674;
}

double f(double x, double y, double z, double t, double a) {
        double r745675 = x;
        double r745676 = y;
        double r745677 = r745675 * r745676;
        double r745678 = -8.151654836079344e+300;
        bool r745679 = r745677 <= r745678;
        double r745680 = 0.5;
        double r745681 = a;
        double r745682 = r745681 / r745676;
        double r745683 = r745675 / r745682;
        double r745684 = r745680 * r745683;
        double r745685 = 4.5;
        double r745686 = t;
        double r745687 = z;
        double r745688 = r745686 * r745687;
        double r745689 = r745688 / r745681;
        double r745690 = r745685 * r745689;
        double r745691 = r745684 - r745690;
        double r745692 = 5.1798943199915e-242;
        bool r745693 = r745677 <= r745692;
        double r745694 = r745677 / r745681;
        double r745695 = r745680 * r745694;
        double r745696 = r745686 * r745685;
        double r745697 = r745687 / r745681;
        double r745698 = r745696 * r745697;
        double r745699 = r745695 - r745698;
        double r745700 = 6.268845887208631e+203;
        bool r745701 = r745677 <= r745700;
        double r745702 = 9.0;
        double r745703 = cbrt(r745702);
        double r745704 = r745703 * r745703;
        double r745705 = r745703 * r745688;
        double r745706 = r745704 * r745705;
        double r745707 = r745677 - r745706;
        double r745708 = 2.0;
        double r745709 = r745681 * r745708;
        double r745710 = r745707 / r745709;
        double r745711 = r745701 ? r745710 : r745691;
        double r745712 = r745693 ? r745699 : r745711;
        double r745713 = r745679 ? r745691 : r745712;
        return r745713;
}

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.8
Herbie5.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) < -8.151654836079344e+300 or 6.268845887208631e+203 < (* x y)

    1. Initial program 40.5

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

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

    if -8.151654836079344e+300 < (* x y) < 5.1798943199915e-242

    1. Initial program 4.1

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

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

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

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

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

    if 5.1798943199915e-242 < (* x y) < 6.268845887208631e+203

    1. Initial program 3.9

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

      \[\leadsto \frac{\color{blue}{x \cdot y - 9 \cdot \left(t \cdot z\right)}}{a \cdot 2}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt3.8

      \[\leadsto \frac{x \cdot y - \color{blue}{\left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \sqrt[3]{9}\right)} \cdot \left(t \cdot z\right)}{a \cdot 2}\]
    5. Applied associate-*l*3.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -8.1516548360793441 \cdot 10^{300}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 5.1798943199914996 \cdot 10^{-242}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y \le 6.2688458872086312 \cdot 10^{203}:\\ \;\;\;\;\frac{x \cdot y - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot z\right)\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

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