?

Average Error: 6.3 → 2.1
Time: 11.9s
Precision: binary64
Cost: 840

?

\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-279}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-184}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= x -6.5e-279)
   (+ x (/ (- y x) (/ t z)))
   (if (<= x 5e-184) (+ x (/ (* (- y x) z) t)) (+ x (* (- y x) (/ z t))))))
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 tmp;
	if (x <= -6.5e-279) {
		tmp = x + ((y - x) / (t / z));
	} else if (x <= 5e-184) {
		tmp = x + (((y - x) * z) / t);
	} else {
		tmp = x + ((y - x) * (z / t));
	}
	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) :: tmp
    if (x <= (-6.5d-279)) then
        tmp = x + ((y - x) / (t / z))
    else if (x <= 5d-184) then
        tmp = x + (((y - x) * z) / t)
    else
        tmp = x + ((y - x) * (z / t))
    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 tmp;
	if (x <= -6.5e-279) {
		tmp = x + ((y - x) / (t / z));
	} else if (x <= 5e-184) {
		tmp = x + (((y - x) * z) / t);
	} else {
		tmp = x + ((y - x) * (z / t));
	}
	return tmp;
}
def code(x, y, z, t):
	return x + (((y - x) * z) / t)
def code(x, y, z, t):
	tmp = 0
	if x <= -6.5e-279:
		tmp = x + ((y - x) / (t / z))
	elif x <= 5e-184:
		tmp = x + (((y - x) * z) / t)
	else:
		tmp = x + ((y - x) * (z / t))
	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)
	tmp = 0.0
	if (x <= -6.5e-279)
		tmp = Float64(x + Float64(Float64(y - x) / Float64(t / z)));
	elseif (x <= 5e-184)
		tmp = Float64(x + Float64(Float64(Float64(y - x) * z) / t));
	else
		tmp = Float64(x + Float64(Float64(y - x) * Float64(z / t)));
	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)
	tmp = 0.0;
	if (x <= -6.5e-279)
		tmp = x + ((y - x) / (t / z));
	elseif (x <= 5e-184)
		tmp = x + (((y - x) * z) / t);
	else
		tmp = x + ((y - x) * (z / t));
	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_] := If[LessEqual[x, -6.5e-279], N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-184], N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{-279}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-184}:\\
\;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\

\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target2.3
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. Split input into 3 regimes
  2. if x < -6.4999999999999997e-279

    1. Initial program 6.5

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

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

      [Start]6.5

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

      rational.json-simplify-49 [=>]6.8

      \[ x + \color{blue}{z \cdot \frac{y - x}{t}} \]
    3. Applied egg-rr1.8

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

    if -6.4999999999999997e-279 < x < 5.00000000000000003e-184

    1. Initial program 5.6

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

    if 5.00000000000000003e-184 < x

    1. Initial program 6.4

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

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

      [Start]6.4

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

      rational.json-simplify-2 [=>]6.4

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

      rational.json-simplify-49 [=>]1.2

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

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

Alternatives

Alternative 1
Error5.5
Cost1104
\[\begin{array}{l} t_1 := x + z \cdot \frac{y - x}{t}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.52 \cdot 10^{-288}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.12 \cdot 10^{-237}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error10.5
Cost976
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -3.9 \cdot 10^{-125}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{+76}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error26.3
Cost912
\[\begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-126}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-136}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-57}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-5}:\\ \;\;\;\;x \cdot \frac{z}{-t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error2.0
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -1.18 \cdot 10^{-113}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y - x}}\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-277}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]
Alternative 5
Error16.5
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -5.4 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-143}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error15.4
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -2.2 \cdot 10^{-110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-137}:\\ \;\;\;\;\frac{z}{t} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error25.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-132}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-136}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error25.3
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.75 \cdot 10^{-131}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-150}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error2.0
Cost576
\[x + \left(y - x\right) \cdot \frac{z}{t} \]
Alternative 10
Error31.8
Cost64
\[x \]

Error

Reproduce?

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