?

Average Accuracy: 89.8% → 98.5%
Time: 10.2s
Precision: binary64
Cost: 3154

?

\[x + \frac{\left(y - x\right) \cdot z}{t} \]
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+298} \lor \neg \left(t_1 \leq -1 \cdot 10^{-139} \lor \neg \left(t_1 \leq 5 \cdot 10^{-177}\right) \land t_1 \leq 2 \cdot 10^{+297}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{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 (/ (* (- y x) z) t))))
   (if (or (<= t_1 -5e+298)
           (not
            (or (<= t_1 -1e-139) (and (not (<= t_1 5e-177)) (<= t_1 2e+297)))))
     (+ x (* z (/ (- y x) 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 + (((y - x) * z) / t);
	double tmp;
	if ((t_1 <= -5e+298) || !((t_1 <= -1e-139) || (!(t_1 <= 5e-177) && (t_1 <= 2e+297)))) {
		tmp = x + (z * ((y - x) / 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 + (((y - x) * z) / t)
    if ((t_1 <= (-5d+298)) .or. (.not. (t_1 <= (-1d-139)) .or. (.not. (t_1 <= 5d-177)) .and. (t_1 <= 2d+297))) then
        tmp = x + (z * ((y - x) / 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 + (((y - x) * z) / t);
	double tmp;
	if ((t_1 <= -5e+298) || !((t_1 <= -1e-139) || (!(t_1 <= 5e-177) && (t_1 <= 2e+297)))) {
		tmp = x + (z * ((y - x) / 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 + (((y - x) * z) / t)
	tmp = 0
	if (t_1 <= -5e+298) or not ((t_1 <= -1e-139) or (not (t_1 <= 5e-177) and (t_1 <= 2e+297))):
		tmp = x + (z * ((y - x) / 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(Float64(Float64(y - x) * z) / t))
	tmp = 0.0
	if ((t_1 <= -5e+298) || !((t_1 <= -1e-139) || (!(t_1 <= 5e-177) && (t_1 <= 2e+297))))
		tmp = Float64(x + Float64(z * Float64(Float64(y - x) / 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 + (((y - x) * z) / t);
	tmp = 0.0;
	if ((t_1 <= -5e+298) || ~(((t_1 <= -1e-139) || (~((t_1 <= 5e-177)) && (t_1 <= 2e+297)))))
		tmp = x + (z * ((y - x) / 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[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+298], N[Not[Or[LessEqual[t$95$1, -1e-139], And[N[Not[LessEqual[t$95$1, 5e-177]], $MachinePrecision], LessEqual[t$95$1, 2e+297]]]], $MachinePrecision]], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+298} \lor \neg \left(t_1 \leq -1 \cdot 10^{-139} \lor \neg \left(t_1 \leq 5 \cdot 10^{-177}\right) \land t_1 \leq 2 \cdot 10^{+297}\right):\\
\;\;\;\;x + z \cdot \frac{y - x}{t}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original89.8%
Target96.5%
Herbie98.5%
\[\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)) < -5.0000000000000003e298 or -1.00000000000000003e-139 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 5e-177 or 2e297 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 53.9%

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

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

      [Start]53.9

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

      associate-*l/ [<=]94.5

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

    if -5.0000000000000003e298 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -1.00000000000000003e-139 or 5e-177 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 2e297

    1. Initial program 99.6%

      \[x + \frac{\left(y - x\right) \cdot z}{t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \leq -5 \cdot 10^{+298} \lor \neg \left(x + \frac{\left(y - x\right) \cdot z}{t} \leq -1 \cdot 10^{-139} \lor \neg \left(x + \frac{\left(y - x\right) \cdot z}{t} \leq 5 \cdot 10^{-177}\right) \land x + \frac{\left(y - x\right) \cdot z}{t} \leq 2 \cdot 10^{+297}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy97.4%
Cost7492
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq 5 \cdot 10^{-177}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+263}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{z}{t}}{\frac{1}{y - x}}\\ \end{array} \]
Alternative 2
Accuracy97.4%
Cost1993
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq 5 \cdot 10^{-177} \lor \neg \left(t_1 \leq 5 \cdot 10^{+263}\right):\\ \;\;\;\;x + \frac{\frac{z}{t}}{\frac{1}{y - x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy72.2%
Cost977
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -1.05 \cdot 10^{-171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.65 \cdot 10^{-201}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-174} \lor \neg \left(x \leq 9.5 \cdot 10^{-126}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \end{array} \]
Alternative 4
Accuracy92.3%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1 \cdot 10^{-229} \lor \neg \left(t \leq 7.2 \cdot 10^{-140}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y - x\right) \cdot z}{t}\\ \end{array} \]
Alternative 5
Accuracy96.5%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-88} \lor \neg \left(x \leq 5.8 \cdot 10^{-247}\right):\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \end{array} \]
Alternative 6
Accuracy86.3%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.22 \cdot 10^{-63} \lor \neg \left(y \leq 2.3 \cdot 10^{-187}\right):\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \end{array} \]
Alternative 7
Accuracy86.4%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-61} \lor \neg \left(y \leq 8.6 \cdot 10^{-187}\right):\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \end{array} \]
Alternative 8
Accuracy58.9%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-172}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-125}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Accuracy58.8%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{-172}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-125}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy50.3%
Cost64
\[x \]

Error

Reproduce?

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