
(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 17 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 (sqrt (pow x (pow n -1.0)))) (t_1 (/ (log1p x) n)))
(if (<= n -6900000.0)
(-
(fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) t_1)
(fma 0.5 (/ (pow (log x) 2.0) (* n n)) (/ (log x) n)))
(if (<= n 1.2e-7)
(fma t_0 (- t_0) (exp t_1))
(if (<= n 3.3e+78)
(/ (pow x (/ 1.0 n)) (* n x))
(/ (- (log1p x) (log x)) n))))))
double code(double x, double n) {
double t_0 = sqrt(pow(x, pow(n, -1.0)));
double t_1 = log1p(x) / n;
double tmp;
if (n <= -6900000.0) {
tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), t_1) - fma(0.5, (pow(log(x), 2.0) / (n * n)), (log(x) / n));
} else if (n <= 1.2e-7) {
tmp = fma(t_0, -t_0, exp(t_1));
} else if (n <= 3.3e+78) {
tmp = pow(x, (1.0 / n)) / (n * x);
} else {
tmp = (log1p(x) - log(x)) / n;
}
return tmp;
}
function code(x, n) t_0 = sqrt((x ^ (n ^ -1.0))) t_1 = Float64(log1p(x) / n) tmp = 0.0 if (n <= -6900000.0) tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), t_1) - fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), Float64(log(x) / n))); elseif (n <= 1.2e-7) tmp = fma(t_0, Float64(-t_0), exp(t_1)); elseif (n <= 3.3e+78) tmp = Float64((x ^ Float64(1.0 / n)) / Float64(n * x)); else tmp = Float64(Float64(log1p(x) - log(x)) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Sqrt[N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -6900000.0], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.2e-7], N[(t$95$0 * (-t$95$0) + N[Exp[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.3e+78], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{{x}^{\left({n}^{-1}\right)}}\\
t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
\mathbf{if}\;n \leq -6900000:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, t_1\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\
\mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(t_0, -t_0, e^{t_1}\right)\\
\mathbf{elif}\;n \leq 3.3 \cdot 10^{+78}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\end{array}
\end{array}
if n < -6.9e6Initial program 31.6%
Taylor expanded in n around inf 79.4%
fma-def79.4%
log1p-def79.4%
unpow279.4%
log1p-def79.4%
fma-def79.4%
unpow279.4%
Simplified79.4%
if -6.9e6 < n < 1.19999999999999989e-7Initial program 85.1%
sub-neg85.1%
+-commutative85.1%
sqr-pow85.1%
distribute-rgt-neg-in85.1%
fma-def85.1%
sqrt-pow185.1%
pow185.1%
pow185.1%
inv-pow85.1%
sqrt-pow185.1%
pow185.1%
pow185.1%
inv-pow85.1%
pow-to-exp85.1%
un-div-inv85.1%
+-commutative85.1%
log1p-udef99.8%
Applied egg-rr99.8%
if 1.19999999999999989e-7 < n < 3.3e78Initial program 16.5%
add-log-exp16.5%
pow-to-exp16.5%
un-div-inv16.5%
+-commutative16.5%
log1p-udef16.5%
Applied egg-rr16.5%
Taylor expanded in x around inf 70.8%
mul-1-neg70.8%
log-rec70.8%
distribute-neg-frac70.8%
remove-double-neg70.8%
*-lft-identity70.8%
associate-*l/70.8%
*-commutative70.8%
exp-to-pow70.8%
*-commutative70.8%
Simplified70.8%
if 3.3e78 < n Initial program 23.5%
Taylor expanded in n around inf 83.0%
+-rgt-identity83.0%
+-rgt-identity83.0%
log1p-def83.0%
Simplified83.0%
Final simplification88.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log1p x) n)))
(if (<= n -28000000.0)
(-
(fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) t_1)
(fma 0.5 (/ (pow (log x) 2.0) (* n n)) (/ (log x) n)))
(if (<= n 1.2e-7)
(- (exp t_1) t_0)
(if (<= n 6.6e+77) (/ t_0 (* n x)) (/ (- (log1p x) (log x)) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log1p(x) / n;
double tmp;
if (n <= -28000000.0) {
tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), t_1) - fma(0.5, (pow(log(x), 2.0) / (n * n)), (log(x) / n));
} else if (n <= 1.2e-7) {
tmp = exp(t_1) - t_0;
} else if (n <= 6.6e+77) {
tmp = t_0 / (n * x);
} else {
tmp = (log1p(x) - log(x)) / n;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log1p(x) / n) tmp = 0.0 if (n <= -28000000.0) tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), t_1) - fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), Float64(log(x) / n))); elseif (n <= 1.2e-7) tmp = Float64(exp(t_1) - t_0); elseif (n <= 6.6e+77) tmp = Float64(t_0 / Float64(n * x)); else tmp = Float64(Float64(log1p(x) - log(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[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -28000000.0], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.2e-7], N[(N[Exp[t$95$1], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[n, 6.6e+77], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
\mathbf{if}\;n \leq -28000000:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, t_1\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\
\mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\
\;\;\;\;e^{t_1} - t_0\\
\mathbf{elif}\;n \leq 6.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\end{array}
\end{array}
if n < -2.8e7Initial program 31.6%
Taylor expanded in n around inf 79.4%
fma-def79.4%
log1p-def79.4%
unpow279.4%
log1p-def79.4%
fma-def79.4%
unpow279.4%
Simplified79.4%
if -2.8e7 < n < 1.19999999999999989e-7Initial program 85.1%
Taylor expanded in n around 0 85.1%
log1p-def99.8%
Simplified99.8%
if 1.19999999999999989e-7 < n < 6.5999999999999996e77Initial program 16.5%
add-log-exp16.5%
pow-to-exp16.5%
un-div-inv16.5%
+-commutative16.5%
log1p-udef16.5%
Applied egg-rr16.5%
Taylor expanded in x around inf 70.8%
mul-1-neg70.8%
log-rec70.8%
distribute-neg-frac70.8%
remove-double-neg70.8%
*-lft-identity70.8%
associate-*l/70.8%
*-commutative70.8%
exp-to-pow70.8%
*-commutative70.8%
Simplified70.8%
if 6.5999999999999996e77 < n Initial program 23.5%
Taylor expanded in n around inf 83.0%
+-rgt-identity83.0%
+-rgt-identity83.0%
log1p-def83.0%
Simplified83.0%
Final simplification88.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (exp (/ (log1p x) n)) t_0)))
(if (<= (/ 1.0 n) -0.004)
(log (exp t_1))
(if (<= (/ 1.0 n) 5e-84)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 10000000.0) (/ t_0 (* n x)) t_1)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = exp((log1p(x) / n)) - t_0;
double tmp;
if ((1.0 / n) <= -0.004) {
tmp = log(exp(t_1));
} else if ((1.0 / n) <= 5e-84) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_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.exp((Math.log1p(x) / n)) - t_0;
double tmp;
if ((1.0 / n) <= -0.004) {
tmp = Math.log(Math.exp(t_1));
} else if ((1.0 / n) <= 5e-84) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_0 / (n * x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.exp((math.log1p(x) / n)) - t_0 tmp = 0 if (1.0 / n) <= -0.004: tmp = math.log(math.exp(t_1)) elif (1.0 / n) <= 5e-84: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 10000000.0: tmp = t_0 / (n * x) else: tmp = t_1 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(exp(Float64(log1p(x) / n)) - t_0) tmp = 0.0 if (Float64(1.0 / n) <= -0.004) tmp = log(exp(t_1)); elseif (Float64(1.0 / n) <= 5e-84) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 10000000.0) tmp = Float64(t_0 / Float64(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[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.004], N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-84], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10000000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\mathbf{if}\;\frac{1}{n} \leq -0.004:\\
\;\;\;\;\log \left(e^{t_1}\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -0.0040000000000000001Initial program 99.7%
add-log-exp99.8%
pow-to-exp99.8%
un-div-inv99.8%
+-commutative99.8%
log1p-udef99.8%
Applied egg-rr99.8%
add-log-exp99.7%
add-log-exp99.8%
Applied egg-rr99.8%
if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84Initial program 27.9%
Taylor expanded in n around inf 80.9%
+-rgt-identity80.9%
+-rgt-identity80.9%
log1p-def80.9%
Simplified80.9%
flip--80.8%
unpow280.8%
unpow280.8%
Applied egg-rr80.8%
unpow280.8%
unpow280.8%
flip--80.9%
log1p-udef80.9%
diff-log81.0%
Applied egg-rr81.0%
if 5.0000000000000002e-84 < (/.f64 1 n) < 1e7Initial program 16.5%
add-log-exp16.5%
pow-to-exp16.5%
un-div-inv16.5%
+-commutative16.5%
log1p-udef16.5%
Applied egg-rr16.5%
Taylor expanded in x around inf 70.8%
mul-1-neg70.8%
log-rec70.8%
distribute-neg-frac70.8%
remove-double-neg70.8%
*-lft-identity70.8%
associate-*l/70.8%
*-commutative70.8%
exp-to-pow70.8%
*-commutative70.8%
Simplified70.8%
if 1e7 < (/.f64 1 n) Initial program 52.1%
Taylor expanded in n around 0 52.1%
log1p-def99.9%
Simplified99.9%
Final simplification88.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= n -22000000000.0)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= n 1.2e-7)
(- (exp (/ (log1p x) n)) t_0)
(if (<= n 3.2e+78) (/ t_0 (* n x)) (/ (- (log1p x) (log x)) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (n <= -22000000000.0) {
tmp = log(((x + 1.0) / x)) / n;
} else if (n <= 1.2e-7) {
tmp = exp((log1p(x) / n)) - t_0;
} else if (n <= 3.2e+78) {
tmp = t_0 / (n * x);
} else {
tmp = (log1p(x) - log(x)) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (n <= -22000000000.0) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if (n <= 1.2e-7) {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
} else if (n <= 3.2e+78) {
tmp = t_0 / (n * x);
} else {
tmp = (Math.log1p(x) - Math.log(x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if n <= -22000000000.0: tmp = math.log(((x + 1.0) / x)) / n elif n <= 1.2e-7: tmp = math.exp((math.log1p(x) / n)) - t_0 elif n <= 3.2e+78: tmp = t_0 / (n * x) else: tmp = (math.log1p(x) - math.log(x)) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (n <= -22000000000.0) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (n <= 1.2e-7) tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); elseif (n <= 3.2e+78) tmp = Float64(t_0 / Float64(n * x)); else tmp = Float64(Float64(log1p(x) - log(x)) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -22000000000.0], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 1.2e-7], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[n, 3.2e+78], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;n \leq -22000000000:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\mathbf{elif}\;n \leq 3.2 \cdot 10^{+78}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\end{array}
\end{array}
if n < -2.2e10Initial program 31.6%
Taylor expanded in n around inf 79.2%
+-rgt-identity79.2%
+-rgt-identity79.2%
log1p-def79.2%
Simplified79.2%
flip--79.1%
unpow279.1%
unpow279.1%
Applied egg-rr79.1%
unpow279.1%
unpow279.1%
flip--79.2%
log1p-udef79.2%
diff-log79.3%
Applied egg-rr79.3%
if -2.2e10 < n < 1.19999999999999989e-7Initial program 85.1%
Taylor expanded in n around 0 85.1%
log1p-def99.8%
Simplified99.8%
if 1.19999999999999989e-7 < n < 3.19999999999999994e78Initial program 16.5%
add-log-exp16.5%
pow-to-exp16.5%
un-div-inv16.5%
+-commutative16.5%
log1p-udef16.5%
Applied egg-rr16.5%
Taylor expanded in x around inf 70.8%
mul-1-neg70.8%
log-rec70.8%
distribute-neg-frac70.8%
remove-double-neg70.8%
*-lft-identity70.8%
associate-*l/70.8%
*-commutative70.8%
exp-to-pow70.8%
*-commutative70.8%
Simplified70.8%
if 3.19999999999999994e78 < n Initial program 23.5%
Taylor expanded in n around inf 83.0%
+-rgt-identity83.0%
+-rgt-identity83.0%
log1p-def83.0%
Simplified83.0%
Final simplification88.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.004)
(- (pow (+ x 1.0) (/ 1.0 n)) t_0)
(if (<= (/ 1.0 n) 5e-84)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 10000000.0)
(/ t_0 (* n x))
(-
(+ 1.0 (fma (* x x) (- (/ 0.5 (* n n)) (/ 0.5 n)) (/ x n)))
t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.004) {
tmp = pow((x + 1.0), (1.0 / n)) - t_0;
} else if ((1.0 / n) <= 5e-84) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_0 / (n * x);
} else {
tmp = (1.0 + fma((x * x), ((0.5 / (n * n)) - (0.5 / n)), (x / n))) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.004) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0); elseif (Float64(1.0 / n) <= 5e-84) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 10000000.0) tmp = Float64(t_0 / Float64(n * x)); else tmp = Float64(Float64(1.0 + fma(Float64(x * x), Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)), Float64(x / n))) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.004], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-84], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10000000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(x * x), $MachinePrecision] * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.004:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{0.5}{n}, \frac{x}{n}\right)\right) - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -0.0040000000000000001Initial program 99.7%
if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84Initial program 27.9%
Taylor expanded in n around inf 80.9%
+-rgt-identity80.9%
+-rgt-identity80.9%
log1p-def80.9%
Simplified80.9%
flip--80.8%
unpow280.8%
unpow280.8%
Applied egg-rr80.8%
unpow280.8%
unpow280.8%
flip--80.9%
log1p-udef80.9%
diff-log81.0%
Applied egg-rr81.0%
if 5.0000000000000002e-84 < (/.f64 1 n) < 1e7Initial program 16.5%
add-log-exp16.5%
pow-to-exp16.5%
un-div-inv16.5%
+-commutative16.5%
log1p-udef16.5%
Applied egg-rr16.5%
Taylor expanded in x around inf 70.8%
mul-1-neg70.8%
log-rec70.8%
distribute-neg-frac70.8%
remove-double-neg70.8%
*-lft-identity70.8%
associate-*l/70.8%
*-commutative70.8%
exp-to-pow70.8%
*-commutative70.8%
Simplified70.8%
if 1e7 < (/.f64 1 n) Initial program 52.1%
Taylor expanded in x around 0 70.4%
fma-def70.4%
unpow270.4%
associate-*r/70.4%
metadata-eval70.4%
unpow270.4%
associate-*r/70.4%
metadata-eval70.4%
Simplified70.4%
Final simplification84.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= (/ 1.0 n) -0.004)
t_1
(if (<= (/ 1.0 n) 5e-84)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 10000000.0)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 1e+143) t_1 (/ (/ n x) (* n n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if ((1.0 / n) <= -0.004) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-84) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 1e+143) {
tmp = t_1;
} else {
tmp = (n / x) / (n * 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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = ((x + 1.0d0) ** (1.0d0 / n)) - t_0
if ((1.0d0 / n) <= (-0.004d0)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-84) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 10000000.0d0) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 1d+143) then
tmp = t_1
else
tmp = (n / x) / (n * n)
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 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if ((1.0 / n) <= -0.004) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-84) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 1e+143) {
tmp = t_1;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if (1.0 / n) <= -0.004: tmp = t_1 elif (1.0 / n) <= 5e-84: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 10000000.0: tmp = t_0 / (n * x) elif (1.0 / n) <= 1e+143: tmp = t_1 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (Float64(1.0 / n) <= -0.004) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-84) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 10000000.0) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 1e+143) tmp = t_1; else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0; tmp = 0.0; if ((1.0 / n) <= -0.004) tmp = t_1; elseif ((1.0 / n) <= 5e-84) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 10000000.0) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 1e+143) tmp = t_1; else tmp = (n / x) / (n * n); 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[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.004], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-84], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10000000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+143], t$95$1, N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{if}\;\frac{1}{n} \leq -0.004:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+143}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -0.0040000000000000001 or 1e7 < (/.f64 1 n) < 1e143Initial program 94.5%
if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84Initial program 27.9%
Taylor expanded in n around inf 80.9%
+-rgt-identity80.9%
+-rgt-identity80.9%
log1p-def80.9%
Simplified80.9%
flip--80.8%
unpow280.8%
unpow280.8%
Applied egg-rr80.8%
unpow280.8%
unpow280.8%
flip--80.9%
log1p-udef80.9%
diff-log81.0%
Applied egg-rr81.0%
if 5.0000000000000002e-84 < (/.f64 1 n) < 1e7Initial program 16.5%
add-log-exp16.5%
pow-to-exp16.5%
un-div-inv16.5%
+-commutative16.5%
log1p-udef16.5%
Applied egg-rr16.5%
Taylor expanded in x around inf 70.8%
mul-1-neg70.8%
log-rec70.8%
distribute-neg-frac70.8%
remove-double-neg70.8%
*-lft-identity70.8%
associate-*l/70.8%
*-commutative70.8%
exp-to-pow70.8%
*-commutative70.8%
Simplified70.8%
if 1e143 < (/.f64 1 n) Initial program 31.5%
Taylor expanded in n around inf 6.1%
+-rgt-identity6.1%
+-rgt-identity6.1%
log1p-def6.1%
Simplified6.1%
div-sub6.1%
Applied egg-rr6.1%
frac-sub81.8%
Applied egg-rr81.8%
log1p-def81.8%
*-commutative81.8%
distribute-lft-out--81.8%
log1p-def81.8%
Simplified81.8%
Taylor expanded in x around inf 81.8%
Final simplification85.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -5e+81)
(/ (/ 0.3333333333333333 (pow x 3.0)) n)
(if (<= (/ 1.0 n) -5e+19)
t_0
(if (<= (/ 1.0 n) 5e-84)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e-21)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 1e+143) t_0 (/ (/ n x) (* n n)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e+81) {
tmp = (0.3333333333333333 / pow(x, 3.0)) / n;
} else if ((1.0 / n) <= -5e+19) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-84) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-21) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 1e+143) {
tmp = t_0;
} else {
tmp = (n / x) / (n * 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 ** (1.0d0 / n))
if ((1.0d0 / n) <= (-5d+81)) then
tmp = (0.3333333333333333d0 / (x ** 3.0d0)) / n
else if ((1.0d0 / n) <= (-5d+19)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d-84) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d-21) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 1d+143) then
tmp = t_0
else
tmp = (n / x) / (n * n)
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 tmp;
if ((1.0 / n) <= -5e+81) {
tmp = (0.3333333333333333 / Math.pow(x, 3.0)) / n;
} else if ((1.0 / n) <= -5e+19) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-84) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-21) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 1e+143) {
tmp = t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e+81: tmp = (0.3333333333333333 / math.pow(x, 3.0)) / n elif (1.0 / n) <= -5e+19: tmp = t_0 elif (1.0 / n) <= 5e-84: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e-21: tmp = (1.0 / n) / x elif (1.0 / n) <= 1e+143: tmp = t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -5e+81) tmp = Float64(Float64(0.3333333333333333 / (x ^ 3.0)) / n); elseif (Float64(1.0 / n) <= -5e+19) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-84) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 1e+143) tmp = t_0; else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -5e+81) tmp = (0.3333333333333333 / (x ^ 3.0)) / n; elseif ((1.0 / n) <= -5e+19) tmp = t_0; elseif ((1.0 / n) <= 5e-84) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e-21) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 1e+143) tmp = t_0; else tmp = (n / x) / (n * n); 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]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+81], N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+19], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-84], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+143], t$95$0, N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+81}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+19}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+143}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999998e81Initial program 100.0%
Taylor expanded in n around inf 53.0%
+-rgt-identity53.0%
+-rgt-identity53.0%
log1p-def53.0%
Simplified53.0%
Taylor expanded in x around inf 23.8%
Taylor expanded in x around 0 80.8%
if -4.9999999999999998e81 < (/.f64 1 n) < -5e19 or 1.99999999999999982e-21 < (/.f64 1 n) < 1e143Initial program 79.0%
Taylor expanded in x around 0 65.9%
if -5e19 < (/.f64 1 n) < 5.0000000000000002e-84Initial program 31.8%
Taylor expanded in n around inf 81.5%
+-rgt-identity81.5%
+-rgt-identity81.5%
log1p-def81.5%
Simplified81.5%
flip--81.4%
unpow281.4%
unpow281.4%
Applied egg-rr81.4%
unpow281.4%
unpow281.4%
flip--81.5%
log1p-udef81.5%
diff-log81.5%
Applied egg-rr81.5%
if 5.0000000000000002e-84 < (/.f64 1 n) < 1.99999999999999982e-21Initial program 12.3%
Taylor expanded in n around inf 31.6%
fma-def31.6%
log1p-def31.6%
unpow231.6%
log1p-def31.6%
fma-def31.6%
unpow231.6%
Simplified31.6%
Taylor expanded in x around inf 80.7%
+-commutative80.7%
mul-1-neg80.7%
distribute-frac-neg80.7%
log-rec80.7%
remove-double-neg80.7%
unpow280.7%
Simplified80.7%
Taylor expanded in n around inf 80.7%
if 1e143 < (/.f64 1 n) Initial program 31.5%
Taylor expanded in n around inf 6.1%
+-rgt-identity6.1%
+-rgt-identity6.1%
log1p-def6.1%
Simplified6.1%
div-sub6.1%
Applied egg-rr6.1%
frac-sub81.8%
Applied egg-rr81.8%
log1p-def81.8%
*-commutative81.8%
distribute-lft-out--81.8%
log1p-def81.8%
Simplified81.8%
Taylor expanded in x around inf 81.8%
Final simplification79.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -0.004)
t_1
(if (<= (/ 1.0 n) 5e-84)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 10000000.0)
t_1
(if (<= (/ 1.0 n) 1e+143)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ n x) (* n 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) <= -0.004) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-84) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+143) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (n / x) / (n * 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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-0.004d0)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-84) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 10000000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+143) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (n / x) / (n * n)
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 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -0.004) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-84) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+143) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (n / x) / (n * 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) <= -0.004: tmp = t_1 elif (1.0 / n) <= 5e-84: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 10000000.0: tmp = t_1 elif (1.0 / n) <= 1e+143: tmp = (1.0 + (x / n)) - t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -0.004) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-84) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 10000000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+143) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -0.004) tmp = t_1; elseif ((1.0 / n) <= 5e-84) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 10000000.0) tmp = t_1; elseif ((1.0 / n) <= 1e+143) tmp = (1.0 + (x / n)) - t_0; else tmp = (n / x) / (n * n); 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[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.004], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-84], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10000000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+143], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -0.004:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+143}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -0.0040000000000000001 or 5.0000000000000002e-84 < (/.f64 1 n) < 1e7Initial program 86.5%
add-log-exp86.5%
pow-to-exp86.5%
un-div-inv86.5%
+-commutative86.5%
log1p-udef86.5%
Applied egg-rr86.5%
Taylor expanded in x around inf 94.5%
mul-1-neg94.5%
log-rec94.5%
distribute-neg-frac94.5%
remove-double-neg94.5%
*-lft-identity94.5%
associate-*l/94.5%
*-commutative94.5%
exp-to-pow94.5%
*-commutative94.5%
Simplified94.5%
if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84Initial program 27.9%
Taylor expanded in n around inf 80.9%
+-rgt-identity80.9%
+-rgt-identity80.9%
log1p-def80.9%
Simplified80.9%
flip--80.8%
unpow280.8%
unpow280.8%
Applied egg-rr80.8%
unpow280.8%
unpow280.8%
flip--80.9%
log1p-udef80.9%
diff-log81.0%
Applied egg-rr81.0%
if 1e7 < (/.f64 1 n) < 1e143Initial program 71.6%
Taylor expanded in x around 0 66.0%
if 1e143 < (/.f64 1 n) Initial program 31.5%
Taylor expanded in n around inf 6.1%
+-rgt-identity6.1%
+-rgt-identity6.1%
log1p-def6.1%
Simplified6.1%
div-sub6.1%
Applied egg-rr6.1%
frac-sub81.8%
Applied egg-rr81.8%
log1p-def81.8%
*-commutative81.8%
distribute-lft-out--81.8%
log1p-def81.8%
Simplified81.8%
Taylor expanded in x around inf 81.8%
Final simplification84.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -0.004)
t_1
(if (<= (/ 1.0 n) 5e-84)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 10000000.0)
t_1
(if (<= (/ 1.0 n) 1e+143) (- 1.0 t_0) (/ (/ n x) (* n 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) <= -0.004) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-84) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+143) {
tmp = 1.0 - t_0;
} else {
tmp = (n / x) / (n * 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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-0.004d0)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-84) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 10000000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+143) then
tmp = 1.0d0 - t_0
else
tmp = (n / x) / (n * n)
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 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -0.004) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-84) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 10000000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+143) {
tmp = 1.0 - t_0;
} else {
tmp = (n / x) / (n * 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) <= -0.004: tmp = t_1 elif (1.0 / n) <= 5e-84: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 10000000.0: tmp = t_1 elif (1.0 / n) <= 1e+143: tmp = 1.0 - t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -0.004) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-84) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 10000000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+143) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -0.004) tmp = t_1; elseif ((1.0 / n) <= 5e-84) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 10000000.0) tmp = t_1; elseif ((1.0 / n) <= 1e+143) tmp = 1.0 - t_0; else tmp = (n / x) / (n * n); 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[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.004], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-84], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10000000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+143], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -0.004:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+143}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -0.0040000000000000001 or 5.0000000000000002e-84 < (/.f64 1 n) < 1e7Initial program 86.5%
add-log-exp86.5%
pow-to-exp86.5%
un-div-inv86.5%
+-commutative86.5%
log1p-udef86.5%
Applied egg-rr86.5%
Taylor expanded in x around inf 94.5%
mul-1-neg94.5%
log-rec94.5%
distribute-neg-frac94.5%
remove-double-neg94.5%
*-lft-identity94.5%
associate-*l/94.5%
*-commutative94.5%
exp-to-pow94.5%
*-commutative94.5%
Simplified94.5%
if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84Initial program 27.9%
Taylor expanded in n around inf 80.9%
+-rgt-identity80.9%
+-rgt-identity80.9%
log1p-def80.9%
Simplified80.9%
flip--80.8%
unpow280.8%
unpow280.8%
Applied egg-rr80.8%
unpow280.8%
unpow280.8%
flip--80.9%
log1p-udef80.9%
diff-log81.0%
Applied egg-rr81.0%
if 1e7 < (/.f64 1 n) < 1e143Initial program 71.6%
Taylor expanded in x around 0 65.9%
if 1e143 < (/.f64 1 n) Initial program 31.5%
Taylor expanded in n around inf 6.1%
+-rgt-identity6.1%
+-rgt-identity6.1%
log1p-def6.1%
Simplified6.1%
div-sub6.1%
Applied egg-rr6.1%
frac-sub81.8%
Applied egg-rr81.8%
log1p-def81.8%
*-commutative81.8%
distribute-lft-out--81.8%
log1p-def81.8%
Simplified81.8%
Taylor expanded in x around inf 81.8%
Final simplification84.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)) (t_1 (/ (/ 0.3333333333333333 (pow x 3.0)) n)))
(if (<= x 1.4e-259)
t_0
(if (<= x 7.5e-230)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 3.3e-97)
t_0
(if (<= x 7.5e-74)
t_1
(if (<= x 0.98)
(/ (- x (log x)) n)
(if (<= x 1.15e+113)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)
t_1))))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double t_1 = (0.3333333333333333 / pow(x, 3.0)) / n;
double tmp;
if (x <= 1.4e-259) {
tmp = t_0;
} else if (x <= 7.5e-230) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 3.3e-97) {
tmp = t_0;
} else if (x <= 7.5e-74) {
tmp = t_1;
} else if (x <= 0.98) {
tmp = (x - log(x)) / n;
} else if (x <= 1.15e+113) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} 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 = -log(x) / n
t_1 = (0.3333333333333333d0 / (x ** 3.0d0)) / n
if (x <= 1.4d-259) then
tmp = t_0
else if (x <= 7.5d-230) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 3.3d-97) then
tmp = t_0
else if (x <= 7.5d-74) then
tmp = t_1
else if (x <= 0.98d0) then
tmp = (x - log(x)) / n
else if (x <= 1.15d+113) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double t_1 = (0.3333333333333333 / Math.pow(x, 3.0)) / n;
double tmp;
if (x <= 1.4e-259) {
tmp = t_0;
} else if (x <= 7.5e-230) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 3.3e-97) {
tmp = t_0;
} else if (x <= 7.5e-74) {
tmp = t_1;
} else if (x <= 0.98) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.15e+113) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n t_1 = (0.3333333333333333 / math.pow(x, 3.0)) / n tmp = 0 if x <= 1.4e-259: tmp = t_0 elif x <= 7.5e-230: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 3.3e-97: tmp = t_0 elif x <= 7.5e-74: tmp = t_1 elif x <= 0.98: tmp = (x - math.log(x)) / n elif x <= 1.15e+113: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) t_1 = Float64(Float64(0.3333333333333333 / (x ^ 3.0)) / n) tmp = 0.0 if (x <= 1.4e-259) tmp = t_0; elseif (x <= 7.5e-230) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 3.3e-97) tmp = t_0; elseif (x <= 7.5e-74) tmp = t_1; elseif (x <= 0.98) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.15e+113) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = t_1; end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; t_1 = (0.3333333333333333 / (x ^ 3.0)) / n; tmp = 0.0; if (x <= 1.4e-259) tmp = t_0; elseif (x <= 7.5e-230) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 3.3e-97) tmp = t_0; elseif (x <= 7.5e-74) tmp = t_1; elseif (x <= 0.98) tmp = (x - log(x)) / n; elseif (x <= 1.15e+113) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = t_1; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 1.4e-259], t$95$0, If[LessEqual[x, 7.5e-230], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.3e-97], t$95$0, If[LessEqual[x, 7.5e-74], t$95$1, If[LessEqual[x, 0.98], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.15e+113], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := \frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\
\mathbf{if}\;x \leq 1.4 \cdot 10^{-259}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-230}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-74}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 0.98:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{+113}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < 1.4e-259 or 7.50000000000000006e-230 < x < 3.3000000000000001e-97Initial program 33.3%
Taylor expanded in n around inf 67.9%
+-rgt-identity67.9%
+-rgt-identity67.9%
log1p-def67.9%
Simplified67.9%
Taylor expanded in x around 0 67.9%
neg-mul-167.9%
Simplified67.9%
if 1.4e-259 < x < 7.50000000000000006e-230Initial program 76.4%
Taylor expanded in x around 0 76.4%
if 3.3000000000000001e-97 < x < 7.5e-74 or 1.14999999999999998e113 < x Initial program 75.8%
Taylor expanded in n around inf 69.5%
+-rgt-identity69.5%
+-rgt-identity69.5%
log1p-def69.5%
Simplified69.5%
Taylor expanded in x around inf 63.5%
Taylor expanded in x around 0 79.4%
if 7.5e-74 < x < 0.97999999999999998Initial program 41.8%
Taylor expanded in n around inf 54.2%
+-rgt-identity54.2%
+-rgt-identity54.2%
log1p-def54.2%
Simplified54.2%
Taylor expanded in x around 0 52.4%
neg-mul-152.4%
unsub-neg52.4%
Simplified52.4%
if 0.97999999999999998 < x < 1.14999999999999998e113Initial program 37.1%
Taylor expanded in n around inf 39.1%
+-rgt-identity39.1%
+-rgt-identity39.1%
log1p-def39.1%
Simplified39.1%
Taylor expanded in x around inf 63.8%
associate-*r/63.8%
metadata-eval63.8%
unpow263.8%
Simplified63.8%
Final simplification69.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 1.9e-258)
t_0
(if (<= x 6e-230)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 7.6e-90)
t_0
(if (<= x 1.1e-73)
(/ (/ n x) (* n n))
(if (<= x 1.0)
(/ (- x (log x)) n)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n))))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 1.9e-258) {
tmp = t_0;
} else if (x <= 6e-230) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 7.6e-90) {
tmp = t_0;
} else if (x <= 1.1e-73) {
tmp = (n / x) / (n * n);
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / x) - (0.5 / (x * 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 = -log(x) / n
if (x <= 1.9d-258) then
tmp = t_0
else if (x <= 6d-230) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 7.6d-90) then
tmp = t_0
else if (x <= 1.1d-73) then
tmp = (n / x) / (n * n)
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double tmp;
if (x <= 1.9e-258) {
tmp = t_0;
} else if (x <= 6e-230) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 7.6e-90) {
tmp = t_0;
} else if (x <= 1.1e-73) {
tmp = (n / x) / (n * n);
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 1.9e-258: tmp = t_0 elif x <= 6e-230: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 7.6e-90: tmp = t_0 elif x <= 1.1e-73: tmp = (n / x) / (n * n) elif x <= 1.0: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / x) - (0.5 / (x * x))) / n return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 1.9e-258) tmp = t_0; elseif (x <= 6e-230) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 7.6e-90) tmp = t_0; elseif (x <= 1.1e-73) tmp = Float64(Float64(n / x) / Float64(n * n)); elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (x <= 1.9e-258) tmp = t_0; elseif (x <= 6e-230) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 7.6e-90) tmp = t_0; elseif (x <= 1.1e-73) tmp = (n / x) / (n * n); elseif (x <= 1.0) tmp = (x - log(x)) / n; else tmp = ((1.0 / x) - (0.5 / (x * x))) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 1.9e-258], t$95$0, If[LessEqual[x, 6e-230], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.6e-90], t$95$0, If[LessEqual[x, 1.1e-73], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 1.9 \cdot 10^{-258}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-230}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-73}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\end{array}
\end{array}
if x < 1.8999999999999999e-258 or 6e-230 < x < 7.6e-90Initial program 33.1%
Taylor expanded in n around inf 66.1%
+-rgt-identity66.1%
+-rgt-identity66.1%
log1p-def66.1%
Simplified66.1%
Taylor expanded in x around 0 66.1%
neg-mul-166.1%
Simplified66.1%
if 1.8999999999999999e-258 < x < 6e-230Initial program 76.4%
Taylor expanded in x around 0 76.4%
if 7.6e-90 < x < 1.1e-73Initial program 51.7%
Taylor expanded in n around inf 12.9%
+-rgt-identity12.9%
+-rgt-identity12.9%
log1p-def12.9%
Simplified12.9%
div-sub12.9%
Applied egg-rr12.9%
frac-sub72.8%
Applied egg-rr72.8%
log1p-def72.8%
*-commutative72.8%
distribute-lft-out--72.8%
log1p-def72.8%
Simplified72.8%
Taylor expanded in x around inf 66.2%
if 1.1e-73 < x < 1Initial program 41.8%
Taylor expanded in n around inf 54.2%
+-rgt-identity54.2%
+-rgt-identity54.2%
log1p-def54.2%
Simplified54.2%
Taylor expanded in x around 0 52.4%
neg-mul-152.4%
unsub-neg52.4%
Simplified52.4%
if 1 < x Initial program 65.4%
Taylor expanded in n around inf 66.2%
+-rgt-identity66.2%
+-rgt-identity66.2%
log1p-def66.2%
Simplified66.2%
Taylor expanded in x around inf 63.7%
associate-*r/63.7%
metadata-eval63.7%
unpow263.7%
Simplified63.7%
Final simplification63.6%
(FPCore (x n)
:precision binary64
(if (<= x 7.6e-90)
(/ (- (log x)) n)
(if (<= x 7.5e-74)
(/ (/ n x) (* n n))
(if (<= x 0.95)
(/ (- x (log x)) n)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)))))
double code(double x, double n) {
double tmp;
if (x <= 7.6e-90) {
tmp = -log(x) / n;
} else if (x <= 7.5e-74) {
tmp = (n / x) / (n * n);
} else if (x <= 0.95) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / x) - (0.5 / (x * 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 <= 7.6d-90) then
tmp = -log(x) / n
else if (x <= 7.5d-74) then
tmp = (n / x) / (n * n)
else if (x <= 0.95d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 7.6e-90) {
tmp = -Math.log(x) / n;
} else if (x <= 7.5e-74) {
tmp = (n / x) / (n * n);
} else if (x <= 0.95) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 7.6e-90: tmp = -math.log(x) / n elif x <= 7.5e-74: tmp = (n / x) / (n * n) elif x <= 0.95: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / x) - (0.5 / (x * x))) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 7.6e-90) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 7.5e-74) tmp = Float64(Float64(n / x) / Float64(n * n)); elseif (x <= 0.95) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 7.6e-90) tmp = -log(x) / n; elseif (x <= 7.5e-74) tmp = (n / x) / (n * n); elseif (x <= 0.95) tmp = (x - log(x)) / n; else tmp = ((1.0 / x) - (0.5 / (x * x))) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 7.6e-90], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 7.5e-74], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.95], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.6 \cdot 10^{-90}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\end{array}
\end{array}
if x < 7.6e-90Initial program 38.5%
Taylor expanded in n around inf 61.5%
+-rgt-identity61.5%
+-rgt-identity61.5%
log1p-def61.5%
Simplified61.5%
Taylor expanded in x around 0 61.5%
neg-mul-161.5%
Simplified61.5%
if 7.6e-90 < x < 7.5e-74Initial program 51.7%
Taylor expanded in n around inf 12.9%
+-rgt-identity12.9%
+-rgt-identity12.9%
log1p-def12.9%
Simplified12.9%
div-sub12.9%
Applied egg-rr12.9%
frac-sub72.8%
Applied egg-rr72.8%
log1p-def72.8%
*-commutative72.8%
distribute-lft-out--72.8%
log1p-def72.8%
Simplified72.8%
Taylor expanded in x around inf 66.2%
if 7.5e-74 < x < 0.94999999999999996Initial program 41.8%
Taylor expanded in n around inf 54.2%
+-rgt-identity54.2%
+-rgt-identity54.2%
log1p-def54.2%
Simplified54.2%
Taylor expanded in x around 0 52.4%
neg-mul-152.4%
unsub-neg52.4%
Simplified52.4%
if 0.94999999999999996 < x Initial program 65.4%
Taylor expanded in n around inf 66.2%
+-rgt-identity66.2%
+-rgt-identity66.2%
log1p-def66.2%
Simplified66.2%
Taylor expanded in x around inf 63.7%
associate-*r/63.7%
metadata-eval63.7%
unpow263.7%
Simplified63.7%
Final simplification61.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 6.5e-90)
t_0
(if (<= x 7.5e-74)
(/ (/ n x) (* n n))
(if (<= x 0.7) t_0 (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 6.5e-90) {
tmp = t_0;
} else if (x <= 7.5e-74) {
tmp = (n / x) / (n * n);
} else if (x <= 0.7) {
tmp = t_0;
} else {
tmp = ((1.0 / x) - (0.5 / (x * 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 = -log(x) / n
if (x <= 6.5d-90) then
tmp = t_0
else if (x <= 7.5d-74) then
tmp = (n / x) / (n * n)
else if (x <= 0.7d0) then
tmp = t_0
else
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double tmp;
if (x <= 6.5e-90) {
tmp = t_0;
} else if (x <= 7.5e-74) {
tmp = (n / x) / (n * n);
} else if (x <= 0.7) {
tmp = t_0;
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 6.5e-90: tmp = t_0 elif x <= 7.5e-74: tmp = (n / x) / (n * n) elif x <= 0.7: tmp = t_0 else: tmp = ((1.0 / x) - (0.5 / (x * x))) / n return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 6.5e-90) tmp = t_0; elseif (x <= 7.5e-74) tmp = Float64(Float64(n / x) / Float64(n * n)); elseif (x <= 0.7) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (x <= 6.5e-90) tmp = t_0; elseif (x <= 7.5e-74) tmp = (n / x) / (n * n); elseif (x <= 0.7) tmp = t_0; else tmp = ((1.0 / x) - (0.5 / (x * x))) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 6.5e-90], t$95$0, If[LessEqual[x, 7.5e-74], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.7], t$95$0, N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 6.5 \cdot 10^{-90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{elif}\;x \leq 0.7:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\end{array}
\end{array}
if x < 6.4999999999999996e-90 or 7.5e-74 < x < 0.69999999999999996Initial program 39.4%
Taylor expanded in n around inf 59.5%
+-rgt-identity59.5%
+-rgt-identity59.5%
log1p-def59.5%
Simplified59.5%
Taylor expanded in x around 0 58.6%
neg-mul-158.6%
Simplified58.6%
if 6.4999999999999996e-90 < x < 7.5e-74Initial program 51.7%
Taylor expanded in n around inf 12.9%
+-rgt-identity12.9%
+-rgt-identity12.9%
log1p-def12.9%
Simplified12.9%
div-sub12.9%
Applied egg-rr12.9%
frac-sub72.8%
Applied egg-rr72.8%
log1p-def72.8%
*-commutative72.8%
distribute-lft-out--72.8%
log1p-def72.8%
Simplified72.8%
Taylor expanded in x around inf 66.2%
if 0.69999999999999996 < x Initial program 65.4%
Taylor expanded in n around inf 66.2%
+-rgt-identity66.2%
+-rgt-identity66.2%
log1p-def66.2%
Simplified66.2%
Taylor expanded in x around inf 63.7%
associate-*r/63.7%
metadata-eval63.7%
unpow263.7%
Simplified63.7%
Final simplification61.2%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (/ n x) (* n n)) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (n / x) / (n * n);
} else {
tmp = ((1.0 / x) - (0.5 / (x * 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 <= 1.0d0) then
tmp = (n / x) / (n * n)
else
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (n / x) / (n * n);
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (n / x) / (n * n) else: tmp = ((1.0 / x) - (0.5 / (x * x))) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(n / x) / Float64(n * n)); else tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = (n / x) / (n * n); else tmp = ((1.0 / x) - (0.5 / (x * x))) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\end{array}
\end{array}
if x < 1Initial program 40.6%
Taylor expanded in n around inf 55.0%
+-rgt-identity55.0%
+-rgt-identity55.0%
log1p-def55.0%
Simplified55.0%
div-sub55.0%
Applied egg-rr55.0%
frac-sub49.2%
Applied egg-rr49.2%
log1p-def49.2%
*-commutative49.2%
distribute-lft-out--49.2%
log1p-def49.2%
Simplified49.2%
Taylor expanded in x around inf 28.3%
if 1 < x Initial program 65.4%
Taylor expanded in n around inf 66.2%
+-rgt-identity66.2%
+-rgt-identity66.2%
log1p-def66.2%
Simplified66.2%
Taylor expanded in x around inf 63.7%
associate-*r/63.7%
metadata-eval63.7%
unpow263.7%
Simplified63.7%
Final simplification43.4%
(FPCore (x n) :precision binary64 (if (<= x 0.0065) (/ (/ n x) (* n n)) (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.0065) {
tmp = (n / x) / (n * n);
} else {
tmp = (1.0 / 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.0065d0) then
tmp = (n / x) / (n * n)
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.0065) {
tmp = (n / x) / (n * n);
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.0065: tmp = (n / x) / (n * n) else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.0065) tmp = Float64(Float64(n / x) / Float64(n * n)); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.0065) tmp = (n / x) / (n * n); else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.0065], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0065:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if x < 0.0064999999999999997Initial program 40.4%
Taylor expanded in n around inf 55.1%
+-rgt-identity55.1%
+-rgt-identity55.1%
log1p-def55.1%
Simplified55.1%
div-sub55.1%
Applied egg-rr55.1%
frac-sub49.2%
Applied egg-rr49.2%
log1p-def49.2%
*-commutative49.2%
distribute-lft-out--49.2%
log1p-def49.2%
Simplified49.2%
Taylor expanded in x around inf 28.6%
if 0.0064999999999999997 < x Initial program 65.2%
Taylor expanded in n around inf 50.6%
fma-def50.6%
log1p-def50.6%
unpow250.6%
log1p-def50.7%
fma-def50.7%
unpow250.7%
Simplified50.7%
Taylor expanded in x around inf 62.0%
+-commutative62.0%
mul-1-neg62.0%
distribute-frac-neg62.0%
log-rec62.0%
remove-double-neg62.0%
unpow262.0%
Simplified62.0%
Taylor expanded in n around inf 62.3%
Final simplification43.2%
(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 51.2%
Taylor expanded in n around inf 59.8%
+-rgt-identity59.8%
+-rgt-identity59.8%
log1p-def59.8%
Simplified59.8%
Taylor expanded in x around inf 38.8%
*-commutative38.8%
Simplified38.8%
Final simplification38.8%
(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(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 51.2%
Taylor expanded in n around inf 52.6%
fma-def52.6%
log1p-def52.6%
unpow252.6%
log1p-def52.6%
fma-def52.6%
unpow252.6%
Simplified52.6%
Taylor expanded in x around inf 39.6%
+-commutative39.6%
mul-1-neg39.6%
distribute-frac-neg39.6%
log-rec39.6%
remove-double-neg39.6%
unpow239.6%
Simplified39.6%
Taylor expanded in n around inf 39.3%
Final simplification39.3%
herbie shell --seed 2023280
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))