Average Error: 26.8 → 0.5
Time: 20.6s
Precision: 64
\[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000013984514225739985704422\right) \cdot x + 263.5050747210000281484099105000495910645\right) \cdot x + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.914499972464791844188398177846978570663 \cdot 10^{71} \lor \neg \left(x \le 2.287943170826980441039975419814875490697 \cdot 10^{47}\right):\\ \;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - 2\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}\\ \end{array}\]
\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000013984514225739985704422\right) \cdot x + 263.5050747210000281484099105000495910645\right) \cdot x + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}
\begin{array}{l}
\mathbf{if}\;x \le -1.914499972464791844188398177846978570663 \cdot 10^{71} \lor \neg \left(x \le 2.287943170826980441039975419814875490697 \cdot 10^{47}\right):\\
\;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x - 2\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r287067 = x;
        double r287068 = 2.0;
        double r287069 = r287067 - r287068;
        double r287070 = 4.16438922228;
        double r287071 = r287067 * r287070;
        double r287072 = 78.6994924154;
        double r287073 = r287071 + r287072;
        double r287074 = r287073 * r287067;
        double r287075 = 137.519416416;
        double r287076 = r287074 + r287075;
        double r287077 = r287076 * r287067;
        double r287078 = y;
        double r287079 = r287077 + r287078;
        double r287080 = r287079 * r287067;
        double r287081 = z;
        double r287082 = r287080 + r287081;
        double r287083 = r287069 * r287082;
        double r287084 = 43.3400022514;
        double r287085 = r287067 + r287084;
        double r287086 = r287085 * r287067;
        double r287087 = 263.505074721;
        double r287088 = r287086 + r287087;
        double r287089 = r287088 * r287067;
        double r287090 = 313.399215894;
        double r287091 = r287089 + r287090;
        double r287092 = r287091 * r287067;
        double r287093 = 47.066876606;
        double r287094 = r287092 + r287093;
        double r287095 = r287083 / r287094;
        return r287095;
}

double f(double x, double y, double z) {
        double r287096 = x;
        double r287097 = -1.9144999724647918e+71;
        bool r287098 = r287096 <= r287097;
        double r287099 = 2.2879431708269804e+47;
        bool r287100 = r287096 <= r287099;
        double r287101 = !r287100;
        bool r287102 = r287098 || r287101;
        double r287103 = 2.0;
        double r287104 = r287096 - r287103;
        double r287105 = y;
        double r287106 = 3.0;
        double r287107 = pow(r287096, r287106);
        double r287108 = r287105 / r287107;
        double r287109 = 4.16438922228;
        double r287110 = r287108 + r287109;
        double r287111 = 101.7851458539211;
        double r287112 = r287111 / r287096;
        double r287113 = r287110 - r287112;
        double r287114 = r287104 * r287113;
        double r287115 = 78.6994924154;
        double r287116 = fma(r287096, r287109, r287115);
        double r287117 = 137.519416416;
        double r287118 = fma(r287116, r287096, r287117);
        double r287119 = fma(r287118, r287096, r287105);
        double r287120 = z;
        double r287121 = fma(r287119, r287096, r287120);
        double r287122 = 43.3400022514;
        double r287123 = r287096 + r287122;
        double r287124 = 263.505074721;
        double r287125 = fma(r287123, r287096, r287124);
        double r287126 = 313.399215894;
        double r287127 = fma(r287125, r287096, r287126);
        double r287128 = 47.066876606;
        double r287129 = fma(r287127, r287096, r287128);
        double r287130 = r287121 / r287129;
        double r287131 = r287104 * r287130;
        double r287132 = r287102 ? r287114 : r287131;
        return r287132;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.8
Target0.5
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;x \lt -3.326128725870004842699683658678411714981 \cdot 10^{62}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999963610045597306452691555 \cdot x\right) - 110.1139242984810948655649553984403610229\\ \mathbf{elif}\;x \lt 9.429991714554672672712552870340896976735 \cdot 10^{55}:\\ \;\;\;\;\frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.5050747210000281484099105000495910645 \cdot x + \left(43.3400022514000013984514225739985704422 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999963610045597306452691555 \cdot x\right) - 110.1139242984810948655649553984403610229\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.9144999724647918e+71 or 2.2879431708269804e+47 < x

    1. Initial program 62.8

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000013984514225739985704422\right) \cdot x + 263.5050747210000281484099105000495910645\right) \cdot x + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}\]
    2. Simplified60.0

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}}}\]
    3. Using strategy rm
    4. Applied div-inv60.0

      \[\leadsto \color{blue}{\left(x - 2\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}}}\]
    5. Simplified60.0

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\]
    6. Taylor expanded around inf 0.3

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - 101.785145853921093817007204052060842514 \cdot \frac{1}{x}\right)}\]
    7. Simplified0.3

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)}\]

    if -1.9144999724647918e+71 < x < 2.2879431708269804e+47

    1. Initial program 2.4

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000013984514225739985704422\right) \cdot x + 263.5050747210000281484099105000495910645\right) \cdot x + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}\]
    2. Simplified0.9

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}}}\]
    3. Using strategy rm
    4. Applied div-inv0.9

      \[\leadsto \color{blue}{\left(x - 2\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}}}\]
    5. Simplified0.7

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.914499972464791844188398177846978570663 \cdot 10^{71} \lor \neg \left(x \le 2.287943170826980441039975419814875490697 \cdot 10^{47}\right):\\ \;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - 2\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019326 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2) 1) (/ (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z) (+ (* (+ (+ (* 263.505074721 x) (+ (* 43.3400022514 (* x x)) (* x (* x x)))) 313.399215894) x) 47.066876606))) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811)))

  (/ (* (- x 2) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))