?

Average Error: 6.4 → 0.8
Time: 9.7s
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 5 \cdot 10^{+303}\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 5e+303)))
     (+ 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 <= 5e+303)) {
		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 <= 5e+303)) {
		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 <= 5e+303):
		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 <= 5e+303))
		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 <= 5e+303)))
		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, 5e+303]], $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 5 \cdot 10^{+303}\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.4
Target2.1
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 4.9999999999999997e303 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 61.5

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

      \[\leadsto \color{blue}{x + \frac{y - x}{t} \cdot z} \]
      Proof

      [Start]61.5

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

      associate-*l/ [<=]1.3

      \[ x + \color{blue}{\frac{y - x}{t} \cdot z} \]

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

    1. Initial program 0.8

      \[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 \lor \neg \left(x + \frac{\left(y - x\right) \cdot z}{t} \leq 5 \cdot 10^{+303}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error24.8
Cost1901
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ \mathbf{if}\;x \leq -2.5 \cdot 10^{+43}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-29}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.35 \cdot 10^{-167}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-167}:\\ \;\;\;\;z \cdot \frac{x}{-t}\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-186}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-262} \lor \neg \left(x \leq 1.1 \cdot 10^{-248}\right) \land x \leq 3.5 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error9.2
Cost976
\[\begin{array}{l} t_1 := x - x \cdot \frac{z}{t}\\ t_2 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -7.5 \cdot 10^{-69}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-213}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-79}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;y \leq 5800:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error9.4
Cost976
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -3.7 \cdot 10^{-66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-213}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-80}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;y \leq 165:\\ \;\;\;\;x - \frac{x \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error25.9
Cost849
\[\begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-45}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-261} \lor \neg \left(x \leq 2.6 \cdot 10^{-238}\right) \land x \leq 1.14 \cdot 10^{-147}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error26.1
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-42}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-261}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-237}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 10^{-147}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error4.6
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-193} \lor \neg \left(z \leq 8 \cdot 10^{-130}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 7
Error9.2
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{-203} \lor \neg \left(y \leq 1.52 \cdot 10^{-196}\right):\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \frac{x}{t}\\ \end{array} \]
Alternative 8
Error11.2
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq 2 \cdot 10^{+117}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y - x}{t}\\ \end{array} \]
Alternative 9
Error1.8
Cost576
\[x + \frac{y - x}{\frac{t}{z}} \]
Alternative 10
Error30.8
Cost64
\[x \]

Error

Reproduce?

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