
(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 12 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 (- (log1p x) (log x))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-19)
(* t_1 (/ (/ 1.0 x) n))
(if (<= (/ 1.0 n) -1e-137)
(* (/ 1.0 n) t_0)
(if (<= (/ 1.0 n) -2e-154)
(/
(-
(+ (/ 1.0 x) (/ 0.3333333333333333 (pow x 3.0)))
(+ (/ 0.5 (pow x 2.0)) (/ 0.25 (pow x 4.0))))
n)
(if (<= (/ 1.0 n) 2e-150)
(/ t_0 n)
(if (<= (/ 1.0 n) 100000.0)
(/ (/ t_1 n) x)
(- (exp (/ x n)) t_1))))))))
double code(double x, double n) {
double t_0 = log1p(x) - log(x);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = (1.0 / n) * t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = (((1.0 / x) + (0.3333333333333333 / pow(x, 3.0))) - ((0.5 / pow(x, 2.0)) + (0.25 / pow(x, 4.0)))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else {
tmp = exp((x / n)) - t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log1p(x) - Math.log(x);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = (1.0 / n) * t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = (((1.0 / x) + (0.3333333333333333 / Math.pow(x, 3.0))) - ((0.5 / Math.pow(x, 2.0)) + (0.25 / Math.pow(x, 4.0)))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else {
tmp = Math.exp((x / n)) - t_1;
}
return tmp;
}
def code(x, n): t_0 = math.log1p(x) - math.log(x) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-19: tmp = t_1 * ((1.0 / x) / n) elif (1.0 / n) <= -1e-137: tmp = (1.0 / n) * t_0 elif (1.0 / n) <= -2e-154: tmp = (((1.0 / x) + (0.3333333333333333 / math.pow(x, 3.0))) - ((0.5 / math.pow(x, 2.0)) + (0.25 / math.pow(x, 4.0)))) / n elif (1.0 / n) <= 2e-150: tmp = t_0 / n elif (1.0 / n) <= 100000.0: tmp = (t_1 / n) / x else: tmp = math.exp((x / n)) - t_1 return tmp
function code(x, n) t_0 = Float64(log1p(x) - log(x)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-19) tmp = Float64(t_1 * Float64(Float64(1.0 / x) / n)); elseif (Float64(1.0 / n) <= -1e-137) tmp = Float64(Float64(1.0 / n) * t_0); elseif (Float64(1.0 / n) <= -2e-154) tmp = Float64(Float64(Float64(Float64(1.0 / x) + Float64(0.3333333333333333 / (x ^ 3.0))) - Float64(Float64(0.5 / (x ^ 2.0)) + Float64(0.25 / (x ^ 4.0)))) / n); elseif (Float64(1.0 / n) <= 2e-150) tmp = Float64(t_0 / n); elseif (Float64(1.0 / n) <= 100000.0) tmp = Float64(Float64(t_1 / n) / x); else tmp = Float64(exp(Float64(x / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-19], N[(t$95$1 * N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-137], N[(N[(1.0 / n), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-154], N[(N[(N[(N[(1.0 / x), $MachinePrecision] + N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.25 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-150], N[(t$95$0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100000.0], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(x\right) - \log x\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-19}:\\
\;\;\;\;t_1 \cdot \frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-137}:\\
\;\;\;\;\frac{1}{n} \cdot t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-154}:\\
\;\;\;\;\frac{\left(\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}\right) - \left(\frac{0.5}{{x}^{2}} + \frac{0.25}{{x}^{4}}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-150}:\\
\;\;\;\;\frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{\frac{t_1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.0000000000000004e-19Initial program 97.2%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
log-rec98.8%
mul-1-neg98.8%
distribute-neg-frac98.8%
mul-1-neg98.8%
remove-double-neg98.8%
*-commutative98.8%
Simplified98.8%
div-inv98.8%
associate-/r*98.8%
div-inv98.8%
exp-to-pow98.8%
Applied egg-rr98.8%
if -5.0000000000000004e-19 < (/.f64 1 n) < -9.99999999999999978e-138Initial program 14.1%
Taylor expanded in n around inf 76.8%
log1p-def76.8%
Simplified76.8%
div-sub76.8%
Applied egg-rr76.8%
div-inv73.9%
div-inv76.8%
distribute-rgt-out--76.8%
Applied egg-rr76.8%
if -9.99999999999999978e-138 < (/.f64 1 n) < -1.9999999999999999e-154Initial program 22.0%
Taylor expanded in n around inf 39.7%
log1p-def39.7%
Simplified39.7%
Taylor expanded in x around inf 86.8%
+-commutative86.8%
associate-*r/86.8%
metadata-eval86.8%
+-commutative86.8%
associate-*r/86.8%
metadata-eval86.8%
associate-*r/86.8%
metadata-eval86.8%
Simplified86.8%
if -1.9999999999999999e-154 < (/.f64 1 n) < 2.00000000000000001e-150Initial program 40.0%
Taylor expanded in n around inf 96.5%
log1p-def96.5%
Simplified96.5%
if 2.00000000000000001e-150 < (/.f64 1 n) < 1e5Initial program 18.2%
Taylor expanded in x around inf 76.7%
mul-1-neg76.7%
log-rec76.7%
mul-1-neg76.7%
distribute-neg-frac76.7%
mul-1-neg76.7%
remove-double-neg76.7%
*-commutative76.7%
Simplified76.7%
*-un-lft-identity76.7%
times-frac76.7%
div-inv76.7%
exp-to-pow76.7%
Applied egg-rr76.7%
associate-*l/76.9%
*-un-lft-identity76.9%
Applied egg-rr76.9%
if 1e5 < (/.f64 1 n) Initial program 60.0%
Taylor expanded in n around 0 60.0%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification92.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (log1p x) (log x))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-19)
(* t_1 (/ (/ 1.0 x) n))
(if (<= (/ 1.0 n) -1e-137)
(* (/ 1.0 n) t_0)
(if (<= (/ 1.0 n) -2e-154)
(/ (- (/ 1.0 x) (/ 0.5 (pow x 2.0))) n)
(if (<= (/ 1.0 n) 2e-150)
(/ t_0 n)
(if (<= (/ 1.0 n) 100000.0)
(/ (/ t_1 n) x)
(- (exp (/ x n)) t_1))))))))
double code(double x, double n) {
double t_0 = log1p(x) - log(x);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = (1.0 / n) * t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = ((1.0 / x) - (0.5 / pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else {
tmp = exp((x / n)) - t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log1p(x) - Math.log(x);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = (1.0 / n) * t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = ((1.0 / x) - (0.5 / Math.pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else {
tmp = Math.exp((x / n)) - t_1;
}
return tmp;
}
def code(x, n): t_0 = math.log1p(x) - math.log(x) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-19: tmp = t_1 * ((1.0 / x) / n) elif (1.0 / n) <= -1e-137: tmp = (1.0 / n) * t_0 elif (1.0 / n) <= -2e-154: tmp = ((1.0 / x) - (0.5 / math.pow(x, 2.0))) / n elif (1.0 / n) <= 2e-150: tmp = t_0 / n elif (1.0 / n) <= 100000.0: tmp = (t_1 / n) / x else: tmp = math.exp((x / n)) - t_1 return tmp
function code(x, n) t_0 = Float64(log1p(x) - log(x)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-19) tmp = Float64(t_1 * Float64(Float64(1.0 / x) / n)); elseif (Float64(1.0 / n) <= -1e-137) tmp = Float64(Float64(1.0 / n) * t_0); elseif (Float64(1.0 / n) <= -2e-154) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / (x ^ 2.0))) / n); elseif (Float64(1.0 / n) <= 2e-150) tmp = Float64(t_0 / n); elseif (Float64(1.0 / n) <= 100000.0) tmp = Float64(Float64(t_1 / n) / x); else tmp = Float64(exp(Float64(x / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-19], N[(t$95$1 * N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-137], N[(N[(1.0 / n), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-154], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-150], N[(t$95$0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100000.0], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(x\right) - \log x\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-19}:\\
\;\;\;\;t_1 \cdot \frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-137}:\\
\;\;\;\;\frac{1}{n} \cdot t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-154}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{{x}^{2}}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-150}:\\
\;\;\;\;\frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{\frac{t_1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.0000000000000004e-19Initial program 97.2%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
log-rec98.8%
mul-1-neg98.8%
distribute-neg-frac98.8%
mul-1-neg98.8%
remove-double-neg98.8%
*-commutative98.8%
Simplified98.8%
div-inv98.8%
associate-/r*98.8%
div-inv98.8%
exp-to-pow98.8%
Applied egg-rr98.8%
if -5.0000000000000004e-19 < (/.f64 1 n) < -9.99999999999999978e-138Initial program 14.1%
Taylor expanded in n around inf 76.8%
log1p-def76.8%
Simplified76.8%
div-sub76.8%
Applied egg-rr76.8%
div-inv73.9%
div-inv76.8%
distribute-rgt-out--76.8%
Applied egg-rr76.8%
if -9.99999999999999978e-138 < (/.f64 1 n) < -1.9999999999999999e-154Initial program 22.0%
Taylor expanded in n around inf 39.7%
log1p-def39.7%
Simplified39.7%
Taylor expanded in x around inf 84.4%
associate-*r/84.4%
metadata-eval84.4%
Simplified84.4%
if -1.9999999999999999e-154 < (/.f64 1 n) < 2.00000000000000001e-150Initial program 40.0%
Taylor expanded in n around inf 96.5%
log1p-def96.5%
Simplified96.5%
if 2.00000000000000001e-150 < (/.f64 1 n) < 1e5Initial program 18.2%
Taylor expanded in x around inf 76.7%
mul-1-neg76.7%
log-rec76.7%
mul-1-neg76.7%
distribute-neg-frac76.7%
mul-1-neg76.7%
remove-double-neg76.7%
*-commutative76.7%
Simplified76.7%
*-un-lft-identity76.7%
times-frac76.7%
div-inv76.7%
exp-to-pow76.7%
Applied egg-rr76.7%
associate-*l/76.9%
*-un-lft-identity76.9%
Applied egg-rr76.9%
if 1e5 < (/.f64 1 n) Initial program 60.0%
Taylor expanded in n around 0 60.0%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification92.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (log1p x) (log x))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-19)
(* t_1 (/ (/ 1.0 x) n))
(if (<= (/ 1.0 n) -1e-137)
(* (/ 1.0 n) t_0)
(if (<= (/ 1.0 n) -2e-154)
(/
(+
(/ 0.3333333333333333 (pow x 3.0))
(- (/ 1.0 x) (/ 0.5 (pow x 2.0))))
n)
(if (<= (/ 1.0 n) 2e-150)
(/ t_0 n)
(if (<= (/ 1.0 n) 100000.0)
(/ (/ t_1 n) x)
(- (exp (/ x n)) t_1))))))))
double code(double x, double n) {
double t_0 = log1p(x) - log(x);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = (1.0 / n) * t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = ((0.3333333333333333 / pow(x, 3.0)) + ((1.0 / x) - (0.5 / pow(x, 2.0)))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else {
tmp = exp((x / n)) - t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log1p(x) - Math.log(x);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = (1.0 / n) * t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = ((0.3333333333333333 / Math.pow(x, 3.0)) + ((1.0 / x) - (0.5 / Math.pow(x, 2.0)))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else {
tmp = Math.exp((x / n)) - t_1;
}
return tmp;
}
def code(x, n): t_0 = math.log1p(x) - math.log(x) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-19: tmp = t_1 * ((1.0 / x) / n) elif (1.0 / n) <= -1e-137: tmp = (1.0 / n) * t_0 elif (1.0 / n) <= -2e-154: tmp = ((0.3333333333333333 / math.pow(x, 3.0)) + ((1.0 / x) - (0.5 / math.pow(x, 2.0)))) / n elif (1.0 / n) <= 2e-150: tmp = t_0 / n elif (1.0 / n) <= 100000.0: tmp = (t_1 / n) / x else: tmp = math.exp((x / n)) - t_1 return tmp
function code(x, n) t_0 = Float64(log1p(x) - log(x)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-19) tmp = Float64(t_1 * Float64(Float64(1.0 / x) / n)); elseif (Float64(1.0 / n) <= -1e-137) tmp = Float64(Float64(1.0 / n) * t_0); elseif (Float64(1.0 / n) <= -2e-154) tmp = Float64(Float64(Float64(0.3333333333333333 / (x ^ 3.0)) + Float64(Float64(1.0 / x) - Float64(0.5 / (x ^ 2.0)))) / n); elseif (Float64(1.0 / n) <= 2e-150) tmp = Float64(t_0 / n); elseif (Float64(1.0 / n) <= 100000.0) tmp = Float64(Float64(t_1 / n) / x); else tmp = Float64(exp(Float64(x / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-19], N[(t$95$1 * N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-137], N[(N[(1.0 / n), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-154], N[(N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-150], N[(t$95$0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100000.0], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(x\right) - \log x\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-19}:\\
\;\;\;\;t_1 \cdot \frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-137}:\\
\;\;\;\;\frac{1}{n} \cdot t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-154}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{{x}^{2}}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-150}:\\
\;\;\;\;\frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{\frac{t_1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.0000000000000004e-19Initial program 97.2%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
log-rec98.8%
mul-1-neg98.8%
distribute-neg-frac98.8%
mul-1-neg98.8%
remove-double-neg98.8%
*-commutative98.8%
Simplified98.8%
div-inv98.8%
associate-/r*98.8%
div-inv98.8%
exp-to-pow98.8%
Applied egg-rr98.8%
if -5.0000000000000004e-19 < (/.f64 1 n) < -9.99999999999999978e-138Initial program 14.1%
Taylor expanded in n around inf 76.8%
log1p-def76.8%
Simplified76.8%
div-sub76.8%
Applied egg-rr76.8%
div-inv73.9%
div-inv76.8%
distribute-rgt-out--76.8%
Applied egg-rr76.8%
if -9.99999999999999978e-138 < (/.f64 1 n) < -1.9999999999999999e-154Initial program 22.0%
Taylor expanded in n around inf 39.7%
log1p-def39.7%
Simplified39.7%
Taylor expanded in x around inf 85.8%
associate--l+85.8%
associate-*r/85.8%
metadata-eval85.8%
associate-*r/85.8%
metadata-eval85.8%
Simplified85.8%
if -1.9999999999999999e-154 < (/.f64 1 n) < 2.00000000000000001e-150Initial program 40.0%
Taylor expanded in n around inf 96.5%
log1p-def96.5%
Simplified96.5%
if 2.00000000000000001e-150 < (/.f64 1 n) < 1e5Initial program 18.2%
Taylor expanded in x around inf 76.7%
mul-1-neg76.7%
log-rec76.7%
mul-1-neg76.7%
distribute-neg-frac76.7%
mul-1-neg76.7%
remove-double-neg76.7%
*-commutative76.7%
Simplified76.7%
*-un-lft-identity76.7%
times-frac76.7%
div-inv76.7%
exp-to-pow76.7%
Applied egg-rr76.7%
associate-*l/76.9%
*-un-lft-identity76.9%
Applied egg-rr76.9%
if 1e5 < (/.f64 1 n) Initial program 60.0%
Taylor expanded in n around 0 60.0%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification92.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log1p x) (log x)) n)) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-19)
(* t_1 (/ (/ 1.0 x) n))
(if (<= (/ 1.0 n) -1e-137)
t_0
(if (<= (/ 1.0 n) -2e-154)
(/ (- (/ 1.0 x) (/ 0.5 (pow x 2.0))) n)
(if (<= (/ 1.0 n) 2e-150)
t_0
(if (<= (/ 1.0 n) 100000.0)
(/ (/ t_1 n) x)
(if (<= (/ 1.0 n) 1e+204)
(- (+ 1.0 (/ x n)) t_1)
(/ 0.3333333333333333 (* n (pow x 3.0)))))))))))
double code(double x, double n) {
double t_0 = (log1p(x) - log(x)) / n;
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = ((1.0 / x) - (0.5 / pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 1e+204) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (Math.log1p(x) - Math.log(x)) / n;
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = ((1.0 / x) - (0.5 / Math.pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 1e+204) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
}
return tmp;
}
def code(x, n): t_0 = (math.log1p(x) - math.log(x)) / n t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-19: tmp = t_1 * ((1.0 / x) / n) elif (1.0 / n) <= -1e-137: tmp = t_0 elif (1.0 / n) <= -2e-154: tmp = ((1.0 / x) - (0.5 / math.pow(x, 2.0))) / n elif (1.0 / n) <= 2e-150: tmp = t_0 elif (1.0 / n) <= 100000.0: tmp = (t_1 / n) / x elif (1.0 / n) <= 1e+204: tmp = (1.0 + (x / n)) - t_1 else: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) return tmp
function code(x, n) t_0 = Float64(Float64(log1p(x) - log(x)) / n) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-19) tmp = Float64(t_1 * Float64(Float64(1.0 / x) / n)); elseif (Float64(1.0 / n) <= -1e-137) tmp = t_0; elseif (Float64(1.0 / n) <= -2e-154) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / (x ^ 2.0))) / n); elseif (Float64(1.0 / n) <= 2e-150) tmp = t_0; elseif (Float64(1.0 / n) <= 100000.0) tmp = Float64(Float64(t_1 / n) / x); elseif (Float64(1.0 / n) <= 1e+204) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); else tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.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]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-19], N[(t$95$1 * N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-137], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-154], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-150], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 100000.0], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+204], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-19}:\\
\;\;\;\;t_1 \cdot \frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-137}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-154}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{{x}^{2}}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{\frac{t_1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+204}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.0000000000000004e-19Initial program 97.2%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
log-rec98.8%
mul-1-neg98.8%
distribute-neg-frac98.8%
mul-1-neg98.8%
remove-double-neg98.8%
*-commutative98.8%
Simplified98.8%
div-inv98.8%
associate-/r*98.8%
div-inv98.8%
exp-to-pow98.8%
Applied egg-rr98.8%
if -5.0000000000000004e-19 < (/.f64 1 n) < -9.99999999999999978e-138 or -1.9999999999999999e-154 < (/.f64 1 n) < 2.00000000000000001e-150Initial program 33.0%
Taylor expanded in n around inf 91.1%
log1p-def91.1%
Simplified91.1%
if -9.99999999999999978e-138 < (/.f64 1 n) < -1.9999999999999999e-154Initial program 22.0%
Taylor expanded in n around inf 39.7%
log1p-def39.7%
Simplified39.7%
Taylor expanded in x around inf 84.4%
associate-*r/84.4%
metadata-eval84.4%
Simplified84.4%
if 2.00000000000000001e-150 < (/.f64 1 n) < 1e5Initial program 18.2%
Taylor expanded in x around inf 76.7%
mul-1-neg76.7%
log-rec76.7%
mul-1-neg76.7%
distribute-neg-frac76.7%
mul-1-neg76.7%
remove-double-neg76.7%
*-commutative76.7%
Simplified76.7%
*-un-lft-identity76.7%
times-frac76.7%
div-inv76.7%
exp-to-pow76.7%
Applied egg-rr76.7%
associate-*l/76.9%
*-un-lft-identity76.9%
Applied egg-rr76.9%
if 1e5 < (/.f64 1 n) < 9.99999999999999989e203Initial program 84.4%
Taylor expanded in x around 0 86.3%
if 9.99999999999999989e203 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 7.4%
log1p-def7.4%
Simplified7.4%
Taylor expanded in x around inf 11.1%
associate--l+11.1%
associate-*r/11.1%
metadata-eval11.1%
*-commutative11.1%
*-commutative11.1%
associate-*r/11.1%
metadata-eval11.1%
*-commutative11.1%
Simplified11.1%
Taylor expanded in x around 0 100.0%
Final simplification91.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (log1p x) (log x))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-19)
(* t_1 (/ (/ 1.0 x) n))
(if (<= (/ 1.0 n) -1e-137)
(* (/ 1.0 n) t_0)
(if (<= (/ 1.0 n) -2e-154)
(/ (- (/ 1.0 x) (/ 0.5 (pow x 2.0))) n)
(if (<= (/ 1.0 n) 2e-150)
(/ t_0 n)
(if (<= (/ 1.0 n) 100000.0)
(/ (/ t_1 n) x)
(if (<= (/ 1.0 n) 1e+204)
(- (+ 1.0 (/ x n)) t_1)
(/ 0.3333333333333333 (* n (pow x 3.0)))))))))))
double code(double x, double n) {
double t_0 = log1p(x) - log(x);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = (1.0 / n) * t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = ((1.0 / x) - (0.5 / pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 1e+204) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log1p(x) - Math.log(x);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-19) {
tmp = t_1 * ((1.0 / x) / n);
} else if ((1.0 / n) <= -1e-137) {
tmp = (1.0 / n) * t_0;
} else if ((1.0 / n) <= -2e-154) {
tmp = ((1.0 / x) - (0.5 / Math.pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 2e-150) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 100000.0) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 1e+204) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
}
return tmp;
}
def code(x, n): t_0 = math.log1p(x) - math.log(x) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-19: tmp = t_1 * ((1.0 / x) / n) elif (1.0 / n) <= -1e-137: tmp = (1.0 / n) * t_0 elif (1.0 / n) <= -2e-154: tmp = ((1.0 / x) - (0.5 / math.pow(x, 2.0))) / n elif (1.0 / n) <= 2e-150: tmp = t_0 / n elif (1.0 / n) <= 100000.0: tmp = (t_1 / n) / x elif (1.0 / n) <= 1e+204: tmp = (1.0 + (x / n)) - t_1 else: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) return tmp
function code(x, n) t_0 = Float64(log1p(x) - log(x)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-19) tmp = Float64(t_1 * Float64(Float64(1.0 / x) / n)); elseif (Float64(1.0 / n) <= -1e-137) tmp = Float64(Float64(1.0 / n) * t_0); elseif (Float64(1.0 / n) <= -2e-154) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / (x ^ 2.0))) / n); elseif (Float64(1.0 / n) <= 2e-150) tmp = Float64(t_0 / n); elseif (Float64(1.0 / n) <= 100000.0) tmp = Float64(Float64(t_1 / n) / x); elseif (Float64(1.0 / n) <= 1e+204) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); else tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-19], N[(t$95$1 * N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-137], N[(N[(1.0 / n), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-154], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-150], N[(t$95$0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100000.0], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+204], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(x\right) - \log x\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-19}:\\
\;\;\;\;t_1 \cdot \frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-137}:\\
\;\;\;\;\frac{1}{n} \cdot t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-154}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{{x}^{2}}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-150}:\\
\;\;\;\;\frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{\frac{t_1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+204}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.0000000000000004e-19Initial program 97.2%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
log-rec98.8%
mul-1-neg98.8%
distribute-neg-frac98.8%
mul-1-neg98.8%
remove-double-neg98.8%
*-commutative98.8%
Simplified98.8%
div-inv98.8%
associate-/r*98.8%
div-inv98.8%
exp-to-pow98.8%
Applied egg-rr98.8%
if -5.0000000000000004e-19 < (/.f64 1 n) < -9.99999999999999978e-138Initial program 14.1%
Taylor expanded in n around inf 76.8%
log1p-def76.8%
Simplified76.8%
div-sub76.8%
Applied egg-rr76.8%
div-inv73.9%
div-inv76.8%
distribute-rgt-out--76.8%
Applied egg-rr76.8%
if -9.99999999999999978e-138 < (/.f64 1 n) < -1.9999999999999999e-154Initial program 22.0%
Taylor expanded in n around inf 39.7%
log1p-def39.7%
Simplified39.7%
Taylor expanded in x around inf 84.4%
associate-*r/84.4%
metadata-eval84.4%
Simplified84.4%
if -1.9999999999999999e-154 < (/.f64 1 n) < 2.00000000000000001e-150Initial program 40.0%
Taylor expanded in n around inf 96.5%
log1p-def96.5%
Simplified96.5%
if 2.00000000000000001e-150 < (/.f64 1 n) < 1e5Initial program 18.2%
Taylor expanded in x around inf 76.7%
mul-1-neg76.7%
log-rec76.7%
mul-1-neg76.7%
distribute-neg-frac76.7%
mul-1-neg76.7%
remove-double-neg76.7%
*-commutative76.7%
Simplified76.7%
*-un-lft-identity76.7%
times-frac76.7%
div-inv76.7%
exp-to-pow76.7%
Applied egg-rr76.7%
associate-*l/76.9%
*-un-lft-identity76.9%
Applied egg-rr76.9%
if 1e5 < (/.f64 1 n) < 9.99999999999999989e203Initial program 84.4%
Taylor expanded in x around 0 86.3%
if 9.99999999999999989e203 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 7.4%
log1p-def7.4%
Simplified7.4%
Taylor expanded in x around inf 11.1%
associate--l+11.1%
associate-*r/11.1%
metadata-eval11.1%
*-commutative11.1%
*-commutative11.1%
associate-*r/11.1%
metadata-eval11.1%
*-commutative11.1%
Simplified11.1%
Taylor expanded in x around 0 100.0%
Final simplification91.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 x) n)) (t_1 (/ (- (log x)) n)))
(if (<= n -5.8e+139)
t_0
(if (<= n -18.0)
t_1
(if (<= n 1.2e-204)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= n 6800000000.0)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= n 4.6e+149) t_0 t_1)))))))
double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double t_1 = -log(x) / n;
double tmp;
if (n <= -5.8e+139) {
tmp = t_0;
} else if (n <= -18.0) {
tmp = t_1;
} else if (n <= 1.2e-204) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if (n <= 6800000000.0) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (n <= 4.6e+149) {
tmp = t_0;
} else {
tmp = t_1;
}
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) / n
t_1 = -log(x) / n
if (n <= (-5.8d+139)) then
tmp = t_0
else if (n <= (-18.0d0)) then
tmp = t_1
else if (n <= 1.2d-204) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if (n <= 6800000000.0d0) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (n <= 4.6d+149) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double t_1 = -Math.log(x) / n;
double tmp;
if (n <= -5.8e+139) {
tmp = t_0;
} else if (n <= -18.0) {
tmp = t_1;
} else if (n <= 1.2e-204) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if (n <= 6800000000.0) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (n <= 4.6e+149) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = (1.0 / x) / n t_1 = -math.log(x) / n tmp = 0 if n <= -5.8e+139: tmp = t_0 elif n <= -18.0: tmp = t_1 elif n <= 1.2e-204: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif n <= 6800000000.0: tmp = 1.0 - math.pow(x, (1.0 / n)) elif n <= 4.6e+149: tmp = t_0 else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64(Float64(1.0 / x) / n) t_1 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (n <= -5.8e+139) tmp = t_0; elseif (n <= -18.0) tmp = t_1; elseif (n <= 1.2e-204) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (n <= 6800000000.0) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (n <= 4.6e+149) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, n) t_0 = (1.0 / x) / n; t_1 = -log(x) / n; tmp = 0.0; if (n <= -5.8e+139) tmp = t_0; elseif (n <= -18.0) tmp = t_1; elseif (n <= 1.2e-204) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif (n <= 6800000000.0) tmp = 1.0 - (x ^ (1.0 / n)); elseif (n <= 4.6e+149) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[n, -5.8e+139], t$95$0, If[LessEqual[n, -18.0], t$95$1, If[LessEqual[n, 1.2e-204], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 6800000000.0], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.6e+149], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
t_1 := \frac{-\log x}{n}\\
\mathbf{if}\;n \leq -5.8 \cdot 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -18:\\
\;\;\;\;t_1\\
\mathbf{elif}\;n \leq 1.2 \cdot 10^{-204}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;n \leq 6800000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 4.6 \cdot 10^{+149}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if n < -5.7999999999999998e139 or 6.8e9 < n < 4.5999999999999997e149Initial program 33.0%
Taylor expanded in n around inf 68.9%
log1p-def68.9%
Simplified68.9%
Taylor expanded in x around inf 63.3%
if -5.7999999999999998e139 < n < -18 or 4.5999999999999997e149 < n Initial program 24.6%
Taylor expanded in n around inf 84.0%
log1p-def84.0%
Simplified84.0%
Taylor expanded in x around 0 63.7%
mul-1-neg63.7%
Simplified63.7%
if -18 < n < 1.2e-204Initial program 89.9%
Taylor expanded in n around inf 48.6%
log1p-def48.6%
Simplified48.6%
Taylor expanded in x around inf 6.7%
associate--l+6.7%
associate-*r/6.7%
metadata-eval6.7%
*-commutative6.7%
*-commutative6.7%
associate-*r/6.7%
metadata-eval6.7%
*-commutative6.7%
Simplified6.7%
Taylor expanded in x around 0 72.2%
if 1.2e-204 < n < 6.8e9Initial program 76.0%
Taylor expanded in x around 0 75.9%
Final simplification67.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 x) n)))
(if (<= n -1.02e+139)
t_0
(if (<= n -7.1)
(/ (- x (log x)) n)
(if (<= n 1.35e-204)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= n 1300000000.0)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= n 6.8e+149) t_0 (/ (- (log x)) n))))))))
double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if (n <= -1.02e+139) {
tmp = t_0;
} else if (n <= -7.1) {
tmp = (x - log(x)) / n;
} else if (n <= 1.35e-204) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if (n <= 1300000000.0) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (n <= 6.8e+149) {
tmp = t_0;
} else {
tmp = -log(x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / x) / n
if (n <= (-1.02d+139)) then
tmp = t_0
else if (n <= (-7.1d0)) then
tmp = (x - log(x)) / n
else if (n <= 1.35d-204) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if (n <= 1300000000.0d0) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (n <= 6.8d+149) then
tmp = t_0
else
tmp = -log(x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if (n <= -1.02e+139) {
tmp = t_0;
} else if (n <= -7.1) {
tmp = (x - Math.log(x)) / n;
} else if (n <= 1.35e-204) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if (n <= 1300000000.0) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (n <= 6.8e+149) {
tmp = t_0;
} else {
tmp = -Math.log(x) / n;
}
return tmp;
}
def code(x, n): t_0 = (1.0 / x) / n tmp = 0 if n <= -1.02e+139: tmp = t_0 elif n <= -7.1: tmp = (x - math.log(x)) / n elif n <= 1.35e-204: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif n <= 1300000000.0: tmp = 1.0 - math.pow(x, (1.0 / n)) elif n <= 6.8e+149: tmp = t_0 else: tmp = -math.log(x) / n return tmp
function code(x, n) t_0 = Float64(Float64(1.0 / x) / n) tmp = 0.0 if (n <= -1.02e+139) tmp = t_0; elseif (n <= -7.1) tmp = Float64(Float64(x - log(x)) / n); elseif (n <= 1.35e-204) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (n <= 1300000000.0) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (n <= 6.8e+149) tmp = t_0; else tmp = Float64(Float64(-log(x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = (1.0 / x) / n; tmp = 0.0; if (n <= -1.02e+139) tmp = t_0; elseif (n <= -7.1) tmp = (x - log(x)) / n; elseif (n <= 1.35e-204) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif (n <= 1300000000.0) tmp = 1.0 - (x ^ (1.0 / n)); elseif (n <= 6.8e+149) tmp = t_0; else tmp = -log(x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -1.02e+139], t$95$0, If[LessEqual[n, -7.1], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 1.35e-204], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1300000000.0], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 6.8e+149], t$95$0, N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
\mathbf{if}\;n \leq -1.02 \cdot 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -7.1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;n \leq 1.35 \cdot 10^{-204}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;n \leq 1300000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 6.8 \cdot 10^{+149}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-\log x}{n}\\
\end{array}
\end{array}
if n < -1.02e139 or 1.3e9 < n < 6.7999999999999997e149Initial program 33.0%
Taylor expanded in n around inf 68.9%
log1p-def68.9%
Simplified68.9%
Taylor expanded in x around inf 63.3%
if -1.02e139 < n < -7.0999999999999996Initial program 15.3%
Taylor expanded in n around inf 71.4%
log1p-def71.4%
Simplified71.4%
Taylor expanded in x around 0 62.2%
mul-1-neg62.2%
Simplified62.2%
if -7.0999999999999996 < n < 1.34999999999999996e-204Initial program 89.9%
Taylor expanded in n around inf 48.6%
log1p-def48.6%
Simplified48.6%
Taylor expanded in x around inf 6.7%
associate--l+6.7%
associate-*r/6.7%
metadata-eval6.7%
*-commutative6.7%
*-commutative6.7%
associate-*r/6.7%
metadata-eval6.7%
*-commutative6.7%
Simplified6.7%
Taylor expanded in x around 0 72.2%
if 1.34999999999999996e-204 < n < 1.3e9Initial program 76.0%
Taylor expanded in x around 0 75.9%
if 6.7999999999999997e149 < n Initial program 32.1%
Taylor expanded in n around inf 94.1%
log1p-def94.1%
Simplified94.1%
Taylor expanded in x around 0 65.4%
mul-1-neg65.4%
Simplified65.4%
Final simplification67.7%
(FPCore (x n) :precision binary64 (if (<= x 0.55) (/ (- (log x)) n) (if (<= x 6.5e+185) (/ (/ 1.0 x) n) (* (/ (log x) n) 0.0))))
double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -log(x) / n;
} else if (x <= 6.5e+185) {
tmp = (1.0 / x) / n;
} else {
tmp = (log(x) / n) * 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.55d0) then
tmp = -log(x) / n
else if (x <= 6.5d+185) then
tmp = (1.0d0 / x) / n
else
tmp = (log(x) / n) * 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -Math.log(x) / n;
} else if (x <= 6.5e+185) {
tmp = (1.0 / x) / n;
} else {
tmp = (Math.log(x) / n) * 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.55: tmp = -math.log(x) / n elif x <= 6.5e+185: tmp = (1.0 / x) / n else: tmp = (math.log(x) / n) * 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.55) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 6.5e+185) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(Float64(log(x) / n) * 0.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.55) tmp = -log(x) / n; elseif (x <= 6.5e+185) tmp = (1.0 / x) / n; else tmp = (log(x) / n) * 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.55], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 6.5e+185], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] * 0.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.55:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log x}{n} \cdot 0\\
\end{array}
\end{array}
if x < 0.55000000000000004Initial program 43.8%
Taylor expanded in n around inf 53.7%
log1p-def53.7%
Simplified53.7%
Taylor expanded in x around 0 52.9%
mul-1-neg52.9%
Simplified52.9%
if 0.55000000000000004 < x < 6.5000000000000002e185Initial program 53.9%
Taylor expanded in n around inf 55.6%
log1p-def55.6%
Simplified55.6%
Taylor expanded in x around inf 61.1%
if 6.5000000000000002e185 < x Initial program 89.1%
Taylor expanded in n around inf 89.1%
log1p-def89.1%
Simplified89.1%
log1p-def89.1%
div-sub86.7%
add-sqr-sqrt10.8%
cancel-sign-sub-inv10.8%
log1p-def10.8%
Applied egg-rr10.8%
*-commutative10.8%
Simplified10.8%
Taylor expanded in x around inf 86.7%
associate-*r/86.7%
log-rec86.7%
neg-mul-186.7%
remove-double-neg86.7%
log-rec86.7%
distribute-frac-neg86.7%
mul-1-neg86.7%
*-lft-identity86.7%
distribute-rgt-out86.7%
metadata-eval86.7%
Simplified86.7%
Final simplification60.8%
(FPCore (x n) :precision binary64 (if (<= x 5e-32) (/ (- (log x)) n) (/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 5e-32) {
tmp = -log(x) / n;
} else {
tmp = (pow(x, (1.0 / n)) / 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 <= 5d-32) then
tmp = -log(x) / n
else
tmp = ((x ** (1.0d0 / n)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 5e-32) {
tmp = -Math.log(x) / n;
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5e-32: tmp = -math.log(x) / n else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 5e-32) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5e-32) tmp = -log(x) / n; else tmp = ((x ^ (1.0 / n)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5e-32], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-32}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 5e-32Initial program 42.8%
Taylor expanded in n around inf 54.8%
log1p-def54.8%
Simplified54.8%
Taylor expanded in x around 0 54.8%
mul-1-neg54.8%
Simplified54.8%
if 5e-32 < x Initial program 66.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-commutative94.3%
Simplified94.3%
*-un-lft-identity94.3%
times-frac95.4%
div-inv95.4%
exp-to-pow95.4%
Applied egg-rr95.4%
associate-*l/95.5%
*-un-lft-identity95.5%
Applied egg-rr95.5%
Final simplification74.5%
(FPCore (x n) :precision binary64 (if (<= x 0.55) (/ (- (log x)) n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -log(x) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.55d0) then
tmp = -log(x) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -Math.log(x) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.55: tmp = -math.log(x) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.55) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.55) tmp = -log(x) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.55], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.55:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 0.55000000000000004Initial program 43.8%
Taylor expanded in n around inf 53.7%
log1p-def53.7%
Simplified53.7%
Taylor expanded in x around 0 52.9%
mul-1-neg52.9%
Simplified52.9%
if 0.55000000000000004 < x Initial program 66.8%
Taylor expanded in n around inf 67.8%
log1p-def67.8%
Simplified67.8%
Taylor expanded in x around inf 61.9%
Final simplification57.0%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 54.1%
Taylor expanded in n around inf 60.0%
log1p-def60.0%
Simplified60.0%
Taylor expanded in x around inf 40.4%
*-commutative40.4%
Simplified40.4%
Final simplification40.4%
(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 54.1%
Taylor expanded in n around inf 60.0%
log1p-def60.0%
Simplified60.0%
Taylor expanded in x around inf 40.9%
Final simplification40.9%
herbie shell --seed 2023336
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))