Average Error: 0.1 → 0.2
Time: 2.2s
Precision: binary64
\[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
\[\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right) - \log x \]
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right) - \log x
(FPCore (x)
 :precision binary64
 (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))
(FPCore (x) :precision binary64 (- (log1p (sqrt (- 1.0 (* x x)))) (log x)))
double code(double x) {
	return log(((1.0 / x) + (sqrt((1.0 - (x * x))) / x)));
}
double code(double x) {
	return log1p(sqrt((1.0 - (x * x)))) - log(x);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.1

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

    \[\leadsto \color{blue}{\left(-\log x\right) + \mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right)} \]
  3. Final simplification0.2

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

Reproduce

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