| Alternative 1 | |
|---|---|
| Error | 2.3 |
| Cost | 26756 |
(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 (if (<= b 8.5e-11) (/ (* (exp (+ (* (+ t -1.0) (log a)) (* y (log z)))) x) y) (/ (/ x (* a (exp b))) y)))
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 tmp;
if (b <= 8.5e-11) {
tmp = (exp((((t + -1.0) * log(a)) + (y * log(z)))) * x) / y;
} else {
tmp = (x / (a * exp(b))) / y;
}
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) :: tmp
if (b <= 8.5d-11) then
tmp = (exp((((t + (-1.0d0)) * log(a)) + (y * log(z)))) * x) / y
else
tmp = (x / (a * exp(b))) / y
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 tmp;
if (b <= 8.5e-11) {
tmp = (Math.exp((((t + -1.0) * Math.log(a)) + (y * Math.log(z)))) * x) / y;
} else {
tmp = (x / (a * Math.exp(b))) / y;
}
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): tmp = 0 if b <= 8.5e-11: tmp = (math.exp((((t + -1.0) * math.log(a)) + (y * math.log(z)))) * x) / y else: tmp = (x / (a * math.exp(b))) / y 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) tmp = 0.0 if (b <= 8.5e-11) tmp = Float64(Float64(exp(Float64(Float64(Float64(t + -1.0) * log(a)) + Float64(y * log(z)))) * x) / y); else tmp = Float64(Float64(x / Float64(a * exp(b))) / y); 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) tmp = 0.0; if (b <= 8.5e-11) tmp = (exp((((t + -1.0) * log(a)) + (y * log(z)))) * x) / y; else tmp = (x / (a * exp(b))) / y; 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_] := If[LessEqual[b, 8.5e-11], N[(N[(N[Exp[N[(N[(N[(t + -1.0), $MachinePrecision] * N[Log[a], $MachinePrecision]), $MachinePrecision] + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / N[(a * N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}
\begin{array}{l}
\mathbf{if}\;b \leq 8.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{e^{\left(t + -1\right) \cdot \log a + y \cdot \log z} \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{a \cdot e^{b}}}{y}\\
\end{array}
Results
| Original | 1.8 |
|---|---|
| Target | 11.4 |
| Herbie | 2.3 |
if b < 8.50000000000000037e-11Initial program 2.9
Taylor expanded in b around 0 3.1
Simplified3.1
[Start]3.1 | \[ \frac{e^{y \cdot \log z + \left(t - 1\right) \cdot \log a} \cdot x}{y}
\] |
|---|---|
exponential.json-simplify-1 [=>]11.5 | \[ \frac{\color{blue}{\left(e^{y \cdot \log z} \cdot e^{\left(t - 1\right) \cdot \log a}\right)} \cdot x}{y}
\] |
rational.json-simplify-4 [<=]11.5 | \[ \frac{\left(e^{y \cdot \log z} \cdot e^{\color{blue}{\left(t - 1\right) \cdot \log a + 0}}\right) \cdot x}{y}
\] |
rational.json-simplify-4 [<=]11.5 | \[ \frac{\left(e^{y \cdot \log z} \cdot e^{\color{blue}{\left(\left(t - 1\right) \cdot \log a + 0\right)} + 0}\right) \cdot x}{y}
\] |
rational.json-simplify-1 [<=]11.5 | \[ \frac{\left(e^{y \cdot \log z} \cdot e^{\color{blue}{\left(0 + \left(t - 1\right) \cdot \log a\right)} + 0}\right) \cdot x}{y}
\] |
exponential.json-simplify-1 [<=]3.1 | \[ \frac{\color{blue}{e^{y \cdot \log z + \left(\left(0 + \left(t - 1\right) \cdot \log a\right) + 0\right)}} \cdot x}{y}
\] |
rational.json-simplify-1 [=>]3.1 | \[ \frac{e^{y \cdot \log z + \color{blue}{\left(0 + \left(0 + \left(t - 1\right) \cdot \log a\right)\right)}} \cdot x}{y}
\] |
rational.json-simplify-1 [=>]3.1 | \[ \frac{e^{y \cdot \log z + \left(0 + \color{blue}{\left(\left(t - 1\right) \cdot \log a + 0\right)}\right)} \cdot x}{y}
\] |
rational.json-simplify-4 [=>]3.1 | \[ \frac{e^{y \cdot \log z + \left(0 + \color{blue}{\left(t - 1\right) \cdot \log a}\right)} \cdot x}{y}
\] |
rational.json-simplify-41 [<=]3.1 | \[ \frac{e^{\color{blue}{\left(t - 1\right) \cdot \log a + \left(y \cdot \log z + 0\right)}} \cdot x}{y}
\] |
rational.json-simplify-15 [<=]3.1 | \[ \frac{e^{\color{blue}{\left(t + -1\right)} \cdot \log a + \left(y \cdot \log z + 0\right)} \cdot x}{y}
\] |
rational.json-simplify-4 [=>]3.1 | \[ \frac{e^{\left(t + -1\right) \cdot \log a + \color{blue}{y \cdot \log z}} \cdot x}{y}
\] |
if 8.50000000000000037e-11 < b Initial program 0.1
Taylor expanded in t around 0 1.3
Simplified7.5
[Start]1.3 | \[ \frac{t \cdot \left(e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot \left(x \cdot \log a\right)\right) + e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot x}{y}
\] |
|---|---|
rational.json-simplify-2 [=>]1.3 | \[ \frac{t \cdot \color{blue}{\left(\left(x \cdot \log a\right) \cdot e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b}\right)} + e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot x}{y}
\] |
rational.json-simplify-2 [<=]1.3 | \[ \frac{t \cdot \left(\color{blue}{\left(\log a \cdot x\right)} \cdot e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b}\right) + e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot x}{y}
\] |
rational.json-simplify-43 [<=]7.5 | \[ \frac{\color{blue}{e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot \left(t \cdot \left(\log a \cdot x\right)\right)} + e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot x}{y}
\] |
rational.json-simplify-2 [<=]7.5 | \[ \frac{e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot \color{blue}{\left(\left(\log a \cdot x\right) \cdot t\right)} + e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot x}{y}
\] |
rational.json-simplify-2 [=>]7.5 | \[ \frac{e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot \left(\left(\log a \cdot x\right) \cdot t\right) + \color{blue}{x \cdot e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b}}}{y}
\] |
rational.json-simplify-47 [=>]7.5 | \[ \frac{\color{blue}{e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot \left(x + \left(\log a \cdot x\right) \cdot t\right)}}{y}
\] |
rational.json-simplify-2 [=>]7.5 | \[ \frac{e^{\left(y \cdot \log z + \color{blue}{\log a \cdot -1}\right) - b} \cdot \left(x + \left(\log a \cdot x\right) \cdot t\right)}{y}
\] |
rational.json-simplify-9 [=>]7.5 | \[ \frac{e^{\left(y \cdot \log z + \color{blue}{\left(-\log a\right)}\right) - b} \cdot \left(x + \left(\log a \cdot x\right) \cdot t\right)}{y}
\] |
Taylor expanded in y around 0 7.4
Simplified7.2
[Start]7.4 | \[ \frac{e^{-\left(b + \log a\right)} \cdot \left(t \cdot \left(x \cdot \log a\right) + x\right)}{y}
\] |
|---|---|
exponential.json-simplify-2 [=>]7.4 | \[ \frac{\color{blue}{\frac{1}{e^{b + \log a}}} \cdot \left(t \cdot \left(x \cdot \log a\right) + x\right)}{y}
\] |
rational.json-simplify-1 [=>]7.4 | \[ \frac{\frac{1}{e^{\color{blue}{\log a + b}}} \cdot \left(t \cdot \left(x \cdot \log a\right) + x\right)}{y}
\] |
exponential.json-simplify-1 [=>]7.4 | \[ \frac{\frac{1}{\color{blue}{e^{\log a} \cdot e^{b}}} \cdot \left(t \cdot \left(x \cdot \log a\right) + x\right)}{y}
\] |
exponential.json-simplify-7 [=>]7.4 | \[ \frac{\frac{1}{\color{blue}{a} \cdot e^{b}} \cdot \left(t \cdot \left(x \cdot \log a\right) + x\right)}{y}
\] |
rational.json-simplify-1 [=>]7.4 | \[ \frac{\frac{1}{a \cdot e^{b}} \cdot \color{blue}{\left(x + t \cdot \left(x \cdot \log a\right)\right)}}{y}
\] |
rational.json-simplify-43 [<=]7.2 | \[ \frac{\frac{1}{a \cdot e^{b}} \cdot \left(x + \color{blue}{\log a \cdot \left(t \cdot x\right)}\right)}{y}
\] |
Taylor expanded in t around 0 0.8
Final simplification2.3
| Alternative 1 | |
|---|---|
| Error | 2.3 |
| Cost | 26756 |
| Alternative 2 | |
|---|---|
| Error | 1.8 |
| Cost | 20160 |
| Alternative 3 | |
|---|---|
| Error | 10.2 |
| Cost | 13768 |
| Alternative 4 | |
|---|---|
| Error | 11.6 |
| Cost | 7564 |
| Alternative 5 | |
|---|---|
| Error | 9.9 |
| Cost | 7428 |
| Alternative 6 | |
|---|---|
| Error | 14.0 |
| Cost | 7308 |
| Alternative 7 | |
|---|---|
| Error | 14.0 |
| Cost | 7308 |
| Alternative 8 | |
|---|---|
| Error | 12.0 |
| Cost | 7308 |
| Alternative 9 | |
|---|---|
| Error | 16.4 |
| Cost | 7112 |
| Alternative 10 | |
|---|---|
| Error | 16.0 |
| Cost | 7048 |
| Alternative 11 | |
|---|---|
| Error | 16.6 |
| Cost | 6916 |
| Alternative 12 | |
|---|---|
| Error | 40.9 |
| Cost | 716 |
| Alternative 13 | |
|---|---|
| Error | 40.9 |
| Cost | 716 |
| Alternative 14 | |
|---|---|
| Error | 29.2 |
| Cost | 704 |
| Alternative 15 | |
|---|---|
| Error | 40.6 |
| Cost | 452 |
| Alternative 16 | |
|---|---|
| Error | 54.4 |
| Cost | 192 |
herbie shell --seed 2023077
(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))