\[\log \left(x + \sqrt{x \cdot x + 1}\right)
\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.4:\\
\;\;\;\;-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x \cdot \left(1 + \frac{x}{1 + \mathsf{hypot}\left(1, x\right)}\right)\right)\\
\end{array}
\]
(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
↓
(FPCore (x)
:precision binary64
(if (<= x -0.4)
(- (log (- (hypot 1.0 x) x)))
(log1p (* x (+ 1.0 (/ x (+ 1.0 (hypot 1.0 x))))))))
double code(double x) {
return log((x + sqrt(((x * x) + 1.0))));
}
↓
double code(double x) {
double tmp;
if (x <= -0.4) {
tmp = -log((hypot(1.0, x) - x));
} else {
tmp = log1p((x * (1.0 + (x / (1.0 + hypot(1.0, x))))));
}
return tmp;
}
public static double code(double x) {
return Math.log((x + Math.sqrt(((x * x) + 1.0))));
}
↓
public static double code(double x) {
double tmp;
if (x <= -0.4) {
tmp = -Math.log((Math.hypot(1.0, x) - x));
} else {
tmp = Math.log1p((x * (1.0 + (x / (1.0 + Math.hypot(1.0, x))))));
}
return tmp;
}
def code(x):
return math.log((x + math.sqrt(((x * x) + 1.0))))
↓
def code(x):
tmp = 0
if x <= -0.4:
tmp = -math.log((math.hypot(1.0, x) - x))
else:
tmp = math.log1p((x * (1.0 + (x / (1.0 + math.hypot(1.0, x))))))
return tmp
function code(x)
return log(Float64(x + sqrt(Float64(Float64(x * x) + 1.0))))
end
↓
function code(x)
tmp = 0.0
if (x <= -0.4)
tmp = Float64(-log(Float64(hypot(1.0, x) - x)));
else
tmp = log1p(Float64(x * Float64(1.0 + Float64(x / Float64(1.0 + hypot(1.0, x))))));
end
return tmp
end
code[x_] := N[Log[N[(x + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
↓
code[x_] := If[LessEqual[x, -0.4], (-N[Log[N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), N[Log[1 + N[(x * N[(1.0 + N[(x / N[(1.0 + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\log \left(x + \sqrt{x \cdot x + 1}\right)
↓
\begin{array}{l}
\mathbf{if}\;x \leq -0.4:\\
\;\;\;\;-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x \cdot \left(1 + \frac{x}{1 + \mathsf{hypot}\left(1, x\right)}\right)\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.4 |
|---|
| Cost | 13508 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-9}:\\
\;\;\;\;-\log \left(x + \left(\mathsf{hypot}\left(1, x\right) - \left(x + x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.1 |
|---|
| Cost | 13320 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-\log \left(x \cdot -2 + \frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 0.0042:\\
\;\;\;\;\mathsf{log1p}\left(x + \frac{x}{x \cdot 0.5 + \frac{1}{x} \cdot 2}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.4 |
|---|
| Cost | 13316 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.00075:\\
\;\;\;\;-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.6 |
|---|
| Cost | 13252 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{-8}:\\
\;\;\;\;-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x + \frac{x}{\left(1 + \frac{1}{x}\right) + \frac{0.5}{x \cdot x}}\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.3 |
|---|
| Cost | 7496 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-\log \left(x \cdot -2 + \frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\mathsf{log1p}\left(x + \frac{x}{x \cdot 0.5 + \frac{1}{x} \cdot 2}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \left(x + \frac{0.5}{x}\right)\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.8 |
|---|
| Cost | 7492 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.36:\\
\;\;\;\;-\log \left(x \cdot -2 + \frac{-0.5}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x + \frac{x}{\left(1 + \frac{1}{x}\right) + \frac{0.5}{x \cdot x}}\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.4 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;-\log \left(\frac{x}{-0.5}\right)\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \left(x + \frac{0.5}{x}\right)\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 0.3 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.95:\\
\;\;\;\;-\log \left(x \cdot -2 + \frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \left(x + \frac{0.5}{x}\right)\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 0.4 |
|---|
| Cost | 7048 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;-\log \left(\frac{x}{-0.5}\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + x\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 0.6 |
|---|
| Cost | 6856 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + x\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 0.6 |
|---|
| Cost | 6856 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;-\log \left(\frac{x}{-0.5}\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + x\right)\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 15.4 |
|---|
| Cost | 6724 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.25:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + x\right)\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 26.5 |
|---|
| Cost | 6596 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.6:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x\right)\\
\end{array}
\]
| Alternative 14 |
|---|
| Error | 30.7 |
|---|
| Cost | 64 |
|---|
\[x
\]