| Alternative 1 | |
|---|---|
| Error | 13.4 |
| Cost | 7044 |
\[\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{-19}:\\
\;\;\;\;\frac{x}{y \cdot \frac{a}{{z}^{y}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(a \cdot e^{b}\right)}\\
\end{array}
\]
(FPCore (x y z t a b) :precision binary64 (/ (* x (exp (- (+ (* y (log z)) (* (- t 1.0) (log a))) b))) y))
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (/ (/ (pow a t) a) y) x)))
(if (<= b 6.5e-252)
t_1
(if (<= b 2.7e-158)
(/ x (* y (/ a (pow z y))))
(if (<= b 2.4e-8) t_1 (/ x (* y (* a (exp b)))))))))double code(double x, double y, double z, double t, double a, double b) {
return (x * exp((((y * log(z)) + ((t - 1.0) * log(a))) - b))) / y;
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((pow(a, t) / a) / y) * x;
double tmp;
if (b <= 6.5e-252) {
tmp = t_1;
} else if (b <= 2.7e-158) {
tmp = x / (y * (a / pow(z, y)));
} else if (b <= 2.4e-8) {
tmp = t_1;
} else {
tmp = x / (y * (a * exp(b)));
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (x * exp((((y * log(z)) + ((t - 1.0d0) * log(a))) - b))) / y
end function
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = (((a ** t) / a) / y) * x
if (b <= 6.5d-252) then
tmp = t_1
else if (b <= 2.7d-158) then
tmp = x / (y * (a / (z ** y)))
else if (b <= 2.4d-8) then
tmp = t_1
else
tmp = x / (y * (a * exp(b)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (x * Math.exp((((y * Math.log(z)) + ((t - 1.0) * Math.log(a))) - b))) / y;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((Math.pow(a, t) / a) / y) * x;
double tmp;
if (b <= 6.5e-252) {
tmp = t_1;
} else if (b <= 2.7e-158) {
tmp = x / (y * (a / Math.pow(z, y)));
} else if (b <= 2.4e-8) {
tmp = t_1;
} else {
tmp = x / (y * (a * Math.exp(b)));
}
return tmp;
}
def code(x, y, z, t, a, b): return (x * math.exp((((y * math.log(z)) + ((t - 1.0) * math.log(a))) - b))) / y
def code(x, y, z, t, a, b): t_1 = ((math.pow(a, t) / a) / y) * x tmp = 0 if b <= 6.5e-252: tmp = t_1 elif b <= 2.7e-158: tmp = x / (y * (a / math.pow(z, y))) elif b <= 2.4e-8: tmp = t_1 else: tmp = x / (y * (a * math.exp(b))) return tmp
function code(x, y, z, t, a, b) return Float64(Float64(x * exp(Float64(Float64(Float64(y * log(z)) + Float64(Float64(t - 1.0) * log(a))) - b))) / y) end
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64((a ^ t) / a) / y) * x) tmp = 0.0 if (b <= 6.5e-252) tmp = t_1; elseif (b <= 2.7e-158) tmp = Float64(x / Float64(y * Float64(a / (z ^ y)))); elseif (b <= 2.4e-8) tmp = t_1; else tmp = Float64(x / Float64(y * Float64(a * exp(b)))); end return tmp end
function tmp = code(x, y, z, t, a, b) tmp = (x * exp((((y * log(z)) + ((t - 1.0) * log(a))) - b))) / y; end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (((a ^ t) / a) / y) * x; tmp = 0.0; if (b <= 6.5e-252) tmp = t_1; elseif (b <= 2.7e-158) tmp = x / (y * (a / (z ^ y))); elseif (b <= 2.4e-8) tmp = t_1; else tmp = x / (y * (a * exp(b))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * N[Exp[N[(N[(N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision] + N[(N[(t - 1.0), $MachinePrecision] * N[Log[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[Power[a, t], $MachinePrecision] / a), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[b, 6.5e-252], t$95$1, If[LessEqual[b, 2.7e-158], N[(x / N[(y * N[(a / N[Power[z, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-8], t$95$1, N[(x / N[(y * N[(a * N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}
\begin{array}{l}
t_1 := \frac{\frac{{a}^{t}}{a}}{y} \cdot x\\
\mathbf{if}\;b \leq 6.5 \cdot 10^{-252}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{-158}:\\
\;\;\;\;\frac{x}{y \cdot \frac{a}{{z}^{y}}}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(a \cdot e^{b}\right)}\\
\end{array}
Results
| Original | 2.0 |
|---|---|
| Target | 11.1 |
| Herbie | 10.9 |
if b < 6.4999999999999998e-252 or 2.6999999999999998e-158 < b < 2.39999999999999998e-8Initial program 3.2
Taylor expanded in y around 0 19.7
Simplified24.6
Taylor expanded in b around 0 17.3
Simplified17.3
Applied egg-rr16.4
if 6.4999999999999998e-252 < b < 2.6999999999999998e-158Initial program 3.6
Simplified12.2
Taylor expanded in t around 0 21.7
Taylor expanded in b around 0 21.7
Taylor expanded in z around inf 21.7
Simplified21.8
if 2.39999999999999998e-8 < b Initial program 0.1
Simplified25.2
Taylor expanded in t around 0 10.0
Taylor expanded in y around 0 0.7
Final simplification10.9
| Alternative 1 | |
|---|---|
| Error | 13.4 |
| Cost | 7044 |
| Alternative 2 | |
|---|---|
| Error | 17.2 |
| Cost | 6980 |
| Alternative 3 | |
|---|---|
| Error | 35.4 |
| Cost | 844 |
| Alternative 4 | |
|---|---|
| Error | 28.7 |
| Cost | 844 |
| Alternative 5 | |
|---|---|
| Error | 36.6 |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Error | 35.5 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 29.5 |
| Cost | 708 |
| Alternative 8 | |
|---|---|
| Error | 39.7 |
| Cost | 584 |
| Alternative 9 | |
|---|---|
| Error | 37.9 |
| Cost | 452 |
| Alternative 10 | |
|---|---|
| Error | 41.3 |
| Cost | 320 |

herbie shell --seed 2022228
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:incompleteBetaWorker from math-functions-0.1.5.2, A"
:precision binary64
:herbie-target
(if (< t -0.8845848504127471) (/ (* x (/ (pow a (- t 1.0)) y)) (- (+ b 1.0) (* y (log z)))) (if (< t 852031.2288374073) (/ (* (/ x y) (pow a (- t 1.0))) (exp (- b (* (log z) y)))) (/ (* x (/ (pow a (- t 1.0)) y)) (- (+ b 1.0) (* y (log z))))))
(/ (* x (exp (- (+ (* y (log z)) (* (- t 1.0) (log a))) b))) y))