?

Average Error: 11.01% → 0.17%
Time: 15.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 11.01

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

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

    [Start]11.01

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

    +-commutative [=>]11.01

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

    fma-def [=>]11.01

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

    sub-neg [=>]11.01

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

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

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

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

    sub-neg [=>]0.17

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

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

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

Alternatives

Alternative 1
Error0.53%
Cost7872
\[\left(\log y \cdot \left(x + -1\right) + \left(\left(y \cdot y\right) \cdot \left(0.5 + z \cdot -0.5\right) + y \cdot \left(1 - z\right)\right)\right) - t \]
Alternative 2
Error4.25%
Cost7497
\[\begin{array}{l} \mathbf{if}\;x + -1 \leq -1.0001 \lor \neg \left(x + -1 \leq -0.99\right):\\ \;\;\;\;\log y \cdot \left(x + -1\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(1 - z\right) - \log y\right) - t\\ \end{array} \]
Alternative 3
Error5.58%
Cost7368
\[\begin{array}{l} t_1 := \log y \cdot \left(x + -1\right)\\ \mathbf{if}\;t \leq -3 \cdot 10^{-10}:\\ \;\;\;\;t_1 - t\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{+54}:\\ \;\;\;\;t_1 + y \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - t\\ \end{array} \]
Alternative 4
Error13.46%
Cost7241
\[\begin{array}{l} \mathbf{if}\;x + -1 \leq -2 \cdot 10^{+22} \lor \neg \left(x + -1 \leq -0.99\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(-\log y\right) - t\\ \end{array} \]
Alternative 5
Error0.85%
Cost7232
\[\left(\log y \cdot \left(x + -1\right) + y \cdot \left(1 - z\right)\right) - t \]
Alternative 6
Error22.55%
Cost7121
\[\begin{array}{l} \mathbf{if}\;t \leq -1.9 \cdot 10^{+47}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \mathbf{elif}\;t \leq 1.85 \cdot 10^{+28}:\\ \;\;\;\;\log y \cdot \left(x + -1\right)\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+141} \lor \neg \left(t \leq 9 \cdot 10^{+148}\right):\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y\\ \end{array} \]
Alternative 7
Error9.8%
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{+252}:\\ \;\;\;\;y \cdot \left(1 - z\right) + x \cdot \log y\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+270}:\\ \;\;\;\;\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 8
Error10.85%
Cost6980
\[\begin{array}{l} \mathbf{if}\;z \leq 2.3 \cdot 10^{+270}:\\ \;\;\;\;\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 9
Error23.39%
Cost6921
\[\begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{+45} \lor \neg \left(x \leq 1.8 \cdot 10^{+54}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;\left(-\log y\right) - t\\ \end{array} \]
Alternative 10
Error31.91%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+49} \lor \neg \left(x \leq 7.2 \cdot 10^{+55}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \end{array} \]
Alternative 11
Error53.37%
Cost704
\[z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t \]
Alternative 12
Error57.74%
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{-18}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{+57}:\\ \;\;\;\;y \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 13
Error58.03%
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -1.65 \cdot 10^{-33}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{+57}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 14
Error53.44%
Cost448
\[y \cdot \left(1 - z\right) - t \]
Alternative 15
Error53.64%
Cost384
\[z \cdot \left(-y\right) - t \]
Alternative 16
Error64.1%
Cost128
\[-t \]

Error

Reproduce?

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