?

Average Accuracy: 99.8% → 99.9%
Time: 18.3s
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

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 \]
  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(\log y \cdot \left(-0.5 - y\right) + -1\right)\right)\right) - z \]

Alternatives

Alternative 1
Accuracy99.9%
Cost13376
\[x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right) \]
Alternative 2
Accuracy70.2%
Cost7640
\[\begin{array}{l} t_0 := x + \log y \cdot -0.5\\ t_1 := y + \log y \cdot \left(-0.5 - y\right)\\ \mathbf{if}\;z \leq -1.4 \cdot 10^{+42}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-216}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-307}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 9.4 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
Alternative 3
Accuracy70.2%
Cost7508
\[\begin{array}{l} t_0 := x + \log y \cdot -0.5\\ t_1 := y + \log y \cdot \left(-0.5 - y\right)\\ \mathbf{if}\;z \leq -1.45 \cdot 10^{-14}:\\ \;\;\;\;y \cdot \left(1 - \log y\right) - z\\ \mathbf{elif}\;z \leq -6.2 \cdot 10^{-215}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-307}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-85}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 9.4 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
Alternative 4
Accuracy88.1%
Cost7245
\[\begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{+29} \lor \neg \left(y \leq 3.3 \cdot 10^{+61}\right) \land y \leq 1.4 \cdot 10^{+92}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \end{array} \]
Alternative 5
Accuracy55.5%
Cost7122
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{-22} \lor \neg \left(x \leq -3 \cdot 10^{-297}\right) \land \left(x \leq 4.7 \cdot 10^{-92} \lor \neg \left(x \leq 4.2 \cdot 10^{-45}\right)\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot -0.5\\ \end{array} \]
Alternative 6
Accuracy99.8%
Cost7104
\[\left(y + \left(x + \log y \cdot \left(-0.5 - y\right)\right)\right) - z \]
Alternative 7
Accuracy99.8%
Cost7104
\[\left(x + \left(y + \log y \cdot \left(-0.5 - y\right)\right)\right) - z \]
Alternative 8
Accuracy70.6%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -3900000 \lor \neg \left(z \leq 190\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;x + \log y \cdot -0.5\\ \end{array} \]
Alternative 9
Accuracy88.7%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq 4.9 \cdot 10^{+98}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right) - z\\ \end{array} \]
Alternative 10
Accuracy48.2%
Cost656
\[\begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+25}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+51}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+67}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{+103}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 11
Accuracy58.5%
Cost192
\[x - z \]
Alternative 12
Accuracy29.6%
Cost64
\[x \]

Error

Reproduce?

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