Average Error: 26.5 → 0.9
Time: 12.6s
Precision: binary64
\[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -4.459699750903103 \cdot 10^{+47}:\\ \;\;\;\;\left(\mathsf{fma}\left(x, 4.16438922228, \frac{3655.1204654076414}{x}\right) + \frac{y}{x \cdot x}\right) - \left(110.1139242984811 + \frac{130977.50649958357}{x \cdot x}\right)\\ \mathbf{elif}\;x \leq 6.7265151660717154 \cdot 10^{+75}:\\ \;\;\;\;\left(x - 2\right) \cdot \frac{x \cdot \left(y + x \cdot \left(x \cdot \left(x \cdot 4.16438922228 + 78.6994924154\right) + 137.519416416\right)\right) + z}{x \cdot \left(\left(x \cdot \left(263.505074721 + x \cdot 43.3400022514\right) + {x}^{3}\right) + 313.399215894\right) + 47.066876606}\\ \mathbf{else}:\\ \;\;\;\;\left(x - 2\right) \cdot \left(4.16438922228 - \left(\frac{101.7851458539211}{x} + \frac{1305.1163169399765}{{x}^{3}}\right)\right)\\ \end{array} \]
\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}
\begin{array}{l}
\mathbf{if}\;x \leq -4.459699750903103 \cdot 10^{+47}:\\
\;\;\;\;\left(\mathsf{fma}\left(x, 4.16438922228, \frac{3655.1204654076414}{x}\right) + \frac{y}{x \cdot x}\right) - \left(110.1139242984811 + \frac{130977.50649958357}{x \cdot x}\right)\\

\mathbf{elif}\;x \leq 6.7265151660717154 \cdot 10^{+75}:\\
\;\;\;\;\left(x - 2\right) \cdot \frac{x \cdot \left(y + x \cdot \left(x \cdot \left(x \cdot 4.16438922228 + 78.6994924154\right) + 137.519416416\right)\right) + z}{x \cdot \left(\left(x \cdot \left(263.505074721 + x \cdot 43.3400022514\right) + {x}^{3}\right) + 313.399215894\right) + 47.066876606}\\

\mathbf{else}:\\
\;\;\;\;\left(x - 2\right) \cdot \left(4.16438922228 - \left(\frac{101.7851458539211}{x} + \frac{1305.1163169399765}{{x}^{3}}\right)\right)\\


\end{array}
(FPCore (x y z)
 :precision binary64
 (/
  (*
   (- x 2.0)
   (+
    (*
     (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y)
     x)
    z))
  (+
   (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x)
   47.066876606)))
(FPCore (x y z)
 :precision binary64
 (if (<= x -4.459699750903103e+47)
   (-
    (+ (fma x 4.16438922228 (/ 3655.1204654076414 x)) (/ y (* x x)))
    (+ 110.1139242984811 (/ 130977.50649958357 (* x x))))
   (if (<= x 6.7265151660717154e+75)
     (*
      (- x 2.0)
      (/
       (+
        (*
         x
         (+
          y
          (* x (+ (* x (+ (* x 4.16438922228) 78.6994924154)) 137.519416416))))
        z)
       (+
        (*
         x
         (+
          (+ (* x (+ 263.505074721 (* x 43.3400022514))) (pow x 3.0))
          313.399215894))
        47.066876606)))
     (*
      (- x 2.0)
      (-
       4.16438922228
       (+ (/ 101.7851458539211 x) (/ 1305.1163169399765 (pow x 3.0))))))))
double code(double x, double y, double z) {
	return ((x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / (((((((x + 43.3400022514) * x) + 263.505074721) * x) + 313.399215894) * x) + 47.066876606);
}
double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.459699750903103e+47) {
		tmp = (fma(x, 4.16438922228, (3655.1204654076414 / x)) + (y / (x * x))) - (110.1139242984811 + (130977.50649958357 / (x * x)));
	} else if (x <= 6.7265151660717154e+75) {
		tmp = (x - 2.0) * (((x * (y + (x * ((x * ((x * 4.16438922228) + 78.6994924154)) + 137.519416416)))) + z) / ((x * (((x * (263.505074721 + (x * 43.3400022514))) + pow(x, 3.0)) + 313.399215894)) + 47.066876606));
	} else {
		tmp = (x - 2.0) * (4.16438922228 - ((101.7851458539211 / x) + (1305.1163169399765 / pow(x, 3.0))));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.5
Target0.8
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;x < -3.326128725870005 \cdot 10^{+62}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\ \mathbf{elif}\;x < 9.429991714554673 \cdot 10^{+55}:\\ \;\;\;\;\frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.505074721 \cdot x + \left(43.3400022514 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.399215894\right) \cdot x + 47.066876606}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if x < -4.45969975090310303e47

    1. Initial program 61.8

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606} \]
    2. Taylor expanded in x around inf 1.3

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + \left(3655.1204654076414 \cdot \frac{1}{x} + 4.16438922228 \cdot x\right)\right) - \left(110.1139242984811 + 130977.50649958357 \cdot \frac{1}{{x}^{2}}\right)} \]
    3. Simplified1.3

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, 4.16438922228, \frac{3655.1204654076414}{x}\right) + \frac{y}{x \cdot x}\right) - \left(110.1139242984811 + \frac{130977.50649958357}{x \cdot x}\right)} \]

    if -4.45969975090310303e47 < x < 6.726515166071715e75

    1. Initial program 2.5

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606} \]
    2. Applied *-un-lft-identity_binary642.5

      \[\leadsto \frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\color{blue}{1 \cdot \left(\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606\right)}} \]
    3. Applied times-frac_binary640.7

      \[\leadsto \color{blue}{\frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}} \]
    4. Taylor expanded in x around inf 0.7

      \[\leadsto \frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\color{blue}{\left(43.3400022514 \cdot {x}^{2} + \left(263.505074721 \cdot x + {x}^{3}\right)\right)} + 313.399215894\right) \cdot x + 47.066876606} \]
    5. Applied associate-+r+_binary640.7

      \[\leadsto \frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\color{blue}{\left(\left(43.3400022514 \cdot {x}^{2} + 263.505074721 \cdot x\right) + {x}^{3}\right)} + 313.399215894\right) \cdot x + 47.066876606} \]
    6. Simplified0.7

      \[\leadsto \frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(\color{blue}{x \cdot \left(263.505074721 + 43.3400022514 \cdot x\right)} + {x}^{3}\right) + 313.399215894\right) \cdot x + 47.066876606} \]

    if 6.726515166071715e75 < x

    1. Initial program 64.0

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606} \]
    2. Applied *-un-lft-identity_binary6464.0

      \[\leadsto \frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\color{blue}{1 \cdot \left(\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606\right)}} \]
    3. Applied times-frac_binary6463.8

      \[\leadsto \color{blue}{\frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}} \]
    4. Applied add-cube-cbrt_binary6463.8

      \[\leadsto \frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\color{blue}{\left(\left(\sqrt[3]{\left(x + 43.3400022514\right) \cdot x + 263.505074721} \cdot \sqrt[3]{\left(x + 43.3400022514\right) \cdot x + 263.505074721}\right) \cdot \sqrt[3]{\left(x + 43.3400022514\right) \cdot x + 263.505074721}\right)} \cdot x + 313.399215894\right) \cdot x + 47.066876606} \]
    5. Applied associate-*l*_binary6463.8

      \[\leadsto \frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\color{blue}{\left(\sqrt[3]{\left(x + 43.3400022514\right) \cdot x + 263.505074721} \cdot \sqrt[3]{\left(x + 43.3400022514\right) \cdot x + 263.505074721}\right) \cdot \left(\sqrt[3]{\left(x + 43.3400022514\right) \cdot x + 263.505074721} \cdot x\right)} + 313.399215894\right) \cdot x + 47.066876606} \]
    6. Simplified63.8

      \[\leadsto \frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(\sqrt[3]{\left(x + 43.3400022514\right) \cdot x + 263.505074721} \cdot \sqrt[3]{\left(x + 43.3400022514\right) \cdot x + 263.505074721}\right) \cdot \color{blue}{\left(x \cdot \sqrt[3]{\mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right)}\right)} + 313.399215894\right) \cdot x + 47.066876606} \]
    7. Taylor expanded in x around inf 1.1

      \[\leadsto \frac{x - 2}{1} \cdot \color{blue}{\left(4.16438922228 - \left(101.7851458539211 \cdot \frac{1}{x} + 1305.1163169399765 \cdot \frac{1}{{x}^{3}}\right)\right)} \]
    8. Simplified1.1

      \[\leadsto \frac{x - 2}{1} \cdot \color{blue}{\left(4.16438922228 - \left(\frac{101.7851458539211}{x} + \frac{1305.1163169399765}{{x}^{3}}\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.459699750903103 \cdot 10^{+47}:\\ \;\;\;\;\left(\mathsf{fma}\left(x, 4.16438922228, \frac{3655.1204654076414}{x}\right) + \frac{y}{x \cdot x}\right) - \left(110.1139242984811 + \frac{130977.50649958357}{x \cdot x}\right)\\ \mathbf{elif}\;x \leq 6.7265151660717154 \cdot 10^{+75}:\\ \;\;\;\;\left(x - 2\right) \cdot \frac{x \cdot \left(y + x \cdot \left(x \cdot \left(x \cdot 4.16438922228 + 78.6994924154\right) + 137.519416416\right)\right) + z}{x \cdot \left(\left(x \cdot \left(263.505074721 + x \cdot 43.3400022514\right) + {x}^{3}\right) + 313.399215894\right) + 47.066876606}\\ \mathbf{else}:\\ \;\;\;\;\left(x - 2\right) \cdot \left(4.16438922228 - \left(\frac{101.7851458539211}{x} + \frac{1305.1163169399765}{{x}^{3}}\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2021340 
(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.0) 1.0) (/ (+ (* (+ (* (+ (* (+ (* 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.0) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))