Average Error: 7.4 → 1.2
Time: 12.1s
Precision: binary64
\[[x, y]=\mathsf{sort}([x, y])\]
\[[z, t]=\mathsf{sort}([z, t])\]
\[\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 \leq -2.2668851269500015 \cdot 10^{+249}:\\ \;\;\;\;\frac{x}{\frac{a}{\frac{y}{2}}} - \left(t \cdot \frac{z}{a}\right) \cdot 4.5\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq 7.503128600354255 \cdot 10^{+142}:\\ \;\;\;\;\frac{x \cdot y}{a \cdot 2} - \frac{4.5 \cdot \left(z \cdot t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{2} \cdot \frac{x}{a} - \left(t \cdot \frac{z}{a}\right) \cdot 4.5\\ \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 \leq -2.2668851269500015 \cdot 10^{+249}:\\
\;\;\;\;\frac{x}{\frac{a}{\frac{y}{2}}} - \left(t \cdot \frac{z}{a}\right) \cdot 4.5\\

\mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq 7.503128600354255 \cdot 10^{+142}:\\
\;\;\;\;\frac{x \cdot y}{a \cdot 2} - \frac{4.5 \cdot \left(z \cdot t\right)}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{2} \cdot \frac{x}{a} - \left(t \cdot \frac{z}{a}\right) \cdot 4.5\\

\end{array}
(FPCore (x y z t a)
 :precision binary64
 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
(FPCore (x y z t a)
 :precision binary64
 (if (<= (- (* x y) (* (* z 9.0) t)) -2.2668851269500015e+249)
   (- (/ x (/ a (/ y 2.0))) (* (* t (/ z a)) 4.5))
   (if (<= (- (* x y) (* (* z 9.0) t)) 7.503128600354255e+142)
     (- (/ (* x y) (* a 2.0)) (/ (* 4.5 (* z t)) a))
     (- (* (/ y 2.0) (/ x a)) (* (* t (/ z a)) 4.5)))))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((x * y) - ((z * 9.0) * t)) <= -2.2668851269500015e+249) {
		tmp = (x / (a / (y / 2.0))) - ((t * (z / a)) * 4.5);
	} else if (((x * y) - ((z * 9.0) * t)) <= 7.503128600354255e+142) {
		tmp = ((x * y) / (a * 2.0)) - ((4.5 * (z * t)) / a);
	} else {
		tmp = ((y / 2.0) * (x / a)) - ((t * (z / a)) * 4.5);
	}
	return tmp;
}

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.4
Target5.8
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;a < -2.090464557976709 \cdot 10^{+86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a < 2.144030707833976 \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 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < -2.2668851269500015e249

    1. Initial program 38.1

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Using strategy rm
    3. Applied div-sub_binary6438.1

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

      \[\leadsto \frac{x \cdot y}{a \cdot 2} - \color{blue}{\frac{t \cdot z}{a} \cdot 4.5}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity_binary6437.8

      \[\leadsto \frac{x \cdot y}{a \cdot 2} - \frac{t \cdot z}{\color{blue}{1 \cdot a}} \cdot 4.5\]
    7. Applied times-frac_binary6421.3

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{a \cdot 2}{y}}} - \left(t \cdot \frac{z}{a}\right) \cdot 4.5\]
    11. Simplified0.7

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

    if -2.2668851269500015e249 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 7.50312860035425482e142

    1. Initial program 0.9

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

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

      \[\leadsto \frac{x \cdot y}{a \cdot 2} - \color{blue}{\frac{t \cdot z}{a} \cdot 4.5}\]
    5. Using strategy rm
    6. Applied associate-*l/_binary640.9

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

    if 7.50312860035425482e142 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 19.3

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

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

      \[\leadsto \frac{x \cdot y}{a \cdot 2} - \color{blue}{\frac{t \cdot z}{a} \cdot 4.5}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity_binary6419.0

      \[\leadsto \frac{x \cdot y}{a \cdot 2} - \frac{t \cdot z}{\color{blue}{1 \cdot a}} \cdot 4.5\]
    7. Applied times-frac_binary6412.2

      \[\leadsto \frac{x \cdot y}{a \cdot 2} - \color{blue}{\left(\frac{t}{1} \cdot \frac{z}{a}\right)} \cdot 4.5\]
    8. Simplified12.2

      \[\leadsto \frac{x \cdot y}{a \cdot 2} - \left(\color{blue}{t} \cdot \frac{z}{a}\right) \cdot 4.5\]
    9. Using strategy rm
    10. Applied times-frac_binary642.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq -2.2668851269500015 \cdot 10^{+249}:\\ \;\;\;\;\frac{x}{\frac{a}{\frac{y}{2}}} - \left(t \cdot \frac{z}{a}\right) \cdot 4.5\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq 7.503128600354255 \cdot 10^{+142}:\\ \;\;\;\;\frac{x \cdot y}{a \cdot 2} - \frac{4.5 \cdot \left(z \cdot t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{2} \cdot \frac{x}{a} - \left(t \cdot \frac{z}{a}\right) \cdot 4.5\\ \end{array}\]

Alternatives

Reproduce

herbie shell --seed 2021111 
(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.0 t))) (* a 2.0)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))