| Alternative 1 | |
|---|---|
| Error | 3.12% |
| Cost | 33408 |
\[\frac{x}{\mathsf{fma}\left(y, {\left(e^{2}\right)}^{\left(\mathsf{fma}\left(b - c, \frac{0.6666666666666666}{t} - \left(a + 0.8333333333333334\right), z \cdot \frac{\sqrt{t + a}}{t}\right)\right)}, x\right)}
\]
(FPCore (x y z t a b c)
:precision binary64
(/
x
(+
x
(*
y
(exp
(*
2.0
(-
(/ (* z (sqrt (+ t a))) t)
(* (- b c) (- (+ a (/ 5.0 6.0)) (/ 2.0 (* t 3.0)))))))))))(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (* (- b c) (+ (/ 2.0 (* t 3.0)) (- -0.8333333333333334 a))))
(t_2 (sqrt (+ t a))))
(if (<= (+ (/ (* z t_2) t) t_1) INFINITY)
(/ x (+ x (* y (pow (exp 2.0) (+ (/ z (/ t t_2)) t_1)))))
(/ x (+ x (* y (exp (* (- b c) -1.6666666666666667))))))))double code(double x, double y, double z, double t, double a, double b, double c) {
return x / (x + (y * exp((2.0 * (((z * sqrt((t + a))) / t) - ((b - c) * ((a + (5.0 / 6.0)) - (2.0 / (t * 3.0)))))))));
}
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (b - c) * ((2.0 / (t * 3.0)) + (-0.8333333333333334 - a));
double t_2 = sqrt((t + a));
double tmp;
if ((((z * t_2) / t) + t_1) <= ((double) INFINITY)) {
tmp = x / (x + (y * pow(exp(2.0), ((z / (t / t_2)) + t_1))));
} else {
tmp = x / (x + (y * exp(((b - c) * -1.6666666666666667))));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return x / (x + (y * Math.exp((2.0 * (((z * Math.sqrt((t + a))) / t) - ((b - c) * ((a + (5.0 / 6.0)) - (2.0 / (t * 3.0)))))))));
}
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (b - c) * ((2.0 / (t * 3.0)) + (-0.8333333333333334 - a));
double t_2 = Math.sqrt((t + a));
double tmp;
if ((((z * t_2) / t) + t_1) <= Double.POSITIVE_INFINITY) {
tmp = x / (x + (y * Math.pow(Math.exp(2.0), ((z / (t / t_2)) + t_1))));
} else {
tmp = x / (x + (y * Math.exp(((b - c) * -1.6666666666666667))));
}
return tmp;
}
def code(x, y, z, t, a, b, c): return x / (x + (y * math.exp((2.0 * (((z * math.sqrt((t + a))) / t) - ((b - c) * ((a + (5.0 / 6.0)) - (2.0 / (t * 3.0)))))))))
def code(x, y, z, t, a, b, c): t_1 = (b - c) * ((2.0 / (t * 3.0)) + (-0.8333333333333334 - a)) t_2 = math.sqrt((t + a)) tmp = 0 if (((z * t_2) / t) + t_1) <= math.inf: tmp = x / (x + (y * math.pow(math.exp(2.0), ((z / (t / t_2)) + t_1)))) else: tmp = x / (x + (y * math.exp(((b - c) * -1.6666666666666667)))) return tmp
function code(x, y, z, t, a, b, c) return Float64(x / Float64(x + Float64(y * exp(Float64(2.0 * Float64(Float64(Float64(z * sqrt(Float64(t + a))) / t) - Float64(Float64(b - c) * Float64(Float64(a + Float64(5.0 / 6.0)) - Float64(2.0 / Float64(t * 3.0)))))))))) end
function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(b - c) * Float64(Float64(2.0 / Float64(t * 3.0)) + Float64(-0.8333333333333334 - a))) t_2 = sqrt(Float64(t + a)) tmp = 0.0 if (Float64(Float64(Float64(z * t_2) / t) + t_1) <= Inf) tmp = Float64(x / Float64(x + Float64(y * (exp(2.0) ^ Float64(Float64(z / Float64(t / t_2)) + t_1))))); else tmp = Float64(x / Float64(x + Float64(y * exp(Float64(Float64(b - c) * -1.6666666666666667))))); end return tmp end
function tmp = code(x, y, z, t, a, b, c) tmp = x / (x + (y * exp((2.0 * (((z * sqrt((t + a))) / t) - ((b - c) * ((a + (5.0 / 6.0)) - (2.0 / (t * 3.0))))))))); end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = (b - c) * ((2.0 / (t * 3.0)) + (-0.8333333333333334 - a)); t_2 = sqrt((t + a)); tmp = 0.0; if ((((z * t_2) / t) + t_1) <= Inf) tmp = x / (x + (y * (exp(2.0) ^ ((z / (t / t_2)) + t_1)))); else tmp = x / (x + (y * exp(((b - c) * -1.6666666666666667)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(x / N[(x + N[(y * N[Exp[N[(2.0 * N[(N[(N[(z * N[Sqrt[N[(t + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] - N[(N[(b - c), $MachinePrecision] * N[(N[(a + N[(5.0 / 6.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / N[(t * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(b - c), $MachinePrecision] * N[(N[(2.0 / N[(t * 3.0), $MachinePrecision]), $MachinePrecision] + N[(-0.8333333333333334 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t + a), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(z * t$95$2), $MachinePrecision] / t), $MachinePrecision] + t$95$1), $MachinePrecision], Infinity], N[(x / N[(x + N[(y * N[Power[N[Exp[2.0], $MachinePrecision], N[(N[(z / N[(t / t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + N[(y * N[Exp[N[(N[(b - c), $MachinePrecision] * -1.6666666666666667), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x}{x + y \cdot e^{2 \cdot \left(\frac{z \cdot \sqrt{t + a}}{t} - \left(b - c\right) \cdot \left(\left(a + \frac{5}{6}\right) - \frac{2}{t \cdot 3}\right)\right)}}
\begin{array}{l}
t_1 := \left(b - c\right) \cdot \left(\frac{2}{t \cdot 3} + \left(-0.8333333333333334 - a\right)\right)\\
t_2 := \sqrt{t + a}\\
\mathbf{if}\;\frac{z \cdot t_2}{t} + t_1 \leq \infty:\\
\;\;\;\;\frac{x}{x + y \cdot {\left(e^{2}\right)}^{\left(\frac{z}{\frac{t}{t_2}} + t_1\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + y \cdot e^{\left(b - c\right) \cdot -1.6666666666666667}}\\
\end{array}
Results
| Original | 5.86% |
|---|---|
| Target | 4.43% |
| Herbie | 2.77% |
if (-.f64 (/.f64 (*.f64 z (sqrt.f64 (+.f64 t a))) t) (*.f64 (-.f64 b c) (-.f64 (+.f64 a (/.f64 5 6)) (/.f64 2 (*.f64 t 3))))) < +inf.0Initial program 1.08
Simplified0.9
[Start]1.08 | \[ \frac{x}{x + y \cdot e^{2 \cdot \left(\frac{z \cdot \sqrt{t + a}}{t} - \left(b - c\right) \cdot \left(\left(a + \frac{5}{6}\right) - \frac{2}{t \cdot 3}\right)\right)}}
\] |
|---|---|
exp-prod [=>]1.08 | \[ \frac{x}{x + y \cdot \color{blue}{{\left(e^{2}\right)}^{\left(\frac{z \cdot \sqrt{t + a}}{t} - \left(b - c\right) \cdot \left(\left(a + \frac{5}{6}\right) - \frac{2}{t \cdot 3}\right)\right)}}}
\] |
associate-/l* [=>]0.9 | \[ \frac{x}{x + y \cdot {\left(e^{2}\right)}^{\left(\color{blue}{\frac{z}{\frac{t}{\sqrt{t + a}}}} - \left(b - c\right) \cdot \left(\left(a + \frac{5}{6}\right) - \frac{2}{t \cdot 3}\right)\right)}}
\] |
metadata-eval [=>]0.9 | \[ \frac{x}{x + y \cdot {\left(e^{2}\right)}^{\left(\frac{z}{\frac{t}{\sqrt{t + a}}} - \left(b - c\right) \cdot \left(\left(a + \color{blue}{0.8333333333333334}\right) - \frac{2}{t \cdot 3}\right)\right)}}
\] |
if +inf.0 < (-.f64 (/.f64 (*.f64 z (sqrt.f64 (+.f64 t a))) t) (*.f64 (-.f64 b c) (-.f64 (+.f64 a (/.f64 5 6)) (/.f64 2 (*.f64 t 3))))) Initial program 100
Taylor expanded in t around inf 36.05
Simplified36.05
[Start]36.05 | \[ \frac{x}{x + y \cdot e^{2 \cdot \left(-1 \cdot \left(\left(b - c\right) \cdot \left(0.8333333333333334 + a\right)\right)\right)}}
\] |
|---|---|
mul-1-neg [=>]36.05 | \[ \frac{x}{x + y \cdot e^{2 \cdot \color{blue}{\left(-\left(b - c\right) \cdot \left(0.8333333333333334 + a\right)\right)}}}
\] |
distribute-rgt-neg-in [=>]36.05 | \[ \frac{x}{x + y \cdot e^{2 \cdot \color{blue}{\left(\left(b - c\right) \cdot \left(-\left(0.8333333333333334 + a\right)\right)\right)}}}
\] |
neg-sub0 [=>]36.05 | \[ \frac{x}{x + y \cdot e^{2 \cdot \left(\left(b - c\right) \cdot \color{blue}{\left(0 - \left(0.8333333333333334 + a\right)\right)}\right)}}
\] |
associate--r+ [=>]36.05 | \[ \frac{x}{x + y \cdot e^{2 \cdot \left(\left(b - c\right) \cdot \color{blue}{\left(\left(0 - 0.8333333333333334\right) - a\right)}\right)}}
\] |
metadata-eval [=>]36.05 | \[ \frac{x}{x + y \cdot e^{2 \cdot \left(\left(b - c\right) \cdot \left(\color{blue}{-0.8333333333333334} - a\right)\right)}}
\] |
Taylor expanded in a around 0 39.55
Final simplification2.77
| Alternative 1 | |
|---|---|
| Error | 3.12% |
| Cost | 33408 |
| Alternative 2 | |
|---|---|
| Error | 2.94% |
| Cost | 22468 |
| Alternative 3 | |
|---|---|
| Error | 20.17% |
| Cost | 14288 |
| Alternative 4 | |
|---|---|
| Error | 20.28% |
| Cost | 14160 |
| Alternative 5 | |
|---|---|
| Error | 46.96% |
| Cost | 8164 |
| Alternative 6 | |
|---|---|
| Error | 39.45% |
| Cost | 8161 |
| Alternative 7 | |
|---|---|
| Error | 48% |
| Cost | 8028 |
| Alternative 8 | |
|---|---|
| Error | 39.32% |
| Cost | 7757 |
| Alternative 9 | |
|---|---|
| Error | 19.66% |
| Cost | 7752 |
| Alternative 10 | |
|---|---|
| Error | 29.93% |
| Cost | 7628 |
| Alternative 11 | |
|---|---|
| Error | 21.78% |
| Cost | 7624 |
| Alternative 12 | |
|---|---|
| Error | 31.46% |
| Cost | 7369 |
| Alternative 13 | |
|---|---|
| Error | 50.84% |
| Cost | 1612 |
| Alternative 14 | |
|---|---|
| Error | 47.21% |
| Cost | 1608 |
| Alternative 15 | |
|---|---|
| Error | 50.97% |
| Cost | 1232 |
| Alternative 16 | |
|---|---|
| Error | 51.28% |
| Cost | 1100 |
| Alternative 17 | |
|---|---|
| Error | 49.47% |
| Cost | 1096 |
| Alternative 18 | |
|---|---|
| Error | 49.59% |
| Cost | 968 |
| Alternative 19 | |
|---|---|
| Error | 49.57% |
| Cost | 840 |
| Alternative 20 | |
|---|---|
| Error | 49.1% |
| Cost | 64 |
herbie shell --seed 2023089
(FPCore (x y z t a b c)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, I"
:precision binary64
:herbie-target
(if (< t -2.118326644891581e-50) (/ x (+ x (* y (exp (* 2.0 (- (+ (* a c) (* 0.8333333333333334 c)) (* a b))))))) (if (< t 5.196588770651547e-123) (/ x (+ x (* y (exp (* 2.0 (/ (- (* (* z (sqrt (+ t a))) (* (* 3.0 t) (- a (/ 5.0 6.0)))) (* (- (* (+ (/ 5.0 6.0) a) (* 3.0 t)) 2.0) (* (- a (/ 5.0 6.0)) (* (- b c) t)))) (* (* (* t t) 3.0) (- a (/ 5.0 6.0))))))))) (/ x (+ x (* y (exp (* 2.0 (- (/ (* z (sqrt (+ t a))) t) (* (- b c) (- (+ a (/ 5.0 6.0)) (/ 2.0 (* t 3.0))))))))))))
(/ x (+ x (* y (exp (* 2.0 (- (/ (* z (sqrt (+ t a))) t) (* (- b c) (- (+ a (/ 5.0 6.0)) (/ 2.0 (* t 3.0)))))))))))