Average Error: 0.1 → 0.0
Time: 2.2s
Precision: binary64
\[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
\[-\log \left(x \cdot \frac{x}{\mathsf{fma}\left(x, \sqrt{1 - x \cdot x}, x\right)}\right) \]
(FPCore (x)
 :precision binary64
 (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))
(FPCore (x)
 :precision binary64
 (- (log (* x (/ x (fma x (sqrt (- 1.0 (* x x))) x))))))
double code(double x) {
	return log(((1.0 / x) + (sqrt((1.0 - (x * x))) / x)));
}
double code(double x) {
	return -log((x * (x / fma(x, sqrt((1.0 - (x * x))), 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 Float64(-log(Float64(x * Float64(x / fma(x, sqrt(Float64(1.0 - Float64(x * x))), 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 * N[(x / N[(x * N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
-\log \left(x \cdot \frac{x}{\mathsf{fma}\left(x, \sqrt{1 - x \cdot x}, x\right)}\right)

Error

Bits error versus x

Derivation

  1. Initial program 0.1

    \[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
  2. Applied egg-rr0.1

    \[\leadsto \log \color{blue}{\left(\frac{\frac{\mathsf{fma}\left(x, \sqrt{1 - x \cdot x}, x\right)}{x}}{x}\right)} \]
  3. Applied egg-rr0.0

    \[\leadsto \color{blue}{-\log \left(x \cdot \frac{x}{\mathsf{fma}\left(x, \sqrt{1 - x \cdot x}, x\right)}\right)} \]
  4. Final simplification0.0

    \[\leadsto -\log \left(x \cdot \frac{x}{\mathsf{fma}\left(x, \sqrt{1 - x \cdot x}, x\right)}\right) \]

Reproduce

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