?

Average Error: 6.4 → 3.9
Time: 8.1s
Precision: binary64
Cost: 2628

?

\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} t_1 := x + \frac{y - x}{t} \cdot z\\ t_2 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_2 \leq 10^{+302}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(t_1 \cdot \frac{1}{t_1}\right)\\ \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 (* (/ (- y x) t) z))) (t_2 (+ x (/ (* (- y x) z) t))))
   (if (<= t_2 1e+302) t_2 (* t_1 (* t_1 (/ 1.0 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 + (((y - x) / t) * z);
	double t_2 = x + (((y - x) * z) / t);
	double tmp;
	if (t_2 <= 1e+302) {
		tmp = t_2;
	} else {
		tmp = t_1 * (t_1 * (1.0 / 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) :: t_2
    real(8) :: tmp
    t_1 = x + (((y - x) / t) * z)
    t_2 = x + (((y - x) * z) / t)
    if (t_2 <= 1d+302) then
        tmp = t_2
    else
        tmp = t_1 * (t_1 * (1.0d0 / 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 + (((y - x) / t) * z);
	double t_2 = x + (((y - x) * z) / t);
	double tmp;
	if (t_2 <= 1e+302) {
		tmp = t_2;
	} else {
		tmp = t_1 * (t_1 * (1.0 / 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 + (((y - x) / t) * z)
	t_2 = x + (((y - x) * z) / t)
	tmp = 0
	if t_2 <= 1e+302:
		tmp = t_2
	else:
		tmp = t_1 * (t_1 * (1.0 / 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(Float64(Float64(y - x) / t) * z))
	t_2 = Float64(x + Float64(Float64(Float64(y - x) * z) / t))
	tmp = 0.0
	if (t_2 <= 1e+302)
		tmp = t_2;
	else
		tmp = Float64(t_1 * Float64(t_1 * Float64(1.0 / 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 + (((y - x) / t) * z);
	t_2 = x + (((y - x) * z) / t);
	tmp = 0.0;
	if (t_2 <= 1e+302)
		tmp = t_2;
	else
		tmp = t_1 * (t_1 * (1.0 / 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[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 1e+302], t$95$2, N[(t$95$1 * N[(t$95$1 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
t_1 := x + \frac{y - x}{t} \cdot z\\
t_2 := x + \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{if}\;t_2 \leq 10^{+302}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(t_1 \cdot \frac{1}{t_1}\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.4
Target2.1
Herbie3.9
\[\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 (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 1.0000000000000001e302

    1. Initial program 3.8

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

    if 1.0000000000000001e302 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 56.3

      \[x + \frac{\left(y - x\right) \cdot z}{t} \]
    2. Taylor expanded in z around 0 4.2

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

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

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

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

Alternatives

Alternative 1
Error4.5
Cost1220
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq 10^{+302}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t} \cdot z + x\\ \end{array} \]
Alternative 2
Error3.9
Cost1220
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq 10^{+302}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y - x}{t} \cdot z + x\\ \end{array} \]
Alternative 3
Error28.3
Cost1112
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ \mathbf{if}\;x \leq -96000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-106}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{t}\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-130}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -8.6 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-217}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{-62}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error18.7
Cost976
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{-130}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.62 \cdot 10^{-189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-218}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{-62}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error26.8
Cost848
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{-130}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-191}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-217}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-62}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error11.2
Cost840
\[\begin{array}{l} t_1 := \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z\\ \mathbf{if}\;z \leq -7 \cdot 10^{+113}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+24}:\\ \;\;\;\;x + \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error11.3
Cost712
\[\begin{array}{l} t_1 := x + \frac{z \cdot y}{t}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-229}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error11.6
Cost712
\[\begin{array}{l} t_1 := x + \frac{z \cdot y}{t}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{-149}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{-229}:\\ \;\;\;\;x - \frac{x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error31.9
Cost64
\[x \]

Error

Reproduce?

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