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

Error

Derivation

  1. Initial program 7.1

    \[\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}{\left(x + -1\right) \cdot \log y - \mathsf{fma}\left(\mathsf{log1p}\left(-y\right), 1 - z, t\right)} \]
    Proof
    (-.f64 (*.f64 (+.f64 x -1) (log.f64 y)) (fma.f64 (log1p.f64 (neg.f64 y)) (-.f64 1 z) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (+.f64 x (Rewrite<= metadata-eval (neg.f64 1))) (log.f64 y)) (fma.f64 (log1p.f64 (neg.f64 y)) (-.f64 1 z) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (Rewrite<= sub-neg_binary64 (-.f64 x 1)) (log.f64 y)) (fma.f64 (log1p.f64 (neg.f64 y)) (-.f64 1 z) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (fma.f64 (Rewrite<= log1p-def_binary64 (log.f64 (+.f64 1 (neg.f64 y)))) (-.f64 1 z) t)): 26 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (fma.f64 (log.f64 (Rewrite<= sub-neg_binary64 (-.f64 1 y))) (-.f64 1 z) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (fma.f64 (log.f64 (-.f64 1 y)) (Rewrite<= unsub-neg_binary64 (+.f64 1 (neg.f64 z))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (fma.f64 (log.f64 (-.f64 1 y)) (Rewrite=> +-commutative_binary64 (+.f64 (neg.f64 z) 1)) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (fma.f64 (log.f64 (-.f64 1 y)) (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 z)) 1) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (fma.f64 (log.f64 (-.f64 1 y)) (Rewrite<= associate--r-_binary64 (-.f64 0 (-.f64 z 1))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (fma.f64 (log.f64 (-.f64 1 y)) (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 z 1))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (fma.f64 (log.f64 (-.f64 1 y)) (neg.f64 (-.f64 z 1)) (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 t))))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 (log.f64 (-.f64 1 y)) (neg.f64 (-.f64 z 1))) (neg.f64 t)))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 (neg.f64 (-.f64 z 1)) (log.f64 (-.f64 1 y)))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (-.f64 (*.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (-.f64 z 1))) (log.f64 (-.f64 1 y))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (-.f64 (*.f64 (Rewrite=> associate--r-_binary64 (+.f64 (-.f64 0 z) 1)) (log.f64 (-.f64 1 y))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (-.f64 (*.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 z)) 1) (log.f64 (-.f64 1 y))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (-.f64 (Rewrite<= distribute-rgt1-in_binary64 (+.f64 (log.f64 (-.f64 1 y)) (*.f64 (neg.f64 z) (log.f64 (-.f64 1 y))))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (-.f64 (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (log.f64 (-.f64 1 y)) (*.f64 z (log.f64 (-.f64 1 y))))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (-.f64 (-.f64 (log.f64 (-.f64 1 y)) (Rewrite<= *-commutative_binary64 (*.f64 (log.f64 (-.f64 1 y)) z))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (Rewrite<= associate--r+_binary64 (-.f64 (log.f64 (-.f64 1 y)) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) z) (neg.f64 t))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (log.f64 (-.f64 1 y))) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) z) (neg.f64 t)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (-.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (Rewrite<= *-lft-identity_binary64 (*.f64 1 (log.f64 (-.f64 1 y))))) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) z) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite=> cancel-sign-sub-inv_binary64 (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (*.f64 (neg.f64 1) (log.f64 (-.f64 1 y))))) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) z) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (Rewrite<= *-commutative_binary64 (*.f64 (log.f64 (-.f64 1 y)) (neg.f64 1)))) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) z) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+r+_binary64 (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) (neg.f64 1)) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) z) (neg.f64 t))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (*.f64 (log.f64 (-.f64 1 y)) (neg.f64 1)) (*.f64 (log.f64 (-.f64 1 y)) z)) (neg.f64 t)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (+.f64 (Rewrite<= distribute-lft-in_binary64 (*.f64 (log.f64 (-.f64 1 y)) (+.f64 (neg.f64 1) z))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) (Rewrite<= +-commutative_binary64 (+.f64 z (neg.f64 1)))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (+.f64 (*.f64 (log.f64 (-.f64 1 y)) (Rewrite<= sub-neg_binary64 (-.f64 z 1))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 z 1) (log.f64 (-.f64 1 y)))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (*.f64 (-.f64 z 1) (log.f64 (-.f64 1 y)))) (neg.f64 t))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= sub-neg_binary64 (-.f64 (+.f64 (*.f64 (-.f64 x 1) (log.f64 y)) (*.f64 (-.f64 z 1) (log.f64 (-.f64 1 y)))) t)): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error0.2
Cost8128
\[\left(\log y \cdot \left(x + -1\right) + \left(-1 + z\right) \cdot \left(\left(y \cdot y\right) \cdot \left(-0.5 + y \cdot \left(-0.3333333333333333 + y \cdot -0.25\right)\right) - y\right)\right) - t \]
Alternative 2
Error0.3
Cost7872
\[\left(\log y \cdot \left(x + -1\right) + \left(-1 + z\right) \cdot \left(\left(y \cdot y\right) \cdot \left(-0.5 + y \cdot -0.3333333333333333\right) - y\right)\right) - t \]
Alternative 3
Error1.1
Cost7624
\[\begin{array}{l} t_1 := \left(y \cdot \left(1 - z\right) + x \cdot \log y\right) - t\\ \mathbf{if}\;x + -1 \leq -200000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + -1 \leq -0.5:\\ \;\;\;\;\left(y - \left(\log y + y \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error0.3
Cost7616
\[\left(\log y \cdot \left(x + -1\right) + \left(-1 + z\right) \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right)\right) - t \]
Alternative 5
Error2.8
Cost7496
\[\begin{array}{l} t_1 := \log y \cdot \left(x + -1\right) - t\\ \mathbf{if}\;x + -1 \leq -200000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + -1 \leq -1:\\ \;\;\;\;\left(y - \left(\log y + y \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error9.3
Cost7248
\[\begin{array}{l} t_1 := \left(-t\right) - \log y\\ t_2 := x \cdot \log y - t\\ \mathbf{if}\;x \leq -341112.80033699406:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.5127317485757855 \cdot 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.931929962972541 \cdot 10^{-141}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \mathbf{elif}\;x \leq 0.010566879608918509:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error9.3
Cost7248
\[\begin{array}{l} t_1 := x \cdot \log y - t\\ \mathbf{if}\;x \leq -341112.80033699406:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.5127317485757855 \cdot 10^{-53}:\\ \;\;\;\;\left(-t\right) - \log y\\ \mathbf{elif}\;x \leq -4.931929962972541 \cdot 10^{-141}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \mathbf{elif}\;x \leq 0.010566879608918509:\\ \;\;\;\;y - \left(\log y + t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error9.2
Cost7248
\[\begin{array}{l} t_1 := x \cdot \log y - t\\ \mathbf{if}\;x \leq -341112.80033699406:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.5127317485757855 \cdot 10^{-53}:\\ \;\;\;\;\left(-t\right) - \log y\\ \mathbf{elif}\;x \leq -4.931929962972541 \cdot 10^{-141}:\\ \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\ \mathbf{elif}\;x \leq 0.010566879608918509:\\ \;\;\;\;y - \left(\log y + t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error0.5
Cost7232
\[\left(\log y \cdot \left(x + -1\right) + y \cdot \left(1 - z\right)\right) - t \]
Alternative 10
Error16.1
Cost7184
\[\begin{array}{l} t_1 := x \cdot \log y\\ t_2 := \left(-t\right) - \log y\\ \mathbf{if}\;x \leq -9.293911180540875 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.5127317485757855 \cdot 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -4.931929962972541 \cdot 10^{-141}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \mathbf{elif}\;x \leq 1407734896.0447881:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error6.3
Cost7112
\[\begin{array}{l} t_1 := \mathsf{log1p}\left(-y\right) \cdot z - t\\ \mathbf{if}\;z \leq -3.3197659754394294 \cdot 10^{+227}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.943340997243441 \cdot 10^{+246}:\\ \;\;\;\;\log y \cdot \left(x + -1\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error21.5
Cost6856
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -9.293911180540875 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1407734896.0447881:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error34.5
Cost704
\[z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t \]
Alternative 14
Error37.1
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -1.4973389531383523 \cdot 10^{+45}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 4.482375555979833 \cdot 10^{-7}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 15
Error34.5
Cost448
\[y \cdot \left(1 - z\right) - t \]
Alternative 16
Error34.7
Cost384
\[\left(-t\right) - y \cdot z \]
Alternative 17
Error41.4
Cost128
\[-t \]

Error

Reproduce

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