\[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \frac{x \cdot x}{2 + \left(x \cdot x\right) \cdot 0.5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\]
(FPCore (x)
:precision binary32
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
↓
(FPCore (x)
:precision binary32
(if (<= x -0.5)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (log1p (+ x (/ (* x x) (+ 2.0 (* (* x x) 0.5))))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
↓
float code(float x) {
float tmp;
if (x <= -0.5f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf(log1pf((x + ((x * x) / (2.0f + ((x * x) * 0.5f))))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x)
return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
end
↓
function code(x)
tmp = Float32(0.0)
if (x <= Float32(-0.5))
tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x);
elseif (x <= Float32(0.05000000074505806))
tmp = copysign(log1p(Float32(x + Float32(Float32(x * x) / Float32(Float32(2.0) + Float32(Float32(x * x) * Float32(0.5)))))), x);
else
tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
end
return tmp
end
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
↓
\begin{array}{l}
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \frac{x \cdot x}{2 + \left(x \cdot x\right) \cdot 0.5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Accuracy | 98.1% |
|---|
| Cost | 22916 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Accuracy | 98.9% |
|---|
| Cost | 9896 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \frac{x \cdot x}{2 + \left(x \cdot x\right) \cdot 0.5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Accuracy | 99.5% |
|---|
| Cost | 9896 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \frac{x \cdot x}{2 + \left(x \cdot x\right) \cdot 0.5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Accuracy | 98.4% |
|---|
| Cost | 7048 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \frac{x \cdot x}{2 + \left(x \cdot x\right) \cdot 0.5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(1 + x \cdot \frac{x}{x + \left(1 + \frac{0.5}{x}\right)}\right)\right), x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Accuracy | 98.4% |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \frac{x \cdot x}{2 + \left(x \cdot x\right) \cdot 0.5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Accuracy | 98.2% |
|---|
| Cost | 6792 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Accuracy | 97.8% |
|---|
| Cost | 6760 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Accuracy | 83.6% |
|---|
| Cost | 6664 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Accuracy | 97.1% |
|---|
| Cost | 6664 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Accuracy | 68.8% |
|---|
| Cost | 6564 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Accuracy | 62.5% |
|---|
| Cost | 6532 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.600000023841858:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\]
| Alternative 12 |
|---|
| Accuracy | 54.5% |
|---|
| Cost | 3264 |
|---|
\[\mathsf{copysign}\left(x, x\right)
\]