Average Error: 0.0 → 0.2
Time: 13.6s
Precision: 64
\[\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
double f(double x) {
        double r1534774 = 1.0;
        double r1534775 = x;
        double r1534776 = r1534774 / r1534775;
        double r1534777 = r1534775 * r1534775;
        double r1534778 = r1534774 - r1534777;
        double r1534779 = sqrt(r1534778);
        double r1534780 = r1534779 / r1534775;
        double r1534781 = r1534776 + r1534780;
        double r1534782 = log(r1534781);
        return r1534782;
}

double f(double x) {
        double r1534783 = 1.0;
        double r1534784 = x;
        double r1534785 = r1534784 * r1534784;
        double r1534786 = r1534783 - r1534785;
        double r1534787 = sqrt(r1534786);
        double r1534788 = log1p(r1534787);
        double r1534789 = log(r1534784);
        double r1534790 = r1534788 - r1534789;
        return r1534790;
}

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 div-inv0.0

    \[\leadsto \log \left(\frac{1}{x} + \color{blue}{\sqrt{1 - x \cdot x} \cdot \frac{1}{x}}\right)\]
  4. Applied *-un-lft-identity0.0

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

    \[\leadsto \log \color{blue}{\left(\frac{1}{x} \cdot \left(1 + \sqrt{1 - x \cdot x}\right)\right)}\]
  6. Using strategy rm
  7. Applied associate-*l/0.0

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

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

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

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

Reproduce

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