| Alternative 1 | |
|---|---|
| Error | 6.7 |
| Cost | 7232 |
\[x + \frac{-1}{\frac{t}{y \cdot \mathsf{expm1}\left(z\right)} + t \cdot 0.5}
\]
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
(FPCore (x y z t) :precision binary64 (- x (/ (log1p (* y (expm1 z))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
double code(double x, double y, double z, double t) {
return x - (log1p((y * expm1(z))) / t);
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log1p((y * Math.expm1(z))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
def code(x, y, z, t): return x - (math.log1p((y * math.expm1(z))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function code(x, y, z, t) return Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)) end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}
Results
| Original | 25.1 |
|---|---|
| Target | 16.3 |
| Herbie | 1.1 |
Initial program 25.1
Simplified1.1
[Start]25.1 | \[ x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\] |
|---|---|
*-lft-identity [<=]25.1 | \[ \color{blue}{1 \cdot \left(x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)}
\] |
distribute-lft-out-- [<=]25.1 | \[ \color{blue}{1 \cdot x - 1 \cdot \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}}
\] |
*-lft-identity [=>]25.1 | \[ \color{blue}{x} - 1 \cdot \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\] |
*-commutative [<=]25.1 | \[ x - \color{blue}{\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \cdot 1}
\] |
*-rgt-identity [=>]25.1 | \[ x - \color{blue}{\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}}
\] |
Final simplification1.1
| Alternative 1 | |
|---|---|
| Error | 6.7 |
| Cost | 7232 |
| Alternative 2 | |
|---|---|
| Error | 6.6 |
| Cost | 7112 |
| Alternative 3 | |
|---|---|
| Error | 7.7 |
| Cost | 6980 |
| Alternative 4 | |
|---|---|
| Error | 10.3 |
| Cost | 1220 |
| Alternative 5 | |
|---|---|
| Error | 10.9 |
| Cost | 964 |
| Alternative 6 | |
|---|---|
| Error | 18.7 |
| Cost | 913 |
| Alternative 7 | |
|---|---|
| Error | 19.7 |
| Cost | 913 |
| Alternative 8 | |
|---|---|
| Error | 11.6 |
| Cost | 580 |
| Alternative 9 | |
|---|---|
| Error | 18.3 |
| Cost | 64 |
herbie shell --seed 2023039
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))