| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 14336 |
\[\left(\left(x \cdot \log y - z \cdot y\right) + \left(\mathsf{fma}\left(-z, y, z \cdot y\right) + \left(z \cdot y\right) \cdot \left(y \cdot -0.5\right)\right)\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 z (log1p (- y)) (* x (log 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(z, log1p(-y), (x * log(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(z, log1p(Float64(-y)), Float64(x * log(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[(z * N[Log[1 + (-y)], $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(z, \mathsf{log1p}\left(-y\right), x \cdot \log y\right) - t
| Original | 9.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
Initial program 9.5
Simplified0.1
[Start]9.5 | \[ \left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\] |
|---|---|
+-commutative [=>]9.5 | \[ \color{blue}{\left(z \cdot \log \left(1 - y\right) + x \cdot \log y\right)} - t
\] |
fma-def [=>]9.5 | \[ \color{blue}{\mathsf{fma}\left(z, \log \left(1 - y\right), x \cdot \log y\right)} - t
\] |
sub-neg [=>]9.5 | \[ \mathsf{fma}\left(z, \log \color{blue}{\left(1 + \left(-y\right)\right)}, x \cdot \log y\right) - t
\] |
log1p-def [=>]0.1 | \[ \mathsf{fma}\left(z, \color{blue}{\mathsf{log1p}\left(-y\right)}, x \cdot \log y\right) - t
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 14336 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 13760 |
| Alternative 3 | |
|---|---|
| Error | 6.5 |
| Cost | 7314 |
| Alternative 4 | |
|---|---|
| Error | 6.5 |
| Cost | 7250 |
| Alternative 5 | |
|---|---|
| Error | 6.3 |
| Cost | 7113 |
| Alternative 6 | |
|---|---|
| Error | 0.5 |
| Cost | 6976 |
| Alternative 7 | |
|---|---|
| Error | 14.5 |
| Cost | 6857 |
| Alternative 8 | |
|---|---|
| Error | 27.2 |
| Cost | 704 |
| Alternative 9 | |
|---|---|
| Error | 32.9 |
| Cost | 520 |
| Alternative 10 | |
|---|---|
| Error | 27.4 |
| Cost | 384 |
| Alternative 11 | |
|---|---|
| Error | 36.7 |
| Cost | 128 |
herbie shell --seed 2023018
(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))