Average Error: 7.7 → 6.7
Time: 5.0s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;t \le -5.258769420001926597471570957877483246948 \cdot 10^{108}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{elif}\;t \le -1.004492575604983216075165247832217389845 \cdot 10^{46}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;t \le 7477629592254325719040:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 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}\;t \le -5.258769420001926597471570957877483246948 \cdot 10^{108}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\

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

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r787784 = x;
        double r787785 = y;
        double r787786 = r787784 * r787785;
        double r787787 = z;
        double r787788 = 9.0;
        double r787789 = r787787 * r787788;
        double r787790 = t;
        double r787791 = r787789 * r787790;
        double r787792 = r787786 - r787791;
        double r787793 = a;
        double r787794 = 2.0;
        double r787795 = r787793 * r787794;
        double r787796 = r787792 / r787795;
        return r787796;
}

double f(double x, double y, double z, double t, double a) {
        double r787797 = t;
        double r787798 = -5.258769420001927e+108;
        bool r787799 = r787797 <= r787798;
        double r787800 = 0.5;
        double r787801 = x;
        double r787802 = a;
        double r787803 = y;
        double r787804 = r787802 / r787803;
        double r787805 = r787801 / r787804;
        double r787806 = r787800 * r787805;
        double r787807 = 4.5;
        double r787808 = z;
        double r787809 = r787797 * r787808;
        double r787810 = r787807 * r787809;
        double r787811 = r787810 / r787802;
        double r787812 = r787806 - r787811;
        double r787813 = -1.0044925756049832e+46;
        bool r787814 = r787797 <= r787813;
        double r787815 = r787801 * r787803;
        double r787816 = r787815 / r787802;
        double r787817 = r787800 * r787816;
        double r787818 = r787797 * r787807;
        double r787819 = r787808 / r787802;
        double r787820 = r787818 * r787819;
        double r787821 = r787817 - r787820;
        double r787822 = 7.477629592254326e+21;
        bool r787823 = r787797 <= r787822;
        double r787824 = 9.0;
        double r787825 = r787824 * r787797;
        double r787826 = r787808 * r787825;
        double r787827 = r787815 - r787826;
        double r787828 = 2.0;
        double r787829 = r787802 * r787828;
        double r787830 = r787827 / r787829;
        double r787831 = r787802 / r787808;
        double r787832 = r787797 / r787831;
        double r787833 = r787807 * r787832;
        double r787834 = r787817 - r787833;
        double r787835 = r787823 ? r787830 : r787834;
        double r787836 = r787814 ? r787821 : r787835;
        double r787837 = r787799 ? r787812 : r787836;
        return r787837;
}

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
Herbie6.7
\[\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 4 regimes
  2. if t < -5.258769420001927e+108

    1. Initial program 14.2

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

      \[\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/13.5

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

    if -5.258769420001927e+108 < t < -1.0044925756049832e+46

    1. Initial program 10.0

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

      \[\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*6.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. Simplified6.3

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

    if -1.0044925756049832e+46 < t < 7.477629592254326e+21

    1. Initial program 4.6

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

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

    if 7.477629592254326e+21 < t

    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.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*8.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.258769420001926597471570957877483246948 \cdot 10^{108}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \frac{4.5 \cdot \left(t \cdot z\right)}{a}\\ \mathbf{elif}\;t \le -1.004492575604983216075165247832217389845 \cdot 10^{46}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;t \le 7477629592254325719040:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

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