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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r293013 = x;
        double r293014 = y;
        double r293015 = z;
        double r293016 = r293015 - r293013;
        double r293017 = r293014 * r293016;
        double r293018 = t;
        double r293019 = r293017 / r293018;
        double r293020 = r293013 + r293019;
        return r293020;
}

double f(double x, double y, double z, double t) {
        double r293021 = x;
        double r293022 = y;
        double r293023 = z;
        double r293024 = r293023 - r293021;
        double r293025 = r293022 * r293024;
        double r293026 = t;
        double r293027 = r293025 / r293026;
        double r293028 = r293021 + r293027;
        double r293029 = -inf.0;
        bool r293030 = r293028 <= r293029;
        double r293031 = r293024 / r293026;
        double r293032 = r293022 * r293031;
        double r293033 = r293021 + r293032;
        double r293034 = 3.9093850113859416e+208;
        bool r293035 = r293028 <= r293034;
        double r293036 = r293022 / r293026;
        double r293037 = fma(r293036, r293024, r293021);
        double r293038 = r293035 ? r293028 : r293037;
        double r293039 = r293030 ? r293033 : r293038;
        return r293039;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.5
Target2.1
Herbie1.2
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

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

    1. Initial program 64.0

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

      \[\leadsto x + \frac{y \cdot \left(z - x\right)}{\color{blue}{1 \cdot t}}\]
    4. Applied times-frac0.2

      \[\leadsto x + \color{blue}{\frac{y}{1} \cdot \frac{z - x}{t}}\]
    5. Simplified0.2

      \[\leadsto x + \color{blue}{y} \cdot \frac{z - x}{t}\]

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

    1. Initial program 0.8

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

    if 3.9093850113859416e+208 < (+ x (/ (* y (- z x)) t))

    1. Initial program 20.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.2

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

Reproduce

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

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

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