Average Error: 6.6 → 1.5
Time: 18.8s
Precision: binary64
Cost: 968
\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} t_1 := \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t \leq -6 \cdot 10^{-14}:\\ \;\;\;\;x + \begin{array}{l} \mathbf{if}\;y - x \ne 0:\\ \;\;\;\;\frac{z}{\frac{t}{y - x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ \mathbf{elif}\;t \leq 5 \cdot 10^{+56}:\\ \;\;\;\;x + t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (* (- y x) z) t)))
   (if (<= t -6e-14)
     (+ x (if (!= (- y x) 0.0) (/ z (/ t (- y x))) t_1))
     (if (<= t 5e+56) (+ x t_1) (+ x (* (/ z t) (- y x)))))))
double code(double x, double y, double z, double t) {
	return x + (((y - x) * z) / t);
}
double code(double x, double y, double z, double t) {
	double t_1 = ((y - x) * z) / t;
	double tmp_1;
	if (t <= -6e-14) {
		double tmp_2;
		if ((y - x) != 0.0) {
			tmp_2 = z / (t / (y - x));
		} else {
			tmp_2 = t_1;
		}
		tmp_1 = x + tmp_2;
	} else if (t <= 5e+56) {
		tmp_1 = x + t_1;
	} else {
		tmp_1 = x + ((z / t) * (y - x));
	}
	return tmp_1;
}
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 - x) * z) / t)
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) :: t_1
    real(8) :: tmp
    real(8) :: tmp_1
    real(8) :: tmp_2
    t_1 = ((y - x) * z) / t
    if (t <= (-6d-14)) then
        if ((y - x) /= 0.0d0) then
            tmp_2 = z / (t / (y - x))
        else
            tmp_2 = t_1
        end if
        tmp_1 = x + tmp_2
    else if (t <= 5d+56) then
        tmp_1 = x + t_1
    else
        tmp_1 = x + ((z / t) * (y - x))
    end if
    code = tmp_1
end function
public static double code(double x, double y, double z, double t) {
	return x + (((y - x) * z) / t);
}
public static double code(double x, double y, double z, double t) {
	double t_1 = ((y - x) * z) / t;
	double tmp_1;
	if (t <= -6e-14) {
		double tmp_2;
		if ((y - x) != 0.0) {
			tmp_2 = z / (t / (y - x));
		} else {
			tmp_2 = t_1;
		}
		tmp_1 = x + tmp_2;
	} else if (t <= 5e+56) {
		tmp_1 = x + t_1;
	} else {
		tmp_1 = x + ((z / t) * (y - x));
	}
	return tmp_1;
}
def code(x, y, z, t):
	return x + (((y - x) * z) / t)
def code(x, y, z, t):
	t_1 = ((y - x) * z) / t
	tmp_1 = 0
	if t <= -6e-14:
		tmp_2 = 0
		if (y - x) != 0.0:
			tmp_2 = z / (t / (y - x))
		else:
			tmp_2 = t_1
		tmp_1 = x + tmp_2
	elif t <= 5e+56:
		tmp_1 = x + t_1
	else:
		tmp_1 = x + ((z / t) * (y - x))
	return tmp_1
function code(x, y, z, t)
	return Float64(x + Float64(Float64(Float64(y - x) * z) / t))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(Float64(y - x) * z) / t)
	tmp_1 = 0.0
	if (t <= -6e-14)
		tmp_2 = 0.0
		if (Float64(y - x) != 0.0)
			tmp_2 = Float64(z / Float64(t / Float64(y - x)));
		else
			tmp_2 = t_1;
		end
		tmp_1 = Float64(x + tmp_2);
	elseif (t <= 5e+56)
		tmp_1 = Float64(x + t_1);
	else
		tmp_1 = Float64(x + Float64(Float64(z / t) * Float64(y - x)));
	end
	return tmp_1
end
function tmp = code(x, y, z, t)
	tmp = x + (((y - x) * z) / t);
end
function tmp_4 = code(x, y, z, t)
	t_1 = ((y - x) * z) / t;
	tmp_2 = 0.0;
	if (t <= -6e-14)
		tmp_3 = 0.0;
		if ((y - x) ~= 0.0)
			tmp_3 = z / (t / (y - x));
		else
			tmp_3 = t_1;
		end
		tmp_2 = x + tmp_3;
	elseif (t <= 5e+56)
		tmp_2 = x + t_1;
	else
		tmp_2 = x + ((z / t) * (y - x));
	end
	tmp_4 = tmp_2;
end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[t, -6e-14], N[(x + If[Unequal[N[(y - x), $MachinePrecision], 0.0], N[(z / N[(t / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]), $MachinePrecision], If[LessEqual[t, 5e+56], N[(x + t$95$1), $MachinePrecision], N[(x + N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
t_1 := \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{if}\;t \leq -6 \cdot 10^{-14}:\\
\;\;\;\;x + \begin{array}{l}
\mathbf{if}\;y - x \ne 0:\\
\;\;\;\;\frac{z}{\frac{t}{y - x}}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}\\

\mathbf{elif}\;t \leq 5 \cdot 10^{+56}:\\
\;\;\;\;x + t_1\\

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


\end{array}

Error

Target

Original6.6
Target2.0
Herbie1.5
\[\begin{array}{l} \mathbf{if}\;x < -9.025511195533005 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{elif}\;x < 4.275032163700715 \cdot 10^{-250}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if t < -5.9999999999999997e-14

    1. Initial program 8.7

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

      \[\leadsto x + \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;y - x \ne 0:\\ \;\;\;\;\frac{z}{\frac{t}{y - x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y - x\right) \cdot z}{t}\\ } \end{array}} \]

    if -5.9999999999999997e-14 < t < 5.00000000000000024e56

    1. Initial program 2.2

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

    if 5.00000000000000024e56 < t

    1. Initial program 11.0

      \[x + \frac{\left(y - x\right) \cdot z}{t} \]
    2. Applied egg-rr1.2

      \[\leadsto x + \color{blue}{\frac{z}{t} \cdot \left(y - x\right)} \]
  3. Recombined 3 regimes into one program.

Alternatives

Alternative 1
Error20.6
Cost976
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot y\\ t_2 := \frac{t - z}{t} \cdot x\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.08 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+105}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error20.5
Cost976
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot y\\ t_2 := \frac{t - z}{t} \cdot x\\ \mathbf{if}\;y \leq -1.36 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -6200:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -6.3 \cdot 10^{-55}:\\ \;\;\;\;\frac{y - x}{t} \cdot z\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+102}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error29.6
Cost848
\[\begin{array}{l} t_1 := \frac{y}{t} \cdot z\\ \mathbf{if}\;z \leq -1.45 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-165}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error30.8
Cost848
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot y\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-231}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-296}:\\ \;\;\;\;-\frac{z \cdot x}{t}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+64}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error30.8
Cost848
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot y\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-231}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-296}:\\ \;\;\;\;\left(-\frac{z}{t}\right) \cdot x\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+64}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error1.6
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -1.25 \cdot 10^{-60}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{+57}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\ \end{array} \]
Alternative 7
Error26.5
Cost712
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot y\\ \mathbf{if}\;y \leq -4.2 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+104}:\\ \;\;\;\;\frac{x}{t} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error10.6
Cost712
\[\begin{array}{l} t_1 := x + \frac{y \cdot z}{t}\\ \mathbf{if}\;y \leq -5.3 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.45 \cdot 10^{-118}:\\ \;\;\;\;\frac{t - z}{t} \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error29.8
Cost584
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot y\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{+64}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error2.0
Cost576
\[x + \frac{z}{t} \cdot \left(y - x\right) \]
Alternative 11
Error31.4
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

  (+ x (/ (* (- y x) z) t)))