\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-11}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\]
(FPCore (x n)
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
↓
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-11)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-9)
(/ (log1p (/ 1.0 x)) n)
(- (exp (/ x n)) (pow x (/ 1.0 n))))))double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
↓
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
↓
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n):
return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
↓
def code(x, n):
tmp = 0
if (1.0 / n) <= -5e-11:
tmp = math.exp((math.log(x) / n)) / (n * x)
elif (1.0 / n) <= 5e-9:
tmp = math.log1p((1.0 / x)) / n
else:
tmp = math.exp((x / n)) - math.pow(x, (1.0 / n))
return tmp
function code(x, n)
return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n)))
end
↓
function code(x, n)
tmp = 0.0
if (Float64(1.0 / n) <= -5e-11)
tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x));
elseif (Float64(1.0 / n) <= 5e-9)
tmp = Float64(log1p(Float64(1.0 / x)) / n);
else
tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n)));
end
return tmp
end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
↓
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-11], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
↓
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-11}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 1.4 |
|---|
| Cost | 13508 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-11}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 1.5 |
|---|
| Cost | 7436 |
|---|
\[\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{if}\;n \leq -8:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 4.8773133851961986 \cdot 10^{-298}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 3200000:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 1.6 |
|---|
| Cost | 7180 |
|---|
\[\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{if}\;n \leq -8.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 4.8773133851961986 \cdot 10^{-298}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 28000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 6.8 |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{if}\;n \leq -6.2:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -4.100026628795156 \cdot 10^{-309}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 15.6 |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.66:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{+142}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{\frac{0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 29.5 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := \frac{1}{n \cdot x}\\
\mathbf{if}\;n \leq -13.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 1.42 \cdot 10^{-84}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 29.1 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{1}{n}}{x}\\
\mathbf{if}\;n \leq -10:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 1.42 \cdot 10^{-84}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 29.1 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
\mathbf{if}\;n \leq -7.4:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 1.42 \cdot 10^{-84}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 39.5 |
|---|
| Cost | 64 |
|---|
\[0
\]