(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
(+
(/ 3655.1204654076414 x)
(-
(fma x 4.16438922228 (/ y (* x x)))
(+ 110.1139242984811 (/ 130977.50649958357 (* x x))))))
(t_1
(fma
x
(fma x (fma x (+ x 43.3400022514) 263.505074721) 313.399215894)
47.066876606)))
(if (<= x -3.3694724817171055e+42)
t_0
(if (<= x 2.5215728630517518e+60)
(*
(+ x -2.0)
(fma
(/ y t_1)
x
(fma
(/ (fma x (fma x 4.16438922228 78.6994924154) 137.519416416) t_1)
(* x x)
(/ z t_1))))
t_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 t_0 = (3655.1204654076414 / x) + (fma(x, 4.16438922228, (y / (x * x))) - (110.1139242984811 + (130977.50649958357 / (x * x))));
double t_1 = fma(x, fma(x, fma(x, (x + 43.3400022514), 263.505074721), 313.399215894), 47.066876606);
double tmp;
if (x <= -3.3694724817171055e+42) {
tmp = t_0;
} else if (x <= 2.5215728630517518e+60) {
tmp = (x + -2.0) * fma((y / t_1), x, fma((fma(x, fma(x, 4.16438922228, 78.6994924154), 137.519416416) / t_1), (x * x), (z / t_1)));
} else {
tmp = t_0;
}
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(Float64(3655.1204654076414 / x) + Float64(fma(x, 4.16438922228, Float64(y / Float64(x * x))) - Float64(110.1139242984811 + Float64(130977.50649958357 / Float64(x * x))))) t_1 = fma(x, fma(x, fma(x, Float64(x + 43.3400022514), 263.505074721), 313.399215894), 47.066876606) tmp = 0.0 if (x <= -3.3694724817171055e+42) tmp = t_0; elseif (x <= 2.5215728630517518e+60) tmp = Float64(Float64(x + -2.0) * fma(Float64(y / t_1), x, fma(Float64(fma(x, fma(x, 4.16438922228, 78.6994924154), 137.519416416) / t_1), Float64(x * x), Float64(z / t_1)))); else tmp = t_0; 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[(N[(3655.1204654076414 / x), $MachinePrecision] + N[(N[(x * 4.16438922228 + N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(110.1139242984811 + N[(130977.50649958357 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * N[(x * N[(x + 43.3400022514), $MachinePrecision] + 263.505074721), $MachinePrecision] + 313.399215894), $MachinePrecision] + 47.066876606), $MachinePrecision]}, If[LessEqual[x, -3.3694724817171055e+42], t$95$0, If[LessEqual[x, 2.5215728630517518e+60], N[(N[(x + -2.0), $MachinePrecision] * N[(N[(y / t$95$1), $MachinePrecision] * x + N[(N[(N[(x * N[(x * 4.16438922228 + 78.6994924154), $MachinePrecision] + 137.519416416), $MachinePrecision] / t$95$1), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(z / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$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}
\begin{array}{l}
t_0 := \frac{3655.1204654076414}{x} + \left(\mathsf{fma}\left(x, 4.16438922228, \frac{y}{x \cdot x}\right) - \left(110.1139242984811 + \frac{130977.50649958357}{x \cdot x}\right)\right)\\
t_1 := \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x + 43.3400022514, 263.505074721\right), 313.399215894\right), 47.066876606\right)\\
\mathbf{if}\;x \leq -3.3694724817171055 \cdot 10^{+42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.5215728630517518 \cdot 10^{+60}:\\
\;\;\;\;\left(x + -2\right) \cdot \mathsf{fma}\left(\frac{y}{t_1}, x, \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right)}{t_1}, x \cdot x, \frac{z}{t_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
| Original | 26.4 |
|---|---|
| Target | 0.7 |
| Herbie | 0.6 |
if x < -3.36947248171710553e42 or 2.521572863051752e60 < x Initial program 62.0
Simplified58.0
Taylor expanded in z around 0 58.0
Simplified57.3
Taylor expanded in x around inf 1.0
Simplified1.0
if -3.36947248171710553e42 < x < 2.521572863051752e60Initial program 1.4
Simplified0.6
Taylor expanded in y around 0 0.6
Simplified0.3
Final simplification0.6
herbie shell --seed 2022182
(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)))