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

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.6
Target0.1
Herbie0.1
\[\frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right) \]

Derivation

  1. Initial program 9.6

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

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

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

    \[\leadsto \frac{x}{y} + \color{blue}{\mathsf{fma}\left(2, {t}^{-1}, \frac{2}{t \cdot z} + -2\right)} \]
  5. Final simplification0.1

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

Reproduce

herbie shell --seed 2022150 
(FPCore (x y z t)
  :name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
  :precision binary64

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

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