Average Error: 2.0 → 2.0
Time: 2.7s
Precision: 64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)\]
\frac{x}{y} \cdot \left(z - t\right) + t
\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)
double f(double x, double y, double z, double t) {
        double r418770 = x;
        double r418771 = y;
        double r418772 = r418770 / r418771;
        double r418773 = z;
        double r418774 = t;
        double r418775 = r418773 - r418774;
        double r418776 = r418772 * r418775;
        double r418777 = r418776 + r418774;
        return r418777;
}

double f(double x, double y, double z, double t) {
        double r418778 = x;
        double r418779 = y;
        double r418780 = r418778 / r418779;
        double r418781 = z;
        double r418782 = t;
        double r418783 = r418781 - r418782;
        double r418784 = fma(r418780, r418783, r418782);
        return r418784;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.0
Target2.1
Herbie2.0
\[\begin{array}{l} \mathbf{if}\;z \lt 2.7594565545626922 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z \lt 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 2.0

    \[\frac{x}{y} \cdot \left(z - t\right) + t\]
  2. Using strategy rm
  3. Applied fma-def2.0

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

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

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(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))