Average Error: 6.7 → 0.1
Time: 22.1s
Precision: binary64
Cost: 26304
\[\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), \mathsf{fma}\left(\log y, x + -1, -t\right)\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)) (fma (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), fma(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)), fma(log(y), Float64(x + -1.0), Float64(-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[Log[y], $MachinePrecision] * N[(x + -1.0), $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), \mathsf{fma}\left(\log y, x + -1, -t\right)\right)

Error

Derivation

  1. Initial program 6.7

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

Alternatives

Alternative 1
Error0.1
Cost13696
\[\left(\left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(1 - x\right) \cdot \log y\right) - t \]
Alternative 2
Error2.9
Cost7368
\[\begin{array}{l} t_1 := \left(x - 1\right) \cdot \log y\\ \mathbf{if}\;t \leq -28:\\ \;\;\;\;t_1 - t\\ \mathbf{elif}\;t \leq 35000:\\ \;\;\;\;t_1 - \left(z - 1\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot x - t\\ \end{array} \]
Alternative 3
Error0.6
Cost7232
\[\left(\left(x + -1\right) \cdot \log y - y \cdot \left(z + -1\right)\right) - t \]
Alternative 4
Error6.8
Cost7108
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{+225}:\\ \;\;\;\;\left(-y \cdot z\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(y + \left(x - 1\right) \cdot \log y\right) - t\\ \end{array} \]
Alternative 5
Error14.8
Cost6984
\[\begin{array}{l} t_1 := \log y \cdot x - t\\ \mathbf{if}\;x \leq -4.7 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 175000:\\ \;\;\;\;y \cdot \left(1 - z\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error7.9
Cost6984
\[\begin{array}{l} t_1 := \log y \cdot x - t\\ \mathbf{if}\;x \leq -1550:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-6}:\\ \;\;\;\;\left(y - \log y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error6.9
Cost6980
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+233}:\\ \;\;\;\;\left(-y \cdot z\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(x - 1\right) \cdot \log y - t\\ \end{array} \]
Alternative 8
Error22.0
Cost6856
\[\begin{array}{l} t_1 := \log y \cdot x\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{+80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 17000000000:\\ \;\;\;\;y \cdot \left(1 - z\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error36.7
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -0.009:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 1800000000000:\\ \;\;\;\;-y \cdot z\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 10
Error34.6
Cost448
\[y \cdot \left(1 - z\right) - t \]
Alternative 11
Error34.8
Cost384
\[\left(-y \cdot z\right) - t \]
Alternative 12
Error41.0
Cost192
\[y - t \]
Alternative 13
Error41.1
Cost128
\[-t \]

Error

Reproduce

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