?

Average Error: 0.18% → 0.13%
Time: 14.1s
Precision: binary64
Cost: 20032

?

\[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
\[\left(x + \left(\left(e^{\mathsf{log1p}\left(y\right)} + -1\right) + \log y \cdot \left(-0.5 - y\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) (- -0.5 y)))) 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) * (-0.5 - y)))) - 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) * (-0.5 - y)))) - 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) * (-0.5 - y)))) - 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(Float64(exp(log1p(y)) + -1.0) + Float64(log(y) * Float64(-0.5 - y)))) - 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[(N[Exp[N[Log[1 + y], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\left(x + \left(\left(e^{\mathsf{log1p}\left(y\right)} + -1\right) + \log y \cdot \left(-0.5 - y\right)\right)\right) - z

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 0.18

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

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

    [Start]0.18

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

    associate-+l- [=>]0.17

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

    \[\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.13

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

    [Start]0.13

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

    associate-+l- [=>]0.13

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

    *-commutative [=>]0.13

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

    +-commutative [<=]0.13

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

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

Alternatives

Alternative 1
Error0.14%
Cost13376
\[x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right) \]
Alternative 2
Error23.62%
Cost7509
\[\begin{array}{l} t_0 := \log y \cdot -0.5 - z\\ \mathbf{if}\;y \leq 4.2 \cdot 10^{-228}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-216}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 68000000000:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y \leq 10^{+35} \lor \neg \left(y \leq 2.6 \cdot 10^{+42}\right):\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error22.72%
Cost7508
\[\begin{array}{l} t_0 := y - \left(z + y \cdot \log y\right)\\ \mathbf{if}\;x \leq -3.5 \cdot 10^{+67}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;x \leq -2.55 \cdot 10^{-259}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-269}:\\ \;\;\;\;y + \log y \cdot \left(-0.5 - y\right)\\ \mathbf{elif}\;x \leq 16.5:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.62 \cdot 10^{+138}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \end{array} \]
Alternative 4
Error28.72%
Cost7381
\[\begin{array}{l} \mathbf{if}\;y \leq 2.45 \cdot 10^{-228}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-216}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+96} \lor \neg \left(y \leq 5.1 \cdot 10^{+157}\right) \land y \leq 3.4 \cdot 10^{+169}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \end{array} \]
Alternative 5
Error10.88%
Cost7245
\[\begin{array}{l} \mathbf{if}\;y \leq 70000000000:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+34} \lor \neg \left(y \leq 3.8 \cdot 10^{+53}\right):\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;y - \left(z + y \cdot \log y\right)\\ \end{array} \]
Alternative 6
Error10.48%
Cost7244
\[\begin{array}{l} \mathbf{if}\;x \leq -1.95 \cdot 10^{+67}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;x \leq 16.5:\\ \;\;\;\;\left(y + \log y \cdot \left(-0.5 - y\right)\right) - z\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+143}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \end{array} \]
Alternative 7
Error28.45%
Cost7117
\[\begin{array}{l} \mathbf{if}\;y \leq 4.5 \cdot 10^{+97} \lor \neg \left(y \leq 5.1 \cdot 10^{+157}\right) \land y \leq 9.6 \cdot 10^{+169}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \end{array} \]
Alternative 8
Error0.18%
Cost7104
\[\left(y - z\right) + \left(x + \log y \cdot \left(-0.5 - y\right)\right) \]
Alternative 9
Error51.62%
Cost392
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+82}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+15}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error41.82%
Cost192
\[x - z \]
Alternative 11
Error69.43%
Cost64
\[x \]

Error

Reproduce?

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