Average Error: 6.1 → 0.7
Time: 19.5s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(z - x\right) \cdot y}{t} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\ \mathbf{elif}\;x + \frac{\left(z - x\right) \cdot y}{t} \le 1.011049397526569 \cdot 10^{+308}:\\ \;\;\;\;x + \frac{\left(z - x\right) \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(z - x\right) \cdot y}{t} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\

\mathbf{elif}\;x + \frac{\left(z - x\right) \cdot y}{t} \le 1.011049397526569 \cdot 10^{+308}:\\
\;\;\;\;x + \frac{\left(z - x\right) \cdot y}{t}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r19645795 = x;
        double r19645796 = y;
        double r19645797 = z;
        double r19645798 = r19645797 - r19645795;
        double r19645799 = r19645796 * r19645798;
        double r19645800 = t;
        double r19645801 = r19645799 / r19645800;
        double r19645802 = r19645795 + r19645801;
        return r19645802;
}

double f(double x, double y, double z, double t) {
        double r19645803 = x;
        double r19645804 = z;
        double r19645805 = r19645804 - r19645803;
        double r19645806 = y;
        double r19645807 = r19645805 * r19645806;
        double r19645808 = t;
        double r19645809 = r19645807 / r19645808;
        double r19645810 = r19645803 + r19645809;
        double r19645811 = -inf.0;
        bool r19645812 = r19645810 <= r19645811;
        double r19645813 = r19645805 / r19645808;
        double r19645814 = fma(r19645813, r19645806, r19645803);
        double r19645815 = 1.011049397526569e+308;
        bool r19645816 = r19645810 <= r19645815;
        double r19645817 = r19645816 ? r19645810 : r19645814;
        double r19645818 = r19645812 ? r19645814 : r19645817;
        return r19645818;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.1
Target2.0
Herbie0.7
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if (+ x (/ (* y (- z x)) t)) < -inf.0 or 1.011049397526569e+308 < (+ x (/ (* y (- z x)) t))

    1. Initial program 60.2

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

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

    if -inf.0 < (+ x (/ (* y (- z x)) t)) < 1.011049397526569e+308

    1. Initial program 0.8

      \[x + \frac{y \cdot \left(z - x\right)}{t}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(z - x\right) \cdot y}{t} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\ \mathbf{elif}\;x + \frac{\left(z - x\right) \cdot y}{t} \le 1.011049397526569 \cdot 10^{+308}:\\ \;\;\;\;x + \frac{\left(z - x\right) \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"

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

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