Average Error: 0.0 → 0.2
Time: 3.3s
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 \]
(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);
}
public static double code(double x) {
	return Math.log(((1.0 / x) + (Math.sqrt((1.0 - (x * x))) / x)));
}
public static double code(double x) {
	return Math.log1p(Math.sqrt((1.0 - (x * x)))) - Math.log(x);
}
def code(x):
	return math.log(((1.0 / x) + (math.sqrt((1.0 - (x * x))) / x)))
def code(x):
	return math.log1p(math.sqrt((1.0 - (x * x)))) - math.log(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(log1p(sqrt(Float64(1.0 - Float64(x * x)))) - log(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[(N[Log[1 + N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
\mathsf{log1p}\left(\sqrt{1 - x \cdot x}\right) - \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.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 unsub-neg_binary640.2

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

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

Reproduce

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