?

Average Accuracy: 99.8% → 99.9%
Time: 16.9s
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(-1 - \log y \cdot \left(y + 0.5\right)\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)) (- -1.0 (* (log y) (+ y 0.5))))) 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)) + (-1.0 - (log(y) * (y + 0.5))))) - 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)) + (-1.0 - (Math.log(y) * (y + 0.5))))) - 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)) + (-1.0 - (math.log(y) * (y + 0.5))))) - 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(-1.0 - Float64(log(y) * Float64(y + 0.5))))) - 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[(-1.0 - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $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(-1 - \log y \cdot \left(y + 0.5\right)\right)\right)\right) - z

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original99.8%
Target99.8%
Herbie99.9%
\[\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y \]

Derivation?

  1. Initial program 99.8%

    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
  2. Simplified99.8%

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

    [Start]99.8

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

    associate-+l- [=>]99.8

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

    \[\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 \]
    Proof

    [Start]99.8

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

    expm1-log1p-u [=>]99.9

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

    expm1-udef [=>]99.9

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

    associate--r- [=>]99.9

    \[ \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. Simplified99.9%

    \[\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]99.9

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

    +-commutative [=>]99.9

    \[ \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- [=>]99.9

    \[ \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 [=>]99.9

    \[ \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 [<=]99.9

    \[ \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 simplification99.9%

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

Alternatives

Alternative 1
Accuracy99.9%
Cost13376
\[x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right) \]
Alternative 2
Accuracy76.0%
Cost7244
\[\begin{array}{l} \mathbf{if}\;y \leq 3 \cdot 10^{-69}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-27}:\\ \;\;\;\;x + \log y \cdot -0.5\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+105}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right) - z\\ \end{array} \]
Alternative 3
Accuracy71.0%
Cost7116
\[\begin{array}{l} \mathbf{if}\;y \leq 5.5 \cdot 10^{-69}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-27}:\\ \;\;\;\;x + \log y \cdot -0.5\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+108}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \end{array} \]
Alternative 4
Accuracy76.9%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -4.1 \cdot 10^{+103} \lor \neg \left(z \leq 9 \cdot 10^{+45}\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - y \cdot \log y\right)\\ \end{array} \]
Alternative 5
Accuracy99.8%
Cost7104
\[\left(y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\right) - z \]
Alternative 6
Accuracy99.8%
Cost7104
\[\left(x + \left(y - \log y \cdot \left(y + 0.5\right)\right)\right) - z \]
Alternative 7
Accuracy89.4%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq 9.5 \cdot 10^{+105}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right) - z\\ \end{array} \]
Alternative 8
Accuracy71.7%
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq 1.6 \cdot 10^{+106}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \end{array} \]
Alternative 9
Accuracy46.7%
Cost656
\[\begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+84}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{+24}:\\ \;\;\;\;-z\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+86}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+159}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy57.9%
Cost192
\[x - z \]
Alternative 11
Accuracy30.2%
Cost64
\[x \]

Error

Reproduce?

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