Average Error: 7.5 → 1.3
Time: 12.1s
Precision: binary64
\[\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 -5.312039159080881 \cdot 10^{+284}:\\ \;\;\;\;\frac{x}{\frac{a}{\frac{y}{2}}} - t \cdot \left(4.5 \cdot \frac{z}{a}\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq 3.4078992350031647 \cdot 10^{+140}:\\ \;\;\;\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{2} \cdot \frac{x}{a} - t \cdot \frac{1}{\frac{a}{z \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 -5.312039159080881 \cdot 10^{+284}:\\
\;\;\;\;\frac{x}{\frac{a}{\frac{y}{2}}} - t \cdot \left(4.5 \cdot \frac{z}{a}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\frac{y}{2} \cdot \frac{x}{a} - t \cdot \frac{1}{\frac{a}{z \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)) -5.312039159080881e+284)
   (- (/ x (/ a (/ y 2.0))) (* t (* 4.5 (/ z a))))
   (if (<= (- (* x y) (* (* z 9.0) t)) 3.4078992350031647e+140)
     (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0))
     (- (* (/ y 2.0) (/ x a)) (* t (/ 1.0 (/ a (* z 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)) <= -5.312039159080881e+284) {
		tmp = (x / (a / (y / 2.0))) - (t * (4.5 * (z / a)));
	} else if (((x * y) - ((z * 9.0) * t)) <= 3.4078992350031647e+140) {
		tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
	} else {
		tmp = ((y / 2.0) * (x / a)) - (t * (1.0 / (a / (z * 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.5
Target5.5
Herbie1.3
\[\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)) < -5.3120391590808808e284

    1. Initial program 51.5

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

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

      \[\leadsto \frac{x \cdot y}{a \cdot 2} - \color{blue}{t \cdot \left(4.5 \cdot \frac{z}{a}\right)}\]
    5. Using strategy rm
    6. Applied associate-/l*_binary64_198010.3

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

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

    if -5.3120391590808808e284 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 3.4078992350031647e140

    1. Initial program 1.0

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

    if 3.4078992350031647e140 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 19.6

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

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

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

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

      \[\leadsto \frac{x}{a} \cdot \frac{y}{2} - t \cdot \color{blue}{\frac{4.5 \cdot z}{a}}\]
    9. Using strategy rm
    10. Applied clear-num_binary64_198553.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq -5.312039159080881 \cdot 10^{+284}:\\ \;\;\;\;\frac{x}{\frac{a}{\frac{y}{2}}} - t \cdot \left(4.5 \cdot \frac{z}{a}\right)\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq 3.4078992350031647 \cdot 10^{+140}:\\ \;\;\;\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{2} \cdot \frac{x}{a} - t \cdot \frac{1}{\frac{a}{z \cdot 4.5}}\\ \end{array}\]

Reproduce

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