\[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\]
↓
\[\begin{array}{l}
t_0 := \left|x\right| - -1\\
t_1 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_2 := \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{if}\;t_1 \leq -2:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{copysign}\left(\left(-0.041666666666666664 \cdot \left({x}^{4} \cdot \frac{\frac{3}{t_0} + 3}{t_0}\right) + \frac{0.5 \cdot {x}^{2}}{t_0}\right) + \mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
(FPCore (x)
:precision binary64
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
↓
(FPCore (x)
:precision binary64
(let* ((t_0 (- (fabs x) -1.0))
(t_1 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(t_2 (copysign (log (+ (fabs x) (hypot 1.0 x))) x)))
(if (<= t_1 -2.0)
t_2
(if (<= t_1 2e-5)
(copysign
(+
(+
(* -0.041666666666666664 (* (pow x 4.0) (/ (+ (/ 3.0 t_0) 3.0) t_0)))
(/ (* 0.5 (pow x 2.0)) t_0))
(log1p (fabs x)))
x)
t_2))))double code(double x) {
return copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
}
↓
double code(double x) {
double t_0 = fabs(x) - -1.0;
double t_1 = copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
double t_2 = copysign(log((fabs(x) + hypot(1.0, x))), x);
double tmp;
if (t_1 <= -2.0) {
tmp = t_2;
} else if (t_1 <= 2e-5) {
tmp = copysign((((-0.041666666666666664 * (pow(x, 4.0) * (((3.0 / t_0) + 3.0) / t_0))) + ((0.5 * pow(x, 2.0)) / t_0)) + log1p(fabs(x))), x);
} else {
tmp = t_2;
}
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.abs(x) - -1.0;
double t_1 = Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
double t_2 = Math.copySign(Math.log((Math.abs(x) + Math.hypot(1.0, x))), x);
double tmp;
if (t_1 <= -2.0) {
tmp = t_2;
} else if (t_1 <= 2e-5) {
tmp = Math.copySign((((-0.041666666666666664 * (Math.pow(x, 4.0) * (((3.0 / t_0) + 3.0) / t_0))) + ((0.5 * Math.pow(x, 2.0)) / t_0)) + Math.log1p(Math.abs(x))), x);
} else {
tmp = t_2;
}
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.fabs(x) - -1.0
t_1 = math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
t_2 = math.copysign(math.log((math.fabs(x) + math.hypot(1.0, x))), x)
tmp = 0
if t_1 <= -2.0:
tmp = t_2
elif t_1 <= 2e-5:
tmp = math.copysign((((-0.041666666666666664 * (math.pow(x, 4.0) * (((3.0 / t_0) + 3.0) / t_0))) + ((0.5 * math.pow(x, 2.0)) / t_0)) + math.log1p(math.fabs(x))), x)
else:
tmp = t_2
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 = Float64(abs(x) - -1.0)
t_1 = copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x)
t_2 = copysign(log(Float64(abs(x) + hypot(1.0, x))), x)
tmp = 0.0
if (t_1 <= -2.0)
tmp = t_2;
elseif (t_1 <= 2e-5)
tmp = copysign(Float64(Float64(Float64(-0.041666666666666664 * Float64((x ^ 4.0) * Float64(Float64(Float64(3.0 / t_0) + 3.0) / t_0))) + Float64(Float64(0.5 * (x ^ 2.0)) / t_0)) + log1p(abs(x))), x);
else
tmp = t_2;
end
return 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[(N[Abs[x], $MachinePrecision] - -1.0), $MachinePrecision]}, Block[{t$95$1 = 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]}, Block[{t$95$2 = N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]}, If[LessEqual[t$95$1, -2.0], t$95$2, If[LessEqual[t$95$1, 2e-5], N[With[{TMP1 = Abs[N[(N[(N[(-0.041666666666666664 * N[(N[Power[x, 4.0], $MachinePrecision] * N[(N[(N[(3.0 / t$95$0), $MachinePrecision] + 3.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] + N[Log[1 + N[Abs[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], t$95$2]]]]]
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
↓
\begin{array}{l}
t_0 := \left|x\right| - -1\\
t_1 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_2 := \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{if}\;t_1 \leq -2:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{copysign}\left(\left(-0.041666666666666664 \cdot \left({x}^{4} \cdot \frac{\frac{3}{t_0} + 3}{t_0}\right) + \frac{0.5 \cdot {x}^{2}}{t_0}\right) + \mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.1 |
|---|
| Cost | 78728 |
|---|
\[\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.0002:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\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}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.6 |
|---|
| Cost | 78280 |
|---|
\[\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 -2 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 1.0 |
|---|
| Cost | 19976 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.65:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(\left|x\right| + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.9 |
|---|
| Cost | 19976 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.65:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.65:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(\left|x\right| + x\right)\right), x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 1.0 |
|---|
| Cost | 19720 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 6 |
|---|
| Error | 12.2 |
|---|
| Cost | 19588 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\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 7 |
|---|
| Error | 22.5 |
|---|
| Cost | 19328 |
|---|
\[\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)
\]
| Alternative 8 |
|---|
| Error | 52.3 |
|---|
| Cost | 13124 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 58.3 |
|---|
| Cost | 12928 |
|---|
\[\mathsf{copysign}\left(\log x, x\right)
\]