?

Average Error: 7.1 → 0.1
Time: 14.3s
Precision: binary64
Cost: 19968

?

\[\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), \log y \cdot \left(x + -1\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)) (* (log y) (+ x -1.0))) 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), (log(y) * (x + -1.0))) - 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 Float64(fma(Float64(z + -1.0), log1p(Float64(-y)), Float64(log(y) * Float64(x + -1.0))) - 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[(N[(z + -1.0), $MachinePrecision] * N[Log[1 + (-y)], $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $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), \log y \cdot \left(x + -1\right)\right) - t

Error?

Derivation?

  1. Initial program 7.1

    \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(z - 1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y\right) - t} \]
    Proof

    [Start]7.1

    \[ \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]

    +-commutative [=>]7.1

    \[ \color{blue}{\left(\left(z - 1\right) \cdot \log \left(1 - y\right) + \left(x - 1\right) \cdot \log y\right)} - t \]

    fma-def [=>]7.1

    \[ \color{blue}{\mathsf{fma}\left(z - 1, \log \left(1 - y\right), \left(x - 1\right) \cdot \log y\right)} - t \]

    sub-neg [=>]7.1

    \[ \mathsf{fma}\left(z - 1, \log \color{blue}{\left(1 + \left(-y\right)\right)}, \left(x - 1\right) \cdot \log y\right) - t \]

    log1p-def [=>]0.1

    \[ \mathsf{fma}\left(z - 1, \color{blue}{\mathsf{log1p}\left(-y\right)}, \left(x - 1\right) \cdot \log y\right) - t \]

    remove-double-neg [<=]0.1

    \[ \mathsf{fma}\left(z - 1, \mathsf{log1p}\left(-y\right), \color{blue}{\left(-\left(-\left(x - 1\right)\right)\right)} \cdot \log y\right) - t \]

    remove-double-neg [=>]0.1

    \[ \mathsf{fma}\left(z - 1, \mathsf{log1p}\left(-y\right), \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]

    sub-neg [=>]0.1

    \[ \mathsf{fma}\left(z - 1, \mathsf{log1p}\left(-y\right), \color{blue}{\left(x + \left(-1\right)\right)} \cdot \log y\right) - t \]

    metadata-eval [=>]0.1

    \[ \mathsf{fma}\left(z - 1, \mathsf{log1p}\left(-y\right), \left(x + \color{blue}{-1}\right) \cdot \log y\right) - t \]
  3. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \log y \cdot \left(x + -1\right)\right) - t \]

Alternatives

Alternative 1
Error0.1
Cost19968
\[\mathsf{fma}\left(x + -1, \log y, \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right)\right) - t \]
Alternative 2
Error0.1
Cost13696
\[\left(\left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) + \log y \cdot \left(x + -1\right)\right) - t \]
Alternative 3
Error0.3
Cost7616
\[\left(\log y \cdot \left(x + -1\right) + \left(z + -1\right) \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right)\right) - t \]
Alternative 4
Error1.5
Cost7497
\[\begin{array}{l} \mathbf{if}\;x + -1 \leq -20000000 \lor \neg \left(x + -1 \leq -1\right):\\ \;\;\;\;\left(x \cdot \log y - z \cdot y\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(-\left(\log y + z \cdot y\right)\right) - t\\ \end{array} \]
Alternative 5
Error0.4
Cost7488
\[\left(\log y \cdot \left(x + -1\right) + \frac{z + -1}{0.5 - \frac{1}{y}}\right) - t \]
Alternative 6
Error3.6
Cost7432
\[\begin{array}{l} \mathbf{if}\;x + -1 \leq -2 \cdot 10^{+31}:\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{elif}\;x + -1 \leq 3 \cdot 10^{+30}:\\ \;\;\;\;\left(-\left(\log y + z \cdot y\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot \left(x + -1\right) - t\\ \end{array} \]
Alternative 7
Error16.9
Cost7185
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{+186}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{+155}:\\ \;\;\;\;\left(y - z \cdot y\right) - t\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{+107} \lor \neg \left(x \leq 1.08 \cdot 10^{+33}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(-\log y\right) - t\\ \end{array} \]
Alternative 8
Error27.1
Cost7120
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;t \leq -7800:\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{-303}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.4 \cdot 10^{-208}:\\ \;\;\;\;\left(y - z \cdot y\right) - t\\ \mathbf{elif}\;t \leq 360000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \end{array} \]
Alternative 9
Error0.6
Cost7104
\[\left(\log y \cdot \left(x + -1\right) - z \cdot y\right) - t \]
Alternative 10
Error8.5
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -260000 \lor \neg \left(x \leq 2.8 \cdot 10^{-10}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(-\log y\right) - t\\ \end{array} \]
Alternative 11
Error7.4
Cost6980
\[\begin{array}{l} \mathbf{if}\;z \leq 2.9 \cdot 10^{+188}:\\ \;\;\;\;\log y \cdot \left(x + -1\right) - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \end{array} \]
Alternative 12
Error36.4
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -1720000:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{+28}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 13
Error34.2
Cost448
\[\left(y - z \cdot y\right) - t \]
Alternative 14
Error34.3
Cost384
\[z \cdot \left(-y\right) - t \]
Alternative 15
Error41.1
Cost128
\[-t \]

Error

Reproduce?

herbie shell --seed 2023039 
(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))