?

Average Accuracy: 89.3% → 98.0%
Time: 10.4s
Precision: binary64
Cost: 8136

?

\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;t_1 \leq -5 \cdot 10^{-107}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (/ (* y (- z x)) t))))
   (if (<= t_1 (- INFINITY))
     (+ x (* (- z x) (/ y t)))
     (if (<= t_1 -5e-107) t_1 (fma (/ y t) (- z x) x)))))
double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
	double t_1 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = x + ((z - x) * (y / t));
	} else if (t_1 <= -5e-107) {
		tmp = t_1;
	} else {
		tmp = fma((y / t), (z - x), x);
	}
	return tmp;
}
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * Float64(z - x)) / t))
end
function code(x, y, z, t)
	t_1 = Float64(x + Float64(Float64(y * Float64(z - x)) / t))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(x + Float64(Float64(z - x) * Float64(y / t)));
	elseif (t_1 <= -5e-107)
		tmp = t_1;
	else
		tmp = fma(Float64(y / t), Float64(z - x), x);
	end
	return tmp
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x + N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -5e-107], t$95$1, N[(N[(y / t), $MachinePrecision] * N[(z - x), $MachinePrecision] + x), $MachinePrecision]]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\

\mathbf{elif}\;t_1 \leq -5 \cdot 10^{-107}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Target

Original89.3%
Target97.0%
Herbie98.0%
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation?

  1. Split input into 3 regimes
  2. if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -inf.0

    1. Initial program 0.0%

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

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

      [Start]0.0

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

      associate-*l/ [<=]99.7

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

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

    1. Initial program 99.7%

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

    if -4.99999999999999971e-107 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 89.9%

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

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

      [Start]89.9

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

      +-commutative [=>]89.9

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

      associate-*l/ [<=]96.8

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

      fma-def [=>]96.8

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

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

Alternatives

Alternative 1
Accuracy98.0%
Cost1865
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq -5 \cdot 10^{-107}\right):\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy70.1%
Cost1241
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -5.4 \cdot 10^{-25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.06 \cdot 10^{-200}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-188}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-99} \lor \neg \left(x \leq 7 \cdot 10^{-49}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy67.1%
Cost1241
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ t_2 := y \cdot \frac{z - x}{t}\\ \mathbf{if}\;y \leq -1.02 \cdot 10^{+49}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-131}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 0.0001 \lor \neg \left(y \leq 1.8 \cdot 10^{+35}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy53.0%
Cost1113
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -3.4 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-80}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-131}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-87}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 0.000175 \lor \neg \left(y \leq 2.1 \cdot 10^{+71}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Accuracy52.9%
Cost1113
\[\begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{+47}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{-79}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-131}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{-94}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-5} \lor \neg \left(y \leq 1.8 \cdot 10^{+74}\right):\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Accuracy53.1%
Cost1113
\[\begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{+47}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq -7.8 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-131}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-87}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-5} \lor \neg \left(y \leq 3 \cdot 10^{+71}\right):\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy82.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+46} \lor \neg \left(y \leq 2.25 \cdot 10^{+53}\right):\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 8
Accuracy97.3%
Cost708
\[\begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{+117}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \end{array} \]
Alternative 9
Accuracy58.7%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -7.6 \cdot 10^{-18}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-19}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy97.0%
Cost576
\[x + \left(z - x\right) \cdot \frac{y}{t} \]
Alternative 11
Accuracy50.6%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023136 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
  :precision binary64

  :herbie-target
  (- x (+ (* x (/ y t)) (* (- z) (/ y t))))

  (+ x (/ (* y (- z x)) t)))