Average Error: 1.1 → 1.1
Time: 4.2s
Precision: binary64
\[x + y \cdot \frac{z - t}{z - a} \]
\[\mathsf{fma}\left(y, \frac{t - z}{a - z}, 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 (/ (- t z) (- a z)) 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, ((t - z) / (a - z)), x);
}
function code(x, y, z, t, a)
	return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a))))
end
function code(x, y, z, t, a)
	return fma(y, Float64(Float64(t - z) / Float64(a - z)), x)
end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := N[(y * N[(N[(t - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
x + y \cdot \frac{z - t}{z - a}
\mathsf{fma}\left(y, \frac{t - z}{a - z}, x\right)

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

Derivation

  1. Initial program 1.1

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

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

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

Reproduce

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

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

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