Average Error: 6.5 → 2.1
Time: 4.9s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := \mathsf{fma}\left(z - x, \frac{y}{t}, x\right)\\ \mathbf{if}\;x \leq -2.2 \cdot 10^{-118}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-122}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t} - \frac{x}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (fma (- z x) (/ y t) x)))
   (if (<= x -2.2e-118)
     t_1
     (if (<= x 3.3e-122) (fma y (- (/ z t) (/ x t)) x) t_1))))
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 = fma((z - x), (y / t), x);
	double tmp;
	if (x <= -2.2e-118) {
		tmp = t_1;
	} else if (x <= 3.3e-122) {
		tmp = fma(y, ((z / t) - (x / t)), x);
	} else {
		tmp = t_1;
	}
	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 = fma(Float64(z - x), Float64(y / t), x)
	tmp = 0.0
	if (x <= -2.2e-118)
		tmp = t_1;
	elseif (x <= 3.3e-122)
		tmp = fma(y, Float64(Float64(z / t) - Float64(x / t)), x);
	else
		tmp = t_1;
	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[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -2.2e-118], t$95$1, If[LessEqual[x, 3.3e-122], N[(y * N[(N[(z / t), $MachinePrecision] - N[(x / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := \mathsf{fma}\left(z - x, \frac{y}{t}, x\right)\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{-118}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3.3 \cdot 10^{-122}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t} - \frac{x}{t}, x\right)\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.5
Target1.9
Herbie2.1
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Split input into 2 regimes
  2. if x < -2.19999999999999984e-118 or 3.29999999999999999e-122 < x

    1. Initial program 7.1

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

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

    if -2.19999999999999984e-118 < x < 3.29999999999999999e-122

    1. Initial program 5.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)} \]
    3. Taylor expanded in z around 0 5.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - x}{t}, x\right)} \]
    5. Applied egg-rr5.6

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{fma}\left(\sqrt[3]{\frac{z}{t}} \cdot \sqrt[3]{\frac{z}{t}}, \sqrt[3]{\frac{z}{t}}, -\frac{x}{t}\right)}, x\right) \]
    6. Applied egg-rr5.0

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

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

Reproduce

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