Average Error: 6.5 → 1.0
Time: 8.3s
Precision: binary64
Cost: 1865
\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+305}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \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 x) z) t))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+305)))
     (+ x (* z (/ (- y x) t)))
     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 - x) * z) / t);
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+305)) {
		tmp = x + (z * ((y - x) / t));
	} 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 - x) * z) / t);
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+305)) {
		tmp = x + (z * ((y - x) / t));
	} 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 - x) * z) / t)
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 2e+305):
		tmp = x + (z * ((y - x) / t))
	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(Float64(y - x) * z) / t))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+305))
		tmp = Float64(x + Float64(z * Float64(Float64(y - x) / t)));
	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 - x) * z) / t);
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 2e+305)))
		tmp = x + (z * ((y - x) / t));
	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[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+305]], $MachinePrecision]], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+305}\right):\\
\;\;\;\;x + z \cdot \frac{y - x}{t}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target2.0
Herbie1.0
\[\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 1.9999999999999999e305 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 62.3

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

      \[\leadsto \color{blue}{x + \frac{y - x}{t} \cdot z} \]
      Proof
      (+.f64 x (*.f64 (/.f64 (-.f64 y x) t) z)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 (-.f64 y x) z) t))): 1 points increase in error, 1 points decrease in error

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

    1. Initial program 0.9

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

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

Alternatives

Alternative 1
Error27.0
Cost849
\[\begin{array}{l} \mathbf{if}\;x \leq -1.15 \cdot 10^{+37}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{-48} \lor \neg \left(x \leq -3.8 \cdot 10^{-127}\right) \land x \leq 6.2 \cdot 10^{-71}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error26.9
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.15 \cdot 10^{+37}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.08 \cdot 10^{-44}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-127}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-71}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error4.6
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{-37} \lor \neg \left(z \leq 10^{-157}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 4
Error8.8
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-194} \lor \neg \left(y \leq 2.35 \cdot 10^{-124}\right):\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \frac{x}{t}\\ \end{array} \]
Alternative 5
Error1.9
Cost576
\[x + \frac{y - x}{\frac{t}{z}} \]
Alternative 6
Error12.4
Cost448
\[x + y \cdot \frac{z}{t} \]
Alternative 7
Error32.0
Cost64
\[x \]

Error

Reproduce

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