Average Error: 0.1 → 6.6
Time: 7.9s
Precision: binary64
Cost: 708
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{\left(x + y\right) - z}{t \cdot 2} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -7.779835291625142 \cdot 10^{-14}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{t} - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y - z}{t}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
(FPCore (x y z t)
 :precision binary64
 (if (<= x -7.779835291625142e-14)
   (* 0.5 (- (/ x t) (/ z t)))
   (* 0.5 (/ (- y z) t))))
double code(double x, double y, double z, double t) {
	return ((x + y) - z) / (t * 2.0);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -7.779835291625142e-14) {
		tmp = 0.5 * ((x / t) - (z / t));
	} else {
		tmp = 0.5 * ((y - z) / t);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = ((x + y) - z) / (t * 2.0d0)
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (x <= (-7.779835291625142d-14)) then
        tmp = 0.5d0 * ((x / t) - (z / t))
    else
        tmp = 0.5d0 * ((y - z) / t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return ((x + y) - z) / (t * 2.0);
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -7.779835291625142e-14) {
		tmp = 0.5 * ((x / t) - (z / t));
	} else {
		tmp = 0.5 * ((y - z) / t);
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x + y) - z) / (t * 2.0)
def code(x, y, z, t):
	tmp = 0
	if x <= -7.779835291625142e-14:
		tmp = 0.5 * ((x / t) - (z / t))
	else:
		tmp = 0.5 * ((y - z) / t)
	return tmp
function code(x, y, z, t)
	return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0))
end
function code(x, y, z, t)
	tmp = 0.0
	if (x <= -7.779835291625142e-14)
		tmp = Float64(0.5 * Float64(Float64(x / t) - Float64(z / t)));
	else
		tmp = Float64(0.5 * Float64(Float64(y - z) / t));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = ((x + y) - z) / (t * 2.0);
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (x <= -7.779835291625142e-14)
		tmp = 0.5 * ((x / t) - (z / t));
	else
		tmp = 0.5 * ((y - z) / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[x, -7.779835291625142e-14], N[(0.5 * N[(N[(x / t), $MachinePrecision] - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\frac{\left(x + y\right) - z}{t \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \leq -7.779835291625142 \cdot 10^{-14}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{t} - \frac{z}{t}\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y - z}{t}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -7.7798352916251415e-14

    1. Initial program 0.1

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in y around 0 8.5

      \[\leadsto \color{blue}{0.5 \cdot \frac{x - z}{t}} \]
    3. Applied egg-rr8.5

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

    if -7.7798352916251415e-14 < x

    1. Initial program 0.0

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Taylor expanded in x around 0 0.0

      \[\leadsto \color{blue}{0.5 \cdot \frac{y - z}{t} + 0.5 \cdot \frac{x}{t}} \]
    3. Taylor expanded in x around 0 5.1

      \[\leadsto \color{blue}{0.5 \cdot \frac{y - z}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.779835291625142 \cdot 10^{-14}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{t} - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y - z}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error29.9
Cost1772
\[\begin{array}{l} t_1 := 0.5 \cdot \frac{x}{t}\\ t_2 := \frac{z}{t} \cdot -0.5\\ t_3 := \frac{y}{t \cdot 2}\\ \mathbf{if}\;z \leq -6.400951553559235 \cdot 10^{+54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.2795260216303123 \cdot 10^{-21}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.943121509099285 \cdot 10^{-108}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.192868671019269 \cdot 10^{-184}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.3775269540076336 \cdot 10^{-288}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.407976261569262 \cdot 10^{-301}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.1693666803389322 \cdot 10^{-226}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.6822571756988488 \cdot 10^{-176}:\\ \;\;\;\;y \cdot \frac{0.5}{t}\\ \mathbf{elif}\;z \leq 5.408092287441207 \cdot 10^{-127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.061992211629098 \cdot 10^{-73}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.6009804189190755 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error12.3
Cost844
\[\begin{array}{l} t_1 := \frac{y}{t \cdot 2}\\ t_2 := \frac{0.5}{\frac{t}{x - z}}\\ \mathbf{if}\;y \leq 2.2205170581647987 \cdot 10^{+63}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+136}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error9.1
Cost712
\[\begin{array}{l} t_1 := \frac{0.5}{\frac{t}{x - z}}\\ \mathbf{if}\;z \leq -6.400951553559235 \cdot 10^{+54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.0923113167794744 \cdot 10^{+26}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error9.0
Cost712
\[\begin{array}{l} t_1 := 0.5 \cdot \frac{x - z}{t}\\ \mathbf{if}\;z \leq -6.400951553559235 \cdot 10^{+54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.0923113167794744 \cdot 10^{+26}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error6.6
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq -7.779835291625142 \cdot 10^{-14}:\\ \;\;\;\;0.5 \cdot \frac{x - z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y - z}{t}\\ \end{array} \]
Alternative 6
Error26.9
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq -7.779835291625142 \cdot 10^{-14}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{0.5}{t}\\ \end{array} \]
Alternative 7
Error26.8
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq -7.779835291625142 \cdot 10^{-14}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t \cdot 2}\\ \end{array} \]
Alternative 8
Error40.9
Cost320
\[0.5 \cdot \frac{x}{t} \]

Error

Reproduce

herbie shell --seed 2022228 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
  :precision binary64
  (/ (- (+ x y) z) (* t 2.0)))