(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 (pow (/ 1.0 x) 2.0))
(t_1
(*
(fma
(fma x (fma x (fma x 4.16438922228 78.6994924154) 137.519416416) y)
x
z)
(- x 2.0)))
(t_2
(fma
(+
(fma 43.3400022514 (pow x 2.0) (fma 263.505074721 x (pow x 3.0)))
313.399215894)
x
47.066876606))
(t_3
(fma
(fma (fma (fma x 4.16438922228 78.6994924154) x 137.519416416) x y)
x
z)))
(if (<= x -5.2e+51)
(-
(+
(* 4.16438922228 x)
(+ (* (- y 130977.50649958357) t_0) (* 3655.1204654076414 (/ 1.0 x))))
110.1139242984811)
(if (<= x 1.72e+65)
(if (!= (- x 2.0) 0.0)
(/ t_3 (/ t_2 (- x 2.0)))
(/ (* (- x 2.0) t_3) t_2))
(if (!= t_1 0.0)
(pow
(/
(+
0.24013125253755718
(+ (* -55.572073733743466 t_0) (* 5.86923874282773 (/ 1.0 x))))
(- x 2.0))
-1.0)
(/
t_1
(fma
x
(fma x (fma (+ x 43.3400022514) x 263.505074721) 313.399215894)
47.066876606)))))))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 = pow((1.0 / x), 2.0);
double t_1 = fma(fma(x, fma(x, fma(x, 4.16438922228, 78.6994924154), 137.519416416), y), x, z) * (x - 2.0);
double t_2 = fma((fma(43.3400022514, pow(x, 2.0), fma(263.505074721, x, pow(x, 3.0))) + 313.399215894), x, 47.066876606);
double t_3 = fma(fma(fma(fma(x, 4.16438922228, 78.6994924154), x, 137.519416416), x, y), x, z);
double tmp;
if (x <= -5.2e+51) {
tmp = ((4.16438922228 * x) + (((y - 130977.50649958357) * t_0) + (3655.1204654076414 * (1.0 / x)))) - 110.1139242984811;
} else if (x <= 1.72e+65) {
double tmp_1;
if ((x - 2.0) != 0.0) {
tmp_1 = t_3 / (t_2 / (x - 2.0));
} else {
tmp_1 = ((x - 2.0) * t_3) / t_2;
}
tmp = tmp_1;
} else if (t_1 != 0.0) {
tmp = pow(((0.24013125253755718 + ((-55.572073733743466 * t_0) + (5.86923874282773 * (1.0 / x)))) / (x - 2.0)), -1.0);
} else {
tmp = t_1 / fma(x, fma(x, fma((x + 43.3400022514), x, 263.505074721), 313.399215894), 47.066876606);
}
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 = Float64(1.0 / x) ^ 2.0 t_1 = Float64(fma(fma(x, fma(x, fma(x, 4.16438922228, 78.6994924154), 137.519416416), y), x, z) * Float64(x - 2.0)) t_2 = fma(Float64(fma(43.3400022514, (x ^ 2.0), fma(263.505074721, x, (x ^ 3.0))) + 313.399215894), x, 47.066876606) t_3 = fma(fma(fma(fma(x, 4.16438922228, 78.6994924154), x, 137.519416416), x, y), x, z) tmp = 0.0 if (x <= -5.2e+51) tmp = Float64(Float64(Float64(4.16438922228 * x) + Float64(Float64(Float64(y - 130977.50649958357) * t_0) + Float64(3655.1204654076414 * Float64(1.0 / x)))) - 110.1139242984811); elseif (x <= 1.72e+65) tmp_1 = 0.0 if (Float64(x - 2.0) != 0.0) tmp_1 = Float64(t_3 / Float64(t_2 / Float64(x - 2.0))); else tmp_1 = Float64(Float64(Float64(x - 2.0) * t_3) / t_2); end tmp = tmp_1; elseif (t_1 != 0.0) tmp = Float64(Float64(0.24013125253755718 + Float64(Float64(-55.572073733743466 * t_0) + Float64(5.86923874282773 * Float64(1.0 / x)))) / Float64(x - 2.0)) ^ -1.0; else tmp = Float64(t_1 / fma(x, fma(x, fma(Float64(x + 43.3400022514), x, 263.505074721), 313.399215894), 47.066876606)); 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[Power[N[(1.0 / x), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * N[(x * N[(x * 4.16438922228 + 78.6994924154), $MachinePrecision] + 137.519416416), $MachinePrecision] + y), $MachinePrecision] * x + z), $MachinePrecision] * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(43.3400022514 * N[Power[x, 2.0], $MachinePrecision] + N[(263.505074721 * x + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 313.399215894), $MachinePrecision] * x + 47.066876606), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(x * 4.16438922228 + 78.6994924154), $MachinePrecision] * x + 137.519416416), $MachinePrecision] * x + y), $MachinePrecision] * x + z), $MachinePrecision]}, If[LessEqual[x, -5.2e+51], N[(N[(N[(4.16438922228 * x), $MachinePrecision] + N[(N[(N[(y - 130977.50649958357), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(3655.1204654076414 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 110.1139242984811), $MachinePrecision], If[LessEqual[x, 1.72e+65], If[Unequal[N[(x - 2.0), $MachinePrecision], 0.0], N[(t$95$3 / N[(t$95$2 / N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x - 2.0), $MachinePrecision] * t$95$3), $MachinePrecision] / t$95$2), $MachinePrecision]], If[Unequal[t$95$1, 0.0], N[Power[N[(N[(0.24013125253755718 + N[(N[(-55.572073733743466 * t$95$0), $MachinePrecision] + N[(5.86923874282773 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x - 2.0), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], N[(t$95$1 / N[(x * N[(x * N[(N[(x + 43.3400022514), $MachinePrecision] * x + 263.505074721), $MachinePrecision] + 313.399215894), $MachinePrecision] + 47.066876606), $MachinePrecision]), $MachinePrecision]]]]]]]]
\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 := {\left(\frac{1}{x}\right)}^{2}\\
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), x, z\right) \cdot \left(x - 2\right)\\
t_2 := \mathsf{fma}\left(\mathsf{fma}\left(43.3400022514, {x}^{2}, \mathsf{fma}\left(263.505074721, x, {x}^{3}\right)\right) + 313.399215894, x, 47.066876606\right)\\
t_3 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), x, 137.519416416\right), x, y\right), x, z\right)\\
\mathbf{if}\;x \leq -5.2 \cdot 10^{+51}:\\
\;\;\;\;\left(4.16438922228 \cdot x + \left(\left(y - 130977.50649958357\right) \cdot t_0 + 3655.1204654076414 \cdot \frac{1}{x}\right)\right) - 110.1139242984811\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{+65}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;x - 2 \ne 0:\\
\;\;\;\;\frac{t_3}{\frac{t_2}{x - 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - 2\right) \cdot t_3}{t_2}\\
\end{array}\\
\mathbf{elif}\;t_1 \ne 0:\\
\;\;\;\;{\left(\frac{0.24013125253755718 + \left(-55.572073733743466 \cdot t_0 + 5.86923874282773 \cdot \frac{1}{x}\right)}{x - 2}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), 313.399215894\right), 47.066876606\right)}\\
\end{array}
| Original | 41.75% |
|---|---|
| Target | 1.35% |
| Herbie | 1.61% |
if x < -5.2000000000000002e51Initial program 97.81
Taylor expanded in x around inf 2.04
if -5.2000000000000002e51 < x < 1.7199999999999999e65Initial program 3.03
Taylor expanded in x around 0 3.02
Applied egg-rr1.3
if 1.7199999999999999e65 < x Initial program 100
Applied egg-rr95.71
Taylor expanded in x around inf 2.07
herbie shell --seed 2023136
(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)))