Average Error: 7.6 → 4.4
Time: 9.5s
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} t_1 := x \cdot y - \left(z \cdot 9\right) \cdot t\\ \mathbf{if}\;t_1 \leq -2.445545247323066 \cdot 10^{+245}:\\ \;\;\;\;\frac{y}{\frac{a}{\frac{x}{2}}} - \frac{z \cdot t}{a} \cdot 4.5\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := \frac{x \cdot y}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq 2.7505266388208674 \cdot 10^{+198}:\\ \;\;\;\;t_2 - \left(z \cdot t\right) \cdot \frac{4.5}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\\ \end{array} \]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
t_1 := x \cdot y - \left(z \cdot 9\right) \cdot t\\
\mathbf{if}\;t_1 \leq -2.445545247323066 \cdot 10^{+245}:\\
\;\;\;\;\frac{y}{\frac{a}{\frac{x}{2}}} - \frac{z \cdot t}{a} \cdot 4.5\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \frac{x \cdot y}{a \cdot 2}\\
\mathbf{if}\;t_1 \leq 2.7505266388208674 \cdot 10^{+198}:\\
\;\;\;\;t_2 - \left(z \cdot t\right) \cdot \frac{4.5}{a}\\

\mathbf{else}:\\
\;\;\;\;t_2 - 4.5 \cdot \frac{t}{\frac{a}{z}}\\


\end{array}\\


\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
 (let* ((t_1 (- (* x y) (* (* z 9.0) t))))
   (if (<= t_1 -2.445545247323066e+245)
     (- (/ y (/ a (/ x 2.0))) (* (/ (* z t) a) 4.5))
     (let* ((t_2 (/ (* x y) (* a 2.0))))
       (if (<= t_1 2.7505266388208674e+198)
         (- t_2 (* (* z t) (/ 4.5 a)))
         (- t_2 (* 4.5 (/ t (/ a z)))))))))
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 t_1 = (x * y) - ((z * 9.0) * t);
	double tmp;
	if (t_1 <= -2.445545247323066e+245) {
		tmp = (y / (a / (x / 2.0))) - (((z * t) / a) * 4.5);
	} else {
		double t_2 = (x * y) / (a * 2.0);
		double tmp_1;
		if (t_1 <= 2.7505266388208674e+198) {
			tmp_1 = t_2 - ((z * t) * (4.5 / a));
		} else {
			tmp_1 = t_2 - (4.5 * (t / (a / z)));
		}
		tmp = tmp_1;
	}
	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.6
Target5.4
Herbie4.4
\[\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.44554524732306611e245

    1. Initial program 38.9

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

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

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

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

      \[\leadsto \color{blue}{\frac{y}{\frac{a \cdot 2}{x}}} - \frac{t \cdot z}{a} \cdot 4.5 \]
    8. Simplified19.7

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

    if -2.44554524732306611e245 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 2.750526638820867e198

    1. Initial program 0.8

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

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

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

      \[\leadsto \frac{y \cdot x}{a \cdot 2} - \color{blue}{\frac{t \cdot z}{a} \cdot 4.5} \]
    6. Using strategy rm
    7. Applied div-inv_binary640.9

      \[\leadsto \frac{y \cdot x}{a \cdot 2} - \color{blue}{\left(\left(t \cdot z\right) \cdot \frac{1}{a}\right)} \cdot 4.5 \]
    8. Applied associate-*l*_binary640.9

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

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

    if 2.750526638820867e198 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 29.9

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

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

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

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

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

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

Reproduce

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