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

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

\mathbf{elif}\;t \leq 6.939414757175626 \cdot 10^{+123}:\\
\;\;\;\;x - x \cdot \frac{z}{t}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.0
Target2.1
Herbie12.6
\[\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.4000000000000001e-26 or 6.9394147571756263e123 < t

    1. Initial program 9.1

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

      \[\leadsto x + \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot \frac{1}{t}} \]
    3. Taylor expanded in y around inf 10.3

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
    4. Simplified6.3

      \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
    5. Applied egg-rr6.3

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

    if -1.4000000000000001e-26 < t < 3.1000000000000002e-85

    1. Initial program 2.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)} \]
    3. Taylor expanded in z around -inf 17.6

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

    if 3.1000000000000002e-85 < t < 6.9394147571756263e123

    1. Initial program 3.2

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

      \[\leadsto x + \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot \frac{1}{t}} \]
    3. Applied egg-rr3.3

      \[\leadsto x + \color{blue}{\frac{1}{\frac{t}{\left(y - x\right) \cdot z}}} \]
    4. Taylor expanded in x around inf 22.5

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{z}{t}\right) \cdot x} \]
    5. Simplified22.5

      \[\leadsto \color{blue}{x - x \cdot \frac{z}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification12.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.4 \cdot 10^{-26}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{-85}:\\ \;\;\;\;\frac{z \cdot \left(y - x\right)}{t}\\ \mathbf{elif}\;t \leq 6.939414757175626 \cdot 10^{+123}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \end{array} \]

Alternatives

Alternative 1
Error13.0
Cost1240
\[\begin{array}{l} t_1 := x + \frac{z \cdot y}{t}\\ t_2 := \frac{x \cdot z}{-t}\\ t_3 := x + \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;t \leq -5.30416493504701 \cdot 10^{+81}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -3.4 \cdot 10^{-196}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -3.1 \cdot 10^{-266}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-268}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.95 \cdot 10^{-231}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.2 \cdot 10^{-85}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Error28.6
Cost1112
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{-259}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.95 \cdot 10^{-231}:\\ \;\;\;\;\frac{z}{t} \cdot \left(-x\right)\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{-182}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.1 \cdot 10^{-89}:\\ \;\;\;\;z \cdot \frac{-x}{t}\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{-85}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error28.5
Cost1044
\[\begin{array}{l} t_1 := \frac{x \cdot z}{-t}\\ t_2 := \frac{z \cdot y}{t}\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-268}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.95 \cdot 10^{-231}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{-182}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.56 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error28.5
Cost848
\[\begin{array}{l} \mathbf{if}\;t \leq -1.4 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{-182}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;t \leq 5.1 \cdot 10^{-89}:\\ \;\;\;\;z \cdot \frac{-x}{t}\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{-85}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error14.0
Cost712
\[\begin{array}{l} t_1 := x + \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;t \leq -2.2 \cdot 10^{-137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{-182}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error10.7
Cost712
\[\begin{array}{l} t_1 := x + \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{-26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.14 \cdot 10^{-85}:\\ \;\;\;\;\frac{z \cdot \left(y - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error26.3
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -7.616041622798584 \cdot 10^{-224}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.2252865699026297 \cdot 10^{-87}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error27.5
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.4 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{-85}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error31.2
Cost64
\[x \]

Error

Reproduce

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