Average Error: 6.5 → 2.1
Time: 12.5s
Precision: binary64
Cost: 832
\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[x + \left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right) \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
(FPCore (x y z t) :precision binary64 (+ x (- (/ y (/ t z)) (/ x (/ t z)))))
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) {
	return x + ((y / (t / z)) - (x / (t / z)));
}
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
    code = x + ((y / (t / z)) - (x / (t / z)))
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) {
	return x + ((y / (t / z)) - (x / (t / z)));
}
def code(x, y, z, t):
	return x + (((y - x) * z) / t)
def code(x, y, z, t):
	return x + ((y / (t / z)) - (x / (t / z)))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(Float64(y - x) * z) / t))
end
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y / Float64(t / z)) - Float64(x / Float64(t / z))))
end
function tmp = code(x, y, z, t)
	tmp = x + (((y - x) * z) / t);
end
function tmp = code(x, y, z, t)
	tmp = x + ((y / (t / z)) - (x / (t / z)));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(x + N[(N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision] - N[(x / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{\left(y - x\right) \cdot z}{t}
x + \left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target2.1
Herbie2.1
\[\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. Initial program 6.5

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

    \[\leadsto x + \color{blue}{\left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right)} \]
  3. Final simplification2.1

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

Alternatives

Alternative 1
Error27.5
Cost1112
\[\begin{array}{l} \mathbf{if}\;x \leq -2.0740540346316582 \cdot 10^{+30}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.4589089368834967 \cdot 10^{-28}:\\ \;\;\;\;x \cdot \frac{-z}{t}\\ \mathbf{elif}\;x \leq -3.204605486921345 \cdot 10^{-129}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.703205911010318 \cdot 10^{-152}:\\ \;\;\;\;z \cdot \frac{-x}{t}\\ \mathbf{elif}\;x \leq -2.2338040108120486 \cdot 10^{-155}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.34650554689846 \cdot 10^{-93}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error27.5
Cost980
\[\begin{array}{l} t_1 := \frac{z \cdot \left(-x\right)}{t}\\ \mathbf{if}\;x \leq -2.0740540346316582 \cdot 10^{+30}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.4589089368834967 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.204605486921345 \cdot 10^{-129}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.703205911010318 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.34650554689846 \cdot 10^{-93}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error11.6
Cost976
\[\begin{array}{l} t_1 := x + \frac{y \cdot z}{t}\\ \mathbf{if}\;x \leq -1.2183929955869501 \cdot 10^{-48}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq -3.204605486921345 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.406784514755472 \cdot 10^{-160}:\\ \;\;\;\;\frac{z \cdot \left(y - x\right)}{t}\\ \mathbf{elif}\;x \leq 3.571390056621237 \cdot 10^{-111}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \end{array} \]
Alternative 4
Error27.3
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -2.0740540346316582 \cdot 10^{+30}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.4589089368834967 \cdot 10^{-28}:\\ \;\;\;\;x \cdot \frac{-z}{t}\\ \mathbf{elif}\;x \leq -5.921412181442593 \cdot 10^{-57}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.34650554689846 \cdot 10^{-93}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error4.3
Cost840
\[\begin{array}{l} t_1 := x + \frac{z}{\frac{t}{y - x}}\\ \mathbf{if}\;z \leq -1.8767711387538846 \cdot 10^{-242}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.0084576473584835 \cdot 10^{-174}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error17.3
Cost712
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{z}}\\ \mathbf{if}\;x \leq -2.2338040108120486 \cdot 10^{-155}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.417939074588402 \cdot 10^{-176}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error17.4
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -2.2338040108120486 \cdot 10^{-155}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 5.417939074588402 \cdot 10^{-176}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \end{array} \]
Alternative 8
Error16.2
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3493035174037886 \cdot 10^{-130}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 1.34650554689846 \cdot 10^{-93}:\\ \;\;\;\;\frac{z}{\frac{t}{y - x}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \end{array} \]
Alternative 9
Error16.3
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3789307461895398 \cdot 10^{-108}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 3.571390056621237 \cdot 10^{-111}:\\ \;\;\;\;\frac{z \cdot \left(y - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \end{array} \]
Alternative 10
Error26.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.921412181442593 \cdot 10^{-57}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.34650554689846 \cdot 10^{-93}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error2.2
Cost576
\[x + \left(y - x\right) \cdot \frac{z}{t} \]
Alternative 12
Error31.6
Cost64
\[x \]

Error

Reproduce

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