?

Average Error: 7.7 → 0.7
Time: 14.0s
Precision: binary64
Cost: 2377

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \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 -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+302}\right):\\ \;\;\;\;x \cdot \left(y \cdot \frac{0.5}{a}\right) + \frac{z}{a} \cdot \frac{-9}{\frac{2}{t}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a} + 0.5 \cdot \frac{x \cdot y}{a}\\ \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 (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+302)))
     (+ (* x (* y (/ 0.5 a))) (* (/ z a) (/ -9.0 (/ 2.0 t))))
     (+ (* -4.5 (/ (* z t) a)) (* 0.5 (/ (* x y) 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 t_1 = (x * y) - ((z * 9.0) * t);
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+302)) {
		tmp = (x * (y * (0.5 / a))) + ((z / a) * (-9.0 / (2.0 / t)));
	} else {
		tmp = (-4.5 * ((z * t) / a)) + (0.5 * ((x * y) / a));
	}
	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 = (x * y) - ((z * 9.0) * t);
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+302)) {
		tmp = (x * (y * (0.5 / a))) + ((z / a) * (-9.0 / (2.0 / t)));
	} else {
		tmp = (-4.5 * ((z * t) / a)) + (0.5 * ((x * y) / a));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
def code(x, y, z, t, a):
	t_1 = (x * y) - ((z * 9.0) * t)
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 2e+302):
		tmp = (x * (y * (0.5 / a))) + ((z / a) * (-9.0 / (2.0 / t)))
	else:
		tmp = (-4.5 * ((z * t) / a)) + (0.5 * ((x * y) / a))
	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(x * y) - Float64(Float64(z * 9.0) * t))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+302))
		tmp = Float64(Float64(x * Float64(y * Float64(0.5 / a))) + Float64(Float64(z / a) * Float64(-9.0 / Float64(2.0 / t))));
	else
		tmp = Float64(Float64(-4.5 * Float64(Float64(z * t) / a)) + Float64(0.5 * Float64(Float64(x * y) / a)));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x * y) - ((z * 9.0) * t);
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 2e+302)))
		tmp = (x * (y * (0.5 / a))) + ((z / a) * (-9.0 / (2.0 / t)));
	else
		tmp = (-4.5 * ((z * t) / a)) + (0.5 * ((x * y) / a));
	end
	tmp_2 = 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[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+302]], $MachinePrecision]], N[(N[(x * N[(y * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(z / a), $MachinePrecision] * N[(-9.0 / N[(2.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\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 -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+302}\right):\\
\;\;\;\;x \cdot \left(y \cdot \frac{0.5}{a}\right) + \frac{z}{a} \cdot \frac{-9}{\frac{2}{t}}\\

\mathbf{else}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a} + 0.5 \cdot \frac{x \cdot y}{a}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.7
Target5.3
Herbie0.7
\[\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 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < -inf.0 or 2.0000000000000002e302 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 62.4

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

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

      [Start]62.4

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

      associate-*l* [=>]61.4

      \[ \frac{x \cdot y - \color{blue}{z \cdot \left(9 \cdot t\right)}}{a \cdot 2} \]
    3. Applied egg-rr34.1

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

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

      [Start]34.1

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

      sub-neg [<=]34.1

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

      associate-*l* [=>]0.6

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

      associate-/l* [=>]0.7

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

    if -inf.0 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 2.0000000000000002e302

    1. Initial program 0.7

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

      \[\leadsto \color{blue}{\frac{0.5}{a} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t \cdot -9\right)\right)} \]
      Proof

      [Start]0.7

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

      sub-neg [=>]0.7

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

      remove-double-neg [<=]0.7

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

      distribute-neg-in [<=]0.7

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

      +-commutative [<=]0.7

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

      sub-neg [<=]0.7

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

      neg-mul-1 [=>]0.7

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

      associate-/l* [=>]1.0

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

      associate-/r/ [=>]0.8

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

      sub-neg [=>]0.8

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

      +-commutative [=>]0.8

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

      neg-sub0 [=>]0.8

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

      associate-+l- [=>]0.8

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

      sub0-neg [=>]0.8

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

      distribute-rgt-neg-out [=>]0.8

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

      distribute-lft-neg-in [=>]0.8

      \[ \color{blue}{\left(-\frac{-1}{a \cdot 2}\right) \cdot \left(x \cdot y - \left(z \cdot 9\right) \cdot t\right)} \]
    3. Taylor expanded in x around 0 0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - \left(z \cdot 9\right) \cdot t \leq -\infty \lor \neg \left(x \cdot y - \left(z \cdot 9\right) \cdot t \leq 2 \cdot 10^{+302}\right):\\ \;\;\;\;x \cdot \left(y \cdot \frac{0.5}{a}\right) + \frac{z}{a} \cdot \frac{-9}{\frac{2}{t}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a} + 0.5 \cdot \frac{x \cdot y}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error4.3
Cost2248
\[\begin{array}{l} t_1 := x \cdot y - \left(z \cdot 9\right) \cdot t\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{t}{\frac{\frac{a}{z}}{-4.5}}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+302}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a} + 0.5 \cdot \frac{x \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a} \cdot \left(t \cdot -4.5\right)\\ \end{array} \]
Alternative 2
Error4.3
Cost2120
\[\begin{array}{l} t_1 := x \cdot y - \left(z \cdot 9\right) \cdot t\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{t}{\frac{\frac{a}{z}}{-4.5}}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+302}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a} \cdot \left(t \cdot -4.5\right)\\ \end{array} \]
Alternative 3
Error26.2
Cost1241
\[\begin{array}{l} t_1 := -4.5 \cdot \frac{t}{\frac{a}{z}}\\ t_2 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{+167}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -7.9 \cdot 10^{+62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-107} \lor \neg \left(x \leq 1.6 \cdot 10^{-199}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \end{array} \]
Alternative 4
Error26.2
Cost1240
\[\begin{array}{l} t_1 := -4.5 \cdot \frac{t}{\frac{a}{z}}\\ t_2 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ t_3 := 0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{+167}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.05 \cdot 10^{+63}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-107}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-199}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error26.2
Cost1240
\[\begin{array}{l} t_1 := -4.5 \cdot \frac{t}{\frac{a}{z}}\\ t_2 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{+167}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.46 \cdot 10^{+63}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-107}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-200}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error23.6
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.000165 \lor \neg \left(z \leq 1.6 \cdot 10^{-23}\right):\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 7
Error23.6
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{-5} \lor \neg \left(z \leq 2.4 \cdot 10^{-19}\right):\\ \;\;\;\;\frac{t}{\frac{\frac{a}{z}}{-4.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 8
Error23.7
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -0.000104:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-19}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a} \cdot \left(t \cdot -4.5\right)\\ \end{array} \]
Alternative 9
Error23.6
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-19}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\frac{\frac{a}{z}}{-4.5}}\\ \end{array} \]
Alternative 10
Error23.7
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00013:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-19}:\\ \;\;\;\;\frac{x \cdot y}{\frac{a}{0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\frac{\frac{a}{z}}{-4.5}}\\ \end{array} \]
Alternative 11
Error31.9
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 1.08 \cdot 10^{+175}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \end{array} \]
Alternative 12
Error32.5
Cost448
\[-4.5 \cdot \frac{t}{\frac{a}{z}} \]

Error

Reproduce?

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