?

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

Error?

Derivation?

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

    [Start]89.4

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

    +-commutative [=>]89.4

    \[ \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.4

    \[ \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.4

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

    sub-neg [=>]89.4

    \[ \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), \log y \cdot \left(x + -1\right) - t\right) \]

Alternatives

Alternative 1
Accuracy99.8%
Cost19968
\[\log y \cdot \left(x + -1\right) - \mathsf{fma}\left(\mathsf{log1p}\left(-y\right), 1 - z, t\right) \]
Alternative 2
Accuracy99.2%
Cost13504
\[\mathsf{fma}\left(y, 1 - z, \log y \cdot \left(x + -1\right)\right) - t \]
Alternative 3
Accuracy99.2%
Cost13504
\[\mathsf{fma}\left(\log y, x + -1, y \cdot \left(1 - z\right) - t\right) \]
Alternative 4
Accuracy88.5%
Cost7496
\[\begin{array}{l} t_1 := \log y \cdot \left(x + -1\right)\\ \mathbf{if}\;x + -1 \leq -1:\\ \;\;\;\;\left(y + t_1\right) - t\\ \mathbf{elif}\;x + -1 \leq -0.5:\\ \;\;\;\;\left(y \cdot \left(1 - z\right) - t\right) - \log y\\ \mathbf{else}:\\ \;\;\;\;t_1 - t\\ \end{array} \]
Alternative 5
Accuracy89.9%
Cost7241
\[\begin{array}{l} \mathbf{if}\;z \leq -6.2 \cdot 10^{+251} \lor \neg \left(z \leq 1.9 \cdot 10^{+185}\right):\\ \;\;\;\;\left(-t\right) - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(y + \log y \cdot \left(x + -1\right)\right) - t\\ \end{array} \]
Alternative 6
Accuracy99.2%
Cost7232
\[\left(y \cdot \left(1 - z\right) - t\right) + \log y \cdot \left(x + -1\right) \]
Alternative 7
Accuracy89.8%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{+252} \lor \neg \left(z \leq 3.4 \cdot 10^{+186}\right):\\ \;\;\;\;\left(-t\right) - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot \left(x + -1\right) - t\\ \end{array} \]
Alternative 8
Accuracy76.9%
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-23} \lor \neg \left(x \leq 6.8\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y \cdot y\right) \cdot \left(\left(-0.5 + y \cdot \left(y \cdot -0.25\right)\right) + y \cdot -0.3333333333333333\right) - y\right) - t\\ \end{array} \]
Alternative 9
Accuracy64.9%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -1.75 \cdot 10^{+162} \lor \neg \left(x \leq 2.8 \cdot 10^{+34}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y \cdot y\right) \cdot \left(\left(-0.5 + y \cdot \left(y \cdot -0.25\right)\right) + y \cdot -0.3333333333333333\right) - y\right) - t\\ \end{array} \]
Alternative 10
Accuracy45.9%
Cost1344
\[z \cdot \left(\left(y \cdot y\right) \cdot \left(\left(-0.5 + y \cdot \left(y \cdot -0.25\right)\right) + y \cdot -0.3333333333333333\right) - y\right) - t \]
Alternative 11
Accuracy45.9%
Cost960
\[z \cdot \left(\left(y \cdot y\right) \cdot \left(-0.5 + y \cdot -0.3333333333333333\right) - y\right) - t \]
Alternative 12
Accuracy41.9%
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1 \cdot 10^{+53}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 45000000:\\ \;\;\;\;y - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 13
Accuracy41.6%
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -8.2 \cdot 10^{+52}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 46000000:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 14
Accuracy45.8%
Cost448
\[\left(y - z \cdot y\right) - t \]
Alternative 15
Accuracy45.6%
Cost384
\[\left(-t\right) - z \cdot y \]
Alternative 16
Accuracy35.5%
Cost128
\[-t \]
Alternative 17
Accuracy2.9%
Cost64
\[y \]

Error

Reproduce?

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