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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.1
Target0.1
Herbie0.1
\[\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y \]

Derivation

  1. Initial program 0.1

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

    \[\leadsto \color{blue}{\left(x - \left(\left(y + 0.5\right) \cdot \log y - y\right)\right) - z} \]
    Proof

    [Start]0.1

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

    associate-+l- [=>]0.1

    \[ \color{blue}{\left(x - \left(\left(y + 0.5\right) \cdot \log y - y\right)\right)} - z \]
  3. Applied egg-rr0.1

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

    \[\leadsto \left(x - \color{blue}{\left(\left(1 + \log y \cdot \left(0.5 + y\right)\right) - e^{\mathsf{log1p}\left(y\right)}\right)}\right) - z \]
    Proof

    [Start]0.1

    \[ \left(x - \left(\left(\left(y + 0.5\right) \cdot \log y - e^{\mathsf{log1p}\left(y\right)}\right) + 1\right)\right) - z \]

    +-commutative [=>]0.1

    \[ \left(x - \color{blue}{\left(1 + \left(\left(y + 0.5\right) \cdot \log y - e^{\mathsf{log1p}\left(y\right)}\right)\right)}\right) - z \]

    associate-+r- [=>]0.1

    \[ \left(x - \color{blue}{\left(\left(1 + \left(y + 0.5\right) \cdot \log y\right) - e^{\mathsf{log1p}\left(y\right)}\right)}\right) - z \]

    *-commutative [=>]0.1

    \[ \left(x - \left(\left(1 + \color{blue}{\log y \cdot \left(y + 0.5\right)}\right) - e^{\mathsf{log1p}\left(y\right)}\right)\right) - z \]

    +-commutative [<=]0.1

    \[ \left(x - \left(\left(1 + \log y \cdot \color{blue}{\left(0.5 + y\right)}\right) - e^{\mathsf{log1p}\left(y\right)}\right)\right) - z \]
  5. Final simplification0.1

    \[\leadsto \left(x + \left(e^{\mathsf{log1p}\left(y\right)} + \left(\log y \cdot \left(-0.5 - y\right) + -1\right)\right)\right) - z \]

Alternatives

Alternative 1
Error0.1
Cost13632
\[\left(y \cdot \left(1 - \log y\right) + \left(x + \log y \cdot -0.5\right)\right) - z \]
Alternative 2
Error18.5
Cost7772
\[\begin{array}{l} t_0 := y + \log y \cdot \left(-0.5 - y\right)\\ t_1 := \log y \cdot -0.5 - z\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{+14}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;x \leq -8.8 \cdot 10^{-95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-186}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.4 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.76 \cdot 10^{-184}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7.4 \cdot 10^{-162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-10}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - y \cdot \log y\right)\\ \end{array} \]
Alternative 3
Error15.9
Cost7640
\[\begin{array}{l} t_0 := y + \log y \cdot \left(-0.5 - y\right)\\ t_1 := y \cdot \left(1 - \log y\right) - z\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{+14}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-95}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-138}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-273}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-271}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - y \cdot \log y\right)\\ \end{array} \]
Alternative 4
Error7.4
Cost7241
\[\begin{array}{l} \mathbf{if}\;z \leq -1.08 \cdot 10^{+25} \lor \neg \left(z \leq 5.2 \cdot 10^{+130}\right):\\ \;\;\;\;y \cdot \left(1 - \log y\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) + \log y \cdot \left(-0.5 - y\right)\\ \end{array} \]
Alternative 5
Error18.6
Cost7117
\[\begin{array}{l} \mathbf{if}\;y \leq 2.7 \cdot 10^{+81}:\\ \;\;\;\;y + \left(x - z\right)\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+93} \lor \neg \left(y \leq 3.3 \cdot 10^{+117}\right):\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
Alternative 6
Error18.6
Cost7116
\[\begin{array}{l} \mathbf{if}\;y \leq 2.7 \cdot 10^{+81}:\\ \;\;\;\;y + \left(x - z\right)\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+93}:\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{+117}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y - y \cdot \log y\\ \end{array} \]
Alternative 7
Error20.8
Cost7116
\[\begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{+14}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-83}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{+93}:\\ \;\;\;\;y - y \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
Alternative 8
Error16.6
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq 3.6 \cdot 10^{-189}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+51}:\\ \;\;\;\;y + \left(x - z\right)\\ \mathbf{else}:\\ \;\;\;\;y + \left(x - y \cdot \log y\right)\\ \end{array} \]
Alternative 9
Error16.7
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq 6.2 \cdot 10^{-189}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+52}:\\ \;\;\;\;y + \left(x - z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - y \cdot \log y\right)\\ \end{array} \]
Alternative 10
Error6.6
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq 3.1 \cdot 10^{+30}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+169}:\\ \;\;\;\;y \cdot \left(1 - \log y\right) - z\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - y \cdot \log y\right)\\ \end{array} \]
Alternative 11
Error0.1
Cost7104
\[\left(y + \left(x + \log y \cdot \left(-0.5 - y\right)\right)\right) - z \]
Alternative 12
Error0.1
Cost7104
\[\left(x + \left(y + \log y \cdot \left(-0.5 - y\right)\right)\right) - z \]
Alternative 13
Error32.9
Cost392
\[\begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{+23}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+63}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 14
Error26.5
Cost192
\[x - z \]
Alternative 15
Error44.8
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022364 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (- (- (+ y x) z) (* (+ y 0.5) (log y)))

  (- (+ (- x (* (+ y 0.5) (log y))) y) z))