?

Average Error: 5.9 → 1.7
Time: 11.7s
Precision: binary64
Cost: 840

?

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

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

\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.9
Target2.1
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 3 regimes
  2. if t < -1.99999999999999988e39

    1. Initial program 9.2

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

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

      [Start]9.2

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

      associate-*l/ [<=]1.1

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

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

    if -1.99999999999999988e39 < t < 8.70000000000000013e-305

    1. Initial program 1.9

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

    if 8.70000000000000013e-305 < t

    1. Initial program 5.9

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

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

      [Start]5.9

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

      associate-/l* [=>]1.8

      \[ x + \color{blue}{\frac{y - x}{\frac{t}{z}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.7

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

Alternatives

Alternative 1
Error33.9
Cost1176
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ t_2 := \frac{-x}{\frac{t}{z}}\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+35}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{+17}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-145}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 50000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error33.8
Cost1176
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ t_2 := \frac{-z}{\frac{t}{x}}\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+35}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{+17}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-145}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 57000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error33.8
Cost1176
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ \mathbf{if}\;z \leq -3.5 \cdot 10^{+36}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{+16}:\\ \;\;\;\;\frac{-z}{\frac{t}{x}}\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-146}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6800000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-x}{t}\\ \end{array} \]
Alternative 4
Error24.5
Cost978
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{-163} \lor \neg \left(z \leq 5.5 \cdot 10^{-65}\right) \land \left(z \leq 18000000000 \lor \neg \left(z \leq 6.7 \cdot 10^{+62}\right)\right):\\ \;\;\;\;z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error25.2
Cost976
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{-163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-147}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 7800000000:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+63}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error12.1
Cost976
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ \mathbf{if}\;z \leq -82000000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8.8 \cdot 10^{-169}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-235}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+91}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error10.8
Cost976
\[\begin{array}{l} t_1 := x + \frac{y}{\frac{t}{z}}\\ t_2 := x - x \cdot \frac{z}{t}\\ \mathbf{if}\;x \leq -8 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-188}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-83}:\\ \;\;\;\;\frac{z \cdot \left(y - x\right)}{t}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error4.3
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{-132} \lor \neg \left(z \leq 4 \cdot 10^{-63}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \end{array} \]
Alternative 9
Error4.0
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-164} \lor \neg \left(z \leq 2.06 \cdot 10^{-103}\right):\\ \;\;\;\;x + \frac{z}{\frac{t}{y - x}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 10
Error1.9
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{-122}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y - x}}\\ \mathbf{elif}\;z \leq 10^{-24}:\\ \;\;\;\;x + \frac{z \cdot \left(y - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \end{array} \]
Alternative 11
Error10.9
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.15 \cdot 10^{+17} \lor \neg \left(z \leq 8.6 \cdot 10^{+91}\right):\\ \;\;\;\;z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 12
Error11.0
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.15 \cdot 10^{+17} \lor \neg \left(z \leq 3.2 \cdot 10^{+92}\right):\\ \;\;\;\;z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \end{array} \]
Alternative 13
Error25.7
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-114}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{-37}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error25.6
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{-95}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-37}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 15
Error26.3
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-115}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{-19}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 16
Error31.6
Cost64
\[x \]

Error

Reproduce?

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