?

Average Accuracy: 88.1% → 98.8%
Time: 14.0s
Precision: binary64
Cost: 2249

?

\[ \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 -2 \cdot 10^{+289} \lor \neg \left(t_1 \leq 2 \cdot 10^{+291}\right):\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right) + 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \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 -2e+289) (not (<= t_1 2e+291)))
     (+ (* -4.5 (* z (/ t a))) (* 0.5 (* y (/ x a))))
     (/ (+ (* x y) (* z (* t -9.0))) (* a 2.0)))))
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 <= -2e+289) || !(t_1 <= 2e+291)) {
		tmp = (-4.5 * (z * (t / a))) + (0.5 * (y * (x / a)));
	} else {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x * y) - ((z * 9.0d0) * t)
    if ((t_1 <= (-2d+289)) .or. (.not. (t_1 <= 2d+291))) then
        tmp = ((-4.5d0) * (z * (t / a))) + (0.5d0 * (y * (x / a)))
    else
        tmp = ((x * y) + (z * (t * (-9.0d0)))) / (a * 2.0d0)
    end if
    code = tmp
end function
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 <= -2e+289) || !(t_1 <= 2e+291)) {
		tmp = (-4.5 * (z * (t / a))) + (0.5 * (y * (x / a)));
	} else {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	}
	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 <= -2e+289) or not (t_1 <= 2e+291):
		tmp = (-4.5 * (z * (t / a))) + (0.5 * (y * (x / a)))
	else:
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0)
	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 <= -2e+289) || !(t_1 <= 2e+291))
		tmp = Float64(Float64(-4.5 * Float64(z * Float64(t / a))) + Float64(0.5 * Float64(y * Float64(x / a))));
	else
		tmp = Float64(Float64(Float64(x * y) + Float64(z * Float64(t * -9.0))) / Float64(a * 2.0));
	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 <= -2e+289) || ~((t_1 <= 2e+291)))
		tmp = (-4.5 * (z * (t / a))) + (0.5 * (y * (x / a)));
	else
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	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, -2e+289], N[Not[LessEqual[t$95$1, 2e+291]], $MachinePrecision]], N[(N[(-4.5 * N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $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 -2 \cdot 10^{+289} \lor \neg \left(t_1 \leq 2 \cdot 10^{+291}\right):\\
\;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right) + 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original88.1%
Target91.4%
Herbie98.8%
\[\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)) < -2.0000000000000001e289 or 1.9999999999999999e291 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 14.3%

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

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

      [Start]14.3

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

      sub-neg [=>]14.3

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

      remove-double-neg [<=]14.3

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

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

      +-commutative [<=]14.3

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

      sub-neg [<=]14.3

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

      neg-mul-1 [=>]14.3

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

      associate-/l* [=>]14.3

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

      associate-/r/ [=>]14.3

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

      sub-neg [=>]14.3

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

      +-commutative [=>]14.3

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

      neg-sub0 [=>]14.3

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

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

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

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

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

      \[ \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 14.9%

      \[\leadsto \color{blue}{-4.5 \cdot \frac{t \cdot z}{a} + 0.5 \cdot \frac{y \cdot x}{a}} \]
    4. Applied egg-rr54.9%

      \[\leadsto -4.5 \cdot \frac{t \cdot z}{a} + 0.5 \cdot \color{blue}{\left(\frac{x}{a} \cdot y\right)} \]
    5. Applied egg-rr99.4%

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

    if -2.0000000000000001e289 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 1.9999999999999999e291

    1. Initial program 98.7%

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

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

      [Start]98.7

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

      associate-*l* [=>]98.7

      \[ \frac{x \cdot y - \color{blue}{z \cdot \left(9 \cdot t\right)}}{a \cdot 2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.8%

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

Alternatives

Alternative 1
Accuracy91.2%
Cost2384
\[\begin{array}{l} t_1 := \frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ t_2 := \left(z \cdot 9\right) \cdot t\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+271}:\\ \;\;\;\;\frac{z}{a} \cdot \left(t \cdot -4.5\right)\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-302}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{-179}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+254}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \end{array} \]
Alternative 2
Accuracy63.0%
Cost978
\[\begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-79} \lor \neg \left(y \leq 4.5 \cdot 10^{-31} \lor \neg \left(y \leq 1.15 \cdot 10^{-14}\right) \land y \leq 3.1 \cdot 10^{+67}\right):\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \end{array} \]
Alternative 3
Accuracy62.9%
Cost976
\[\begin{array}{l} t_1 := -4.5 \cdot \frac{z \cdot t}{a}\\ t_2 := 0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{if}\;y \leq -3.2 \cdot 10^{-79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-15}:\\ \;\;\;\;x \cdot \frac{0.5}{\frac{a}{y}}\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy62.8%
Cost976
\[\begin{array}{l} t_1 := -4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{if}\;y \leq -2.45 \cdot 10^{-79}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \frac{0.5}{\frac{a}{y}}\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 5
Accuracy62.9%
Cost976
\[\begin{array}{l} t_1 := -4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{if}\;y \leq -3.2 \cdot 10^{-79}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-14}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{a}\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+68}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 6
Accuracy62.9%
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-79}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-31}:\\ \;\;\;\;\frac{-4.5 \cdot \left(z \cdot t\right)}{a}\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-14}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{a}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+69}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 7
Accuracy63.0%
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{-79}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-31}:\\ \;\;\;\;\frac{t \cdot \left(z \cdot -9\right)}{a \cdot 2}\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-14}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{a}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{+67}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 8
Accuracy50.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;a \leq -1.16 \cdot 10^{+95} \lor \neg \left(a \leq 1.5 \cdot 10^{-81}\right):\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \end{array} \]
Alternative 9
Accuracy48.6%
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{-215}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \end{array} \]
Alternative 10
Accuracy48.7%
Cost448
\[-4.5 \cdot \left(z \cdot \frac{t}{a}\right) \]

Error

Reproduce?

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