Average Error: 0.0 → 0.0
Time: 4.3s
Precision: 64
\[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)\]
\[\log \left(\frac{1}{x} + \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{1 - x \cdot x}\right)\right)}{x}\right)\]
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
\log \left(\frac{1}{x} + \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{1 - x \cdot x}\right)\right)}{x}\right)
double f(double x) {
        double r59170 = 1.0;
        double r59171 = x;
        double r59172 = r59170 / r59171;
        double r59173 = r59171 * r59171;
        double r59174 = r59170 - r59173;
        double r59175 = sqrt(r59174);
        double r59176 = r59175 / r59171;
        double r59177 = r59172 + r59176;
        double r59178 = log(r59177);
        return r59178;
}

double f(double x) {
        double r59179 = 1.0;
        double r59180 = x;
        double r59181 = r59179 / r59180;
        double r59182 = r59180 * r59180;
        double r59183 = r59179 - r59182;
        double r59184 = sqrt(r59183);
        double r59185 = expm1(r59184);
        double r59186 = log1p(r59185);
        double r59187 = r59186 / r59180;
        double r59188 = r59181 + r59187;
        double r59189 = log(r59188);
        return r59189;
}

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. Using strategy rm
  3. Applied log1p-expm1-u0.0

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

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

Reproduce

herbie shell --seed 2019356 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-(co)secant"
  :precision binary64
  (log (+ (/ 1 x) (/ (sqrt (- 1 (* x x))) x))))