Average Error: 7.6 → 4.3
Time: 13.9s
Precision: binary64
Cost: 2632
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
\[\begin{array}{l} t_1 := \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;t_1 \leq 4 \cdot 10^{+305}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \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)) (* a 2.0))))
   (if (<= t_1 (- INFINITY))
     (* 0.5 (/ y (/ a x)))
     (if (<= t_1 4e+305)
       (/ (+ (* x y) (* z (* t -9.0))) (* a 2.0))
       (/ (* t -4.5) (/ 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)) / (a * 2.0);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = 0.5 * (y / (a / x));
	} else if (t_1 <= 4e+305) {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	} else {
		tmp = (t * -4.5) / (a / z);
	}
	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)) / (a * 2.0);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = 0.5 * (y / (a / x));
	} else if (t_1 <= 4e+305) {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	} else {
		tmp = (t * -4.5) / (a / z);
	}
	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)) / (a * 2.0)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = 0.5 * (y / (a / x))
	elif t_1 <= 4e+305:
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0)
	else:
		tmp = (t * -4.5) / (a / z)
	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(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(0.5 * Float64(y / Float64(a / x)));
	elseif (t_1 <= 4e+305)
		tmp = Float64(Float64(Float64(x * y) + Float64(z * Float64(t * -9.0))) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(t * -4.5) / Float64(a / z));
	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)) / (a * 2.0);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = 0.5 * (y / (a / x));
	elseif (t_1 <= 4e+305)
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	else
		tmp = (t * -4.5) / (a / z);
	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[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(0.5 * N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+305], N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(t * -4.5), $MachinePrecision] / N[(a / z), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
t_1 := \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.6
Target5.5
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 3 regimes
  2. if (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2)) < -inf.0

    1. Initial program 64.0

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

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

      [Start]64.0

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

      sub-neg [=>]64.0

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

      remove-double-neg [<=]64.0

      \[ \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 [<=]64.0

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

      +-commutative [<=]64.0

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

      sub-neg [<=]64.0

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

      neg-mul-1 [=>]64.0

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

      associate-/l* [=>]64.0

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

      associate-/r/ [=>]64.0

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

      sub-neg [=>]64.0

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

      +-commutative [=>]64.0

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

      neg-sub0 [=>]64.0

      \[ \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- [=>]64.0

      \[ \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 [=>]64.0

      \[ \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 [=>]64.0

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

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

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

      *-commutative [=>]64.0

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

      associate-/r* [=>]64.0

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

      distribute-neg-frac [=>]64.0

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

      metadata-eval [=>]64.0

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

      metadata-eval [=>]64.0

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

      fma-neg [=>]64.0

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

      associate-*l* [=>]63.5

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

      distribute-rgt-neg-in [=>]63.5

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

      *-commutative [=>]63.5

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

      distribute-rgt-neg-in [=>]63.5

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

      metadata-eval [=>]63.5

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y \cdot x}{a}} \]
    4. Simplified33.2

      \[\leadsto \color{blue}{0.5 \cdot \frac{y}{\frac{a}{x}}} \]
      Proof

      [Start]63.3

      \[ 0.5 \cdot \frac{y \cdot x}{a} \]

      associate-/l* [=>]33.2

      \[ 0.5 \cdot \color{blue}{\frac{y}{\frac{a}{x}}} \]

    if -inf.0 < (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2)) < 3.9999999999999998e305

    1. Initial program 0.9

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

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

      [Start]0.9

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

      associate-*l* [=>]0.9

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

    if 3.9999999999999998e305 < (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2))

    1. Initial program 62.5

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

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

      [Start]62.5

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

      associate-*l* [=>]61.9

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

      \[\leadsto \color{blue}{-4.5 \cdot \frac{t \cdot z}{a}} \]
    4. Simplified31.0

      \[\leadsto \color{blue}{\frac{-4.5 \cdot t}{\frac{a}{z}}} \]
      Proof

      [Start]61.3

      \[ -4.5 \cdot \frac{t \cdot z}{a} \]

      associate-/l* [=>]31.0

      \[ -4.5 \cdot \color{blue}{\frac{t}{\frac{a}{z}}} \]

      associate-*r/ [=>]31.0

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

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

Alternatives

Alternative 1
Error24.3
Cost1504
\[\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 := -4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{if}\;x \leq -1.8 \cdot 10^{+53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{+21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-60}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -5.1 \cdot 10^{-67}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-261}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 3.05 \cdot 10^{-89}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error4.9
Cost1352
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+180}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{elif}\;x \cdot y \leq 10^{+215}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y + z \cdot \left(t \cdot -9\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 3
Error23.8
Cost1240
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;x \leq -1.75 \cdot 10^{+53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+21}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-60}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;x \leq -6.1 \cdot 10^{-65}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-87}:\\ \;\;\;\;\frac{-4.5}{a} \cdot \left(z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error23.8
Cost1240
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;x \leq -9.5 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{+21}:\\ \;\;\;\;t \cdot \frac{-4.5}{\frac{a}{z}}\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.7 \cdot 10^{-56}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-65}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-89}:\\ \;\;\;\;\frac{-4.5}{a} \cdot \left(z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error23.7
Cost1240
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;x \leq -1.1 \cdot 10^{+53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8 \cdot 10^{+20}:\\ \;\;\;\;t \cdot \frac{-4.5}{\frac{a}{z}}\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-57}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-65}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-88}:\\ \;\;\;\;\frac{-4.5}{a} \cdot \left(z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{a}{y}}\\ \end{array} \]
Alternative 6
Error23.5
Cost844
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;y \leq -1.18 \cdot 10^{-147}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-293}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;y \leq 110000:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error32.6
Cost448
\[-4.5 \cdot \left(z \cdot \frac{t}{a}\right) \]
Alternative 8
Error32.8
Cost448
\[-4.5 \cdot \frac{t}{\frac{a}{z}} \]

Error

Reproduce

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