| Alternative 1 | |
|---|---|
| Error | 3.7 |
| Cost | 40396 |
(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 (* (- t 1.0) (log a)))
(t_2 (* x (* (exp (- (* y (log z)) b)) (/ 1.0 (* a y))))))
(if (<= t_1 -685.0)
(* (* (pow a (- t 1.0)) (/ 1.0 y)) x)
(if (<= t_1 20.0)
t_2
(if (<= t_1 690.0)
(/ (* x (* (pow z y) (/ (pow a (+ t -1.0)) (exp b)))) y)
t_2)))))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 = (t - 1.0) * log(a);
double t_2 = x * (exp(((y * log(z)) - b)) * (1.0 / (a * y)));
double tmp;
if (t_1 <= -685.0) {
tmp = (pow(a, (t - 1.0)) * (1.0 / y)) * x;
} else if (t_1 <= 20.0) {
tmp = t_2;
} else if (t_1 <= 690.0) {
tmp = (x * (pow(z, y) * (pow(a, (t + -1.0)) / exp(b)))) / y;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = (t - 1.0d0) * log(a)
t_2 = x * (exp(((y * log(z)) - b)) * (1.0d0 / (a * y)))
if (t_1 <= (-685.0d0)) then
tmp = ((a ** (t - 1.0d0)) * (1.0d0 / y)) * x
else if (t_1 <= 20.0d0) then
tmp = t_2
else if (t_1 <= 690.0d0) then
tmp = (x * ((z ** y) * ((a ** (t + (-1.0d0))) / exp(b)))) / y
else
tmp = t_2
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 = (t - 1.0) * Math.log(a);
double t_2 = x * (Math.exp(((y * Math.log(z)) - b)) * (1.0 / (a * y)));
double tmp;
if (t_1 <= -685.0) {
tmp = (Math.pow(a, (t - 1.0)) * (1.0 / y)) * x;
} else if (t_1 <= 20.0) {
tmp = t_2;
} else if (t_1 <= 690.0) {
tmp = (x * (Math.pow(z, y) * (Math.pow(a, (t + -1.0)) / Math.exp(b)))) / y;
} else {
tmp = t_2;
}
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 = (t - 1.0) * math.log(a) t_2 = x * (math.exp(((y * math.log(z)) - b)) * (1.0 / (a * y))) tmp = 0 if t_1 <= -685.0: tmp = (math.pow(a, (t - 1.0)) * (1.0 / y)) * x elif t_1 <= 20.0: tmp = t_2 elif t_1 <= 690.0: tmp = (x * (math.pow(z, y) * (math.pow(a, (t + -1.0)) / math.exp(b)))) / y else: tmp = t_2 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(t - 1.0) * log(a)) t_2 = Float64(x * Float64(exp(Float64(Float64(y * log(z)) - b)) * Float64(1.0 / Float64(a * y)))) tmp = 0.0 if (t_1 <= -685.0) tmp = Float64(Float64((a ^ Float64(t - 1.0)) * Float64(1.0 / y)) * x); elseif (t_1 <= 20.0) tmp = t_2; elseif (t_1 <= 690.0) tmp = Float64(Float64(x * Float64((z ^ y) * Float64((a ^ Float64(t + -1.0)) / exp(b)))) / y); else tmp = t_2; 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 = (t - 1.0) * log(a); t_2 = x * (exp(((y * log(z)) - b)) * (1.0 / (a * y))); tmp = 0.0; if (t_1 <= -685.0) tmp = ((a ^ (t - 1.0)) * (1.0 / y)) * x; elseif (t_1 <= 20.0) tmp = t_2; elseif (t_1 <= 690.0) tmp = (x * ((z ^ y) * ((a ^ (t + -1.0)) / exp(b)))) / y; else tmp = t_2; 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[(t - 1.0), $MachinePrecision] * N[Log[a], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[Exp[N[(N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(a * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -685.0], N[(N[(N[Power[a, N[(t - 1.0), $MachinePrecision]], $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$1, 20.0], t$95$2, If[LessEqual[t$95$1, 690.0], N[(N[(x * N[(N[Power[z, y], $MachinePrecision] * N[(N[Power[a, N[(t + -1.0), $MachinePrecision]], $MachinePrecision] / N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], t$95$2]]]]]
\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}
\begin{array}{l}
t_1 := \left(t - 1\right) \cdot \log a\\
t_2 := x \cdot \left(e^{y \cdot \log z - b} \cdot \frac{1}{a \cdot y}\right)\\
\mathbf{if}\;t_1 \leq -685:\\
\;\;\;\;\left({a}^{\left(t - 1\right)} \cdot \frac{1}{y}\right) \cdot x\\
\mathbf{elif}\;t_1 \leq 20:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 690:\\
\;\;\;\;\frac{x \cdot \left({z}^{y} \cdot \frac{{a}^{\left(t + -1\right)}}{e^{b}}\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
Results
| Original | 2.0 |
|---|---|
| Target | 11.0 |
| Herbie | 2.7 |
if (*.f64 (-.f64 t 1) (log.f64 a)) < -685Initial program 0.3
Applied egg-rr17.7
Taylor expanded in b around 0 10.1
Taylor expanded in y around 0 0.4
if -685 < (*.f64 (-.f64 t 1) (log.f64 a)) < 20 or 690 < (*.f64 (-.f64 t 1) (log.f64 a)) Initial program 4.1
Taylor expanded in t around 0 4.4
Simplified2.0
[Start]4.4 | \[ \frac{e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b} \cdot x}{y}
\] |
|---|---|
rational.json-simplify-49 [=>]2.0 | \[ \color{blue}{x \cdot \frac{e^{\left(y \cdot \log z + -1 \cdot \log a\right) - b}}{y}}
\] |
rational.json-simplify-48 [=>]2.0 | \[ x \cdot \frac{e^{\color{blue}{-1 \cdot \log a + \left(y \cdot \log z - b\right)}}}{y}
\] |
exponential.json-simplify-1 [=>]2.0 | \[ x \cdot \frac{\color{blue}{e^{-1 \cdot \log a} \cdot e^{y \cdot \log z - b}}}{y}
\] |
rational.json-simplify-49 [=>]3.3 | \[ x \cdot \color{blue}{\left(e^{y \cdot \log z - b} \cdot \frac{e^{-1 \cdot \log a}}{y}\right)}
\] |
rational.json-simplify-2 [=>]3.3 | \[ x \cdot \left(e^{y \cdot \log z - b} \cdot \frac{e^{\color{blue}{\log a \cdot -1}}}{y}\right)
\] |
rational.json-simplify-9 [=>]3.3 | \[ x \cdot \left(e^{y \cdot \log z - b} \cdot \frac{e^{\color{blue}{-\log a}}}{y}\right)
\] |
exponential.json-simplify-2 [=>]3.3 | \[ x \cdot \left(e^{y \cdot \log z - b} \cdot \frac{\color{blue}{\frac{1}{e^{\log a}}}}{y}\right)
\] |
rational.json-simplify-47 [=>]3.3 | \[ x \cdot \left(e^{y \cdot \log z - b} \cdot \color{blue}{\frac{1}{e^{\log a} \cdot y}}\right)
\] |
exponential.json-simplify-7 [=>]2.0 | \[ x \cdot \left(e^{y \cdot \log z - b} \cdot \frac{1}{\color{blue}{a} \cdot y}\right)
\] |
if 20 < (*.f64 (-.f64 t 1) (log.f64 a)) < 690Initial program 1.4
Applied egg-rr7.7
Simplified7.7
[Start]7.7 | \[ \frac{x \cdot \left({a}^{\left(t + -1\right)} \cdot \left({z}^{y} \cdot e^{-b}\right) + 0\right)}{y}
\] |
|---|---|
rational.json-simplify-4 [=>]7.7 | \[ \frac{x \cdot \color{blue}{\left({a}^{\left(t + -1\right)} \cdot \left({z}^{y} \cdot e^{-b}\right)\right)}}{y}
\] |
rational.json-simplify-43 [=>]7.7 | \[ \frac{x \cdot \color{blue}{\left({z}^{y} \cdot \left(e^{-b} \cdot {a}^{\left(t + -1\right)}\right)\right)}}{y}
\] |
exponential.json-simplify-2 [=>]7.7 | \[ \frac{x \cdot \left({z}^{y} \cdot \left(\color{blue}{\frac{1}{e^{b}}} \cdot {a}^{\left(t + -1\right)}\right)\right)}{y}
\] |
rational.json-simplify-7 [<=]7.7 | \[ \frac{x \cdot \left({z}^{y} \cdot \left(\frac{1}{e^{b}} \cdot \color{blue}{\frac{{a}^{\left(t + -1\right)}}{1}}\right)\right)}{y}
\] |
rational.json-simplify-55 [=>]7.7 | \[ \frac{x \cdot \left({z}^{y} \cdot \color{blue}{\frac{\frac{{a}^{\left(t + -1\right)}}{1}}{\frac{e^{b}}{1}}}\right)}{y}
\] |
rational.json-simplify-7 [=>]7.7 | \[ \frac{x \cdot \left({z}^{y} \cdot \frac{\color{blue}{{a}^{\left(t + -1\right)}}}{\frac{e^{b}}{1}}\right)}{y}
\] |
rational.json-simplify-7 [=>]7.7 | \[ \frac{x \cdot \left({z}^{y} \cdot \frac{{a}^{\left(t + -1\right)}}{\color{blue}{e^{b}}}\right)}{y}
\] |
Final simplification2.7
| Alternative 1 | |
|---|---|
| Error | 3.7 |
| Cost | 40396 |
| Alternative 2 | |
|---|---|
| Error | 4.9 |
| Cost | 40268 |
| Alternative 3 | |
|---|---|
| Error | 4.7 |
| Cost | 33996 |
| Alternative 4 | |
|---|---|
| Error | 5.8 |
| Cost | 33868 |
| Alternative 5 | |
|---|---|
| Error | 2.1 |
| Cost | 20160 |
| Alternative 6 | |
|---|---|
| Error | 8.3 |
| Cost | 13768 |
| Alternative 7 | |
|---|---|
| Error | 11.1 |
| Cost | 13704 |
| Alternative 8 | |
|---|---|
| Error | 10.9 |
| Cost | 7572 |
| Alternative 9 | |
|---|---|
| Error | 10.9 |
| Cost | 7572 |
| Alternative 10 | |
|---|---|
| Error | 24.5 |
| Cost | 7376 |
| Alternative 11 | |
|---|---|
| Error | 10.6 |
| Cost | 7044 |
| Alternative 12 | |
|---|---|
| Error | 25.8 |
| Cost | 6984 |
| Alternative 13 | |
|---|---|
| Error | 22.5 |
| Cost | 6984 |
| Alternative 14 | |
|---|---|
| Error | 41.1 |
| Cost | 712 |
| Alternative 15 | |
|---|---|
| Error | 38.9 |
| Cost | 712 |
| Alternative 16 | |
|---|---|
| Error | 35.8 |
| Cost | 708 |
| Alternative 17 | |
|---|---|
| Error | 41.2 |
| Cost | 584 |
| Alternative 18 | |
|---|---|
| Error | 41.1 |
| Cost | 584 |
| Alternative 19 | |
|---|---|
| Error | 42.3 |
| Cost | 320 |
| Alternative 20 | |
|---|---|
| Error | 54.8 |
| Cost | 192 |
herbie shell --seed 2023074
(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))