Average Error: 0.0 → 0.3
Time: 2.8s
Precision: binary64
\[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
\[\log \left(\mathsf{fma}\left(x, -0.5, \frac{2}{x}\right)\right) \]
(FPCore (x)
 :precision binary64
 (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))
(FPCore (x) :precision binary64 (log (fma x -0.5 (/ 2.0 x))))
double code(double x) {
	return log(((1.0 / x) + (sqrt((1.0 - (x * x))) / x)));
}
double code(double x) {
	return log(fma(x, -0.5, (2.0 / x)));
}
function code(x)
	return log(Float64(Float64(1.0 / x) + Float64(sqrt(Float64(1.0 - Float64(x * x))) / x)))
end
function code(x)
	return log(fma(x, -0.5, Float64(2.0 / x)))
end
code[x_] := N[Log[N[(N[(1.0 / x), $MachinePrecision] + N[(N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[Log[N[(x * -0.5 + N[(2.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
\log \left(\mathsf{fma}\left(x, -0.5, \frac{2}{x}\right)\right)

Error

Bits error versus x

Derivation

  1. Initial program 0.0

    \[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
  2. Taylor expanded in x around 0 0.3

    \[\leadsto \log \color{blue}{\left(2 \cdot \frac{1}{x} - 0.5 \cdot x\right)} \]
  3. Simplified0.3

    \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(x, -0.5, \frac{2}{x}\right)\right)} \]
  4. Final simplification0.3

    \[\leadsto \log \left(\mathsf{fma}\left(x, -0.5, \frac{2}{x}\right)\right) \]

Reproduce

herbie shell --seed 2022155 
(FPCore (x)
  :name "Hyperbolic arc-(co)secant"
  :precision binary64
  (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))