?

Average Error: 12.28% → 1.5%
Time: 15.9s
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 + t \cdot \left(z \cdot -9\right)\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+271} \lor \neg \left(t_1 \leq 5 \cdot 10^{+223}\right):\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} + \frac{t}{2} \cdot \frac{z \cdot -9}{a}\\ \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) (* t (* z -9.0)))))
   (if (or (<= t_1 -5e+271) (not (<= t_1 5e+223)))
     (+ (* 0.5 (/ x (/ a y))) (* (/ t 2.0) (/ (* z -9.0) 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) + (t * (z * -9.0));
	double tmp;
	if ((t_1 <= -5e+271) || !(t_1 <= 5e+223)) {
		tmp = (0.5 * (x / (a / y))) + ((t / 2.0) * ((z * -9.0) / 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) + (t * (z * (-9.0d0)))
    if ((t_1 <= (-5d+271)) .or. (.not. (t_1 <= 5d+223))) then
        tmp = (0.5d0 * (x / (a / y))) + ((t / 2.0d0) * ((z * (-9.0d0)) / 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) + (t * (z * -9.0));
	double tmp;
	if ((t_1 <= -5e+271) || !(t_1 <= 5e+223)) {
		tmp = (0.5 * (x / (a / y))) + ((t / 2.0) * ((z * -9.0) / 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) + (t * (z * -9.0))
	tmp = 0
	if (t_1 <= -5e+271) or not (t_1 <= 5e+223):
		tmp = (0.5 * (x / (a / y))) + ((t / 2.0) * ((z * -9.0) / 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(t * Float64(z * -9.0)))
	tmp = 0.0
	if ((t_1 <= -5e+271) || !(t_1 <= 5e+223))
		tmp = Float64(Float64(0.5 * Float64(x / Float64(a / y))) + Float64(Float64(t / 2.0) * Float64(Float64(z * -9.0) / 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) + (t * (z * -9.0));
	tmp = 0.0;
	if ((t_1 <= -5e+271) || ~((t_1 <= 5e+223)))
		tmp = (0.5 * (x / (a / y))) + ((t / 2.0) * ((z * -9.0) / 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[(t * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+271], N[Not[LessEqual[t$95$1, 5e+223]], $MachinePrecision]], N[(N[(0.5 * N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t / 2.0), $MachinePrecision] * N[(N[(z * -9.0), $MachinePrecision] / a), $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 + t \cdot \left(z \cdot -9\right)\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+271} \lor \neg \left(t_1 \leq 5 \cdot 10^{+223}\right):\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}} + \frac{t}{2} \cdot \frac{z \cdot -9}{a}\\

\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

Original12.28%
Target8.84%
Herbie1.5%
\[\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)) < -5.0000000000000003e271 or 4.99999999999999985e223 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 62.11

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y \cdot x}{a}} - \frac{z \cdot 9}{a} \cdot \frac{t}{2} \]
    4. Simplified1.58

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

      [Start]33.98

      \[ 0.5 \cdot \frac{y \cdot x}{a} - \frac{z \cdot 9}{a} \cdot \frac{t}{2} \]

      *-commutative [<=]33.98

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

      associate-/l* [=>]1.58

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

    if -5.0000000000000003e271 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 4.99999999999999985e223

    1. Initial program 1.43

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

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

      [Start]1.43

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

      associate-*l* [=>]1.48

      \[ \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 simplification1.5

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

Alternatives

Alternative 1
Error6.73%
Cost2120
\[\begin{array}{l} t_1 := x \cdot y + t \cdot \left(z \cdot -9\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{elif}\;t_1 \leq 10^{+307}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array} \]
Alternative 2
Error37.71%
Cost1240
\[\begin{array}{l} t_1 := 0.5 \cdot \frac{y}{\frac{a}{x}}\\ t_2 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ t_3 := -4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \mathbf{if}\;z \leq -5.8 \cdot 10^{+34}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-96}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-121}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{-203}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.9 \cdot 10^{-203}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error37.9%
Cost1240
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ t_2 := -4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \mathbf{if}\;z \leq -5.2 \cdot 10^{+33}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-96}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-121}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.7 \cdot 10^{-202}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{-272}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{-150}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error37.69%
Cost1240
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ t_2 := -4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \mathbf{if}\;z \leq -6.2 \cdot 10^{+33}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.9 \cdot 10^{-121}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{-200}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-269}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{-150}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error37.64%
Cost977
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+33}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;z \leq -4.1 \cdot 10^{-97} \lor \neg \left(z \leq -2.75 \cdot 10^{-121}\right) \land z \leq 1.65 \cdot 10^{-149}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array} \]
Alternative 6
Error36.81%
Cost977
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+33}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;z \leq -3.9 \cdot 10^{-97}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-122} \lor \neg \left(z \leq 4.8 \cdot 10^{-149}\right):\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 7
Error36.82%
Cost977
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+34}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;z \leq -1.22 \cdot 10^{-96}:\\ \;\;\;\;\frac{x}{\frac{a \cdot 2}{y}}\\ \mathbf{elif}\;z \leq -2.35 \cdot 10^{-122} \lor \neg \left(z \leq 4.2 \cdot 10^{-149}\right):\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 8
Error36.77%
Cost976
\[\begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{+34}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-97}:\\ \;\;\;\;\frac{x}{\frac{a \cdot 2}{y}}\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-122}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-150}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array} \]
Alternative 9
Error36.76%
Cost976
\[\begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{+33}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{-97}:\\ \;\;\;\;\frac{x}{\frac{a \cdot 2}{y}}\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-121}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-149}:\\ \;\;\;\;\frac{x \cdot y}{\frac{a}{0.5}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array} \]
Alternative 10
Error36.84%
Cost976
\[\begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{+34}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-97}:\\ \;\;\;\;\frac{1}{\frac{a \cdot \frac{2}{y}}{x}}\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-122}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-149}:\\ \;\;\;\;\frac{x \cdot y}{\frac{a}{0.5}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array} \]
Alternative 11
Error13.51%
Cost964
\[\begin{array}{l} \mathbf{if}\;t \leq 5.5 \cdot 10^{+191}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y + -9 \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(z \cdot \frac{-4.5}{a}\right)\\ \end{array} \]
Alternative 12
Error49.57%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -1.1 \cdot 10^{+105}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \leq 2.2 \cdot 10^{-181}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array} \]
Alternative 13
Error51.19%
Cost448
\[-4.5 \cdot \left(t \cdot \frac{z}{a}\right) \]

Error

Reproduce?

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