?

Average Error: 10.39% → 1.23%
Time: 10.6s
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^{+307}\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+307)))
     (+ 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+307)) {
		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+307)) {
		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+307):
		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+307))
		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+307)))
		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+307]], $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^{+307}\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

Original10.39%
Target3.09%
Herbie1.23%
\[\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 5e307 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 98.93

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

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

      [Start]98.93

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

      associate-*l/ [<=]0.6

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

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

    1. Initial program 1.3

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

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

Alternatives

Alternative 1
Error40.5%
Cost1506
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ \mathbf{if}\;t \leq -3.2 \cdot 10^{+76}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -4.6 \cdot 10^{-295}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-245}:\\ \;\;\;\;\frac{x \cdot z}{-t}\\ \mathbf{elif}\;t \leq 2.6 \cdot 10^{-90} \lor \neg \left(t \leq 6.2 \cdot 10^{-76}\right) \land \left(t \leq 8.6 \cdot 10^{+67} \lor \neg \left(t \leq 1.12 \cdot 10^{+119}\right) \land t \leq 4.8 \cdot 10^{+164}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error45.66%
Cost1376
\[\begin{array}{l} \mathbf{if}\;t \leq -3.2 \cdot 10^{+76}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -9.5 \cdot 10^{+65}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;t \leq -3.6 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -5.2 \cdot 10^{-295}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;t \leq 1.6 \cdot 10^{-276}:\\ \;\;\;\;\frac{x \cdot z}{-t}\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{-91}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;t \leq 1.18 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.2 \cdot 10^{+61}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error46.05%
Cost1114
\[\begin{array}{l} \mathbf{if}\;t \leq -4.1 \cdot 10^{+76}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -5 \cdot 10^{+66} \lor \neg \left(t \leq -6.8 \cdot 10^{+40}\right) \land \left(t \leq 1.1 \cdot 10^{-91} \lor \neg \left(t \leq 2.35 \cdot 10^{-7}\right) \land t \leq 8.5 \cdot 10^{+62}\right):\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error46.17%
Cost1113
\[\begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{+76}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -3 \cdot 10^{+61}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;t \leq -1.9 \cdot 10^{+41}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.55 \cdot 10^{-90} \lor \neg \left(t \leq 2.15 \cdot 10^{-7}\right) \land t \leq 7.6 \cdot 10^{+62}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error45.98%
Cost1113
\[\begin{array}{l} \mathbf{if}\;t \leq -4.1 \cdot 10^{+76}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1.2 \cdot 10^{+65}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;t \leq -3.7 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-91} \lor \neg \left(t \leq 4.5 \cdot 10^{-7}\right) \land t \leq 1.8 \cdot 10^{+60}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error45.97%
Cost1113
\[\begin{array}{l} \mathbf{if}\;t \leq -3.2 \cdot 10^{+76}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -2.6 \cdot 10^{+68}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;t \leq -4 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.02 \cdot 10^{-91} \lor \neg \left(t \leq 2.1 \cdot 10^{-7}\right) \land t \leq 1.8 \cdot 10^{+60}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error45.75%
Cost1112
\[\begin{array}{l} \mathbf{if}\;t \leq -3.2 \cdot 10^{+76}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -4.5 \cdot 10^{+64}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;t \leq -3.5 \cdot 10^{+41}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.95 \cdot 10^{-90}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-8}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 2 \cdot 10^{+60}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error8.71%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -1.65 \cdot 10^{-68} \lor \neg \left(t \leq 10^{-108}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y - x\right) \cdot z}{t}\\ \end{array} \]
Alternative 9
Error18.77%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{+215}:\\ \;\;\;\;x \cdot \frac{-z}{t}\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{+91}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y - x}{t}\\ \end{array} \]
Alternative 10
Error18.82%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{+212}:\\ \;\;\;\;x \cdot \frac{-z}{t}\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+90}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y - x}{t}\\ \end{array} \]
Alternative 11
Error14.7%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{-178}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-57}:\\ \;\;\;\;x - z \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 12
Error13.32%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.42 \cdot 10^{-139}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-48}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 13
Error3.29%
Cost576
\[x + \frac{y - x}{\frac{t}{z}} \]
Alternative 14
Error49.86%
Cost64
\[x \]

Error

Reproduce?

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