Average Error: 6.7 → 1.6
Time: 8.7s
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}\\ t_2 := x + z \cdot \frac{y - x}{t}\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{+288}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{+293}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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))) (t_2 (+ x (* z (/ (- y x) t)))))
   (if (<= t_1 -4e+288) t_2 (if (<= t_1 1e+293) t_1 t_2))))
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 t_2 = x + (z * ((y - x) / t));
	double tmp;
	if (t_1 <= -4e+288) {
		tmp = t_2;
	} else if (t_1 <= 1e+293) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + (((y - x) * z) / t)
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x + (((y - x) * z) / t)
    t_2 = x + (z * ((y - x) / t))
    if (t_1 <= (-4d+288)) then
        tmp = t_2
    else if (t_1 <= 1d+293) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
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 t_2 = x + (z * ((y - x) / t));
	double tmp;
	if (t_1 <= -4e+288) {
		tmp = t_2;
	} else if (t_1 <= 1e+293) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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)
	t_2 = x + (z * ((y - x) / t))
	tmp = 0
	if t_1 <= -4e+288:
		tmp = t_2
	elif t_1 <= 1e+293:
		tmp = t_1
	else:
		tmp = t_2
	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))
	t_2 = Float64(x + Float64(z * Float64(Float64(y - x) / t)))
	tmp = 0.0
	if (t_1 <= -4e+288)
		tmp = t_2;
	elseif (t_1 <= 1e+293)
		tmp = t_1;
	else
		tmp = t_2;
	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);
	t_2 = x + (z * ((y - x) / t));
	tmp = 0.0;
	if (t_1 <= -4e+288)
		tmp = t_2;
	elseif (t_1 <= 1e+293)
		tmp = t_1;
	else
		tmp = t_2;
	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]}, Block[{t$95$2 = N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+288], t$95$2, If[LessEqual[t$95$1, 1e+293], t$95$1, t$95$2]]]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\
t_2 := x + z \cdot \frac{y - x}{t}\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{+288}:\\
\;\;\;\;t_2\\

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

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.7
Target1.9
Herbie1.6
\[\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)) < -4e288 or 9.9999999999999992e292 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 46.7

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

      \[\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))): 45 points increase in error, 40 points decrease in error

    if -4e288 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 9.9999999999999992e292

    1. Initial program 0.8

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

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

Alternatives

Alternative 1
Error28.5
Cost1376
\[\begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{+192}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{+133}:\\ \;\;\;\;x \cdot \frac{z}{-t}\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-146}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-302}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{-297}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-209}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{-174}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-54}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error28.6
Cost1376
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+194}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6 \cdot 10^{+133}:\\ \;\;\;\;\frac{-x}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-146}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-302}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{-297}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-209}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-175}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-54}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error19.9
Cost976
\[\begin{array}{l} t_1 := \left(y - x\right) \cdot \frac{z}{t}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;t \leq -1.2 \cdot 10^{+39}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -5.1 \cdot 10^{-132}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.26 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error29.9
Cost848
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;t \leq -1.2 \cdot 10^{+39}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -6.8 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.95 \cdot 10^{-132}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.26 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error29.8
Cost848
\[\begin{array}{l} \mathbf{if}\;t \leq -1.9 \cdot 10^{+39}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -6.3 \cdot 10^{-46}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;t \leq -2.1 \cdot 10^{-132}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.26 \cdot 10^{+41}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error5.2
Cost840
\[\begin{array}{l} t_1 := x + z \cdot \frac{y - x}{t}\\ \mathbf{if}\;t \leq -1.1 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.2 \cdot 10^{-194}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error20.1
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{+51}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+199}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \end{array} \]
Alternative 8
Error10.0
Cost712
\[\begin{array}{l} t_1 := x + \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;y \leq -4.6 \cdot 10^{-122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-111}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error10.0
Cost712
\[\begin{array}{l} t_1 := x + \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{-122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-112}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error1.9
Cost576
\[x + \frac{y - x}{\frac{t}{z}} \]
Alternative 11
Error32.1
Cost64
\[x \]

Error

Reproduce

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