Average Error: 0.0 → 0.0
Time: 1.8s
Precision: binary64
\[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
\[\log \left(\frac{e^{\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right)}}{x}\right) \]
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
\log \left(\frac{e^{\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right)}}{x}\right)
(FPCore (x)
 :precision binary64
 (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))
(FPCore (x)
 :precision binary64
 (log (/ (exp (log1p (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(exp(log1p(sqrt(1.0 - (x * x)))) / 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.0

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

    \[\leadsto \log \left(\frac{1}{x} + \color{blue}{\sqrt{1 - x \cdot x} \cdot \frac{1}{x}}\right) \]
  3. Applied distribute-rgt1-in_binary640.0

    \[\leadsto \log \color{blue}{\left(\left(\sqrt{1 - x \cdot x} + 1\right) \cdot \frac{1}{x}\right)} \]
  4. Applied log-prod_binary640.2

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

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right)} + \log \left(\frac{1}{x}\right) \]
  6. Simplified0.2

    \[\leadsto \mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right) + \color{blue}{\left(-\log x\right)} \]
  7. Applied neg-log_binary640.2

    \[\leadsto \mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right) + \color{blue}{\log \left(\frac{1}{x}\right)} \]
  8. Applied add-log-exp_binary640.2

    \[\leadsto \color{blue}{\log \left(e^{\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right)}\right)} + \log \left(\frac{1}{x}\right) \]
  9. Applied sum-log_binary640.0

    \[\leadsto \color{blue}{\log \left(e^{\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right)} \cdot \frac{1}{x}\right)} \]
  10. Simplified0.0

    \[\leadsto \log \color{blue}{\left(\frac{e^{\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right)}}{x}\right)} \]
  11. Final simplification0.0

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

Reproduce

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