?

Average Accuracy: 90.1% → 97.8%
Time: 13.3s
Precision: binary64
Cost: 8136

?

\[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 -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{-200}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\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) z) t))))
   (if (<= t_1 (- INFINITY))
     (fma (/ (- y x) t) z x)
     (if (<= t_1 -1e-200) t_1 (fma (/ z t) (- y x) x)))))
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 <= -((double) INFINITY)) {
		tmp = fma(((y - x) / t), z, x);
	} else if (t_1 <= -1e-200) {
		tmp = t_1;
	} else {
		tmp = fma((z / t), (y - x), x);
	}
	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 <= Float64(-Inf))
		tmp = fma(Float64(Float64(y - x) / t), z, x);
	elseif (t_1 <= -1e-200)
		tmp = t_1;
	else
		tmp = fma(Float64(z / t), Float64(y - x), x);
	end
	return 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[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[t$95$1, -1e-200], t$95$1, N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]]]
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 -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\

\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-200}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\


\end{array}

Error?

Target

Original90.1%
Target96.9%
Herbie97.8%
\[\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 (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -inf.0

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)} \]
      Proof

      [Start]0.0

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

      +-commutative [=>]0.0

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

      associate-*l/ [<=]99.7

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

      fma-def [=>]99.7

      \[ \color{blue}{\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)} \]

    if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -9.9999999999999998e-201

    1. Initial program 99.6%

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

    if -9.9999999999999998e-201 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 89.9%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)} \]
      Proof

      [Start]89.9

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

      +-commutative [=>]89.9

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

      *-commutative [=>]89.9

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

      associate-*l/ [<=]96.2

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

      fma-def [=>]96.2

      \[ \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification97.8%

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

Alternatives

Alternative 1
Accuracy97.8%
Cost8136
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{-200}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \end{array} \]
Alternative 2
Accuracy97.9%
Cost1865
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq -1 \cdot 10^{-200}\right):\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy66.1%
Cost1108
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;y \leq -2.9 \cdot 10^{-25}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+33}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+125}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+139}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy92.3%
Cost1104
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;x \leq -5.1 \cdot 10^{+73}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-248}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-174}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \end{array} \]
Alternative 5
Accuracy52.3%
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-25}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-225}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-178}:\\ \;\;\;\;x \cdot \frac{-z}{t}\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+30}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 6
Accuracy73.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{-155} \lor \neg \left(x \leq 1.8 \cdot 10^{-156}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \end{array} \]
Alternative 7
Accuracy75.1%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-154} \lor \neg \left(x \leq 3.3 \cdot 10^{-155}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]
Alternative 8
Accuracy83.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{+38} \lor \neg \left(x \leq 2.7 \cdot 10^{-120}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \end{array} \]
Alternative 9
Accuracy83.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{+38}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-120}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \end{array} \]
Alternative 10
Accuracy60.3%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.75 \cdot 10^{-153}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-122}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy60.2%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-153}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-120}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Accuracy51.2%
Cost64
\[x \]

Error

Reproduce?

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