Average Error: 7.9 → 1.0
Time: 6.6s
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 -1.446071231350435 \cdot 10^{+278}:\\ \;\;\;\;\frac{x}{\frac{a}{\frac{y}{2}}} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq 2.2375349926989337 \cdot 10^{+204}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{2} \cdot \frac{x}{a} - t \cdot \left(4.5 \cdot \frac{z}{a}\right)\\ \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 -1.446071231350435 \cdot 10^{+278}:\\
\;\;\;\;\frac{x}{\frac{a}{\frac{y}{2}}} - \left(t \cdot 4.5\right) \cdot \frac{z}{a}\\

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

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

\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)) -1.446071231350435e+278)
   (- (/ x (/ a (/ y 2.0))) (* (* t 4.5) (/ z a)))
   (if (<= (- (* x y) (* (* z 9.0) t)) 2.2375349926989337e+204)
     (/ (+ (* x y) (* z (* t -9.0))) (* a 2.0))
     (- (* (/ y 2.0) (/ x a)) (* t (* 4.5 (/ z a)))))))
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)) <= -1.446071231350435e+278) {
		tmp = (x / (a / (y / 2.0))) - ((t * 4.5) * (z / a));
	} else if (((x * y) - ((z * 9.0) * t)) <= 2.2375349926989337e+204) {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	} else {
		tmp = ((y / 2.0) * (x / a)) - (t * (4.5 * (z / a)));
	}
	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.9
Target5.9
Herbie1.0
\[\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)) < -1.44607123135043502e278

    1. Initial program 48.5

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

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

      \[\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*_binary640.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)\]
    8. Using strategy rm
    9. Applied associate-*r*_binary640.4

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

    if -1.44607123135043502e278 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 2.2375349926989337e204

    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 sub-neg_binary640.9

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

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

    if 2.2375349926989337e204 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 31.4

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

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

      \[\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_binary641.8

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

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

Reproduce

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