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

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.4
Target1.0
Herbie1.1
\[x + \frac{y}{\frac{z - a}{z - t}} \]

Derivation

  1. Initial program 10.4

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)} \]
  3. Final simplification1.1

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

Reproduce

herbie shell --seed 2022166 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
  :precision binary64

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

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