\[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\]
↓
\[\begin{array}{l}
t_0 := \log \left(1 + \left|x\right|\right)\\
t_1 := 2 \cdot t_0\\
t_2 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_2 \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{copysign}\left(\left(\frac{{x}^{2}}{2 + 2 \cdot \left|x\right|} + \left(t_1 + t_1\right)\right) - \left(t_0 + t_1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
\]
(FPCore (x)
:precision binary64
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
↓
(FPCore (x)
:precision binary64
(let* ((t_0 (log (+ 1.0 (fabs x))))
(t_1 (* 2.0 t_0))
(t_2 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_2 -5.0)
(copysign (log (- (+ (- x) (fabs x)) (/ 0.5 x))) x)
(if (<= t_2 5e-11)
(copysign
(-
(+ (/ (pow x 2.0) (+ 2.0 (* 2.0 (fabs x)))) (+ t_1 t_1))
(+ t_0 t_1))
x)
(copysign (log (+ (/ 0.5 x) (+ x (fabs x)))) x)))))double code(double x) {
return copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
}
↓
double code(double x) {
double t_0 = log((1.0 + fabs(x)));
double t_1 = 2.0 * t_0;
double t_2 = copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_2 <= -5.0) {
tmp = copysign(log(((-x + fabs(x)) - (0.5 / x))), x);
} else if (t_2 <= 5e-11) {
tmp = copysign((((pow(x, 2.0) / (2.0 + (2.0 * fabs(x)))) + (t_1 + t_1)) - (t_0 + t_1)), x);
} else {
tmp = copysign(log(((0.5 / x) + (x + fabs(x)))), x);
}
return tmp;
}
public static double code(double x) {
return Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
}
↓
public static double code(double x) {
double t_0 = Math.log((1.0 + Math.abs(x)));
double t_1 = 2.0 * t_0;
double t_2 = Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_2 <= -5.0) {
tmp = Math.copySign(Math.log(((-x + Math.abs(x)) - (0.5 / x))), x);
} else if (t_2 <= 5e-11) {
tmp = Math.copySign((((Math.pow(x, 2.0) / (2.0 + (2.0 * Math.abs(x)))) + (t_1 + t_1)) - (t_0 + t_1)), x);
} else {
tmp = Math.copySign(Math.log(((0.5 / x) + (x + Math.abs(x)))), x);
}
return tmp;
}
def code(x):
return math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
↓
def code(x):
t_0 = math.log((1.0 + math.fabs(x)))
t_1 = 2.0 * t_0
t_2 = math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
tmp = 0
if t_2 <= -5.0:
tmp = math.copysign(math.log(((-x + math.fabs(x)) - (0.5 / x))), x)
elif t_2 <= 5e-11:
tmp = math.copysign((((math.pow(x, 2.0) / (2.0 + (2.0 * math.fabs(x)))) + (t_1 + t_1)) - (t_0 + t_1)), x)
else:
tmp = math.copysign(math.log(((0.5 / x) + (x + math.fabs(x)))), x)
return tmp
function code(x)
return copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x)
end
↓
function code(x)
t_0 = log(Float64(1.0 + abs(x)))
t_1 = Float64(2.0 * t_0)
t_2 = copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x)
tmp = 0.0
if (t_2 <= -5.0)
tmp = copysign(log(Float64(Float64(Float64(-x) + abs(x)) - Float64(0.5 / x))), x);
elseif (t_2 <= 5e-11)
tmp = copysign(Float64(Float64(Float64((x ^ 2.0) / Float64(2.0 + Float64(2.0 * abs(x)))) + Float64(t_1 + t_1)) - Float64(t_0 + t_1)), x);
else
tmp = copysign(log(Float64(Float64(0.5 / x) + Float64(x + abs(x)))), x);
end
return tmp
end
function tmp = code(x)
tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0)))));
end
↓
function tmp_2 = code(x)
t_0 = log((1.0 + abs(x)));
t_1 = 2.0 * t_0;
t_2 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0)))));
tmp = 0.0;
if (t_2 <= -5.0)
tmp = sign(x) * abs(log(((-x + abs(x)) - (0.5 / x))));
elseif (t_2 <= 5e-11)
tmp = sign(x) * abs(((((x ^ 2.0) / (2.0 + (2.0 * abs(x)))) + (t_1 + t_1)) - (t_0 + t_1)));
else
tmp = sign(x) * abs(log(((0.5 / x) + (x + abs(x)))));
end
tmp_2 = tmp;
end
code[x_] := N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
↓
code[x_] := Block[{t$95$0 = N[Log[N[(1.0 + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]}, If[LessEqual[t$95$2, -5.0], N[With[{TMP1 = Abs[N[Log[N[(N[((-x) + N[Abs[x], $MachinePrecision]), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$2, 5e-11], N[With[{TMP1 = Abs[N[(N[(N[(N[Power[x, 2.0], $MachinePrecision] / N[(2.0 + N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 + t$95$1), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 + t$95$1), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(N[(0.5 / x), $MachinePrecision] + N[(x + N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]]]]
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
↓
\begin{array}{l}
t_0 := \log \left(1 + \left|x\right|\right)\\
t_1 := 2 \cdot t_0\\
t_2 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_2 \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{copysign}\left(\left(\frac{{x}^{2}}{2 + 2 \cdot \left|x\right|} + \left(t_1 + t_1\right)\right) - \left(t_0 + t_1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 29.1 |
|---|
| Cost | 85192 |
|---|
\[\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := 1 + \left|x\right|\\
\mathbf{if}\;t_0 \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{copysign}\left(0.5 \cdot \frac{{x}^{2}}{t_1} + \log t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 28.8 |
|---|
| Cost | 59720 |
|---|
\[\begin{array}{l}
t_0 := 1 + \left|x\right|\\
t_1 := \log t_0\\
t_2 := 2 \cdot t_1\\
\mathbf{if}\;x \leq -0.92:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\mathsf{copysign}\left(\frac{1}{\frac{1}{0.5 \cdot \frac{{x}^{2}}{t_0} + \left(\left(t_1 + t_2\right) - t_2\right)}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 28.9 |
|---|
| Cost | 26632 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1000000:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 500:\\
\;\;\;\;\mathsf{copysign}\left(\frac{1}{\frac{1}{\log \left(\sqrt{x \cdot x + 1} + \left|x\right|\right)}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 29.1 |
|---|
| Cost | 26376 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+158}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(-x\right) + \left|x\right|\right), x\right)\\
\mathbf{elif}\;x \leq 500:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 30.0 |
|---|
| Cost | 19908 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-309}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - \frac{0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 30.0 |
|---|
| Cost | 19844 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-309}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(-x\right) + \left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 30.1 |
|---|
| Cost | 19652 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(-x\right) + \left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 40.6 |
|---|
| Cost | 19588 |
|---|
\[\begin{array}{l}
\mathbf{if}\;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 9 |
|---|
| Error | 51.4 |
|---|
| Cost | 19456 |
|---|
\[\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right)
\]
| Alternative 10 |
|---|
| Error | 52.1 |
|---|
| Cost | 13252 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-307}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{x}\right), x\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 58.0 |
|---|
| Cost | 13120 |
|---|
\[\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)
\]