| Alternative 1 | |
|---|---|
| Error | 0.07% |
| Cost | 13504 |
\[\log \left(\frac{\sqrt{1 - x \cdot x}}{x} + \frac{1}{x}\right)
\]
(FPCore (x) :precision binary64 (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))
(FPCore (x) :precision binary64 (log1p (+ (/ (sqrt (- 1.0 (* x x))) x) (+ (/ 1.0 x) -1.0))))
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))) / x) + ((1.0 / 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(((Math.sqrt((1.0 - (x * x))) / x) + ((1.0 / 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(((math.sqrt((1.0 - (x * x))) / x) + ((1.0 / 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(sqrt(Float64(1.0 - Float64(x * x))) / x) + Float64(Float64(1.0 / 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[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
\mathsf{log1p}\left(\frac{\sqrt{1 - x \cdot x}}{x} + \left(\frac{1}{x} + -1\right)\right)
Results
Initial program 0.07
Applied egg-rr0.07
Final simplification0.07
| Alternative 1 | |
|---|---|
| Error | 0.07% |
| Cost | 13504 |
| Alternative 2 | |
|---|---|
| Error | 0.47% |
| Cost | 6976 |
| Alternative 3 | |
|---|---|
| Error | 0.92% |
| Cost | 6656 |
| Alternative 4 | |
|---|---|
| Error | 0.98% |
| Cost | 6592 |
| Alternative 5 | |
|---|---|
| Error | 97.32% |
| Cost | 320 |
herbie shell --seed 2023102
(FPCore (x)
:name "Hyperbolic arc-(co)secant"
:precision binary64
(log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))