?

Average Error: 6.4 → 3.9
Time: 12.5s
Precision: binary64
Cost: 3012

?

\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} t_1 := x + \left(\frac{y}{t} - \frac{x}{t}\right) \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 t) (/ 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 / t) - (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 / t) - (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 / t) - (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 / t) - (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 / t) - Float64(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 / t) - (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 / t), $MachinePrecision] - N[(x / t), $MachinePrecision]), $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 + \left(\frac{y}{t} - \frac{x}{t}\right) \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. Applied egg-rr4.3

      \[\leadsto \color{blue}{\left(x + \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z\right) \cdot \left(\left(x + \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z\right) \cdot \frac{1}{x + \left(\frac{y}{t} - \frac{x}{t}\right) \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 + \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z\right) \cdot \left(\left(x + \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z\right) \cdot \frac{1}{x + \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error3.9
Cost1348
\[\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}:\\ \;\;\;\;\left(\frac{y}{t} - \frac{x}{t}\right) \cdot z + x\\ \end{array} \]
Alternative 2
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 3
Error28.3
Cost1112
\[\begin{array}{l} \mathbf{if}\;x \leq -96000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-106}:\\ \;\;\;\;-\frac{z \cdot x}{t}\\ \mathbf{elif}\;x \leq -8.6 \cdot 10^{-130}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-191}:\\ \;\;\;\;\frac{y}{t} \cdot z\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-217}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{-62}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error29.1
Cost1112
\[\begin{array}{l} \mathbf{if}\;x \leq -9.6 \cdot 10^{+58}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-106}:\\ \;\;\;\;\left(-\frac{x}{t}\right) \cdot z\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-129}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.04 \cdot 10^{-190}:\\ \;\;\;\;\frac{y}{t} \cdot z\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-217}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-62}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error18.7
Cost976
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -8 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-189}:\\ \;\;\;\;\frac{y}{t} \cdot z\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{-62}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error18.3
Cost976
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -1.85 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.55 \cdot 10^{-191}:\\ \;\;\;\;\frac{y - x}{t} \cdot z\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{-62}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error27.2
Cost848
\[\begin{array}{l} t_1 := \frac{y}{t} \cdot z\\ \mathbf{if}\;x \leq -8.6 \cdot 10^{-130}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.9 \cdot 10^{-191}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-236}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error26.8
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-129}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-190}:\\ \;\;\;\;\frac{y}{t} \cdot z\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-217}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{-62}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error11.2
Cost712
\[\begin{array}{l} t_1 := \frac{y - x}{t} \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 10
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)))