Average Error: 6.7 → 1.7
Time: 7.7s
Precision: binary64
Cost: 1992
\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} t_1 := \left(y - x\right) \cdot z\\ t_2 := x + \frac{t_1}{t}\\ t_3 := x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{if}\;t_2 \leq 5 \cdot 10^{+206}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+281}:\\ \;\;\;\;x + t_1 \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* (- y x) z))
        (t_2 (+ x (/ t_1 t)))
        (t_3 (+ x (/ (- y x) (/ t z)))))
   (if (<= t_2 5e+206) t_3 (if (<= t_2 5e+281) (+ x (* t_1 (/ 1.0 t))) t_3))))
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 = (y - x) * z;
	double t_2 = x + (t_1 / t);
	double t_3 = x + ((y - x) / (t / z));
	double tmp;
	if (t_2 <= 5e+206) {
		tmp = t_3;
	} else if (t_2 <= 5e+281) {
		tmp = x + (t_1 * (1.0 / t));
	} else {
		tmp = t_3;
	}
	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) :: t_3
    real(8) :: tmp
    t_1 = (y - x) * z
    t_2 = x + (t_1 / t)
    t_3 = x + ((y - x) / (t / z))
    if (t_2 <= 5d+206) then
        tmp = t_3
    else if (t_2 <= 5d+281) then
        tmp = x + (t_1 * (1.0d0 / t))
    else
        tmp = t_3
    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 = (y - x) * z;
	double t_2 = x + (t_1 / t);
	double t_3 = x + ((y - x) / (t / z));
	double tmp;
	if (t_2 <= 5e+206) {
		tmp = t_3;
	} else if (t_2 <= 5e+281) {
		tmp = x + (t_1 * (1.0 / t));
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(x, y, z, t):
	return x + (((y - x) * z) / t)
def code(x, y, z, t):
	t_1 = (y - x) * z
	t_2 = x + (t_1 / t)
	t_3 = x + ((y - x) / (t / z))
	tmp = 0
	if t_2 <= 5e+206:
		tmp = t_3
	elif t_2 <= 5e+281:
		tmp = x + (t_1 * (1.0 / t))
	else:
		tmp = t_3
	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(Float64(y - x) * z)
	t_2 = Float64(x + Float64(t_1 / t))
	t_3 = Float64(x + Float64(Float64(y - x) / Float64(t / z)))
	tmp = 0.0
	if (t_2 <= 5e+206)
		tmp = t_3;
	elseif (t_2 <= 5e+281)
		tmp = Float64(x + Float64(t_1 * Float64(1.0 / t)));
	else
		tmp = t_3;
	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 = (y - x) * z;
	t_2 = x + (t_1 / t);
	t_3 = x + ((y - x) / (t / z));
	tmp = 0.0;
	if (t_2 <= 5e+206)
		tmp = t_3;
	elseif (t_2 <= 5e+281)
		tmp = x + (t_1 * (1.0 / t));
	else
		tmp = t_3;
	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[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(t$95$1 / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 5e+206], t$95$3, If[LessEqual[t$95$2, 5e+281], N[(x + N[(t$95$1 * N[(1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
t_1 := \left(y - x\right) \cdot z\\
t_2 := x + \frac{t_1}{t}\\
t_3 := x + \frac{y - x}{\frac{t}{z}}\\
\mathbf{if}\;t_2 \leq 5 \cdot 10^{+206}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+281}:\\
\;\;\;\;x + t_1 \cdot \frac{1}{t}\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.7
Target2.0
Herbie1.7
\[\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)) < 5.0000000000000002e206 or 5.00000000000000016e281 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 7.2

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

      \[\leadsto \color{blue}{x + \frac{y - x}{\frac{t}{z}}} \]
      Proof
      (+.f64 x (/.f64 (-.f64 y x) (/.f64 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))): 58 points increase in error, 24 points decrease in error

    if 5.0000000000000002e206 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 5.00000000000000016e281

    1. Initial program 0.2

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

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

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

Alternatives

Alternative 1
Error0.9
Cost1864
\[\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 2 \cdot 10^{+299}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y - x}}\\ \end{array} \]
Alternative 2
Error1.5
Cost1864
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ t_2 := x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{if}\;t_1 \leq 2 \cdot 10^{+23}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+281}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error19.7
Cost1372
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -7.6 \cdot 10^{-209}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-248}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-257}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{-203}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error16.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}\;x \leq -1.12 \cdot 10^{-77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-208}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error26.6
Cost848
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;x \leq -3.6 \cdot 10^{-85}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-208}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.25:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error26.5
Cost848
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ \mathbf{if}\;x \leq -1.06 \cdot 10^{-85}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-208}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.00038:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error11.6
Cost844
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -0.055:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.06 \cdot 10^{-124}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 5200:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error11.5
Cost844
\[\begin{array}{l} \mathbf{if}\;x \leq -0.00068:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-125}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 1.18 \cdot 10^{-7}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \end{array} \]
Alternative 9
Error4.6
Cost840
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{z}}\\ \mathbf{if}\;x \leq -3 \cdot 10^{+209}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{+105}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error4.4
Cost840
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{z}}\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+213}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{+105}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y - x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error31.8
Cost64
\[x \]

Error

Reproduce

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