Average Error: 5.9 → 0.5
Time: 38.8s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le 4352031582741585152966656:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, z \cdot \left(7.936500793651000149400709382518925849581 \cdot 10^{-4} + y\right) - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(\sqrt{x} - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right) \cdot \left(\sqrt{x} + \sqrt{\sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \left(\sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(7.936500793651000149400709382518925849581 \cdot 10^{-4} + y\right) \cdot \frac{z}{\frac{x}{z}} - \frac{0.002777777777777800001512975569539776188321}{\frac{x}{z}}\right) - \left(x - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}
\begin{array}{l}
\mathbf{if}\;x \le 4352031582741585152966656:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, z \cdot \left(7.936500793651000149400709382518925849581 \cdot 10^{-4} + y\right) - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(\sqrt{x} - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right) \cdot \left(\sqrt{x} + \sqrt{\sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \left(\sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\left(7.936500793651000149400709382518925849581 \cdot 10^{-4} + y\right) \cdot \frac{z}{\frac{x}{z}} - \frac{0.002777777777777800001512975569539776188321}{\frac{x}{z}}\right) - \left(x - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)\\

\end{array}
double f(double x, double y, double z) {
        double r24244285 = x;
        double r24244286 = 0.5;
        double r24244287 = r24244285 - r24244286;
        double r24244288 = log(r24244285);
        double r24244289 = r24244287 * r24244288;
        double r24244290 = r24244289 - r24244285;
        double r24244291 = 0.91893853320467;
        double r24244292 = r24244290 + r24244291;
        double r24244293 = y;
        double r24244294 = 0.0007936500793651;
        double r24244295 = r24244293 + r24244294;
        double r24244296 = z;
        double r24244297 = r24244295 * r24244296;
        double r24244298 = 0.0027777777777778;
        double r24244299 = r24244297 - r24244298;
        double r24244300 = r24244299 * r24244296;
        double r24244301 = 0.083333333333333;
        double r24244302 = r24244300 + r24244301;
        double r24244303 = r24244302 / r24244285;
        double r24244304 = r24244292 + r24244303;
        return r24244304;
}

double f(double x, double y, double z) {
        double r24244305 = x;
        double r24244306 = 4.352031582741585e+24;
        bool r24244307 = r24244305 <= r24244306;
        double r24244308 = z;
        double r24244309 = 0.0007936500793651;
        double r24244310 = y;
        double r24244311 = r24244309 + r24244310;
        double r24244312 = r24244308 * r24244311;
        double r24244313 = 0.0027777777777778;
        double r24244314 = r24244312 - r24244313;
        double r24244315 = 0.083333333333333;
        double r24244316 = fma(r24244308, r24244314, r24244315);
        double r24244317 = r24244316 / r24244305;
        double r24244318 = sqrt(r24244305);
        double r24244319 = log(r24244305);
        double r24244320 = 0.5;
        double r24244321 = r24244305 - r24244320;
        double r24244322 = 0.91893853320467;
        double r24244323 = fma(r24244319, r24244321, r24244322);
        double r24244324 = sqrt(r24244323);
        double r24244325 = r24244318 - r24244324;
        double r24244326 = cbrt(r24244323);
        double r24244327 = r24244326 * r24244326;
        double r24244328 = r24244326 * r24244327;
        double r24244329 = sqrt(r24244328);
        double r24244330 = r24244318 + r24244329;
        double r24244331 = r24244325 * r24244330;
        double r24244332 = r24244317 - r24244331;
        double r24244333 = r24244305 / r24244308;
        double r24244334 = r24244308 / r24244333;
        double r24244335 = r24244311 * r24244334;
        double r24244336 = r24244313 / r24244333;
        double r24244337 = r24244335 - r24244336;
        double r24244338 = r24244324 * r24244324;
        double r24244339 = r24244305 - r24244338;
        double r24244340 = r24244337 - r24244339;
        double r24244341 = r24244307 ? r24244332 : r24244340;
        return r24244341;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.9
Target1.4
Herbie0.5
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.9189385332046700050057097541866824030876 - x\right)\right) + \frac{0.08333333333333299564049667651488562114537}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - 0.002777777777777800001512975569539776188321\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < 4.352031582741585e+24

    1. Initial program 0.2

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    2. Simplified0.2

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)\right)}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt0.2

      \[\leadsto \frac{\mathsf{fma}\left(z, \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(x - \color{blue}{\sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}}\right)\]
    5. Applied add-sqr-sqrt0.2

      \[\leadsto \frac{\mathsf{fma}\left(z, \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)\]
    6. Applied difference-of-squares0.2

      \[\leadsto \frac{\mathsf{fma}\left(z, \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \color{blue}{\left(\sqrt{x} + \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right) \cdot \left(\sqrt{x} - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt0.3

      \[\leadsto \frac{\mathsf{fma}\left(z, \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(\sqrt{x} + \sqrt{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}}}\right) \cdot \left(\sqrt{x} - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)\]

    if 4.352031582741585e+24 < x

    1. Initial program 10.5

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    2. Simplified10.5

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(x - \mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)\right)}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt10.7

      \[\leadsto \frac{\mathsf{fma}\left(z, \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(x - \color{blue}{\sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}}\right)\]
    5. Taylor expanded around inf 10.9

      \[\leadsto \color{blue}{\left(\left(7.936500793651000149400709382518925849581 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - 0.002777777777777800001512975569539776188321 \cdot \frac{z}{x}\right)} - \left(x - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)\]
    6. Simplified0.7

      \[\leadsto \color{blue}{\left(\frac{z}{\frac{x}{z}} \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - \frac{0.002777777777777800001512975569539776188321}{\frac{x}{z}}\right)} - \left(x - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 4352031582741585152966656:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, z \cdot \left(7.936500793651000149400709382518925849581 \cdot 10^{-4} + y\right) - 0.002777777777777800001512975569539776188321, 0.08333333333333299564049667651488562114537\right)}{x} - \left(\sqrt{x} - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right) \cdot \left(\sqrt{x} + \sqrt{\sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \left(\sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt[3]{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(7.936500793651000149400709382518925849581 \cdot 10^{-4} + y\right) \cdot \frac{z}{\frac{x}{z}} - \frac{0.002777777777777800001512975569539776188321}{\frac{x}{z}}\right) - \left(x - \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)} \cdot \sqrt{\mathsf{fma}\left(\log x, x - 0.5, 0.9189385332046700050057097541866824030876\right)}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019170 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"

  :herbie-target
  (+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))

  (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))