Average Error: 7.7 → 4.2
Time: 18.6s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.228510223266635066615353468569416308744 \cdot 10^{-99}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \le 64104884799497751389513187328:\\ \;\;\;\;\frac{0.5 \cdot \left(x \cdot y\right) - 4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{y}{\sqrt[3]{a}}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;a \le -1.228510223266635066615353468569416308744 \cdot 10^{-99}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r477672 = x;
        double r477673 = y;
        double r477674 = r477672 * r477673;
        double r477675 = z;
        double r477676 = 9.0;
        double r477677 = r477675 * r477676;
        double r477678 = t;
        double r477679 = r477677 * r477678;
        double r477680 = r477674 - r477679;
        double r477681 = a;
        double r477682 = 2.0;
        double r477683 = r477681 * r477682;
        double r477684 = r477680 / r477683;
        return r477684;
}

double f(double x, double y, double z, double t, double a) {
        double r477685 = a;
        double r477686 = -1.228510223266635e-99;
        bool r477687 = r477685 <= r477686;
        double r477688 = 0.5;
        double r477689 = x;
        double r477690 = y;
        double r477691 = r477685 / r477690;
        double r477692 = r477689 / r477691;
        double r477693 = r477688 * r477692;
        double r477694 = 4.5;
        double r477695 = t;
        double r477696 = z;
        double r477697 = r477685 / r477696;
        double r477698 = r477695 / r477697;
        double r477699 = r477694 * r477698;
        double r477700 = r477693 - r477699;
        double r477701 = 6.410488479949775e+28;
        bool r477702 = r477685 <= r477701;
        double r477703 = r477689 * r477690;
        double r477704 = r477688 * r477703;
        double r477705 = r477695 * r477696;
        double r477706 = r477694 * r477705;
        double r477707 = r477704 - r477706;
        double r477708 = r477707 / r477685;
        double r477709 = cbrt(r477685);
        double r477710 = r477709 * r477709;
        double r477711 = r477689 / r477710;
        double r477712 = r477690 / r477709;
        double r477713 = r477711 * r477712;
        double r477714 = r477688 * r477713;
        double r477715 = r477714 - r477699;
        double r477716 = r477702 ? r477708 : r477715;
        double r477717 = r477687 ? r477700 : r477716;
        return r477717;
}

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.2
Herbie4.2
\[\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 3 regimes
  2. if a < -1.228510223266635e-99

    1. Initial program 9.0

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

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

    if -1.228510223266635e-99 < a < 6.410488479949775e+28

    1. Initial program 1.5

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

      \[\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-*r/1.6

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\frac{4.5 \cdot \left(t \cdot z\right)}{a}}\]
    5. Applied associate-*r/1.5

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

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

    if 6.410488479949775e+28 < a

    1. Initial program 12.3

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

      \[\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 add-cube-cbrt10.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.228510223266635066615353468569416308744 \cdot 10^{-99}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \le 64104884799497751389513187328:\\ \;\;\;\;\frac{0.5 \cdot \left(x \cdot y\right) - 4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{y}{\sqrt[3]{a}}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

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