?

Average Error: 6.2 → 1.4
Time: 14.4s
Precision: binary64
Cost: 1864

?

\[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:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{elif}\;t_1 \leq 10^{+166}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \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 (<= t_1 (- INFINITY))
     (+ x (* z (/ (- y x) t)))
     (if (<= t_1 1e+166) t_1 (+ x (* (- y x) (/ z t)))))))
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)) {
		tmp = x + (z * ((y - x) / t));
	} else if (t_1 <= 1e+166) {
		tmp = t_1;
	} else {
		tmp = x + ((y - x) * (z / t));
	}
	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) {
		tmp = x + (z * ((y - x) / t));
	} else if (t_1 <= 1e+166) {
		tmp = t_1;
	} else {
		tmp = x + ((y - x) * (z / t));
	}
	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:
		tmp = x + (z * ((y - x) / t))
	elif t_1 <= 1e+166:
		tmp = t_1
	else:
		tmp = x + ((y - x) * (z / t))
	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))
		tmp = Float64(x + Float64(z * Float64(Float64(y - x) / t)));
	elseif (t_1 <= 1e+166)
		tmp = t_1;
	else
		tmp = Float64(x + Float64(Float64(y - x) * Float64(z / t)));
	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)
		tmp = x + (z * ((y - x) / t));
	elseif (t_1 <= 1e+166)
		tmp = t_1;
	else
		tmp = x + ((y - x) * (z / t));
	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[LessEqual[t$95$1, (-Infinity)], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+166], t$95$1, N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
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:\\
\;\;\;\;x + z \cdot \frac{y - x}{t}\\

\mathbf{elif}\;t_1 \leq 10^{+166}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target2.1
Herbie1.4
\[\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 (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -inf.0

    1. Initial program 64.0

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

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

      [Start]64.0

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

      rational.json-simplify-49 [=>]0.2

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

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

    1. Initial program 0.9

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

    if 9.9999999999999994e165 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 15.9

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

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

      [Start]15.9

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

      rational.json-simplify-2 [=>]15.9

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

      rational.json-simplify-49 [=>]3.7

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

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

Alternatives

Alternative 1
Error31.2
Cost1508
\[\begin{array}{l} t_1 := z \cdot \left(-\frac{x}{t}\right)\\ t_2 := \frac{z \cdot y}{t}\\ \mathbf{if}\;t \leq -4.1 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -2.8 \cdot 10^{-33}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -8.6 \cdot 10^{-72}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -9.2 \cdot 10^{-149}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -6 \cdot 10^{-241}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-257}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.5 \cdot 10^{-162}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 4.15 \cdot 10^{+133}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{+166}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error31.9
Cost1112
\[\begin{array}{l} \mathbf{if}\;t \leq -3.25 \cdot 10^{+41}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -5.7 \cdot 10^{-33}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;t \leq -2.1 \cdot 10^{-72}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{-192}:\\ \;\;\;\;\frac{z}{t} \cdot \left(-x\right)\\ \mathbf{elif}\;t \leq 4.15 \cdot 10^{+133}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{+166}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error18.0
Cost976
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -5.2 \cdot 10^{-132}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-257}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-224}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error4.6
Cost840
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{+77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{+33}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error18.4
Cost712
\[\begin{array}{l} t_1 := \frac{y - x}{t} \cdot z\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+65}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error8.3
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -3.8 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-131}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error28.9
Cost584
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -5.2 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+65}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error28.8
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+32}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+65}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 9
Error28.7
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+31}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+65}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 10
Error2.1
Cost576
\[x + \left(y - x\right) \cdot \frac{z}{t} \]
Alternative 11
Error32.0
Cost64
\[x \]

Error

Reproduce?

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