Average Error: 0.1 → 0.0
Time: 3.2s
Precision: binary64
\[\frac{\left(x + y\right) - z}{t \cdot 2} \]
\[\mathsf{fma}\left(\frac{x}{t}, 0.5, \frac{0.5 \cdot y + z \cdot -0.5}{t}\right) \]
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
(FPCore (x y z t)
 :precision binary64
 (fma (/ x t) 0.5 (/ (+ (* 0.5 y) (* z -0.5)) t)))
double code(double x, double y, double z, double t) {
	return ((x + y) - z) / (t * 2.0);
}
double code(double x, double y, double z, double t) {
	return fma((x / t), 0.5, (((0.5 * y) + (z * -0.5)) / t));
}
function code(x, y, z, t)
	return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0))
end
function code(x, y, z, t)
	return fma(Float64(x / t), 0.5, Float64(Float64(Float64(0.5 * y) + Float64(z * -0.5)) / t))
end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(x / t), $MachinePrecision] * 0.5 + N[(N[(N[(0.5 * y), $MachinePrecision] + N[(z * -0.5), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\frac{\left(x + y\right) - z}{t \cdot 2}
\mathsf{fma}\left(\frac{x}{t}, 0.5, \frac{0.5 \cdot y + z \cdot -0.5}{t}\right)

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Derivation

  1. Initial program 0.1

    \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
  2. Taylor expanded in x around 0 0.0

    \[\leadsto \color{blue}{\left(0.5 \cdot \frac{x}{t} + 0.5 \cdot \frac{y}{t}\right) - 0.5 \cdot \frac{z}{t}} \]
  3. Applied egg-rr0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{t}, 0.5, \frac{0.5 \cdot y - 0.5 \cdot z}{t}\right)} \]
  4. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(\frac{x}{t}, 0.5, \frac{0.5 \cdot y + z \cdot -0.5}{t}\right) \]

Reproduce

herbie shell --seed 2022166 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
  :precision binary64
  (/ (- (+ x y) z) (* t 2.0)))