\[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\]
↓
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := \left|x\right| - -1\\
t_2 := {t_1}^{2}\\
t_3 := \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(t_3, x\right)\\
\mathbf{elif}\;t_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(-0.041666666666666664, {x}^{4} \cdot \left(\frac{3}{t_1} + \frac{3}{t_2}\right), \mathsf{fma}\left(0.001388888888888889, \left(\frac{45}{t_1} + \left(\frac{30}{{t_1}^{3}} + \frac{45}{t_2}\right)\right) \cdot {x}^{6}, \mathsf{fma}\left(0.5, \frac{x \cdot x}{t_1}, \mathsf{log1p}\left(\left|x\right|\right)\right)\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \left(-1 - \left(-t_3\right)\right), x\right)\\
\end{array}
\]
(FPCore (x)
:precision binary32
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
↓
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(t_1 (- (fabs x) -1.0))
(t_2 (pow t_1 2.0))
(t_3 (log (+ (fabs x) (hypot 1.0 x)))))
(if (<= t_0 -0.20000000298023224)
(copysign t_3 x)
(if (<= t_0 0.20000000298023224)
(copysign
(fma
-0.041666666666666664
(* (pow x 4.0) (+ (/ 3.0 t_1) (/ 3.0 t_2)))
(fma
0.001388888888888889
(*
(+ (/ 45.0 t_1) (+ (/ 30.0 (pow t_1 3.0)) (/ 45.0 t_2)))
(pow x 6.0))
(fma 0.5 (/ (* x x) t_1) (log1p (fabs x)))))
x)
(copysign (+ 1.0 (- -1.0 (- t_3))) x)))))float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
↓
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float t_1 = fabsf(x) - -1.0f;
float t_2 = powf(t_1, 2.0f);
float t_3 = logf((fabsf(x) + hypotf(1.0f, x)));
float tmp;
if (t_0 <= -0.20000000298023224f) {
tmp = copysignf(t_3, x);
} else if (t_0 <= 0.20000000298023224f) {
tmp = copysignf(fmaf(-0.041666666666666664f, (powf(x, 4.0f) * ((3.0f / t_1) + (3.0f / t_2))), fmaf(0.001388888888888889f, (((45.0f / t_1) + ((30.0f / powf(t_1, 3.0f)) + (45.0f / t_2))) * powf(x, 6.0f)), fmaf(0.5f, ((x * x) / t_1), log1pf(fabsf(x))))), x);
} else {
tmp = copysignf((1.0f + (-1.0f - -t_3)), 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)
t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
t_1 = Float32(abs(x) - Float32(-1.0))
t_2 = t_1 ^ Float32(2.0)
t_3 = log(Float32(abs(x) + hypot(Float32(1.0), x)))
tmp = Float32(0.0)
if (t_0 <= Float32(-0.20000000298023224))
tmp = copysign(t_3, x);
elseif (t_0 <= Float32(0.20000000298023224))
tmp = copysign(fma(Float32(-0.041666666666666664), Float32((x ^ Float32(4.0)) * Float32(Float32(Float32(3.0) / t_1) + Float32(Float32(3.0) / t_2))), fma(Float32(0.001388888888888889), Float32(Float32(Float32(Float32(45.0) / t_1) + Float32(Float32(Float32(30.0) / (t_1 ^ Float32(3.0))) + Float32(Float32(45.0) / t_2))) * (x ^ Float32(6.0))), fma(Float32(0.5), Float32(Float32(x * x) / t_1), log1p(abs(x))))), x);
else
tmp = copysign(Float32(Float32(1.0) + Float32(Float32(-1.0) - Float32(-t_3))), x);
end
return tmp
end
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
↓
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := \left|x\right| - -1\\
t_2 := {t_1}^{2}\\
t_3 := \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(t_3, x\right)\\
\mathbf{elif}\;t_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(-0.041666666666666664, {x}^{4} \cdot \left(\frac{3}{t_1} + \frac{3}{t_2}\right), \mathsf{fma}\left(0.001388888888888889, \left(\frac{45}{t_1} + \left(\frac{30}{{t_1}^{3}} + \frac{45}{t_2}\right)\right) \cdot {x}^{6}, \mathsf{fma}\left(0.5, \frac{x \cdot x}{t_1}, \mathsf{log1p}\left(\left|x\right|\right)\right)\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \left(-1 - \left(-t_3\right)\right), x\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.2 |
|---|
| Cost | 52748 |
|---|
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := \left|x\right| - -1\\
t_2 := \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(t_2, x\right)\\
\mathbf{elif}\;t_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-0.041666666666666664 \cdot \frac{{x}^{4} \cdot \left(\frac{-3}{-1 - \left|x\right|} + 3\right)}{1 + \left|x\right|} + \left(0.5 \cdot \begin{array}{l}
\mathbf{if}\;x \ne 0:\\
\;\;\;\;\frac{x}{\frac{t_1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{2}}{t_1}\\
\end{array} + \mathsf{log1p}\left(\left|x\right|\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \left(-1 - \left(-t_2\right)\right), x\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.2 |
|---|
| Cost | 49512 |
|---|
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(t_1, x\right)\\
\mathbf{elif}\;t_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-0.041666666666666664 \cdot \frac{{x}^{4} \cdot \left(\frac{-3}{-1 - \left|x\right|} + 3\right)}{1 + \left|x\right|} + \left(0.5 \cdot \left(x \cdot \frac{x}{\left|x\right| - -1}\right) + \mathsf{log1p}\left(\left|x\right|\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \left(-1 - \left(-t_1\right)\right), x\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.2 |
|---|
| Cost | 42572 |
|---|
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := \left|x\right| - -1\\
t_2 := \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\\
\mathbf{if}\;t_0 \leq -0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(t_2, x\right)\\
\mathbf{elif}\;t_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(0.5, \begin{array}{l}
\mathbf{if}\;x \ne 0:\\
\;\;\;\;\frac{x}{\frac{t_1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{t_1}\\
\end{array}, \mathsf{log1p}\left(\left|x\right|\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \left(-1 - \left(-t_2\right)\right), x\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.2 |
|---|
| Cost | 39368 |
|---|
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\\
\mathbf{if}\;t_0 \leq -0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(t_1, x\right)\\
\mathbf{elif}\;t_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right) - \frac{x \cdot x}{\frac{\left|x\right| - -1}{-0.5}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \left(-1 - \left(-t_1\right)\right), x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.5 |
|---|
| Cost | 39144 |
|---|
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{if}\;t_0 \leq -0.0005000000237487257:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 1.9999999494757503 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 1.3 |
|---|
| Cost | 9992 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(\frac{0.5}{x} + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 1.2 |
|---|
| Cost | 9992 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(\frac{0.5}{x} + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 1.4 |
|---|
| Cost | 9864 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 5.6 |
|---|
| Cost | 9732 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 18.9 |
|---|
| Cost | 6628 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4.0000000204422544 \cdot 10^{-38}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{x}\right), x\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 18.9 |
|---|
| Cost | 6596 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4.0000000204422544 \cdot 10^{-38}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 23.3 |
|---|
| Cost | 6564 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4.0000000204422544 \cdot 10^{-38}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 27.7 |
|---|
| Cost | 6464 |
|---|
\[\mathsf{copysign}\left(\log x, x\right)
\]