Average Error: 6.3 → 1.4
Time: 9.3s
Precision: binary64
Cost: 840
\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} t_1 := x + z \cdot \frac{y - x}{t}\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-14}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \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 (* z (/ (- y x) t)))))
   (if (<= z -9.5e+99) t_1 (if (<= z 8.2e-14) (+ x (/ (- y x) (/ t z))) 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 + (z * ((y - x) / t));
	double tmp;
	if (z <= -9.5e+99) {
		tmp = t_1;
	} else if (z <= 8.2e-14) {
		tmp = x + ((y - x) / (t / z));
	} else {
		tmp = t_1;
	}
	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) :: tmp
    t_1 = x + (z * ((y - x) / t))
    if (z <= (-9.5d+99)) then
        tmp = t_1
    else if (z <= 8.2d-14) then
        tmp = x + ((y - x) / (t / z))
    else
        tmp = t_1
    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 + (z * ((y - x) / t));
	double tmp;
	if (z <= -9.5e+99) {
		tmp = t_1;
	} else if (z <= 8.2e-14) {
		tmp = x + ((y - x) / (t / z));
	} 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 + (z * ((y - x) / t))
	tmp = 0
	if z <= -9.5e+99:
		tmp = t_1
	elif z <= 8.2e-14:
		tmp = x + ((y - x) / (t / z))
	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(z * Float64(Float64(y - x) / t)))
	tmp = 0.0
	if (z <= -9.5e+99)
		tmp = t_1;
	elseif (z <= 8.2e-14)
		tmp = Float64(x + Float64(Float64(y - x) / Float64(t / z)));
	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 + (z * ((y - x) / t));
	tmp = 0.0;
	if (z <= -9.5e+99)
		tmp = t_1;
	elseif (z <= 8.2e-14)
		tmp = x + ((y - x) / (t / z));
	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[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.5e+99], t$95$1, If[LessEqual[z, 8.2e-14], N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
t_1 := x + z \cdot \frac{y - x}{t}\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+99}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 8.2 \cdot 10^{-14}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target1.9
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 2 regimes
  2. if z < -9.49999999999999908e99 or 8.2000000000000004e-14 < z

    1. Initial program 16.5

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

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

    if -9.49999999999999908e99 < z < 8.2000000000000004e-14

    1. Initial program 1.7

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

      \[\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))): 37 points increase in error, 29 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification1.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{+99}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-14}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error29.1
Cost1440
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ t_2 := z \cdot \frac{-x}{t}\\ \mathbf{if}\;z \leq -1.12 \cdot 10^{+129}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{+73}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -5.4 \cdot 10^{+33}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{+56}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+112}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{+231}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error29.1
Cost1440
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -6.6 \cdot 10^{+128}:\\ \;\;\;\;\frac{-z}{\frac{t}{x}}\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{+73}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.22 \cdot 10^{+28}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{+56}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+113}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.15 \cdot 10^{+187}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+227}:\\ \;\;\;\;z \cdot \frac{-x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error29.1
Cost1440
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -2.75 \cdot 10^{+129}:\\ \;\;\;\;\frac{-z}{\frac{t}{x}}\\ \mathbf{elif}\;z \leq -2.15 \cdot 10^{+73}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{+34}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 9.8 \cdot 10^{+60}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{+107}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.15 \cdot 10^{+190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+234}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error17.7
Cost1240
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ t_2 := \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-218}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-116}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 7.6 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-39}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error12.0
Cost1108
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ \mathbf{if}\;z \leq -2.1 \cdot 10^{+156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{+73}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{+33}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-65}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{+147}:\\ \;\;\;\;x + \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error12.1
Cost1108
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ \mathbf{if}\;z \leq -1.18 \cdot 10^{+160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{+73}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;z \leq -9 \cdot 10^{+33}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{-62}:\\ \;\;\;\;x - z \cdot \frac{x}{t}\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{+146}:\\ \;\;\;\;x + \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error16.8
Cost976
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -2 \cdot 10^{-201}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-64}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error11.8
Cost976
\[\begin{array}{l} t_1 := x + \frac{z}{\frac{t}{y}}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -4.9 \cdot 10^{-182}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-176}:\\ \;\;\;\;z \cdot \frac{y - x}{t}\\ \mathbf{elif}\;x \leq 5.8:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error4.4
Cost840
\[\begin{array}{l} t_1 := x + z \cdot \frac{y - x}{t}\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{-228}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.42 \cdot 10^{-111}:\\ \;\;\;\;x + \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error1.3
Cost840
\[\begin{array}{l} t_1 := x + z \cdot \frac{y - x}{t}\\ \mathbf{if}\;t \leq -2 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5000:\\ \;\;\;\;x + \frac{z \cdot \left(y - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error17.7
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.46 \cdot 10^{-217}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error26.0
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.25 \cdot 10^{-73}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-116}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error26.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.55 \cdot 10^{-187}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-116}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error26.6
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-201}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-116}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 15
Error30.7
Cost64
\[x \]

Error

Reproduce

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