Average Error: 6.5 → 0.4
Time: 14.2s
Precision: binary64
Cost: 7744
\[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
\[\left(-0.5 \cdot \left(z \cdot \left(y \cdot y\right)\right) + \left(\left(x + -1\right) \cdot \log y + y \cdot \left(1 - z\right)\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
 (- (+ (* -0.5 (* z (* y y))) (+ (* (+ x -1.0) (log y)) (* 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 ((-0.5 * (z * (y * y))) + (((x + -1.0) * log(y)) + (y * (1.0 - z)))) - t;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (((x - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))) - t
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (((-0.5d0) * (z * (y * y))) + (((x + (-1.0d0)) * log(y)) + (y * (1.0d0 - z)))) - t
end function
public static double code(double x, double y, double z, double t) {
	return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)))) - t;
}
public static double code(double x, double y, double z, double t) {
	return ((-0.5 * (z * (y * y))) + (((x + -1.0) * Math.log(y)) + (y * (1.0 - z)))) - t;
}
def code(x, y, z, t):
	return (((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y)))) - t
def code(x, y, z, t):
	return ((-0.5 * (z * (y * y))) + (((x + -1.0) * math.log(y)) + (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(Float64(-0.5 * Float64(z * Float64(y * y))) + Float64(Float64(Float64(x + -1.0) * log(y)) + Float64(y * Float64(1.0 - z)))) - t)
end
function tmp = code(x, y, z, t)
	tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
end
function tmp = code(x, y, z, t)
	tmp = ((-0.5 * (z * (y * y))) + (((x + -1.0) * log(y)) + (y * (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[(-0.5 * N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(y * N[(1.0 - z), $MachinePrecision]), $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
\left(-0.5 \cdot \left(z \cdot \left(y \cdot y\right)\right) + \left(\left(x + -1\right) \cdot \log y + y \cdot \left(1 - z\right)\right)\right) - t

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 6.5

    \[\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)): 47 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. Taylor expanded in y around 0 0.3

    \[\leadsto \color{blue}{\left(0.5 \cdot \left({y}^{2} \cdot \left(1 - z\right)\right) + \left(\left(x - 1\right) \cdot \log y + y \cdot \left(1 - z\right)\right)\right) - t} \]
  4. Taylor expanded in z around inf 0.4

    \[\leadsto \left(0.5 \cdot \color{blue}{\left(-1 \cdot \left({y}^{2} \cdot z\right)\right)} + \left(\left(x - 1\right) \cdot \log y + y \cdot \left(1 - z\right)\right)\right) - t \]
  5. Simplified0.4

    \[\leadsto \left(0.5 \cdot \color{blue}{\left(z \cdot \left(y \cdot \left(-y\right)\right)\right)} + \left(\left(x - 1\right) \cdot \log y + y \cdot \left(1 - z\right)\right)\right) - t \]
    Proof
    (*.f64 z (*.f64 y (neg.f64 y))): 0 points increase in error, 0 points decrease in error
    (*.f64 z (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 y y)))): 0 points increase in error, 0 points decrease in error
    (*.f64 z (neg.f64 (Rewrite<= unpow2_binary64 (pow.f64 y 2)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 z (pow.f64 y 2)))): 0 points increase in error, 0 points decrease in error
    (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 (pow.f64 y 2) z))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 (pow.f64 y 2) z))): 0 points increase in error, 0 points decrease in error
  6. Final simplification0.4

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

Alternatives

Alternative 1
Error1.1
Cost7624
\[\begin{array}{l} t_1 := y \cdot \left(1 - z\right)\\ t_2 := \left(t_1 + x \cdot \log y\right) - t\\ \mathbf{if}\;x + -1 \leq -400:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + -1 \leq -0.5:\\ \;\;\;\;\left(t_1 - \log y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error1.1
Cost7624
\[\begin{array}{l} t_1 := y \cdot \left(1 - z\right)\\ t_2 := \left(t_1 + x \cdot \log y\right) - t\\ \mathbf{if}\;x + -1 \leq -400:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + -1 \leq -0.5:\\ \;\;\;\;\left(t_1 - t\right) - \log y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error2.6
Cost7496
\[\begin{array}{l} t_1 := \left(x + -1\right) \cdot \log y - t\\ \mathbf{if}\;x + -1 \leq -1.0000000002:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + -1 \leq -1:\\ \;\;\;\;\left(y \cdot \left(1 - z\right) - \log y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error0.4
Cost7488
\[\left(\left(x + -1\right) \cdot \log y + y \cdot \left(z \cdot \left(-1 + y \cdot -0.5\right)\right)\right) - t \]
Alternative 5
Error0.5
Cost7232
\[\left(\left(x + -1\right) \cdot \log y + y \cdot \left(1 - z\right)\right) - t \]
Alternative 6
Error0.5
Cost7232
\[\left(x + -1\right) \cdot \log y - \left(t + y \cdot \left(z + -1\right)\right) \]
Alternative 7
Error14.5
Cost6984
\[\begin{array}{l} t_1 := x \cdot \log y - t\\ \mathbf{if}\;x \leq -3.445481722149641 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.418486705941711 \cdot 10^{+20}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \left(y \cdot \left(1 - z\right)\right) - z\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error6.9
Cost6980
\[\begin{array}{l} \mathbf{if}\;z \leq -4.1015595397090217 \cdot 10^{+161}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \left(y \cdot \left(1 - z\right)\right) - z\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(x + -1\right) \cdot \log y - t\\ \end{array} \]
Alternative 9
Error21.6
Cost6856
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -2.454291440692894 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.1952578389597274 \cdot 10^{+53}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \left(y \cdot \left(1 - z\right)\right) - z\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error34.9
Cost832
\[y \cdot \left(0.5 \cdot \left(y \cdot \left(1 - z\right)\right) - z\right) - t \]
Alternative 11
Error37.3
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1464874407381312 \cdot 10^{+26}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 8.389989227443163 \cdot 10^{+40}:\\ \;\;\;\;y - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 12
Error37.5
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1464874407381312 \cdot 10^{+26}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 8.389989227443163 \cdot 10^{+40}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 13
Error35.0
Cost448
\[\left(y - z \cdot y\right) - t \]
Alternative 14
Error35.1
Cost384
\[\left(-t\right) - z \cdot y \]
Alternative 15
Error41.3
Cost128
\[-t \]
Alternative 16
Error62.2
Cost64
\[y \]

Error

Reproduce

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