?

Average Accuracy: 89.3% → 99.8%
Time: 21.1s
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(x + -1, \log y, \mathsf{log1p}\left(-y\right) \cdot \left(z + -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 (+ x -1.0) (log y) (* (log1p (- y)) (+ z -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((x + -1.0), log(y), (log1p(-y) * (z + -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(x + -1.0), log(y), Float64(log1p(Float64(-y)) * Float64(z + -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[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[Log[1 + (-y)], $MachinePrecision] * N[(z + -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(x + -1, \log y, \mathsf{log1p}\left(-y\right) \cdot \left(z + -1\right)\right) - t

Error?

Derivation?

  1. Initial program 91.4%

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

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

    [Start]91.4

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

    cancel-sign-sub [<=]91.4

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

    distribute-lft-neg-in [<=]91.4

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

    fma-neg [=>]91.4

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

    remove-double-neg [=>]91.4

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

    sub-neg [=>]91.4

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

    log1p-def [=>]99.8

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

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

Alternatives

Alternative 1
Accuracy99.2%
Cost13632
\[\left(\left(x \cdot \log y - \log y\right) - y \cdot \left(z + -1\right)\right) - t \]
Alternative 2
Accuracy88.3%
Cost7497
\[\begin{array}{l} \mathbf{if}\;x + -1 \leq 1.2 \lor \neg \left(x + -1 \leq 1\right):\\ \;\;\;\;\left(x + -1\right) \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(1 - z\right) - \log y\right) - t\\ \end{array} \]
Alternative 3
Accuracy80.6%
Cost7497
\[\begin{array}{l} \mathbf{if}\;x + -1 \leq 2 \lor \neg \left(x + -1 \leq 1\right):\\ \;\;\;\;\left(x \cdot \log y - y \cdot z\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(1 - z\right) - \log y\right) - t\\ \end{array} \]
Alternative 4
Accuracy99.1%
Cost7104
\[\left(\left(x + -1\right) \cdot \log y - y \cdot z\right) - t \]
Alternative 5
Accuracy70.1%
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq 1 \lor \neg \left(x \leq 2.3 \cdot 10^{-13}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(-\log y\right) - t\\ \end{array} \]
Alternative 6
Accuracy44.9%
Cost6980
\[\begin{array}{l} \mathbf{if}\;z \leq 4.8 \cdot 10^{+218}:\\ \;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(x + -1\right) \cdot \log y - t\\ \end{array} \]
Alternative 7
Accuracy36.9%
Cost6921
\[\begin{array}{l} \mathbf{if}\;x \leq 1.2 \cdot 10^{+47} \lor \neg \left(x \leq 2.7 \cdot 10^{+45}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;\left(-\log y\right) - t\\ \end{array} \]
Alternative 8
Accuracy36.9%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq 2.9 \cdot 10^{+46} \lor \neg \left(x \leq 5.3 \cdot 10^{+40}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-1 + y \cdot -0.5\right)\right) - t\\ \end{array} \]
Alternative 9
Accuracy45.9%
Cost704
\[z \cdot \left(y \cdot \left(-1 + y \cdot -0.5\right)\right) - t \]
Alternative 10
Accuracy35.8%
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq 3.4 \cdot 10^{-28}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 235000:\\ \;\;\;\;-y \cdot z\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 11
Accuracy45.9%
Cost448
\[y \cdot \left(1 - z\right) - t \]
Alternative 12
Accuracy45.7%
Cost384
\[\left(-y \cdot z\right) - t \]
Alternative 13
Accuracy35.4%
Cost128
\[-t \]

Error

Reproduce?

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