?

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

Error?

Derivation?

  1. Initial program 89.3%

    \[\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(z - 1, \mathsf{log1p}\left(-y\right), \left(x - 1\right) \cdot \log y - t\right)} \]
    Proof

    [Start]89.3

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

    +-commutative [=>]89.3

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

    associate--l+ [=>]89.3

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

    fma-def [=>]89.3

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

    sub-neg [=>]89.3

    \[ \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 [=>]99.8

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

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

Alternatives

Alternative 1
Accuracy99.4%
Cost7872
\[\left(\left(x + -1\right) \cdot \log y + \left(\left(y \cdot y\right) \cdot \left(0.5 + z \cdot -0.5\right) + \left(y - z \cdot y\right)\right)\right) - t \]
Alternative 2
Accuracy95.1%
Cost7496
\[\begin{array}{l} \mathbf{if}\;x + -1 \leq -5 \cdot 10^{+45}:\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{elif}\;x + -1 \leq -0.99999999999995:\\ \;\;\;\;\left(y \cdot \left(1 - z\right) - \log y\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(x + -1\right) \cdot \log y - t\\ \end{array} \]
Alternative 3
Accuracy76.0%
Cost7248
\[\begin{array}{l} t_1 := \left(-\log y\right) - t\\ t_2 := \left(x + -1\right) \cdot \log y\\ \mathbf{if}\;x \leq -15600000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-283}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{-263}:\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy86.9%
Cost7248
\[\begin{array}{l} t_1 := \left(-\log y\right) - t\\ t_2 := x \cdot \log y - t\\ \mathbf{if}\;x \leq -14:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-283}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{-263}:\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \mathbf{elif}\;x \leq 0.098:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy99.1%
Cost7232
\[\left(\left(x + -1\right) \cdot \log y + y \cdot \left(1 - z\right)\right) - t \]
Alternative 6
Accuracy76.1%
Cost7184
\[\begin{array}{l} t_1 := x \cdot \log y\\ t_2 := \left(-\log y\right) - t\\ \mathbf{if}\;x \leq -2.1 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-283}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 10^{-263}:\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \mathbf{elif}\;x \leq 1.62 \cdot 10^{+72}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Accuracy88.3%
Cost6984
\[\begin{array}{l} \mathbf{if}\;z \leq 1.35 \cdot 10^{+190}:\\ \;\;\;\;\left(x + -1\right) \cdot \log y - t\\ \mathbf{elif}\;z \leq 1.12 \cdot 10^{+293}:\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - t\\ \end{array} \]
Alternative 8
Accuracy65.8%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+61} \lor \neg \left(x \leq 1.95 \cdot 10^{+108}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - z\right) - t\\ \end{array} \]
Alternative 9
Accuracy41.3%
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -8500000000000:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 1.42 \cdot 10^{+50}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 10
Accuracy45.5%
Cost448
\[y \cdot \left(1 - z\right) - t \]
Alternative 11
Accuracy45.3%
Cost384
\[z \cdot \left(-y\right) - t \]
Alternative 12
Accuracy35.1%
Cost128
\[-t \]

Error

Reproduce?

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