
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 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));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); 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]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 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));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); 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]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n)))
(t_1
(/
(cbrt
(pow
(-
(- (log x) (log1p x))
(/
(fma
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
0.5
(*
0.16666666666666666
(/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)))
n))
3.0))
(- n))))
(if (<= x 5.5e-216)
t_1
(if (<= x 8e-192) (- 1.0 t_0) (if (<= x 47000.0) t_1 (/ (/ t_0 n) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = cbrt(pow(((log(x) - log1p(x)) - (fma((pow(log1p(x), 2.0) - pow(log(x), 2.0)), 0.5, (0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n))) / n)), 3.0)) / -n;
double tmp;
if (x <= 5.5e-216) {
tmp = t_1;
} else if (x <= 8e-192) {
tmp = 1.0 - t_0;
} else if (x <= 47000.0) {
tmp = t_1;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(cbrt((Float64(Float64(log(x) - log1p(x)) - Float64(fma(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), 0.5, Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n)) ^ 3.0)) / Float64(-n)) tmp = 0.0 if (x <= 5.5e-216) tmp = t_1; elseif (x <= 8e-192) tmp = Float64(1.0 - t_0); elseif (x <= 47000.0) tmp = t_1; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Power[N[(N[(N[Log[x], $MachinePrecision] - N[Log[1 + x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 5.5e-216], t$95$1, If[LessEqual[x, 8e-192], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 47000.0], t$95$1, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\sqrt[3]{{\left(\left(\log x - \mathsf{log1p}\left(x\right)\right) - \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}\right)}{n}\right)}^{3}}}{-n}\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-216}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-192}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 47000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 5.49999999999999991e-216 or 8.0000000000000008e-192 < x < 47000Initial program 39.0%
Taylor expanded in n around -inf 77.4%
Simplified77.4%
add-cbrt-cube85.4%
pow385.4%
Applied egg-rr85.4%
if 5.49999999999999991e-216 < x < 8.0000000000000008e-192Initial program 90.4%
Taylor expanded in x around 0 90.4%
*-rgt-identity90.4%
associate-*l/90.4%
associate-/l*90.4%
exp-to-pow90.4%
Simplified90.4%
if 47000 < x Initial program 68.8%
Taylor expanded in x around inf 98.0%
associate-/r*99.1%
mul-1-neg99.1%
log-rec99.1%
mul-1-neg99.1%
distribute-neg-frac99.1%
mul-1-neg99.1%
remove-double-neg99.1%
*-rgt-identity99.1%
associate-/l*99.1%
exp-to-pow99.1%
Simplified99.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ 0.5 (pow n 2.0))) (t_1 (pow x (/ 1.0 n))) (t_2 (/ t_1 n)))
(if (<= (/ 1.0 n) -1e-89)
(/ t_2 x)
(if (<= (/ 1.0 n) 1.2e-62)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(if (<= (/ 1.0 n) 1e-5)
(/
(+
t_2
(*
t_1
(+
(/ (+ t_0 (/ -0.5 n)) x)
(/
(+
(/ 0.16666666666666666 (pow n 3.0))
(- (/ 0.3333333333333333 n) t_0))
(pow x 2.0)))))
x)
(- (exp (/ (log1p x) n)) t_1))))))
double code(double x, double n) {
double t_0 = 0.5 / pow(n, 2.0);
double t_1 = pow(x, (1.0 / n));
double t_2 = t_1 / n;
double tmp;
if ((1.0 / n) <= -1e-89) {
tmp = t_2 / x;
} else if ((1.0 / n) <= 1.2e-62) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = (t_2 + (t_1 * (((t_0 + (-0.5 / n)) / x) + (((0.16666666666666666 / pow(n, 3.0)) + ((0.3333333333333333 / n) - t_0)) / pow(x, 2.0))))) / x;
} else {
tmp = exp((log1p(x) / n)) - t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = 0.5 / Math.pow(n, 2.0);
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = t_1 / n;
double tmp;
if ((1.0 / n) <= -1e-89) {
tmp = t_2 / x;
} else if ((1.0 / n) <= 1.2e-62) {
tmp = (Math.log1p(x) + ((0.5 * ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n)) - Math.log(x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = (t_2 + (t_1 * (((t_0 + (-0.5 / n)) / x) + (((0.16666666666666666 / Math.pow(n, 3.0)) + ((0.3333333333333333 / n) - t_0)) / Math.pow(x, 2.0))))) / x;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_1;
}
return tmp;
}
def code(x, n): t_0 = 0.5 / math.pow(n, 2.0) t_1 = math.pow(x, (1.0 / n)) t_2 = t_1 / n tmp = 0 if (1.0 / n) <= -1e-89: tmp = t_2 / x elif (1.0 / n) <= 1.2e-62: tmp = (math.log1p(x) + ((0.5 * ((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n)) - math.log(x))) / n elif (1.0 / n) <= 1e-5: tmp = (t_2 + (t_1 * (((t_0 + (-0.5 / n)) / x) + (((0.16666666666666666 / math.pow(n, 3.0)) + ((0.3333333333333333 / n) - t_0)) / math.pow(x, 2.0))))) / x else: tmp = math.exp((math.log1p(x) / n)) - t_1 return tmp
function code(x, n) t_0 = Float64(0.5 / (n ^ 2.0)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(t_1 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-89) tmp = Float64(t_2 / x); elseif (Float64(1.0 / n) <= 1.2e-62) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(Float64(t_2 + Float64(t_1 * Float64(Float64(Float64(t_0 + Float64(-0.5 / n)) / x) + Float64(Float64(Float64(0.16666666666666666 / (n ^ 3.0)) + Float64(Float64(0.3333333333333333 / n) - t_0)) / (x ^ 2.0))))) / x); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(0.5 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-89], N[(t$95$2 / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.2e-62], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(N[(t$95$2 + N[(t$95$1 * N[(N[(N[(t$95$0 + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(N[(N[(0.16666666666666666 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 / n), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{{n}^{2}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{t\_1}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-89}:\\
\;\;\;\;\frac{t\_2}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{t\_2 + t\_1 \cdot \left(\frac{t\_0 + \frac{-0.5}{n}}{x} + \frac{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - t\_0\right)}{{x}^{2}}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.00000000000000004e-89Initial program 79.6%
Taylor expanded in x around inf 88.8%
associate-/r*90.0%
mul-1-neg90.0%
log-rec90.0%
mul-1-neg90.0%
distribute-neg-frac90.0%
mul-1-neg90.0%
remove-double-neg90.0%
*-rgt-identity90.0%
associate-/l*90.0%
exp-to-pow90.0%
Simplified90.0%
if -1.00000000000000004e-89 < (/.f64 #s(literal 1 binary64) n) < 1.19999999999999992e-62Initial program 39.5%
Taylor expanded in n around inf 88.6%
associate--l+88.6%
log1p-define88.6%
+-commutative88.6%
associate--r+88.6%
distribute-lft-out--88.6%
div-sub88.6%
log1p-define88.6%
Simplified88.6%
if 1.19999999999999992e-62 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000008e-5Initial program 9.3%
Taylor expanded in x around inf 69.6%
Simplified69.6%
if 1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n) Initial program 53.9%
Taylor expanded in n around 0 53.9%
log1p-define97.5%
*-rgt-identity97.5%
associate-*l/97.5%
associate-/l*97.5%
exp-to-pow97.5%
Simplified97.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 n)))
(if (<= (/ 1.0 n) -1e-89)
(/ t_1 x)
(if (<= (/ 1.0 n) 1.2e-62)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(if (<= (/ 1.0 n) 1e-5)
(/ (fma t_0 (/ (+ (/ 0.5 (pow n 2.0)) (/ -0.5 n)) x) t_1) x)
(- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / n;
double tmp;
if ((1.0 / n) <= -1e-89) {
tmp = t_1 / x;
} else if ((1.0 / n) <= 1.2e-62) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = fma(t_0, (((0.5 / pow(n, 2.0)) + (-0.5 / n)) / x), t_1) / x;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-89) tmp = Float64(t_1 / x); elseif (Float64(1.0 / n) <= 1.2e-62) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(fma(t_0, Float64(Float64(Float64(0.5 / (n ^ 2.0)) + Float64(-0.5 / n)) / x), t_1) / x); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-89], N[(t$95$1 / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.2e-62], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(N[(t$95$0 * N[(N[(N[(0.5 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + t$95$1), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-89}:\\
\;\;\;\;\frac{t\_1}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, \frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x}, t\_1\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.00000000000000004e-89Initial program 79.6%
Taylor expanded in x around inf 88.8%
associate-/r*90.0%
mul-1-neg90.0%
log-rec90.0%
mul-1-neg90.0%
distribute-neg-frac90.0%
mul-1-neg90.0%
remove-double-neg90.0%
*-rgt-identity90.0%
associate-/l*90.0%
exp-to-pow90.0%
Simplified90.0%
if -1.00000000000000004e-89 < (/.f64 #s(literal 1 binary64) n) < 1.19999999999999992e-62Initial program 39.5%
Taylor expanded in n around inf 88.6%
associate--l+88.6%
log1p-define88.6%
+-commutative88.6%
associate--r+88.6%
distribute-lft-out--88.6%
div-sub88.6%
log1p-define88.6%
Simplified88.6%
if 1.19999999999999992e-62 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000008e-5Initial program 9.3%
Taylor expanded in x around inf 68.8%
Simplified68.8%
if 1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n) Initial program 53.9%
Taylor expanded in n around 0 53.9%
log1p-define97.5%
*-rgt-identity97.5%
associate-*l/97.5%
associate-/l*97.5%
exp-to-pow97.5%
Simplified97.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 n)))
(if (<= (/ 1.0 n) -1e-89)
(/ t_1 x)
(if (<= (/ 1.0 n) 1.2e-62)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1e-5)
(/ (fma t_0 (/ (+ (/ 0.5 (pow n 2.0)) (/ -0.5 n)) x) t_1) x)
(- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / n;
double tmp;
if ((1.0 / n) <= -1e-89) {
tmp = t_1 / x;
} else if ((1.0 / n) <= 1.2e-62) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = fma(t_0, (((0.5 / pow(n, 2.0)) + (-0.5 / n)) / x), t_1) / x;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-89) tmp = Float64(t_1 / x); elseif (Float64(1.0 / n) <= 1.2e-62) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(fma(t_0, Float64(Float64(Float64(0.5 / (n ^ 2.0)) + Float64(-0.5 / n)) / x), t_1) / x); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-89], N[(t$95$1 / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.2e-62], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(N[(t$95$0 * N[(N[(N[(0.5 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + t$95$1), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-89}:\\
\;\;\;\;\frac{t\_1}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, \frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x}, t\_1\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.00000000000000004e-89Initial program 79.6%
Taylor expanded in x around inf 88.8%
associate-/r*90.0%
mul-1-neg90.0%
log-rec90.0%
mul-1-neg90.0%
distribute-neg-frac90.0%
mul-1-neg90.0%
remove-double-neg90.0%
*-rgt-identity90.0%
associate-/l*90.0%
exp-to-pow90.0%
Simplified90.0%
if -1.00000000000000004e-89 < (/.f64 #s(literal 1 binary64) n) < 1.19999999999999992e-62Initial program 39.5%
Taylor expanded in n around inf 88.6%
log1p-define88.6%
Simplified88.6%
if 1.19999999999999992e-62 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000008e-5Initial program 9.3%
Taylor expanded in x around inf 68.8%
Simplified68.8%
if 1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n) Initial program 53.9%
Taylor expanded in n around 0 53.9%
log1p-define97.5%
*-rgt-identity97.5%
associate-*l/97.5%
associate-/l*97.5%
exp-to-pow97.5%
Simplified97.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (- (log1p x) (log x)) n)))
(if (<= n -35000000000.0)
t_1
(if (<= n 11600.0)
(- (exp (/ (log1p x) n)) t_0)
(if (<= n 8e+61)
(/
(+
(/ t_0 n)
(/
(-
(/ 0.3333333333333333 (pow x 2.0))
(+ (/ 0.5 x) (/ 0.25 (pow x 3.0))))
n))
x)
t_1)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (log1p(x) - log(x)) / n;
double tmp;
if (n <= -35000000000.0) {
tmp = t_1;
} else if (n <= 11600.0) {
tmp = exp((log1p(x) / n)) - t_0;
} else if (n <= 8e+61) {
tmp = ((t_0 / n) + (((0.3333333333333333 / pow(x, 2.0)) - ((0.5 / x) + (0.25 / pow(x, 3.0)))) / n)) / x;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (Math.log1p(x) - Math.log(x)) / n;
double tmp;
if (n <= -35000000000.0) {
tmp = t_1;
} else if (n <= 11600.0) {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
} else if (n <= 8e+61) {
tmp = ((t_0 / n) + (((0.3333333333333333 / Math.pow(x, 2.0)) - ((0.5 / x) + (0.25 / Math.pow(x, 3.0)))) / n)) / x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (math.log1p(x) - math.log(x)) / n tmp = 0 if n <= -35000000000.0: tmp = t_1 elif n <= 11600.0: tmp = math.exp((math.log1p(x) / n)) - t_0 elif n <= 8e+61: tmp = ((t_0 / n) + (((0.3333333333333333 / math.pow(x, 2.0)) - ((0.5 / x) + (0.25 / math.pow(x, 3.0)))) / n)) / x else: tmp = t_1 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(log1p(x) - log(x)) / n) tmp = 0.0 if (n <= -35000000000.0) tmp = t_1; elseif (n <= 11600.0) tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); elseif (n <= 8e+61) tmp = Float64(Float64(Float64(t_0 / n) + Float64(Float64(Float64(0.3333333333333333 / (x ^ 2.0)) - Float64(Float64(0.5 / x) + Float64(0.25 / (x ^ 3.0)))) / n)) / x); else tmp = t_1; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -35000000000.0], t$95$1, If[LessEqual[n, 11600.0], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[n, 8e+61], N[(N[(N[(t$95$0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 / x), $MachinePrecision] + N[(0.25 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{if}\;n \leq -35000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq 11600:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\mathbf{elif}\;n \leq 8 \cdot 10^{+61}:\\
\;\;\;\;\frac{\frac{t\_0}{n} + \frac{\frac{0.3333333333333333}{{x}^{2}} - \left(\frac{0.5}{x} + \frac{0.25}{{x}^{3}}\right)}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if n < -3.5e10 or 7.9999999999999996e61 < n Initial program 36.9%
Taylor expanded in n around inf 84.2%
log1p-define84.3%
Simplified84.3%
if -3.5e10 < n < 11600Initial program 81.0%
Taylor expanded in n around 0 81.0%
log1p-define97.2%
*-rgt-identity97.2%
associate-*l/97.2%
associate-/l*97.2%
exp-to-pow97.2%
Simplified97.2%
if 11600 < n < 7.9999999999999996e61Initial program 9.3%
Taylor expanded in x around inf 68.6%
Simplified68.6%
Taylor expanded in n around inf 68.6%
associate-*r/68.6%
metadata-eval68.6%
+-commutative68.6%
associate-*r/68.6%
metadata-eval68.6%
associate-*r/68.6%
metadata-eval68.6%
Simplified68.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log1p x) (log x)) n)))
(if (<= n -48000000000.0)
t_0
(if (<= n 920.0)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))
(if (<= n 7e+61) (/ (exp (/ (log x) n)) (* x n)) t_0)))))
double code(double x, double n) {
double t_0 = (log1p(x) - log(x)) / n;
double tmp;
if (n <= -48000000000.0) {
tmp = t_0;
} else if (n <= 920.0) {
tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
} else if (n <= 7e+61) {
tmp = exp((log(x) / n)) / (x * n);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (Math.log1p(x) - Math.log(x)) / n;
double tmp;
if (n <= -48000000000.0) {
tmp = t_0;
} else if (n <= 920.0) {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
} else if (n <= 7e+61) {
tmp = Math.exp((Math.log(x) / n)) / (x * n);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = (math.log1p(x) - math.log(x)) / n tmp = 0 if n <= -48000000000.0: tmp = t_0 elif n <= 920.0: tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n)) elif n <= 7e+61: tmp = math.exp((math.log(x) / n)) / (x * n) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(Float64(log1p(x) - log(x)) / n) tmp = 0.0 if (n <= -48000000000.0) tmp = t_0; elseif (n <= 920.0) tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); elseif (n <= 7e+61) tmp = Float64(exp(Float64(log(x) / n)) / Float64(x * n)); else tmp = t_0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -48000000000.0], t$95$0, If[LessEqual[n, 920.0], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7e+61], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{if}\;n \leq -48000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 920:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 7 \cdot 10^{+61}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -4.8e10 or 7.00000000000000036e61 < n Initial program 36.9%
Taylor expanded in n around inf 84.2%
log1p-define84.3%
Simplified84.3%
if -4.8e10 < n < 920Initial program 81.0%
Taylor expanded in n around 0 81.0%
log1p-define97.2%
*-rgt-identity97.2%
associate-*l/97.2%
associate-/l*97.2%
exp-to-pow97.2%
Simplified97.2%
if 920 < n < 7.00000000000000036e61Initial program 9.3%
Taylor expanded in x around inf 67.4%
mul-1-neg67.4%
log-rec67.4%
mul-1-neg67.4%
distribute-neg-frac67.4%
mul-1-neg67.4%
remove-double-neg67.4%
*-commutative67.4%
Simplified67.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -1e-89)
t_1
(if (<= (/ 1.0 n) 1.2e-62)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 4e-51)
(/ (- 1.0 (/ 0.5 x)) (* x n))
(if (<= (/ 1.0 n) 2e-31)
(/ (log x) (- n))
(if (<= (/ 1.0 n) 1e-5)
t_1
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n)))))))
t_0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1e-89) {
tmp = t_1;
} else if ((1.0 / n) <= 1.2e-62) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 4e-51) {
tmp = (1.0 - (0.5 / x)) / (x * n);
} else if ((1.0 / n) <= 2e-31) {
tmp = log(x) / -n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1e-89) {
tmp = t_1;
} else if ((1.0 / n) <= 1.2e-62) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 4e-51) {
tmp = (1.0 - (0.5 / x)) / (x * n);
} else if ((1.0 / n) <= 2e-31) {
tmp = Math.log(x) / -n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -1e-89: tmp = t_1 elif (1.0 / n) <= 1.2e-62: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 4e-51: tmp = (1.0 - (0.5 / x)) / (x * n) elif (1.0 / n) <= 2e-31: tmp = math.log(x) / -n elif (1.0 / n) <= 1e-5: tmp = t_1 else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1e-89) tmp = t_1; elseif (Float64(1.0 / n) <= 1.2e-62) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 4e-51) tmp = Float64(Float64(1.0 - Float64(0.5 / x)) / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-31) tmp = Float64(log(x) / Float64(-n)); elseif (Float64(1.0 / n) <= 1e-5) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) + Float64(0.5 * Float64(-1.0 / n))))))) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-89], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.2e-62], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-51], N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-31], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], t$95$1, N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-89}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 1.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-51}:\\
\;\;\;\;\frac{1 - \frac{0.5}{x}}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-31}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.00000000000000004e-89 or 2e-31 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000008e-5Initial program 76.4%
Taylor expanded in x around inf 88.4%
associate-/r*89.6%
mul-1-neg89.6%
log-rec89.6%
mul-1-neg89.6%
distribute-neg-frac89.6%
mul-1-neg89.6%
remove-double-neg89.6%
*-rgt-identity89.6%
associate-/l*89.6%
exp-to-pow89.6%
Simplified89.6%
if -1.00000000000000004e-89 < (/.f64 #s(literal 1 binary64) n) < 1.19999999999999992e-62Initial program 39.5%
Taylor expanded in n around inf 88.6%
log1p-define88.6%
Simplified88.6%
if 1.19999999999999992e-62 < (/.f64 #s(literal 1 binary64) n) < 4e-51Initial program 5.4%
Taylor expanded in x around inf 99.6%
Simplified99.6%
Taylor expanded in n around inf 99.8%
associate-*r/99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
if 4e-51 < (/.f64 #s(literal 1 binary64) n) < 2e-31Initial program 3.4%
Taylor expanded in x around 0 3.4%
*-rgt-identity3.4%
associate-*l/3.4%
associate-/l*3.4%
exp-to-pow3.4%
Simplified3.4%
Taylor expanded in n around inf 99.6%
associate-*r/99.6%
neg-mul-199.6%
Simplified99.6%
if 1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n) Initial program 53.9%
Taylor expanded in x around 0 83.0%
Final simplification88.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -1e-89)
t_1
(if (<= (/ 1.0 n) 1.2e-62)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 4e-51)
(/ (- 1.0 (/ 0.5 x)) (* x n))
(if (<= (/ 1.0 n) 2e-31)
(/ (log x) (- n))
(if (<= (/ 1.0 n) 1e-5)
t_1
(if (<= (/ 1.0 n) 1e+133)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ (/ 1.0 x) n)))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1e-89) {
tmp = t_1;
} else if ((1.0 / n) <= 1.2e-62) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 4e-51) {
tmp = (1.0 - (0.5 / x)) / (x * n);
} else if ((1.0 / n) <= 2e-31) {
tmp = log(x) / -n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+133) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1(((1.0 / x) / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1e-89) {
tmp = t_1;
} else if ((1.0 / n) <= 1.2e-62) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 4e-51) {
tmp = (1.0 - (0.5 / x)) / (x * n);
} else if ((1.0 / n) <= 2e-31) {
tmp = Math.log(x) / -n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+133) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1(((1.0 / x) / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -1e-89: tmp = t_1 elif (1.0 / n) <= 1.2e-62: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 4e-51: tmp = (1.0 - (0.5 / x)) / (x * n) elif (1.0 / n) <= 2e-31: tmp = math.log(x) / -n elif (1.0 / n) <= 1e-5: tmp = t_1 elif (1.0 / n) <= 1e+133: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1(((1.0 / x) / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1e-89) tmp = t_1; elseif (Float64(1.0 / n) <= 1.2e-62) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 4e-51) tmp = Float64(Float64(1.0 - Float64(0.5 / x)) / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-31) tmp = Float64(log(x) / Float64(-n)); elseif (Float64(1.0 / n) <= 1e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+133) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(Float64(1.0 / x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-89], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.2e-62], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-51], N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-31], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+133], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-89}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 1.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-51}:\\
\;\;\;\;\frac{1 - \frac{0.5}{x}}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-31}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+133}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.00000000000000004e-89 or 2e-31 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000008e-5Initial program 76.4%
Taylor expanded in x around inf 88.4%
associate-/r*89.6%
mul-1-neg89.6%
log-rec89.6%
mul-1-neg89.6%
distribute-neg-frac89.6%
mul-1-neg89.6%
remove-double-neg89.6%
*-rgt-identity89.6%
associate-/l*89.6%
exp-to-pow89.6%
Simplified89.6%
if -1.00000000000000004e-89 < (/.f64 #s(literal 1 binary64) n) < 1.19999999999999992e-62Initial program 39.5%
Taylor expanded in n around inf 88.6%
log1p-define88.6%
Simplified88.6%
if 1.19999999999999992e-62 < (/.f64 #s(literal 1 binary64) n) < 4e-51Initial program 5.4%
Taylor expanded in x around inf 99.6%
Simplified99.6%
Taylor expanded in n around inf 99.8%
associate-*r/99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
if 4e-51 < (/.f64 #s(literal 1 binary64) n) < 2e-31Initial program 3.4%
Taylor expanded in x around 0 3.4%
*-rgt-identity3.4%
associate-*l/3.4%
associate-/l*3.4%
exp-to-pow3.4%
Simplified3.4%
Taylor expanded in n around inf 99.6%
associate-*r/99.6%
neg-mul-199.6%
Simplified99.6%
if 1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n) < 1e133Initial program 79.7%
Taylor expanded in x around 0 79.7%
if 1e133 < (/.f64 #s(literal 1 binary64) n) Initial program 15.2%
Taylor expanded in x around inf 0.4%
mul-1-neg0.4%
log-rec0.4%
mul-1-neg0.4%
distribute-neg-frac0.4%
mul-1-neg0.4%
remove-double-neg0.4%
*-commutative0.4%
Simplified0.4%
Taylor expanded in n around inf 64.8%
*-commutative64.8%
Simplified64.8%
log1p-expm1-u87.9%
associate-/r*87.9%
Applied egg-rr87.9%
Final simplification88.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- 1.0 t_0)) (t_2 (/ (log x) (- n))))
(if (<= x 7.4e-286)
t_1
(if (<= x 6.4e-259)
t_2
(if (<= x 8.2e-241)
t_1
(if (<= x 3.15e-223)
t_2
(if (<= x 1.22e-195)
t_1
(if (<= x 1.18e-130)
t_2
(if (<= x 3.9)
(log1p (expm1 (/ (/ 1.0 x) n)))
(/ (/ t_0 n) x))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double t_2 = log(x) / -n;
double tmp;
if (x <= 7.4e-286) {
tmp = t_1;
} else if (x <= 6.4e-259) {
tmp = t_2;
} else if (x <= 8.2e-241) {
tmp = t_1;
} else if (x <= 3.15e-223) {
tmp = t_2;
} else if (x <= 1.22e-195) {
tmp = t_1;
} else if (x <= 1.18e-130) {
tmp = t_2;
} else if (x <= 3.9) {
tmp = log1p(expm1(((1.0 / x) / n)));
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double t_2 = Math.log(x) / -n;
double tmp;
if (x <= 7.4e-286) {
tmp = t_1;
} else if (x <= 6.4e-259) {
tmp = t_2;
} else if (x <= 8.2e-241) {
tmp = t_1;
} else if (x <= 3.15e-223) {
tmp = t_2;
} else if (x <= 1.22e-195) {
tmp = t_1;
} else if (x <= 1.18e-130) {
tmp = t_2;
} else if (x <= 3.9) {
tmp = Math.log1p(Math.expm1(((1.0 / x) / n)));
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 - t_0 t_2 = math.log(x) / -n tmp = 0 if x <= 7.4e-286: tmp = t_1 elif x <= 6.4e-259: tmp = t_2 elif x <= 8.2e-241: tmp = t_1 elif x <= 3.15e-223: tmp = t_2 elif x <= 1.22e-195: tmp = t_1 elif x <= 1.18e-130: tmp = t_2 elif x <= 3.9: tmp = math.log1p(math.expm1(((1.0 / x) / n))) else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 - t_0) t_2 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 7.4e-286) tmp = t_1; elseif (x <= 6.4e-259) tmp = t_2; elseif (x <= 8.2e-241) tmp = t_1; elseif (x <= 3.15e-223) tmp = t_2; elseif (x <= 1.22e-195) tmp = t_1; elseif (x <= 1.18e-130) tmp = t_2; elseif (x <= 3.9) tmp = log1p(expm1(Float64(Float64(1.0 / x) / n))); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 7.4e-286], t$95$1, If[LessEqual[x, 6.4e-259], t$95$2, If[LessEqual[x, 8.2e-241], t$95$1, If[LessEqual[x, 3.15e-223], t$95$2, If[LessEqual[x, 1.22e-195], t$95$1, If[LessEqual[x, 1.18e-130], t$95$2, If[LessEqual[x, 3.9], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := 1 - t\_0\\
t_2 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 7.4 \cdot 10^{-286}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-259}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-241}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.15 \cdot 10^{-223}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-195}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.18 \cdot 10^{-130}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 3.9:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 7.3999999999999998e-286 or 6.39999999999999975e-259 < x < 8.1999999999999997e-241 or 3.14999999999999993e-223 < x < 1.2200000000000001e-195Initial program 85.1%
Taylor expanded in x around 0 85.1%
*-rgt-identity85.1%
associate-*l/85.1%
associate-/l*85.1%
exp-to-pow85.1%
Simplified85.1%
if 7.3999999999999998e-286 < x < 6.39999999999999975e-259 or 8.1999999999999997e-241 < x < 3.14999999999999993e-223 or 1.2200000000000001e-195 < x < 1.17999999999999993e-130Initial program 28.6%
Taylor expanded in x around 0 28.6%
*-rgt-identity28.6%
associate-*l/28.6%
associate-/l*28.6%
exp-to-pow28.6%
Simplified28.6%
Taylor expanded in n around inf 67.1%
associate-*r/67.1%
neg-mul-167.1%
Simplified67.1%
if 1.17999999999999993e-130 < x < 3.89999999999999991Initial program 36.5%
Taylor expanded in x around inf 34.1%
mul-1-neg34.1%
log-rec34.1%
mul-1-neg34.1%
distribute-neg-frac34.1%
mul-1-neg34.1%
remove-double-neg34.1%
*-commutative34.1%
Simplified34.1%
Taylor expanded in n around inf 21.1%
*-commutative21.1%
Simplified21.1%
log1p-expm1-u53.7%
associate-/r*53.7%
Applied egg-rr53.7%
if 3.89999999999999991 < x Initial program 68.2%
Taylor expanded in x around inf 97.5%
associate-/r*98.6%
mul-1-neg98.6%
log-rec98.6%
mul-1-neg98.6%
distribute-neg-frac98.6%
mul-1-neg98.6%
remove-double-neg98.6%
*-rgt-identity98.6%
associate-/l*98.6%
exp-to-pow98.6%
Simplified98.6%
Final simplification79.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- 1.0 t_0)) (t_2 (/ (log x) (- n))))
(if (<= x 2.55e-289)
t_1
(if (<= x 6.4e-259)
t_2
(if (<= x 2.6e-242)
t_1
(if (<= x 4.5e-223)
t_2
(if (<= x 1.3e-195) t_1 (if (<= x 0.175) t_2 (/ (/ t_0 n) x)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double t_2 = log(x) / -n;
double tmp;
if (x <= 2.55e-289) {
tmp = t_1;
} else if (x <= 6.4e-259) {
tmp = t_2;
} else if (x <= 2.6e-242) {
tmp = t_1;
} else if (x <= 4.5e-223) {
tmp = t_2;
} else if (x <= 1.3e-195) {
tmp = t_1;
} else if (x <= 0.175) {
tmp = t_2;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = 1.0d0 - t_0
t_2 = log(x) / -n
if (x <= 2.55d-289) then
tmp = t_1
else if (x <= 6.4d-259) then
tmp = t_2
else if (x <= 2.6d-242) then
tmp = t_1
else if (x <= 4.5d-223) then
tmp = t_2
else if (x <= 1.3d-195) then
tmp = t_1
else if (x <= 0.175d0) then
tmp = t_2
else
tmp = (t_0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double t_2 = Math.log(x) / -n;
double tmp;
if (x <= 2.55e-289) {
tmp = t_1;
} else if (x <= 6.4e-259) {
tmp = t_2;
} else if (x <= 2.6e-242) {
tmp = t_1;
} else if (x <= 4.5e-223) {
tmp = t_2;
} else if (x <= 1.3e-195) {
tmp = t_1;
} else if (x <= 0.175) {
tmp = t_2;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 - t_0 t_2 = math.log(x) / -n tmp = 0 if x <= 2.55e-289: tmp = t_1 elif x <= 6.4e-259: tmp = t_2 elif x <= 2.6e-242: tmp = t_1 elif x <= 4.5e-223: tmp = t_2 elif x <= 1.3e-195: tmp = t_1 elif x <= 0.175: tmp = t_2 else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 - t_0) t_2 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 2.55e-289) tmp = t_1; elseif (x <= 6.4e-259) tmp = t_2; elseif (x <= 2.6e-242) tmp = t_1; elseif (x <= 4.5e-223) tmp = t_2; elseif (x <= 1.3e-195) tmp = t_1; elseif (x <= 0.175) tmp = t_2; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = 1.0 - t_0; t_2 = log(x) / -n; tmp = 0.0; if (x <= 2.55e-289) tmp = t_1; elseif (x <= 6.4e-259) tmp = t_2; elseif (x <= 2.6e-242) tmp = t_1; elseif (x <= 4.5e-223) tmp = t_2; elseif (x <= 1.3e-195) tmp = t_1; elseif (x <= 0.175) tmp = t_2; else tmp = (t_0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 2.55e-289], t$95$1, If[LessEqual[x, 6.4e-259], t$95$2, If[LessEqual[x, 2.6e-242], t$95$1, If[LessEqual[x, 4.5e-223], t$95$2, If[LessEqual[x, 1.3e-195], t$95$1, If[LessEqual[x, 0.175], t$95$2, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := 1 - t\_0\\
t_2 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 2.55 \cdot 10^{-289}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-259}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-242}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-223}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-195}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.175:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 2.5499999999999998e-289 or 6.39999999999999975e-259 < x < 2.60000000000000017e-242 or 4.49999999999999968e-223 < x < 1.3000000000000001e-195Initial program 85.1%
Taylor expanded in x around 0 85.1%
*-rgt-identity85.1%
associate-*l/85.1%
associate-/l*85.1%
exp-to-pow85.1%
Simplified85.1%
if 2.5499999999999998e-289 < x < 6.39999999999999975e-259 or 2.60000000000000017e-242 < x < 4.49999999999999968e-223 or 1.3000000000000001e-195 < x < 0.17499999999999999Initial program 32.9%
Taylor expanded in x around 0 32.9%
*-rgt-identity32.9%
associate-*l/32.9%
associate-/l*32.9%
exp-to-pow32.9%
Simplified32.9%
Taylor expanded in n around inf 56.7%
associate-*r/56.7%
neg-mul-156.7%
Simplified56.7%
if 0.17499999999999999 < x Initial program 67.7%
Taylor expanded in x around inf 96.8%
associate-/r*97.9%
mul-1-neg97.9%
log-rec97.9%
mul-1-neg97.9%
distribute-neg-frac97.9%
mul-1-neg97.9%
remove-double-neg97.9%
*-rgt-identity97.9%
associate-/l*97.9%
exp-to-pow97.9%
Simplified97.9%
Final simplification77.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log x) (- n))))
(if (<= x 6.2e-289)
t_0
(if (<= x 6.4e-259)
t_1
(if (<= x 3.2e-242)
t_0
(if (<= x 2.2e-223)
t_1
(if (<= x 1.25e-195)
t_0
(if (<= x 0.68) t_1 (/ (/ (- 1.0 (/ 0.5 x)) n) x)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(x) / -n;
double tmp;
if (x <= 6.2e-289) {
tmp = t_0;
} else if (x <= 6.4e-259) {
tmp = t_1;
} else if (x <= 3.2e-242) {
tmp = t_0;
} else if (x <= 2.2e-223) {
tmp = t_1;
} else if (x <= 1.25e-195) {
tmp = t_0;
} else if (x <= 0.68) {
tmp = t_1;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(x) / -n
if (x <= 6.2d-289) then
tmp = t_0
else if (x <= 6.4d-259) then
tmp = t_1
else if (x <= 3.2d-242) then
tmp = t_0
else if (x <= 2.2d-223) then
tmp = t_1
else if (x <= 1.25d-195) then
tmp = t_0
else if (x <= 0.68d0) then
tmp = t_1
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(x) / -n;
double tmp;
if (x <= 6.2e-289) {
tmp = t_0;
} else if (x <= 6.4e-259) {
tmp = t_1;
} else if (x <= 3.2e-242) {
tmp = t_0;
} else if (x <= 2.2e-223) {
tmp = t_1;
} else if (x <= 1.25e-195) {
tmp = t_0;
} else if (x <= 0.68) {
tmp = t_1;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(x) / -n tmp = 0 if x <= 6.2e-289: tmp = t_0 elif x <= 6.4e-259: tmp = t_1 elif x <= 3.2e-242: tmp = t_0 elif x <= 2.2e-223: tmp = t_1 elif x <= 1.25e-195: tmp = t_0 elif x <= 0.68: tmp = t_1 else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 6.2e-289) tmp = t_0; elseif (x <= 6.4e-259) tmp = t_1; elseif (x <= 3.2e-242) tmp = t_0; elseif (x <= 2.2e-223) tmp = t_1; elseif (x <= 1.25e-195) tmp = t_0; elseif (x <= 0.68) tmp = t_1; else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(x) / -n; tmp = 0.0; if (x <= 6.2e-289) tmp = t_0; elseif (x <= 6.4e-259) tmp = t_1; elseif (x <= 3.2e-242) tmp = t_0; elseif (x <= 2.2e-223) tmp = t_1; elseif (x <= 1.25e-195) tmp = t_0; elseif (x <= 0.68) tmp = t_1; else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 6.2e-289], t$95$0, If[LessEqual[x, 6.4e-259], t$95$1, If[LessEqual[x, 3.2e-242], t$95$0, If[LessEqual[x, 2.2e-223], t$95$1, If[LessEqual[x, 1.25e-195], t$95$0, If[LessEqual[x, 0.68], t$95$1, N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 6.2 \cdot 10^{-289}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-259}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-242}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-223}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-195}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 6.2e-289 or 6.39999999999999975e-259 < x < 3.19999999999999999e-242 or 2.20000000000000009e-223 < x < 1.25000000000000002e-195Initial program 85.1%
Taylor expanded in x around 0 85.1%
*-rgt-identity85.1%
associate-*l/85.1%
associate-/l*85.1%
exp-to-pow85.1%
Simplified85.1%
if 6.2e-289 < x < 6.39999999999999975e-259 or 3.19999999999999999e-242 < x < 2.20000000000000009e-223 or 1.25000000000000002e-195 < x < 0.680000000000000049Initial program 32.9%
Taylor expanded in x around 0 32.9%
*-rgt-identity32.9%
associate-*l/32.9%
associate-/l*32.9%
exp-to-pow32.9%
Simplified32.9%
Taylor expanded in n around inf 56.7%
associate-*r/56.7%
neg-mul-156.7%
Simplified56.7%
if 0.680000000000000049 < x Initial program 67.7%
Taylor expanded in x around inf 87.3%
Simplified88.2%
Taylor expanded in n around inf 70.2%
associate-*r/70.2%
metadata-eval70.2%
Simplified70.2%
Final simplification65.7%
(FPCore (x n) :precision binary64 (if (<= x 0.68) (/ (log x) (- n)) (/ (/ (- 1.0 (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = log(x) / -n;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.68d0) then
tmp = log(x) / -n
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = Math.log(x) / -n;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.68: tmp = math.log(x) / -n else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.68) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.68) tmp = log(x) / -n; else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.68], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 43.0%
Taylor expanded in x around 0 43.0%
*-rgt-identity43.0%
associate-*l/43.0%
associate-/l*43.0%
exp-to-pow43.0%
Simplified43.0%
Taylor expanded in n around inf 50.1%
associate-*r/50.1%
neg-mul-150.1%
Simplified50.1%
if 0.680000000000000049 < x Initial program 67.7%
Taylor expanded in x around inf 87.3%
Simplified88.2%
Taylor expanded in n around inf 70.2%
associate-*r/70.2%
metadata-eval70.2%
Simplified70.2%
Final simplification58.9%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 53.8%
Taylor expanded in x around inf 57.8%
mul-1-neg57.8%
log-rec57.8%
mul-1-neg57.8%
distribute-neg-frac57.8%
mul-1-neg57.8%
remove-double-neg57.8%
*-commutative57.8%
Simplified57.8%
Taylor expanded in n around inf 42.8%
*-commutative42.8%
associate-/r*43.2%
Simplified43.2%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 53.8%
Taylor expanded in x around inf 57.8%
mul-1-neg57.8%
log-rec57.8%
mul-1-neg57.8%
distribute-neg-frac57.8%
mul-1-neg57.8%
remove-double-neg57.8%
*-commutative57.8%
Simplified57.8%
Taylor expanded in n around inf 42.8%
*-commutative42.8%
Simplified42.8%
herbie shell --seed 2024108
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))