Average Error: 9.4 → 0.1
Time: 12.3s
Precision: binary64
Cost: 13440
\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t \]
\[\left(z \cdot \mathsf{log1p}\left(-y\right) + x \cdot \log y\right) - t \]
(FPCore (x y z t)
 :precision binary64
 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
(FPCore (x y z t)
 :precision binary64
 (- (+ (* z (log1p (- y))) (* x (log y))) t))
double code(double x, double y, double z, double t) {
	return ((x * log(y)) + (z * log((1.0 - y)))) - t;
}
double code(double x, double y, double z, double t) {
	return ((z * log1p(-y)) + (x * log(y))) - t;
}
public static double code(double x, double y, double z, double t) {
	return ((x * Math.log(y)) + (z * Math.log((1.0 - y)))) - t;
}
public static double code(double x, double y, double z, double t) {
	return ((z * Math.log1p(-y)) + (x * Math.log(y))) - t;
}
def code(x, y, z, t):
	return ((x * math.log(y)) + (z * math.log((1.0 - y)))) - t
def code(x, y, z, t):
	return ((z * math.log1p(-y)) + (x * math.log(y))) - t
function code(x, y, z, t)
	return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t)
end
function code(x, y, z, t)
	return Float64(Float64(Float64(z * log1p(Float64(-y))) + Float64(x * log(y))) - t)
end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(N[(z * N[Log[1 + (-y)], $MachinePrecision]), $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\left(z \cdot \mathsf{log1p}\left(-y\right) + x \cdot \log y\right) - t

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.4
Target0.2
Herbie0.1
\[\left(-z\right) \cdot \left(\left(0.5 \cdot \left(y \cdot y\right) + y\right) + \frac{0.3333333333333333}{1 \cdot \left(1 \cdot 1\right)} \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) - \left(t - x \cdot \log y\right) \]

Derivation

  1. Initial program 9.4

    \[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t \]
  2. Applied egg-rr0.1

    \[\leadsto \left(x \cdot \log y + z \cdot \color{blue}{\left(\mathsf{log1p}\left(-y\right) + 0\right)}\right) - t \]
  3. Simplified0.1

    \[\leadsto \left(x \cdot \log y + z \cdot \color{blue}{\mathsf{log1p}\left(-y\right)}\right) - t \]
    Proof
    (log1p.f64 (neg.f64 y)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-rgt-identity_binary64 (+.f64 (log1p.f64 (neg.f64 y)) 0)): 0 points increase in error, 0 points decrease in error
  4. Final simplification0.1

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

Alternatives

Alternative 1
Error0.3
Cost7360
\[\left(z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) + x \cdot \log y\right) - t \]
Alternative 2
Error0.5
Cost7168
\[\left(\log \left(\frac{1}{y}\right) \cdot \left(-x\right) - y \cdot z\right) - t \]
Alternative 3
Error7.0
Cost7044
\[\begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{+19}:\\ \;\;\;\;\log \left(\frac{1}{y}\right) \cdot \left(-x\right) - t\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-82}:\\ \;\;\;\;z \cdot \left(-0.5 \cdot \left(y \cdot y\right) - y\right) - t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - t\\ \end{array} \]
Alternative 4
Error7.0
Cost6984
\[\begin{array}{l} t_1 := x \cdot \log y - t\\ \mathbf{if}\;x \leq -8 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{-84}:\\ \;\;\;\;z \cdot \left(-0.5 \cdot \left(y \cdot y\right) - y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error0.5
Cost6976
\[\left(x \cdot \log y - y \cdot z\right) - t \]
Alternative 6
Error14.4
Cost6856
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{+53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+54}:\\ \;\;\;\;z \cdot \left(-0.5 \cdot \left(y \cdot y\right) - y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error27.0
Cost704
\[z \cdot \left(-0.5 \cdot \left(y \cdot y\right) - y\right) - t \]
Alternative 8
Error32.6
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -7.4 \cdot 10^{-81}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{-133}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 9
Error27.2
Cost384
\[y \cdot \left(-z\right) - t \]
Alternative 10
Error36.4
Cost128
\[-t \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (- (* (- z) (+ (+ (* 0.5 (* y y)) y) (* (/ 0.3333333333333333 (* 1.0 (* 1.0 1.0))) (* y (* y y))))) (- t (* x (log y))))

  (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))