\[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\]
↓
\[\begin{array}{l}
t_0 := \sqrt{x \cdot x + 1}\\
t_1 := \mathsf{copysign}\left(\log \left(\left|x\right| + t_0\right), x\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_1 \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{\left(t_0 + \left|x\right| \cdot 7\right) - \left|x\right| \cdot 6}{1}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{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
(let* ((t_0 (sqrt (+ (* x x) 1.0))) (t_1 (copysign (log (+ (fabs x) t_0)) x)))
(if (<= t_1 (- INFINITY))
(copysign (log (/ -0.5 x)) x)
(if (<= t_1 2.0)
(copysign (log (/ (- (+ t_0 (* (fabs x) 7.0)) (* (fabs x) 6.0)) 1.0)) x)
(copysign (log (+ (fabs x) (+ x (/ 0.5 x)))) x)))))float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
↓
float code(float x) {
float t_0 = sqrtf(((x * x) + 1.0f));
float t_1 = copysignf(logf((fabsf(x) + t_0)), x);
float tmp;
if (t_1 <= -((float) INFINITY)) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (t_1 <= 2.0f) {
tmp = copysignf(logf((((t_0 + (fabsf(x) * 7.0f)) - (fabsf(x) * 6.0f)) / 1.0f)), x);
} else {
tmp = copysignf(logf((fabsf(x) + (x + (0.5f / 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)
t_0 = sqrt(Float32(Float32(x * x) + Float32(1.0)))
t_1 = copysign(log(Float32(abs(x) + t_0)), x)
tmp = Float32(0.0)
if (t_1 <= Float32(-Float32(Inf)))
tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
elseif (t_1 <= Float32(2.0))
tmp = copysign(log(Float32(Float32(Float32(t_0 + Float32(abs(x) * Float32(7.0))) - Float32(abs(x) * Float32(6.0))) / Float32(1.0))), x);
else
tmp = copysign(log(Float32(abs(x) + Float32(x + Float32(Float32(0.5) / x)))), 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 = sqrt(((x * x) + single(1.0)));
t_1 = sign(x) * abs(log((abs(x) + t_0)));
tmp = single(0.0);
if (t_1 <= -single(Inf))
tmp = sign(x) * abs(log((single(-0.5) / x)));
elseif (t_1 <= single(2.0))
tmp = sign(x) * abs(log((((t_0 + (abs(x) * single(7.0))) - (abs(x) * single(6.0))) / single(1.0))));
else
tmp = sign(x) * abs(log((abs(x) + (x + (single(0.5) / x)))));
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 := \sqrt{x \cdot x + 1}\\
t_1 := \mathsf{copysign}\left(\log \left(\left|x\right| + t_0\right), x\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_1 \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{\left(t_0 + \left|x\right| \cdot 7\right) - \left|x\right| \cdot 6}{1}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 12.4 |
|---|
| Cost | 42696 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{x \cdot x + 1}\\
t_1 := \mathsf{copysign}\left(\log \left(\left|x\right| + t_0\right), x\right)\\
\mathbf{if}\;t_1 \leq -24:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_1 \leq 5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(t_0 + \left(\left|x\right| \cdot 2\right) \cdot 2\right) - \left|x\right| \cdot 3\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 12.4 |
|---|
| Cost | 42632 |
|---|
\[\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 2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| \cdot 3 - \left(\left|x\right| \cdot 2 - \sqrt{1 + x \cdot x}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 12.4 |
|---|
| Cost | 39496 |
|---|
\[\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:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot \left(\left(x + x \cdot 3\right) - x \cdot 3\right) + 1}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 12.4 |
|---|
| Cost | 39304 |
|---|
\[\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 2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\frac{x}{\frac{1}{x}} + 1}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 12.4 |
|---|
| 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 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 13.1 |
|---|
| Cost | 10056 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x} - \left(x - \left|x\right|\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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.2 |
|---|
| 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(\log \left(\left|x\right| + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 13.1 |
|---|
| Cost | 9992 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x} - \left(x - \left|x\right|\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 13.3 |
|---|
| 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 1:\\
\;\;\;\;\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 | 17.5 |
|---|
| Cost | 9796 |
|---|
\[\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(\log \left(\left|x\right| + 1\right), x\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 18.9 |
|---|
| Cost | 6724 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4.000000861221333 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\frac{1}{\frac{-1}{\log \left(\frac{1}{x}\right)}}, x\right)\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 18.9 |
|---|
| Cost | 6628 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4.000000861221333 \cdot 10^{-39}:\\
\;\;\;\;\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 13 |
|---|
| Error | 18.9 |
|---|
| Cost | 6596 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4.000000861221333 \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 14 |
|---|
| Error | 23.2 |
|---|
| Cost | 6564 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4.000000861221333 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\]
| Alternative 15 |
|---|
| Error | 27.6 |
|---|
| Cost | 6464 |
|---|
\[\mathsf{copysign}\left(\log x, x\right)
\]