Average Error: 6.0 → 1.8
Time: 16.8s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le 5.085802590344858309312584733803549621767 \cdot 10^{-285} \lor \neg \left(x \le 5.248255780313278222557610834682352778851 \cdot 10^{-105}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t} + x\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x \le 5.085802590344858309312584733803549621767 \cdot 10^{-285} \lor \neg \left(x \le 5.248255780313278222557610834682352778851 \cdot 10^{-105}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \left(z - x\right)}{t} + x\\

\end{array}
double f(double x, double y, double z, double t) {
        double r231617 = x;
        double r231618 = y;
        double r231619 = z;
        double r231620 = r231619 - r231617;
        double r231621 = r231618 * r231620;
        double r231622 = t;
        double r231623 = r231621 / r231622;
        double r231624 = r231617 + r231623;
        return r231624;
}

double f(double x, double y, double z, double t) {
        double r231625 = x;
        double r231626 = 5.085802590344858e-285;
        bool r231627 = r231625 <= r231626;
        double r231628 = 5.248255780313278e-105;
        bool r231629 = r231625 <= r231628;
        double r231630 = !r231629;
        bool r231631 = r231627 || r231630;
        double r231632 = y;
        double r231633 = t;
        double r231634 = r231632 / r231633;
        double r231635 = z;
        double r231636 = r231635 - r231625;
        double r231637 = fma(r231634, r231636, r231625);
        double r231638 = r231632 * r231636;
        double r231639 = r231638 / r231633;
        double r231640 = r231639 + r231625;
        double r231641 = r231631 ? r231637 : r231640;
        return r231641;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.0
Target1.8
Herbie1.8
\[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 < 5.085802590344858e-285 or 5.248255780313278e-105 < x

    1. Initial program 6.3

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

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

    if 5.085802590344858e-285 < x < 5.248255780313278e-105

    1. Initial program 4.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef4.3

      \[\leadsto \color{blue}{\frac{y}{t} \cdot \left(z - x\right) + x}\]
    5. Simplified4.7

      \[\leadsto \color{blue}{y \cdot \frac{z - x}{t}} + x\]
    6. Using strategy rm
    7. Applied div-inv4.7

      \[\leadsto y \cdot \color{blue}{\left(\left(z - x\right) \cdot \frac{1}{t}\right)} + x\]
    8. Using strategy rm
    9. Applied add-cube-cbrt5.3

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}\right)} \cdot \left(\left(z - x\right) \cdot \frac{1}{t}\right) + x\]
    10. Applied associate-*l*5.3

      \[\leadsto \color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \left(\sqrt[3]{y} \cdot \left(\left(z - x\right) \cdot \frac{1}{t}\right)\right)} + x\]
    11. Simplified4.2

      \[\leadsto \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \color{blue}{\frac{\sqrt[3]{y} \cdot \left(z - x\right)}{t}} + x\]
    12. Using strategy rm
    13. Applied associate-*r/5.2

      \[\leadsto \color{blue}{\frac{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \left(\sqrt[3]{y} \cdot \left(z - x\right)\right)}{t}} + x\]
    14. Simplified4.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 5.085802590344858309312584733803549621767 \cdot 10^{-285} \lor \neg \left(x \le 5.248255780313278222557610834682352778851 \cdot 10^{-105}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2019212 +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)))