Average Error: 7.9 → 0.5
Time: 4.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 - \left(z \cdot 9\right) \cdot t = -\infty \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le -1.570465535572884322699978790782884605691 \cdot 10^{-101} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 1.47440313991068531415406912842436761104 \cdot 10^{-267} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 6.212678920874577831195231744431104229608 \cdot 10^{275}\right)\right)\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 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 - \left(z \cdot 9\right) \cdot t = -\infty \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le -1.570465535572884322699978790782884605691 \cdot 10^{-101} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 1.47440313991068531415406912842436761104 \cdot 10^{-267} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 6.212678920874577831195231744431104229608 \cdot 10^{275}\right)\right)\right):\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r676646 = x;
        double r676647 = y;
        double r676648 = r676646 * r676647;
        double r676649 = z;
        double r676650 = 9.0;
        double r676651 = r676649 * r676650;
        double r676652 = t;
        double r676653 = r676651 * r676652;
        double r676654 = r676648 - r676653;
        double r676655 = a;
        double r676656 = 2.0;
        double r676657 = r676655 * r676656;
        double r676658 = r676654 / r676657;
        return r676658;
}

double f(double x, double y, double z, double t, double a) {
        double r676659 = x;
        double r676660 = y;
        double r676661 = r676659 * r676660;
        double r676662 = z;
        double r676663 = 9.0;
        double r676664 = r676662 * r676663;
        double r676665 = t;
        double r676666 = r676664 * r676665;
        double r676667 = r676661 - r676666;
        double r676668 = -inf.0;
        bool r676669 = r676667 <= r676668;
        double r676670 = -1.5704655355728843e-101;
        bool r676671 = r676667 <= r676670;
        double r676672 = 1.4744031399106853e-267;
        bool r676673 = r676667 <= r676672;
        double r676674 = 6.212678920874578e+275;
        bool r676675 = r676667 <= r676674;
        double r676676 = !r676675;
        bool r676677 = r676673 || r676676;
        double r676678 = !r676677;
        bool r676679 = r676671 || r676678;
        double r676680 = !r676679;
        bool r676681 = r676669 || r676680;
        double r676682 = 0.5;
        double r676683 = a;
        double r676684 = r676683 / r676660;
        double r676685 = r676659 / r676684;
        double r676686 = r676682 * r676685;
        double r676687 = 4.5;
        double r676688 = r676687 * r676665;
        double r676689 = r676662 / r676683;
        double r676690 = r676688 * r676689;
        double r676691 = r676686 - r676690;
        double r676692 = r676661 / r676683;
        double r676693 = r676682 * r676692;
        double r676694 = r676665 * r676662;
        double r676695 = r676694 / r676683;
        double r676696 = r676687 * r676695;
        double r676697 = r676693 - r676696;
        double r676698 = r676681 ? r676691 : r676697;
        return r676698;
}

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.9
Target5.6
Herbie0.5
\[\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 2 regimes
  2. if (- (* x y) (* (* z 9.0) t)) < -inf.0 or -1.5704655355728843e-101 < (- (* x y) (* (* z 9.0) t)) < 1.4744031399106853e-267 or 6.212678920874578e+275 < (- (* x y) (* (* z 9.0) t))

    1. Initial program 33.8

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\color{blue}{t} \cdot \frac{z}{a}\right)\]
    7. Using strategy rm
    8. Applied associate-*r*19.1

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\left(4.5 \cdot t\right) \cdot \frac{z}{a}}\]
    9. Using strategy rm
    10. Applied associate-/l*1.3

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

    if -inf.0 < (- (* x y) (* (* z 9.0) t)) < -1.5704655355728843e-101 or 1.4744031399106853e-267 < (- (* x y) (* (* z 9.0) t)) < 6.212678920874578e+275

    1. Initial program 0.3

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

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

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\color{blue}{t} \cdot \frac{z}{a}\right)\]
    7. Using strategy rm
    8. Applied associate-*r*5.4

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\left(4.5 \cdot t\right) \cdot \frac{z}{a}}\]
    9. Taylor expanded around 0 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t = -\infty \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le -1.570465535572884322699978790782884605691 \cdot 10^{-101} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 1.47440313991068531415406912842436761104 \cdot 10^{-267} \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \le 6.212678920874577831195231744431104229608 \cdot 10^{275}\right)\right)\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} - \left(4.5 \cdot t\right) \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

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