| Alternative 1 | |
|---|---|
| Error | 0.2% |
| Cost | 13440 |
\[\left(z \cdot \mathsf{log1p}\left(-y\right) + x \cdot \log y\right) - t
\]
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
(FPCore (x y z t) :precision binary64 (- (fma x (log y) (* z (log1p (- y)))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (z * log((1.0 - y)))) - t;
}
double code(double x, double y, double z, double t) {
return fma(x, log(y), (z * log1p(-y))) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t) end
function code(x, y, z, t) return Float64(fma(x, log(y), Float64(z * log1p(Float64(-y)))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(x * N[Log[y], $MachinePrecision] + N[(z * N[Log[1 + (-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right) - t
| Original | 14.52% |
|---|---|
| Target | 0.47% |
| Herbie | 0.2% |
Initial program 14.52
Simplified0.2
[Start]14.52 | \[ \left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\] |
|---|---|
cancel-sign-sub [<=]14.52 | \[ \color{blue}{\left(x \cdot \log y - \left(-z\right) \cdot \log \left(1 - y\right)\right)} - t
\] |
distribute-lft-neg-in [<=]14.52 | \[ \left(x \cdot \log y - \color{blue}{\left(-z \cdot \log \left(1 - y\right)\right)}\right) - t
\] |
fma-neg [=>]14.52 | \[ \color{blue}{\mathsf{fma}\left(x, \log y, -\left(-z \cdot \log \left(1 - y\right)\right)\right)} - t
\] |
remove-double-neg [=>]14.52 | \[ \mathsf{fma}\left(x, \log y, \color{blue}{z \cdot \log \left(1 - y\right)}\right) - t
\] |
sub-neg [=>]14.52 | \[ \mathsf{fma}\left(x, \log y, z \cdot \log \color{blue}{\left(1 + \left(-y\right)\right)}\right) - t
\] |
log1p-def [=>]0.2 | \[ \mathsf{fma}\left(x, \log y, z \cdot \color{blue}{\mathsf{log1p}\left(-y\right)}\right) - t
\] |
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.2% |
| Cost | 13440 |
| Alternative 2 | |
|---|---|
| Error | 0.94% |
| Cost | 7360 |
| Alternative 3 | |
|---|---|
| Error | 0.58% |
| Cost | 7360 |
| Alternative 4 | |
|---|---|
| Error | 11.75% |
| Cost | 7108 |
| Alternative 5 | |
|---|---|
| Error | 11.73% |
| Cost | 7049 |
| Alternative 6 | |
|---|---|
| Error | 11.93% |
| Cost | 6985 |
| Alternative 7 | |
|---|---|
| Error | 0.94% |
| Cost | 6976 |
| Alternative 8 | |
|---|---|
| Error | 22.24% |
| Cost | 6857 |
| Alternative 9 | |
|---|---|
| Error | 52.16% |
| Cost | 520 |
| Alternative 10 | |
|---|---|
| Error | 43.8% |
| Cost | 384 |
| Alternative 11 | |
|---|---|
| Error | 58.06% |
| Cost | 128 |
herbie shell --seed 2023088
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(- (* (- z) (+ (+ (* 0.5 (* y y)) y) (* (/ 0.3333333333333333 (* 1.0 (* 1.0 1.0))) (* y (* y y))))) (- t (* x (log y))))
(- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))