Average Error: 7.5 → 4.3
Time: 6.2s
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 := 0.5 \cdot \left(y \cdot \frac{x}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{if}\;x \cdot y \leq -5.957510284115416 \cdot 10^{+296}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 9.2735317214375 \cdot 10^{+303}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (- (* 0.5 (* y (/ x a))) (* 4.5 (/ (* t z) a)))))
   (if (<= (* x y) -5.957510284115416e+296)
     t_1
     (if (<= (* x y) 9.2735317214375e+303)
       (-
        (* 0.5 (/ (* x y) a))
        (* 4.5 (* (/ t (* (cbrt a) (cbrt a))) (/ z (cbrt a)))))
       t_1))))
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 = (0.5 * (y * (x / a))) - (4.5 * ((t * z) / a));
	double tmp;
	if ((x * y) <= -5.957510284115416e+296) {
		tmp = t_1;
	} else if ((x * y) <= 9.2735317214375e+303) {
		tmp = (0.5 * ((x * y) / a)) - (4.5 * ((t / (cbrt(a) * cbrt(a))) * (z / cbrt(a))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (0.5 * (y * (x / a))) - (4.5 * ((t * z) / a));
	double tmp;
	if ((x * y) <= -5.957510284115416e+296) {
		tmp = t_1;
	} else if ((x * y) <= 9.2735317214375e+303) {
		tmp = (0.5 * ((x * y) / a)) - (4.5 * ((t / (Math.cbrt(a) * Math.cbrt(a))) * (z / Math.cbrt(a))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(0.5 * Float64(y * Float64(x / a))) - Float64(4.5 * Float64(Float64(t * z) / a)))
	tmp = 0.0
	if (Float64(x * y) <= -5.957510284115416e+296)
		tmp = t_1;
	elseif (Float64(x * y) <= 9.2735317214375e+303)
		tmp = Float64(Float64(0.5 * Float64(Float64(x * y) / a)) - Float64(4.5 * Float64(Float64(t / Float64(cbrt(a) * cbrt(a))) * Float64(z / cbrt(a)))));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(0.5 * N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(4.5 * N[(N[(t * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -5.957510284115416e+296], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 9.2735317214375e+303], N[(N[(0.5 * N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] - N[(4.5 * N[(N[(t / N[(N[Power[a, 1/3], $MachinePrecision] * N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
t_1 := 0.5 \cdot \left(y \cdot \frac{x}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\
\mathbf{if}\;x \cdot y \leq -5.957510284115416 \cdot 10^{+296}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \cdot y \leq 9.2735317214375 \cdot 10^{+303}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

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.7
Herbie4.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 2 regimes
  2. if (*.f64 x y) < -5.9575102841154163e296 or 9.2735317214374998e303 < (*.f64 x y)

    1. Initial program 58.6

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-9, z \cdot t, x \cdot y\right) \cdot \frac{0.5}{a}} \]
    3. Taylor expanded in z around 0 58.6

      \[\leadsto \color{blue}{0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t \cdot z}{a}} \]
    4. Applied *-un-lft-identity_binary6458.6

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

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

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

    if -5.9575102841154163e296 < (*.f64 x y) < 9.2735317214374998e303

    1. Initial program 4.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-9, z \cdot t, x \cdot y\right) \cdot \frac{0.5}{a}} \]
    3. Taylor expanded in z around 0 4.1

      \[\leadsto \color{blue}{0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t \cdot z}{a}} \]
    4. Applied add-cube-cbrt_binary644.6

      \[\leadsto 0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t \cdot z}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}} \]
    5. Applied times-frac_binary644.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5.957510284115416 \cdot 10^{+296}:\\ \;\;\;\;0.5 \cdot \left(y \cdot \frac{x}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \leq 9.2735317214375 \cdot 10^{+303}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \left(\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y \cdot \frac{x}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array} \]

Reproduce

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