| Alternative 1 | |
|---|---|
| Error | 1.5 |
| Cost | 7944 |
(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 (/ 1.0 x)) (* x 4.16438922228))
(-
(- (/ (+ 130977.50649958357 (- y)) (pow x 2.0)))
110.1139242984811))))
(if (<= x -1.15e+17)
t_0
(if (<= x 3.2e+16)
(/
(*
(- x 2.0)
(+
(*
(+
(* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x)
y)
x)
z))
(+
(*
(+
(+
(pow x 3.0)
(+ (* x 263.505074721) (* (pow x 2.0) 43.3400022514)))
313.399215894)
x)
47.066876606))
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 * (1.0 / x)) + (x * 4.16438922228)) + (-((130977.50649958357 + -y) / pow(x, 2.0)) - 110.1139242984811);
double tmp;
if (x <= -1.15e+17) {
tmp = t_0;
} else if (x <= 3.2e+16) {
tmp = ((x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / ((((pow(x, 3.0) + ((x * 263.505074721) + (pow(x, 2.0) * 43.3400022514))) + 313.399215894) * x) + 47.066876606);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - 2.0d0) * ((((((((x * 4.16438922228d0) + 78.6994924154d0) * x) + 137.519416416d0) * x) + y) * x) + z)) / (((((((x + 43.3400022514d0) * x) + 263.505074721d0) * x) + 313.399215894d0) * x) + 47.066876606d0)
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((3655.1204654076414d0 * (1.0d0 / x)) + (x * 4.16438922228d0)) + (-((130977.50649958357d0 + -y) / (x ** 2.0d0)) - 110.1139242984811d0)
if (x <= (-1.15d+17)) then
tmp = t_0
else if (x <= 3.2d+16) then
tmp = ((x - 2.0d0) * ((((((((x * 4.16438922228d0) + 78.6994924154d0) * x) + 137.519416416d0) * x) + y) * x) + z)) / (((((x ** 3.0d0) + ((x * 263.505074721d0) + ((x ** 2.0d0) * 43.3400022514d0))) + 313.399215894d0) * x) + 47.066876606d0)
else
tmp = t_0
end if
code = tmp
end function
public static 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);
}
public static double code(double x, double y, double z) {
double t_0 = ((3655.1204654076414 * (1.0 / x)) + (x * 4.16438922228)) + (-((130977.50649958357 + -y) / Math.pow(x, 2.0)) - 110.1139242984811);
double tmp;
if (x <= -1.15e+17) {
tmp = t_0;
} else if (x <= 3.2e+16) {
tmp = ((x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / ((((Math.pow(x, 3.0) + ((x * 263.505074721) + (Math.pow(x, 2.0) * 43.3400022514))) + 313.399215894) * x) + 47.066876606);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, 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)
def code(x, y, z): t_0 = ((3655.1204654076414 * (1.0 / x)) + (x * 4.16438922228)) + (-((130977.50649958357 + -y) / math.pow(x, 2.0)) - 110.1139242984811) tmp = 0 if x <= -1.15e+17: tmp = t_0 elif x <= 3.2e+16: tmp = ((x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / ((((math.pow(x, 3.0) + ((x * 263.505074721) + (math.pow(x, 2.0) * 43.3400022514))) + 313.399215894) * x) + 47.066876606) 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(Float64(3655.1204654076414 * Float64(1.0 / x)) + Float64(x * 4.16438922228)) + Float64(Float64(-Float64(Float64(130977.50649958357 + Float64(-y)) / (x ^ 2.0))) - 110.1139242984811)) tmp = 0.0 if (x <= -1.15e+17) tmp = t_0; elseif (x <= 3.2e+16) tmp = 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((x ^ 3.0) + Float64(Float64(x * 263.505074721) + Float64((x ^ 2.0) * 43.3400022514))) + 313.399215894) * x) + 47.066876606)); else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = ((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); end
function tmp_2 = code(x, y, z) t_0 = ((3655.1204654076414 * (1.0 / x)) + (x * 4.16438922228)) + (-((130977.50649958357 + -y) / (x ^ 2.0)) - 110.1139242984811); tmp = 0.0; if (x <= -1.15e+17) tmp = t_0; elseif (x <= 3.2e+16) tmp = ((x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / (((((x ^ 3.0) + ((x * 263.505074721) + ((x ^ 2.0) * 43.3400022514))) + 313.399215894) * x) + 47.066876606); else tmp = t_0; end tmp_2 = 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[(N[(3655.1204654076414 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + N[(x * 4.16438922228), $MachinePrecision]), $MachinePrecision] + N[((-N[(N[(130977.50649958357 + (-y)), $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]) - 110.1139242984811), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.15e+17], t$95$0, If[LessEqual[x, 3.2e+16], 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[Power[x, 3.0], $MachinePrecision] + N[(N[(x * 263.505074721), $MachinePrecision] + N[(N[Power[x, 2.0], $MachinePrecision] * 43.3400022514), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 313.399215894), $MachinePrecision] * x), $MachinePrecision] + 47.066876606), $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 := \left(3655.1204654076414 \cdot \frac{1}{x} + x \cdot 4.16438922228\right) + \left(\left(-\frac{130977.50649958357 + \left(-y\right)}{{x}^{2}}\right) - 110.1139242984811\right)\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{+17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+16}:\\
\;\;\;\;\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({x}^{3} + \left(x \cdot 263.505074721 + {x}^{2} \cdot 43.3400022514\right)\right) + 313.399215894\right) \cdot x + 47.066876606}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Results
| Original | 26.6 |
|---|---|
| Target | 0.9 |
| Herbie | 1.5 |
if x < -1.15e17 or 3.2e16 < x Initial program 55.6
Taylor expanded in x around -inf 2.6
Simplified2.6
[Start]2.6 | \[ \left(-1 \cdot \frac{130977.50649958357 + -1 \cdot y}{{x}^{2}} + \left(4.16438922228 \cdot x + 3655.1204654076414 \cdot \frac{1}{x}\right)\right) - 110.1139242984811
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-107 [=>]2.6 | \[ \color{blue}{\left(4.16438922228 \cdot x + 3655.1204654076414 \cdot \frac{1}{x}\right) + \left(-1 \cdot \frac{130977.50649958357 + -1 \cdot y}{{x}^{2}} - 110.1139242984811\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]2.6 | \[ \color{blue}{\left(3655.1204654076414 \cdot \frac{1}{x} + 4.16438922228 \cdot x\right)} + \left(-1 \cdot \frac{130977.50649958357 + -1 \cdot y}{{x}^{2}} - 110.1139242984811\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]2.6 | \[ \left(3655.1204654076414 \cdot \frac{1}{x} + \color{blue}{x \cdot 4.16438922228}\right) + \left(-1 \cdot \frac{130977.50649958357 + -1 \cdot y}{{x}^{2}} - 110.1139242984811\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]2.6 | \[ \left(3655.1204654076414 \cdot \frac{1}{x} + x \cdot 4.16438922228\right) + \left(\color{blue}{\frac{130977.50649958357 + -1 \cdot y}{{x}^{2}} \cdot -1} - 110.1139242984811\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]2.6 | \[ \left(3655.1204654076414 \cdot \frac{1}{x} + x \cdot 4.16438922228\right) + \left(\color{blue}{\left(-\frac{130977.50649958357 + -1 \cdot y}{{x}^{2}}\right)} - 110.1139242984811\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]2.6 | \[ \left(3655.1204654076414 \cdot \frac{1}{x} + x \cdot 4.16438922228\right) + \left(\left(-\frac{130977.50649958357 + \color{blue}{y \cdot -1}}{{x}^{2}}\right) - 110.1139242984811\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]2.6 | \[ \left(3655.1204654076414 \cdot \frac{1}{x} + x \cdot 4.16438922228\right) + \left(\left(-\frac{130977.50649958357 + \color{blue}{\left(-y\right)}}{{x}^{2}}\right) - 110.1139242984811\right)
\] |
if -1.15e17 < x < 3.2e16Initial program 0.4
Taylor expanded in x around 0 0.4
Simplified0.4
[Start]0.4 | \[ \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(43.3400022514 \cdot {x}^{2} + \left(263.505074721 \cdot x + {x}^{3}\right)\right) + 313.399215894\right) \cdot x + 47.066876606}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.4 | \[ \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(\color{blue}{\left(263.505074721 \cdot x + \left(43.3400022514 \cdot {x}^{2} + {x}^{3}\right)\right)} + 313.399215894\right) \cdot x + 47.066876606}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.4 | \[ \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(263.505074721 \cdot x + \color{blue}{\left({x}^{3} + 43.3400022514 \cdot {x}^{2}\right)}\right) + 313.399215894\right) \cdot x + 47.066876606}
\] |
rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.4 | \[ \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(\color{blue}{\left({x}^{3} + \left(263.505074721 \cdot x + 43.3400022514 \cdot {x}^{2}\right)\right)} + 313.399215894\right) \cdot x + 47.066876606}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]0.4 | \[ \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({x}^{3} + \left(\color{blue}{x \cdot 263.505074721} + 43.3400022514 \cdot {x}^{2}\right)\right) + 313.399215894\right) \cdot x + 47.066876606}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.4 | \[ \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({x}^{3} + \left(x \cdot 263.505074721 + \color{blue}{{x}^{2} \cdot 43.3400022514}\right)\right) + 313.399215894\right) \cdot x + 47.066876606}
\] |
Final simplification1.5
| Alternative 1 | |
|---|---|
| Error | 1.5 |
| Cost | 7944 |
| Alternative 2 | |
|---|---|
| Error | 1.9 |
| Cost | 5064 |
| Alternative 3 | |
|---|---|
| Error | 2.1 |
| Cost | 2760 |
| Alternative 4 | |
|---|---|
| Error | 3.8 |
| Cost | 2636 |
| Alternative 5 | |
|---|---|
| Error | 2.1 |
| Cost | 2632 |
| Alternative 6 | |
|---|---|
| Error | 4.2 |
| Cost | 2248 |
| Alternative 7 | |
|---|---|
| Error | 4.1 |
| Cost | 2120 |
| Alternative 8 | |
|---|---|
| Error | 5.4 |
| Cost | 1736 |
| Alternative 9 | |
|---|---|
| Error | 5.1 |
| Cost | 1480 |
| Alternative 10 | |
|---|---|
| Error | 7.1 |
| Cost | 1352 |
| Alternative 11 | |
|---|---|
| Error | 7.2 |
| Cost | 968 |
| Alternative 12 | |
|---|---|
| Error | 15.4 |
| Cost | 844 |
| Alternative 13 | |
|---|---|
| Error | 7.2 |
| Cost | 840 |
| Alternative 14 | |
|---|---|
| Error | 15.5 |
| Cost | 588 |
| Alternative 15 | |
|---|---|
| Error | 15.5 |
| Cost | 456 |
| Alternative 16 | |
|---|---|
| Error | 41.7 |
| Cost | 192 |
herbie shell --seed 2023090
(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)))