(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))(FPCore (x y z)
:precision binary64
(+
(- (fma (- x 0.5) (log x) 0.91893853320467) x)
(+
(+
(* (sqrt 0.083333333333333) (/ (sqrt 0.083333333333333) x))
(* (* z (/ z x)) (+ 0.0007936500793651 y)))
(* (/ z x) -0.0027777777777778))))double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
double code(double x, double y, double z) {
return (fma((x - 0.5), log(x), 0.91893853320467) - x) + (((sqrt(0.083333333333333) * (sqrt(0.083333333333333) / x)) + ((z * (z / x)) * (0.0007936500793651 + y))) + ((z / x) * -0.0027777777777778));
}
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function code(x, y, z) return Float64(Float64(fma(Float64(x - 0.5), log(x), 0.91893853320467) - x) + Float64(Float64(Float64(sqrt(0.083333333333333) * Float64(sqrt(0.083333333333333) / x)) + Float64(Float64(z * Float64(z / x)) * Float64(0.0007936500793651 + y))) + Float64(Float64(z / x) * -0.0027777777777778))) end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision] + N[(N[(N[(N[Sqrt[0.083333333333333], $MachinePrecision] * N[(N[Sqrt[0.083333333333333], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision] * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(z / x), $MachinePrecision] * -0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\left(\mathsf{fma}\left(x - 0.5, \log x, 0.91893853320467\right) - x\right) + \left(\left(\sqrt{0.083333333333333} \cdot \frac{\sqrt{0.083333333333333}}{x} + \left(z \cdot \frac{z}{x}\right) \cdot \left(0.0007936500793651 + y\right)\right) + \frac{z}{x} \cdot -0.0027777777777778\right)




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 6.1 |
|---|---|
| Target | 1.3 |
| Herbie | 0.5 |
Initial program 6.1
Simplified6.1
Taylor expanded in z around 0 6.2
Simplified0.5
Applied *-un-lft-identity_binary640.5
Applied add-sqr-sqrt_binary640.6
Applied times-frac_binary640.5
Simplified0.5
Final simplification0.5
herbie shell --seed 2022129
(FPCore (x y z)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))
(+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))