Average Error: 6.2 → 0.8
Time: 5.1s
Precision: binary64
\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} t_1 := x + \left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right)\\ t_2 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+265}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (- (/ y (/ t z)) (/ x (/ t z)))))
        (t_2 (+ x (/ (* (- y x) z) t))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+265) t_2 t_1))))
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 = x + ((y / (t / z)) - (x / (t / z)));
	double t_2 = x + (((y - x) * z) / t);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 2e+265) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
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 = x + ((y / (t / z)) - (x / (t / z)));
	double t_2 = x + (((y - x) * z) / t);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 2e+265) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return x + (((y - x) * z) / t)
def code(x, y, z, t):
	t_1 = x + ((y / (t / z)) - (x / (t / z)))
	t_2 = x + (((y - x) * z) / t)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 2e+265:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
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(x + Float64(Float64(y / Float64(t / z)) - Float64(x / Float64(t / z))))
	t_2 = Float64(x + Float64(Float64(Float64(y - x) * z) / t))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 2e+265)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x + (((y - x) * z) / t);
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + ((y / (t / z)) - (x / (t / z)));
	t_2 = x + (((y - x) * z) / t);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 2e+265)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
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[(x + N[(N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision] - N[(x / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+265], t$95$2, t$95$1]]]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
t_1 := x + \left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right)\\
t_2 := x + \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+265}:\\
\;\;\;\;t_2\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target2.0
Herbie0.8
\[\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 2 regimes
  2. if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -inf.0 or 2.00000000000000013e265 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 43.4

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

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

    if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 2.00000000000000013e265

    1. Initial program 0.7

      \[x + \frac{\left(y - x\right) \cdot z}{t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \leq -\infty:\\ \;\;\;\;x + \left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \leq 2 \cdot 10^{+265}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right)\\ \end{array} \]

Reproduce

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