| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 19968 |
\[\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \log y \cdot \left(-1 + x\right)\right) - t
\]
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))
(FPCore (x y z t) :precision binary64 (fma (+ z -1.0) (log1p (- y)) (fma (+ -1.0 x) (log y) (- t))))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
}
double code(double x, double y, double z, double t) {
return fma((z + -1.0), log1p(-y), fma((-1.0 + x), log(y), -t));
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) end
function code(x, y, z, t) return fma(Float64(z + -1.0), log1p(Float64(-y)), fma(Float64(-1.0 + x), log(y), Float64(-t))) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(z + -1.0), $MachinePrecision] * N[Log[1 + (-y)], $MachinePrecision] + N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \mathsf{fma}\left(-1 + x, \log y, -t\right)\right)
Initial program 6.8
Simplified0.1
[Start]6.8 | \[ \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\] |
|---|---|
+-commutative [=>]6.8 | \[ \color{blue}{\left(\left(z - 1\right) \cdot \log \left(1 - y\right) + \left(x - 1\right) \cdot \log y\right)} - t
\] |
associate--l+ [=>]6.8 | \[ \color{blue}{\left(z - 1\right) \cdot \log \left(1 - y\right) + \left(\left(x - 1\right) \cdot \log y - t\right)}
\] |
fma-def [=>]6.8 | \[ \color{blue}{\mathsf{fma}\left(z - 1, \log \left(1 - y\right), \left(x - 1\right) \cdot \log y - t\right)}
\] |
sub-neg [=>]6.8 | \[ \mathsf{fma}\left(\color{blue}{z + \left(-1\right)}, \log \left(1 - y\right), \left(x - 1\right) \cdot \log y - t\right)
\] |
metadata-eval [=>]6.8 | \[ \mathsf{fma}\left(z + \color{blue}{-1}, \log \left(1 - y\right), \left(x - 1\right) \cdot \log y - t\right)
\] |
sub-neg [=>]6.8 | \[ \mathsf{fma}\left(z + -1, \log \color{blue}{\left(1 + \left(-y\right)\right)}, \left(x - 1\right) \cdot \log y - t\right)
\] |
log1p-def [=>]0.1 | \[ \mathsf{fma}\left(z + -1, \color{blue}{\mathsf{log1p}\left(-y\right)}, \left(x - 1\right) \cdot \log y - t\right)
\] |
fma-neg [=>]0.1 | \[ \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \color{blue}{\mathsf{fma}\left(x - 1, \log y, -t\right)}\right)
\] |
sub-neg [=>]0.1 | \[ \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \mathsf{fma}\left(\color{blue}{x + \left(-1\right)}, \log y, -t\right)\right)
\] |
metadata-eval [=>]0.1 | \[ \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \mathsf{fma}\left(x + \color{blue}{-1}, \log y, -t\right)\right)
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 19968 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 13824 |
| Alternative 3 | |
|---|---|
| Error | 0.3 |
| Cost | 7616 |
| Alternative 4 | |
|---|---|
| Error | 3.0 |
| Cost | 7497 |
| Alternative 5 | |
|---|---|
| Error | 7.8 |
| Cost | 7496 |
| Alternative 6 | |
|---|---|
| Error | 0.5 |
| Cost | 7360 |
| Alternative 7 | |
|---|---|
| Error | 0.5 |
| Cost | 7232 |
| Alternative 8 | |
|---|---|
| Error | 27.8 |
| Cost | 7120 |
| Alternative 9 | |
|---|---|
| Error | 15.3 |
| Cost | 7112 |
| Alternative 10 | |
|---|---|
| Error | 15.3 |
| Cost | 6984 |
| Alternative 11 | |
|---|---|
| Error | 15.5 |
| Cost | 6921 |
| Alternative 12 | |
|---|---|
| Error | 7.5 |
| Cost | 6848 |
| Alternative 13 | |
|---|---|
| Error | 36.1 |
| Cost | 584 |
| Alternative 14 | |
|---|---|
| Error | 36.3 |
| Cost | 520 |
| Alternative 15 | |
|---|---|
| Error | 40.9 |
| Cost | 128 |
| Alternative 16 | |
|---|---|
| Error | 62.1 |
| Cost | 64 |
herbie shell --seed 2023016
(FPCore (x y z t)
:name "Statistics.Distribution.Beta:$cdensity from math-functions-0.1.5.2"
:precision binary64
(- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))