\[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\]
↓
\[\begin{array}{l}
t_0 := 1 + \left|x\right|\\
t_1 := 0.5 \cdot \frac{1}{x}\\
t_2 := 0.125 \cdot \frac{1}{{x}^{3}}\\
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(t_2 + \left(\left(-x\right) - \left(t_1 + 0.0625 \cdot \frac{1}{{x}^{5}}\right)\right)\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\log t_0 + \left(\left(3 \cdot \frac{1}{t_0} + 3 \cdot \frac{1}{{t_0}^{2}}\right) \cdot \left(-0.041666666666666664 \cdot {x}^{4}\right) + 0.5 \cdot \frac{{x}^{2}}{t_0}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(t_1 + \left(\left|x\right| + x\right)\right) - t_2\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 (+ 1.0 (fabs x)))
(t_1 (* 0.5 (/ 1.0 x)))
(t_2 (* 0.125 (/ 1.0 (pow x 3.0)))))
(if (<= x -0.5)
(copysign
(log
(+ (fabs x) (+ t_2 (- (- x) (+ t_1 (* 0.0625 (/ 1.0 (pow x 5.0))))))))
x)
(if (<= x 0.019999999552965164)
(copysign
(+
(log t_0)
(+
(*
(+ (* 3.0 (/ 1.0 t_0)) (* 3.0 (/ 1.0 (pow t_0 2.0))))
(* -0.041666666666666664 (pow x 4.0)))
(* 0.5 (/ (pow x 2.0) t_0))))
x)
(copysign (log (- (+ t_1 (+ (fabs x) x)) t_2)) x)))))float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
↓
float code(float x) {
float t_0 = 1.0f + fabsf(x);
float t_1 = 0.5f * (1.0f / x);
float t_2 = 0.125f * (1.0f / powf(x, 3.0f));
float tmp;
if (x <= -0.5f) {
tmp = copysignf(logf((fabsf(x) + (t_2 + (-x - (t_1 + (0.0625f * (1.0f / powf(x, 5.0f)))))))), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((logf(t_0) + ((((3.0f * (1.0f / t_0)) + (3.0f * (1.0f / powf(t_0, 2.0f)))) * (-0.041666666666666664f * powf(x, 4.0f))) + (0.5f * (powf(x, 2.0f) / t_0)))), x);
} else {
tmp = copysignf(logf(((t_1 + (fabsf(x) + x)) - t_2)), 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 = Float32(Float32(1.0) + abs(x))
t_1 = Float32(Float32(0.5) * Float32(Float32(1.0) / x))
t_2 = Float32(Float32(0.125) * Float32(Float32(1.0) / (x ^ Float32(3.0))))
tmp = Float32(0.0)
if (x <= Float32(-0.5))
tmp = copysign(log(Float32(abs(x) + Float32(t_2 + Float32(Float32(-x) - Float32(t_1 + Float32(Float32(0.0625) * Float32(Float32(1.0) / (x ^ Float32(5.0))))))))), x);
elseif (x <= Float32(0.019999999552965164))
tmp = copysign(Float32(log(t_0) + Float32(Float32(Float32(Float32(Float32(3.0) * Float32(Float32(1.0) / t_0)) + Float32(Float32(3.0) * Float32(Float32(1.0) / (t_0 ^ Float32(2.0))))) * Float32(Float32(-0.041666666666666664) * (x ^ Float32(4.0)))) + Float32(Float32(0.5) * Float32((x ^ Float32(2.0)) / t_0)))), x);
else
tmp = copysign(log(Float32(Float32(t_1 + Float32(abs(x) + x)) - t_2)), x);
end
return tmp
end
function tmp = code(x)
tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0))))));
end
↓
function tmp_2 = code(x)
t_0 = single(1.0) + abs(x);
t_1 = single(0.5) * (single(1.0) / x);
t_2 = single(0.125) * (single(1.0) / (x ^ single(3.0)));
tmp = single(0.0);
if (x <= single(-0.5))
tmp = sign(x) * abs(log((abs(x) + (t_2 + (-x - (t_1 + (single(0.0625) * (single(1.0) / (x ^ single(5.0))))))))));
elseif (x <= single(0.019999999552965164))
tmp = sign(x) * abs((log(t_0) + ((((single(3.0) * (single(1.0) / t_0)) + (single(3.0) * (single(1.0) / (t_0 ^ single(2.0))))) * (single(-0.041666666666666664) * (x ^ single(4.0)))) + (single(0.5) * ((x ^ single(2.0)) / t_0)))));
else
tmp = sign(x) * abs(log(((t_1 + (abs(x) + x)) - t_2)));
end
tmp_2 = tmp;
end
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
↓
\begin{array}{l}
t_0 := 1 + \left|x\right|\\
t_1 := 0.5 \cdot \frac{1}{x}\\
t_2 := 0.125 \cdot \frac{1}{{x}^{3}}\\
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(t_2 + \left(\left(-x\right) - \left(t_1 + 0.0625 \cdot \frac{1}{{x}^{5}}\right)\right)\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\log t_0 + \left(\left(3 \cdot \frac{1}{t_0} + 3 \cdot \frac{1}{{t_0}^{2}}\right) \cdot \left(-0.041666666666666664 \cdot {x}^{4}\right) + 0.5 \cdot \frac{{x}^{2}}{t_0}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(t_1 + \left(\left|x\right| + x\right)\right) - t_2\right), x\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 13.0 |
|---|
| Cost | 39528 |
|---|
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.019999999552965164:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(0.5 \cdot \frac{1}{x} + \left(\left|x\right| + x\right)\right) - 0.125 \cdot \frac{1}{{x}^{3}}\right), x\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 12.6 |
|---|
| Cost | 39240 |
|---|
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 5:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(0.5 \cdot \frac{1}{x} + \left(\left|x\right| + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 13.0 |
|---|
| Cost | 29992 |
|---|
\[\begin{array}{l}
t_0 := 1 + \left|x\right|\\
t_1 := 0.5 \cdot \frac{1}{x}\\
t_2 := 0.125 \cdot \frac{1}{{x}^{3}}\\
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(t_2 + \left(\left(-x\right) - \left(t_1 + 0.0625 \cdot \frac{1}{{x}^{5}}\right)\right)\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\log t_0 + \left(\left(3 \cdot \left(\frac{1}{t_0} + \frac{1}{{t_0}^{2}}\right)\right) \cdot \left(-0.041666666666666664 \cdot {x}^{4}\right) + 0.5 \cdot \frac{{x}^{2}}{t_0}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(t_1 + \left(\left|x\right| + x\right)\right) - t_2\right), x\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 13.0 |
|---|
| Cost | 26472 |
|---|
\[\begin{array}{l}
t_0 := 1 + \left|x\right|\\
t_1 := 0.5 \cdot \frac{1}{x}\\
t_2 := 0.125 \cdot \frac{1}{{x}^{3}}\\
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(t_2 + \left(\left(-x\right) - \left(t_1 + 0.0625 \cdot \frac{1}{{x}^{5}}\right)\right)\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\left(\log t_0 + 0.5 \cdot \frac{{x}^{2}}{t_0}\right) + -0.125 \cdot \frac{{x}^{4}}{{t_0}^{2}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(t_1 + \left(\left|x\right| + x\right)\right) - t_2\right), x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 13.0 |
|---|
| Cost | 16868 |
|---|
\[\begin{array}{l}
t_0 := 0.5 \cdot \frac{1}{x}\\
t_1 := 1 + \left|x\right|\\
t_2 := 0.125 \cdot \frac{1}{{x}^{3}}\\
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(t_2 + \left(\left(-x\right) - \left(t_0 + 0.0625 \cdot \frac{1}{{x}^{5}}\right)\right)\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(0.5 \cdot \frac{{x}^{2}}{t_1} + \log t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(t_0 + \left(\left|x\right| + x\right)\right) - t_2\right), x\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 13.5 |
|---|
| Cost | 10056 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(0.5 \cdot \frac{1}{x} + \left(\left|x\right| + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 13.4 |
|---|
| Cost | 10056 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{1}{x} \cdot -0.5\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(0.5 \cdot \frac{1}{x} + \left(\left|x\right| + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 13.5 |
|---|
| Cost | 9864 |
|---|
\[\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.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 13.6 |
|---|
| Cost | 9864 |
|---|
\[\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.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 13.6 |
|---|
| Cost | 9864 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 19.0 |
|---|
| Cost | 6596 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -9.999999350456404 \cdot 10^{-39}:\\
\;\;\;\;\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 | 14.8 |
|---|
| Cost | 6596 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -9.999999350456404 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 23.3 |
|---|
| Cost | 6564 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -9.999999350456404 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\]
| Alternative 14 |
|---|
| Error | 27.6 |
|---|
| Cost | 6464 |
|---|
\[\mathsf{copysign}\left(\log x, x\right)
\]