?

Average Error: 0.0 → 0.0
Time: 3.4s
Precision: binary64
Cost: 13504

?

\[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
\[\mathsf{log1p}\left(\frac{1 + \sqrt{1 - x \cdot x}}{x} + -1\right) \]
(FPCore (x)
 :precision binary64
 (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))
(FPCore (x)
 :precision binary64
 (log1p (+ (/ (+ 1.0 (sqrt (- 1.0 (* x 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((((1.0 + sqrt((1.0 - (x * x)))) / x) + -1.0));
}
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((((1.0 + Math.sqrt((1.0 - (x * x)))) / x) + -1.0));
}
def code(x):
	return math.log(((1.0 / x) + (math.sqrt((1.0 - (x * x))) / x)))
def code(x):
	return math.log1p((((1.0 + math.sqrt((1.0 - (x * 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(Float64(Float64(Float64(1.0 + sqrt(Float64(1.0 - Float64(x * 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[(N[(1.0 + N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
\mathsf{log1p}\left(\frac{1 + \sqrt{1 - x \cdot x}}{x} + -1\right)

Error?

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 egg-rr0.0

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

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{1 + \sqrt{1 - x \cdot x}}{x} + -1\right)} \]
    Proof

    [Start]0.0

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

    sub-neg [=>]0.0

    \[ \mathsf{log1p}\left(\frac{\sqrt{1 - x \cdot x}}{x} + \color{blue}{\left({x}^{-1} + \left(-1\right)\right)}\right) \]

    metadata-eval [=>]0.0

    \[ \mathsf{log1p}\left(\frac{\sqrt{1 - x \cdot x}}{x} + \left({x}^{-1} + \color{blue}{-1}\right)\right) \]

    associate-+r+ [=>]0.0

    \[ \mathsf{log1p}\left(\color{blue}{\left(\frac{\sqrt{1 - x \cdot x}}{x} + {x}^{-1}\right) + -1}\right) \]

    *-lft-identity [<=]0.0

    \[ \mathsf{log1p}\left(\left(\frac{\color{blue}{1 \cdot \sqrt{1 - x \cdot x}}}{x} + {x}^{-1}\right) + -1\right) \]

    associate-*l/ [<=]0.0

    \[ \mathsf{log1p}\left(\left(\color{blue}{\frac{1}{x} \cdot \sqrt{1 - x \cdot x}} + {x}^{-1}\right) + -1\right) \]

    unpow-1 [<=]0.0

    \[ \mathsf{log1p}\left(\left(\color{blue}{{x}^{-1}} \cdot \sqrt{1 - x \cdot x} + {x}^{-1}\right) + -1\right) \]

    *-commutative [<=]0.0

    \[ \mathsf{log1p}\left(\left(\color{blue}{\sqrt{1 - x \cdot x} \cdot {x}^{-1}} + {x}^{-1}\right) + -1\right) \]

    distribute-lft1-in [=>]0.0

    \[ \mathsf{log1p}\left(\color{blue}{\left(\sqrt{1 - x \cdot x} + 1\right) \cdot {x}^{-1}} + -1\right) \]

    +-commutative [<=]0.0

    \[ \mathsf{log1p}\left(\color{blue}{\left(1 + \sqrt{1 - x \cdot x}\right)} \cdot {x}^{-1} + -1\right) \]

    unpow-1 [=>]0.0

    \[ \mathsf{log1p}\left(\left(1 + \sqrt{1 - x \cdot x}\right) \cdot \color{blue}{\frac{1}{x}} + -1\right) \]

    associate-*r/ [=>]0.0

    \[ \mathsf{log1p}\left(\color{blue}{\frac{\left(1 + \sqrt{1 - x \cdot x}\right) \cdot 1}{x}} + -1\right) \]

    +-commutative [=>]0.0

    \[ \mathsf{log1p}\left(\frac{\color{blue}{\left(\sqrt{1 - x \cdot x} + 1\right)} \cdot 1}{x} + -1\right) \]

    distribute-rgt1-in [<=]0.0

    \[ \mathsf{log1p}\left(\frac{\color{blue}{1 + \sqrt{1 - x \cdot x} \cdot 1}}{x} + -1\right) \]

    *-rgt-identity [=>]0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost13376
\[\log \left(\frac{1 + \sqrt{1 - x \cdot x}}{x}\right) \]
Alternative 2
Error0.3
Cost6976
\[\log \left(x \cdot -0.5 + 2 \cdot \frac{1}{x}\right) \]
Alternative 3
Error0.6
Cost6656
\[-\log \left(x \cdot 0.5\right) \]
Alternative 4
Error0.6
Cost6592
\[\log \left(\frac{2}{x}\right) \]

Error

Reproduce?

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