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

Error

Derivation

  1. Initial program 0.0

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

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

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

Reproduce

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