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

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original1.8
Target2.0
Herbie1.8
\[\begin{array}{l} \mathbf{if}\;z < 2.759456554562692 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z < 2.326994450874436 \cdot 10^{-110}:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \end{array} \]

Derivation

  1. Initial program 1.8

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

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

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

Reproduce

herbie shell --seed 2022133 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))

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