?

Average Error: 11.98% → 1.25%
Time: 13.0s
Precision: binary64
Cost: 2377

?

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

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{a \cdot 2}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.98%
Target9.24%
Herbie1.25%
\[\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)) < -1.00000000000000006e290 or 5.00000000000000033e259 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 75.6

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

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

      [Start]75.6

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

      associate-*l* [=>]75.17

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

      \[\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.73

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

      [Start]41.93

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

      sub-neg [<=]41.93

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

      associate-*l* [=>]0.67

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

      associate-/l* [=>]0.73

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

    if -1.00000000000000006e290 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 5.00000000000000033e259

    1. Initial program 1.34

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

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

Alternatives

Alternative 1
Error7.17%
Cost2632
\[\begin{array}{l} t_1 := \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+296}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;t_1 \leq 10^{+304}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a} \cdot \left(t \cdot -4.5\right)\\ \end{array} \]
Alternative 2
Error7.04%
Cost1352
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+249}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}}\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+191}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y + z \cdot \left(t \cdot -9\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \end{array} \]
Alternative 3
Error6.86%
Cost1352
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+276}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}}\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+191}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \end{array} \]
Alternative 4
Error37.13%
Cost1104
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;y \leq -2.06 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-70}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+26}:\\ \;\;\;\;\left(z \cdot t\right) \cdot \left(\frac{0.5}{a} \cdot -9\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \end{array} \]
Alternative 5
Error37.05%
Cost977
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;y \leq -2.06 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-70}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+16} \lor \neg \left(y \leq 8.8 \cdot 10^{+26}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \end{array} \]
Alternative 6
Error36.92%
Cost976
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;y \leq -2.06 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-70}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+28}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}}\\ \end{array} \]
Alternative 7
Error37.31%
Cost976
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;y \leq -2.06 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-71}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+27}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 8
Error37.14%
Cost976
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;y \leq -2.06 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-70}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{+17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{+27}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\ \end{array} \]
Alternative 9
Error49.49%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+76} \lor \neg \left(z \leq 10^{+97}\right):\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \end{array} \]
Alternative 10
Error51.42%
Cost448
\[-4.5 \cdot \frac{t}{\frac{a}{z}} \]

Error

Reproduce?

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