Average Error: 27.0 → 0.5
Time: 6.5s
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} t_0 := \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)\\ t_1 := \left(x + -2\right) \cdot \left(\left(\frac{-101.7851458539211}{x} + \left(4.16438922228 + \frac{y + -124074.40615218398}{{x}^{3}}\right)\right) + \frac{3451.550173699799}{x \cdot x}\right)\\ \mathbf{if}\;x \leq -4.655703106873221 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.759027277177724 \cdot 10^{+49}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), z\right)}{t_0}, x + -2, \frac{y}{\frac{t_0}{x \cdot \left(x + -2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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
 (let* ((t_0
         (fma
          x
          (fma x (fma x (+ x 43.3400022514) 263.505074721) 313.399215894)
          47.066876606))
        (t_1
         (*
          (+ x -2.0)
          (+
           (+
            (/ -101.7851458539211 x)
            (+ 4.16438922228 (/ (+ y -124074.40615218398) (pow x 3.0))))
           (/ 3451.550173699799 (* x x))))))
   (if (<= x -4.655703106873221e+67)
     t_1
     (if (<= x 3.759027277177724e+49)
       (fma
        (/
         (fma
          (* x x)
          (fma x (fma x 4.16438922228 78.6994924154) 137.519416416)
          z)
         t_0)
        (+ x -2.0)
        (/ y (/ t_0 (* x (+ x -2.0)))))
       t_1))))
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 t_0 = fma(x, fma(x, fma(x, (x + 43.3400022514), 263.505074721), 313.399215894), 47.066876606);
	double t_1 = (x + -2.0) * (((-101.7851458539211 / x) + (4.16438922228 + ((y + -124074.40615218398) / pow(x, 3.0)))) + (3451.550173699799 / (x * x)));
	double tmp;
	if (x <= -4.655703106873221e+67) {
		tmp = t_1;
	} else if (x <= 3.759027277177724e+49) {
		tmp = fma((fma((x * x), fma(x, fma(x, 4.16438922228, 78.6994924154), 137.519416416), z) / t_0), (x + -2.0), (y / (t_0 / (x * (x + -2.0)))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z)
	return Float64(Float64(Float64(x - 2.0) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(x + 43.3400022514) * x) + 263.505074721) * x) + 313.399215894) * x) + 47.066876606))
end
function code(x, y, z)
	t_0 = fma(x, fma(x, fma(x, Float64(x + 43.3400022514), 263.505074721), 313.399215894), 47.066876606)
	t_1 = Float64(Float64(x + -2.0) * Float64(Float64(Float64(-101.7851458539211 / x) + Float64(4.16438922228 + Float64(Float64(y + -124074.40615218398) / (x ^ 3.0)))) + Float64(3451.550173699799 / Float64(x * x))))
	tmp = 0.0
	if (x <= -4.655703106873221e+67)
		tmp = t_1;
	elseif (x <= 3.759027277177724e+49)
		tmp = fma(Float64(fma(Float64(x * x), fma(x, fma(x, 4.16438922228, 78.6994924154), 137.519416416), z) / t_0), Float64(x + -2.0), Float64(y / Float64(t_0 / Float64(x * Float64(x + -2.0)))));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_] := N[(N[(N[(x - 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(x * 4.16438922228), $MachinePrecision] + 78.6994924154), $MachinePrecision] * x), $MachinePrecision] + 137.519416416), $MachinePrecision] * x), $MachinePrecision] + y), $MachinePrecision] * x), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(x + 43.3400022514), $MachinePrecision] * x), $MachinePrecision] + 263.505074721), $MachinePrecision] * x), $MachinePrecision] + 313.399215894), $MachinePrecision] * x), $MachinePrecision] + 47.066876606), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(x * N[(x * N[(x + 43.3400022514), $MachinePrecision] + 263.505074721), $MachinePrecision] + 313.399215894), $MachinePrecision] + 47.066876606), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + -2.0), $MachinePrecision] * N[(N[(N[(-101.7851458539211 / x), $MachinePrecision] + N[(4.16438922228 + N[(N[(y + -124074.40615218398), $MachinePrecision] / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(3451.550173699799 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.655703106873221e+67], t$95$1, If[LessEqual[x, 3.759027277177724e+49], N[(N[(N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 4.16438922228 + 78.6994924154), $MachinePrecision] + 137.519416416), $MachinePrecision] + z), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(x + -2.0), $MachinePrecision] + N[(y / N[(t$95$0 / N[(x * N[(x + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\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}
t_0 := \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)\\
t_1 := \left(x + -2\right) \cdot \left(\left(\frac{-101.7851458539211}{x} + \left(4.16438922228 + \frac{y + -124074.40615218398}{{x}^{3}}\right)\right) + \frac{3451.550173699799}{x \cdot x}\right)\\
\mathbf{if}\;x \leq -4.655703106873221 \cdot 10^{+67}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3.759027277177724 \cdot 10^{+49}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), z\right)}{t_0}, x + -2, \frac{y}{\frac{t_0}{x \cdot \left(x + -2\right)}}\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Target

Original27.0
Target0.9
Herbie0.5
\[\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 2 regimes
  2. if x < -4.65570310687322104e67 or 3.75902727717772421e49 < x

    1. Initial program 63.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. Simplified60.1

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

      \[\leadsto \left(x + -2\right) \cdot \color{blue}{\left(\left(4.16438922228 + \left(3451.550173699799 \cdot \frac{1}{{x}^{2}} + -1 \cdot \frac{124074.40615218398 + -1 \cdot y}{{x}^{3}}\right)\right) - 101.7851458539211 \cdot \frac{1}{x}\right)} \]
    4. Simplified0.8

      \[\leadsto \left(x + -2\right) \cdot \color{blue}{\left(\left(\frac{-101.7851458539211}{x} + \left(4.16438922228 - \frac{124074.40615218398 - y}{{x}^{3}}\right)\right) + \frac{3451.550173699799}{x \cdot x}\right)} \]

    if -4.65570310687322104e67 < x < 3.75902727717772421e49

    1. Initial program 2.6

      \[\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. Simplified1.0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), z\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)}, x + -2, \frac{y}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)} \cdot \left(x \cdot \left(x + -2\right)\right)\right)} \]
    5. Taylor expanded in y around 0 1.7

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

      \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), z\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)}, x + -2, \color{blue}{\frac{x \cdot \left(x - 2\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)} \cdot y}\right) \]
    7. Applied egg-rr0.3

      \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), z\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)}, x + -2, \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)}{x \cdot \left(x + -2\right)}}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.655703106873221 \cdot 10^{+67}:\\ \;\;\;\;\left(x + -2\right) \cdot \left(\left(\frac{-101.7851458539211}{x} + \left(4.16438922228 + \frac{y + -124074.40615218398}{{x}^{3}}\right)\right) + \frac{3451.550173699799}{x \cdot x}\right)\\ \mathbf{elif}\;x \leq 3.759027277177724 \cdot 10^{+49}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), z\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)}, x + -2, \frac{y}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)}{x \cdot \left(x + -2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + -2\right) \cdot \left(\left(\frac{-101.7851458539211}{x} + \left(4.16438922228 + \frac{y + -124074.40615218398}{{x}^{3}}\right)\right) + \frac{3451.550173699799}{x \cdot x}\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022210 
(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)))