
(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 13 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
(if (<= x 1500000.0)
(/
(log
(/
(exp
(+ (log1p x) (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n))))
x))
n)
(* (/ 1.0 x) (/ (pow x (/ 1.0 n)) n))))
double code(double x, double n) {
double tmp;
if (x <= 1500000.0) {
tmp = log((exp((log1p(x) + (0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)))) / x)) / n;
} else {
tmp = (1.0 / x) * (pow(x, (1.0 / n)) / n);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 1500000.0) {
tmp = Math.log((Math.exp((Math.log1p(x) + (0.5 * ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n)))) / x)) / n;
} else {
tmp = (1.0 / x) * (Math.pow(x, (1.0 / n)) / n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1500000.0: tmp = math.log((math.exp((math.log1p(x) + (0.5 * ((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n)))) / x)) / n else: tmp = (1.0 / x) * (math.pow(x, (1.0 / n)) / n) return tmp
function code(x, n) tmp = 0.0 if (x <= 1500000.0) tmp = Float64(log(Float64(exp(Float64(log1p(x) + Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)))) / x)) / n); else tmp = Float64(Float64(1.0 / x) * Float64((x ^ Float64(1.0 / n)) / n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 1500000.0], N[(N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] * N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1500000:\\
\;\;\;\;\frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\\
\end{array}
\end{array}
if x < 1.5e6Initial program 35.3%
Taylor expanded in n around inf 69.5%
Simplified69.5%
associate-+r-69.5%
add-log-exp79.7%
exp-diff79.7%
add-exp-log79.8%
Applied egg-rr79.8%
+-commutative79.8%
Simplified79.8%
if 1.5e6 < x Initial program 61.9%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
log-rec97.7%
mul-1-neg97.7%
distribute-neg-frac97.7%
mul-1-neg97.7%
remove-double-neg97.7%
*-commutative97.7%
Simplified97.7%
div-inv97.7%
pow-to-exp97.7%
*-un-lft-identity97.7%
times-frac99.2%
Applied egg-rr99.2%
Final simplification87.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-147)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 2e-6)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(exp (log (- (exp (/ (log1p x) n)) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 2e-6) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else {
tmp = exp(log((exp((log1p(x) / n)) - t_0)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 2e-6) {
tmp = (Math.log1p(x) + ((0.5 * ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n)) - Math.log(x))) / n;
} else {
tmp = Math.exp(Math.log((Math.exp((Math.log1p(x) / n)) - t_0)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-147: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 2e-6: tmp = (math.log1p(x) + ((0.5 * ((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n)) - math.log(x))) / n else: tmp = math.exp(math.log((math.exp((math.log1p(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) <= -1e-147) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 2e-6) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); else tmp = exp(log(Float64(exp(Float64(log1p(x) / n)) - t_0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-147], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[Exp[N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-147}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999997e-148Initial program 65.4%
Taylor expanded in x around inf 84.6%
mul-1-neg84.6%
log-rec84.6%
mul-1-neg84.6%
distribute-neg-frac84.6%
mul-1-neg84.6%
remove-double-neg84.6%
*-commutative84.6%
Simplified84.6%
div-inv84.6%
pow-to-exp84.6%
*-un-lft-identity84.6%
times-frac85.2%
Applied egg-rr85.2%
if -9.9999999999999997e-148 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6Initial program 27.4%
Taylor expanded in n around inf 85.4%
Simplified85.4%
if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) Initial program 53.3%
add-exp-log53.3%
pow-to-exp53.3%
un-div-inv53.3%
+-commutative53.3%
log1p-define99.7%
Applied egg-rr99.7%
Final simplification87.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-147)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 5e-14)
(/ (- (log1p x) (log x)) n)
(exp (log (- (exp (/ (log1p x) n)) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 5e-14) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp(log((exp((log1p(x) / n)) - t_0)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 5e-14) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp(Math.log((Math.exp((Math.log1p(x) / n)) - t_0)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-147: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 5e-14: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp(math.log((math.exp((math.log1p(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) <= -1e-147) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 5e-14) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = exp(log(Float64(exp(Float64(log1p(x) / n)) - t_0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-147], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-14], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[Exp[N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-147}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999997e-148Initial program 65.4%
Taylor expanded in x around inf 84.6%
mul-1-neg84.6%
log-rec84.6%
mul-1-neg84.6%
distribute-neg-frac84.6%
mul-1-neg84.6%
remove-double-neg84.6%
*-commutative84.6%
Simplified84.6%
div-inv84.6%
pow-to-exp84.6%
*-un-lft-identity84.6%
times-frac85.2%
Applied egg-rr85.2%
if -9.9999999999999997e-148 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000002e-14Initial program 28.0%
Taylor expanded in n around inf 87.1%
log1p-define87.1%
Simplified87.1%
if 5.0000000000000002e-14 < (/.f64 #s(literal 1 binary64) n) Initial program 49.2%
add-exp-log49.2%
pow-to-exp49.2%
un-div-inv49.2%
+-commutative49.2%
log1p-define91.5%
Applied egg-rr91.5%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-147)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 5e-14)
(/ (- (log1p x) (log x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 5e-14) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 5e-14) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-147: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 5e-14: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp((math.log1p(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) <= -1e-147) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 5e-14) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-147], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-14], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-147}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999997e-148Initial program 65.4%
Taylor expanded in x around inf 84.6%
mul-1-neg84.6%
log-rec84.6%
mul-1-neg84.6%
distribute-neg-frac84.6%
mul-1-neg84.6%
remove-double-neg84.6%
*-commutative84.6%
Simplified84.6%
div-inv84.6%
pow-to-exp84.6%
*-un-lft-identity84.6%
times-frac85.2%
Applied egg-rr85.2%
if -9.9999999999999997e-148 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000002e-14Initial program 28.0%
Taylor expanded in n around inf 87.1%
log1p-define87.1%
Simplified87.1%
if 5.0000000000000002e-14 < (/.f64 #s(literal 1 binary64) n) Initial program 49.2%
Taylor expanded in n around 0 49.2%
log1p-define91.5%
Simplified91.5%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-147)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 2e-6)
(/ (- (log1p x) (log x)) n)
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n)))))))
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 2e-6) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 2e-6) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-147: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 2e-6: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-147) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 2e-6) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) + Float64(0.5 * Float64(-1.0 / n))))))) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-147], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-147}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999997e-148Initial program 65.4%
Taylor expanded in x around inf 84.6%
mul-1-neg84.6%
log-rec84.6%
mul-1-neg84.6%
distribute-neg-frac84.6%
mul-1-neg84.6%
remove-double-neg84.6%
*-commutative84.6%
Simplified84.6%
div-inv84.6%
pow-to-exp84.6%
*-un-lft-identity84.6%
times-frac85.2%
Applied egg-rr85.2%
if -9.9999999999999997e-148 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6Initial program 27.4%
Taylor expanded in n around inf 85.1%
log1p-define85.1%
Simplified85.1%
if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) Initial program 53.3%
Taylor expanded in x around 0 74.8%
Final simplification83.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (pow x (/ 1.0 n))) (t_2 (- 1.0 t_1)))
(if (<= x 4e-282)
t_0
(if (<= x 1.45e-270)
t_2
(if (<= x 5.5e-214)
t_0
(if (<= x 1.75e-199)
t_2
(if (<= x 1.2e-78)
t_0
(if (<= x 1.9e-70)
(log1p (expm1 (/ (/ 1.0 x) n)))
(if (<= x 5.6e-12) t_0 (* (/ 1.0 x) (/ t_1 n)))))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = pow(x, (1.0 / n));
double t_2 = 1.0 - t_1;
double tmp;
if (x <= 4e-282) {
tmp = t_0;
} else if (x <= 1.45e-270) {
tmp = t_2;
} else if (x <= 5.5e-214) {
tmp = t_0;
} else if (x <= 1.75e-199) {
tmp = t_2;
} else if (x <= 1.2e-78) {
tmp = t_0;
} else if (x <= 1.9e-70) {
tmp = log1p(expm1(((1.0 / x) / n)));
} else if (x <= 5.6e-12) {
tmp = t_0;
} else {
tmp = (1.0 / x) * (t_1 / n);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = 1.0 - t_1;
double tmp;
if (x <= 4e-282) {
tmp = t_0;
} else if (x <= 1.45e-270) {
tmp = t_2;
} else if (x <= 5.5e-214) {
tmp = t_0;
} else if (x <= 1.75e-199) {
tmp = t_2;
} else if (x <= 1.2e-78) {
tmp = t_0;
} else if (x <= 1.9e-70) {
tmp = Math.log1p(Math.expm1(((1.0 / x) / n)));
} else if (x <= 5.6e-12) {
tmp = t_0;
} else {
tmp = (1.0 / x) * (t_1 / n);
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = math.pow(x, (1.0 / n)) t_2 = 1.0 - t_1 tmp = 0 if x <= 4e-282: tmp = t_0 elif x <= 1.45e-270: tmp = t_2 elif x <= 5.5e-214: tmp = t_0 elif x <= 1.75e-199: tmp = t_2 elif x <= 1.2e-78: tmp = t_0 elif x <= 1.9e-70: tmp = math.log1p(math.expm1(((1.0 / x) / n))) elif x <= 5.6e-12: tmp = t_0 else: tmp = (1.0 / x) * (t_1 / n) return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(1.0 - t_1) tmp = 0.0 if (x <= 4e-282) tmp = t_0; elseif (x <= 1.45e-270) tmp = t_2; elseif (x <= 5.5e-214) tmp = t_0; elseif (x <= 1.75e-199) tmp = t_2; elseif (x <= 1.2e-78) tmp = t_0; elseif (x <= 1.9e-70) tmp = log1p(expm1(Float64(Float64(1.0 / x) / n))); elseif (x <= 5.6e-12) tmp = t_0; else tmp = Float64(Float64(1.0 / x) * Float64(t_1 / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, If[LessEqual[x, 4e-282], t$95$0, If[LessEqual[x, 1.45e-270], t$95$2, If[LessEqual[x, 5.5e-214], t$95$0, If[LessEqual[x, 1.75e-199], t$95$2, If[LessEqual[x, 1.2e-78], t$95$0, If[LessEqual[x, 1.9e-70], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 5.6e-12], t$95$0, N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$1 / n), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := 1 - t\_1\\
\mathbf{if}\;x \leq 4 \cdot 10^{-282}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-270}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-214}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-199}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-78}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-70}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_1}{n}\\
\end{array}
\end{array}
if x < 4.0000000000000001e-282 or 1.44999999999999991e-270 < x < 5.50000000000000024e-214 or 1.7499999999999999e-199 < x < 1.2e-78 or 1.8999999999999999e-70 < x < 5.6000000000000004e-12Initial program 26.3%
Taylor expanded in x around 0 25.6%
Taylor expanded in n around inf 69.8%
associate-*r/69.8%
neg-mul-169.8%
Simplified69.8%
if 4.0000000000000001e-282 < x < 1.44999999999999991e-270 or 5.50000000000000024e-214 < x < 1.7499999999999999e-199Initial program 92.6%
Taylor expanded in x around 0 92.6%
if 1.2e-78 < x < 1.8999999999999999e-70Initial program 71.1%
Taylor expanded in x around inf 67.7%
mul-1-neg67.7%
log-rec67.7%
mul-1-neg67.7%
distribute-neg-frac67.7%
mul-1-neg67.7%
remove-double-neg67.7%
*-commutative67.7%
Simplified67.7%
Taylor expanded in n around inf 16.5%
*-commutative16.5%
Simplified16.5%
log1p-expm1-u89.2%
associate-/r*89.2%
Applied egg-rr89.2%
if 5.6000000000000004e-12 < x Initial program 60.5%
Taylor expanded in x around inf 93.7%
mul-1-neg93.7%
log-rec93.7%
mul-1-neg93.7%
distribute-neg-frac93.7%
mul-1-neg93.7%
remove-double-neg93.7%
*-commutative93.7%
Simplified93.7%
div-inv93.7%
pow-to-exp93.7%
*-un-lft-identity93.7%
times-frac95.1%
Applied egg-rr95.1%
Final simplification82.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ 1.0 (* x n))))
(if (<= (/ 1.0 n) -1e-147)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 2e-6)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e+131)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (* t_1 t_1)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 / (x * n);
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 2e-6) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e+131) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt((t_1 * t_1));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = 1.0 / (x * n);
double tmp;
if ((1.0 / n) <= -1e-147) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 2e-6) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e+131) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt((t_1 * t_1));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 / (x * n) tmp = 0 if (1.0 / n) <= -1e-147: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 2e-6: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e+131: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt((t_1 * t_1)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 / Float64(x * n)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-147) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 2e-6) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e+131) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt(Float64(t_1 * 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[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-147], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+131], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[(t$95$1 * t$95$1), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{x \cdot n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-147}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+131}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1 \cdot t\_1}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999997e-148Initial program 65.4%
Taylor expanded in x around inf 84.6%
mul-1-neg84.6%
log-rec84.6%
mul-1-neg84.6%
distribute-neg-frac84.6%
mul-1-neg84.6%
remove-double-neg84.6%
*-commutative84.6%
Simplified84.6%
div-inv84.6%
pow-to-exp84.6%
*-un-lft-identity84.6%
times-frac85.2%
Applied egg-rr85.2%
if -9.9999999999999997e-148 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6Initial program 27.4%
Taylor expanded in n around inf 85.1%
log1p-define85.1%
Simplified85.1%
if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999995e131Initial program 78.3%
Taylor expanded in x around 0 85.5%
if 4.99999999999999995e131 < (/.f64 #s(literal 1 binary64) n) Initial program 32.7%
Taylor expanded in x around inf 0.6%
mul-1-neg0.6%
log-rec0.6%
mul-1-neg0.6%
distribute-neg-frac0.6%
mul-1-neg0.6%
remove-double-neg0.6%
*-commutative0.6%
Simplified0.6%
Taylor expanded in n around inf 39.4%
*-commutative39.4%
Simplified39.4%
add-sqr-sqrt39.4%
sqrt-unprod77.2%
inv-pow77.2%
inv-pow77.2%
pow-prod-up77.2%
metadata-eval77.2%
Applied egg-rr77.2%
metadata-eval77.2%
pow-prod-up77.2%
inv-pow77.2%
inv-pow77.2%
Applied egg-rr77.2%
Final simplification84.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (pow x (/ 1.0 n))) (t_2 (- 1.0 t_1)))
(if (<= x 4.1e-282)
t_0
(if (<= x 4.8e-271)
t_2
(if (<= x 5.5e-214)
t_0
(if (<= x 1.9e-199)
t_2
(if (<= x 5.5e-12) t_0 (* (/ 1.0 x) (/ t_1 n)))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = pow(x, (1.0 / n));
double t_2 = 1.0 - t_1;
double tmp;
if (x <= 4.1e-282) {
tmp = t_0;
} else if (x <= 4.8e-271) {
tmp = t_2;
} else if (x <= 5.5e-214) {
tmp = t_0;
} else if (x <= 1.9e-199) {
tmp = t_2;
} else if (x <= 5.5e-12) {
tmp = t_0;
} else {
tmp = (1.0 / x) * (t_1 / 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) :: t_2
real(8) :: tmp
t_0 = log(x) / -n
t_1 = x ** (1.0d0 / n)
t_2 = 1.0d0 - t_1
if (x <= 4.1d-282) then
tmp = t_0
else if (x <= 4.8d-271) then
tmp = t_2
else if (x <= 5.5d-214) then
tmp = t_0
else if (x <= 1.9d-199) then
tmp = t_2
else if (x <= 5.5d-12) then
tmp = t_0
else
tmp = (1.0d0 / x) * (t_1 / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = 1.0 - t_1;
double tmp;
if (x <= 4.1e-282) {
tmp = t_0;
} else if (x <= 4.8e-271) {
tmp = t_2;
} else if (x <= 5.5e-214) {
tmp = t_0;
} else if (x <= 1.9e-199) {
tmp = t_2;
} else if (x <= 5.5e-12) {
tmp = t_0;
} else {
tmp = (1.0 / x) * (t_1 / n);
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = math.pow(x, (1.0 / n)) t_2 = 1.0 - t_1 tmp = 0 if x <= 4.1e-282: tmp = t_0 elif x <= 4.8e-271: tmp = t_2 elif x <= 5.5e-214: tmp = t_0 elif x <= 1.9e-199: tmp = t_2 elif x <= 5.5e-12: tmp = t_0 else: tmp = (1.0 / x) * (t_1 / n) return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(1.0 - t_1) tmp = 0.0 if (x <= 4.1e-282) tmp = t_0; elseif (x <= 4.8e-271) tmp = t_2; elseif (x <= 5.5e-214) tmp = t_0; elseif (x <= 1.9e-199) tmp = t_2; elseif (x <= 5.5e-12) tmp = t_0; else tmp = Float64(Float64(1.0 / x) * Float64(t_1 / n)); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = x ^ (1.0 / n); t_2 = 1.0 - t_1; tmp = 0.0; if (x <= 4.1e-282) tmp = t_0; elseif (x <= 4.8e-271) tmp = t_2; elseif (x <= 5.5e-214) tmp = t_0; elseif (x <= 1.9e-199) tmp = t_2; elseif (x <= 5.5e-12) tmp = t_0; else tmp = (1.0 / x) * (t_1 / n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, If[LessEqual[x, 4.1e-282], t$95$0, If[LessEqual[x, 4.8e-271], t$95$2, If[LessEqual[x, 5.5e-214], t$95$0, If[LessEqual[x, 1.9e-199], t$95$2, If[LessEqual[x, 5.5e-12], t$95$0, N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$1 / n), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := 1 - t\_1\\
\mathbf{if}\;x \leq 4.1 \cdot 10^{-282}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-271}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-214}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-199}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_1}{n}\\
\end{array}
\end{array}
if x < 4.09999999999999977e-282 or 4.8000000000000005e-271 < x < 5.50000000000000024e-214 or 1.8999999999999999e-199 < x < 5.5000000000000004e-12Initial program 29.3%
Taylor expanded in x around 0 28.6%
Taylor expanded in n around inf 66.1%
associate-*r/66.1%
neg-mul-166.1%
Simplified66.1%
if 4.09999999999999977e-282 < x < 4.8000000000000005e-271 or 5.50000000000000024e-214 < x < 1.8999999999999999e-199Initial program 92.6%
Taylor expanded in x around 0 92.6%
if 5.5000000000000004e-12 < x Initial program 60.5%
Taylor expanded in x around inf 93.7%
mul-1-neg93.7%
log-rec93.7%
mul-1-neg93.7%
distribute-neg-frac93.7%
mul-1-neg93.7%
remove-double-neg93.7%
*-commutative93.7%
Simplified93.7%
div-inv93.7%
pow-to-exp93.7%
*-un-lft-identity93.7%
times-frac95.1%
Applied egg-rr95.1%
Final simplification79.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 1.25e-282)
t_0
(if (<= x 8.4e-271)
t_1
(if (<= x 3.2e-215)
t_0
(if (<= x 9.5e-197)
t_1
(if (<= x 1.72e-12) t_0 (/ (pow x (+ (/ 1.0 n) -1.0)) n))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 1.25e-282) {
tmp = t_0;
} else if (x <= 8.4e-271) {
tmp = t_1;
} else if (x <= 3.2e-215) {
tmp = t_0;
} else if (x <= 9.5e-197) {
tmp = t_1;
} else if (x <= 1.72e-12) {
tmp = t_0;
} else {
tmp = pow(x, ((1.0 / n) + -1.0)) / 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 = log(x) / -n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 1.25d-282) then
tmp = t_0
else if (x <= 8.4d-271) then
tmp = t_1
else if (x <= 3.2d-215) then
tmp = t_0
else if (x <= 9.5d-197) then
tmp = t_1
else if (x <= 1.72d-12) then
tmp = t_0
else
tmp = (x ** ((1.0d0 / n) + (-1.0d0))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.25e-282) {
tmp = t_0;
} else if (x <= 8.4e-271) {
tmp = t_1;
} else if (x <= 3.2e-215) {
tmp = t_0;
} else if (x <= 9.5e-197) {
tmp = t_1;
} else if (x <= 1.72e-12) {
tmp = t_0;
} else {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.25e-282: tmp = t_0 elif x <= 8.4e-271: tmp = t_1 elif x <= 3.2e-215: tmp = t_0 elif x <= 9.5e-197: tmp = t_1 elif x <= 1.72e-12: tmp = t_0 else: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 1.25e-282) tmp = t_0; elseif (x <= 8.4e-271) tmp = t_1; elseif (x <= 3.2e-215) tmp = t_0; elseif (x <= 9.5e-197) tmp = t_1; elseif (x <= 1.72e-12) tmp = t_0; else tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 1.25e-282) tmp = t_0; elseif (x <= 8.4e-271) tmp = t_1; elseif (x <= 3.2e-215) tmp = t_0; elseif (x <= 9.5e-197) tmp = t_1; elseif (x <= 1.72e-12) tmp = t_0; else tmp = (x ^ ((1.0 / n) + -1.0)) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.25e-282], t$95$0, If[LessEqual[x, 8.4e-271], t$95$1, If[LessEqual[x, 3.2e-215], t$95$0, If[LessEqual[x, 9.5e-197], t$95$1, If[LessEqual[x, 1.72e-12], t$95$0, N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.25 \cdot 10^{-282}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.4 \cdot 10^{-271}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-215}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-197}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\end{array}
\end{array}
if x < 1.25e-282 or 8.4000000000000003e-271 < x < 3.2000000000000001e-215 or 9.5000000000000003e-197 < x < 1.7199999999999999e-12Initial program 29.3%
Taylor expanded in x around 0 28.6%
Taylor expanded in n around inf 66.1%
associate-*r/66.1%
neg-mul-166.1%
Simplified66.1%
if 1.25e-282 < x < 8.4000000000000003e-271 or 3.2000000000000001e-215 < x < 9.5000000000000003e-197Initial program 92.6%
Taylor expanded in x around 0 92.6%
if 1.7199999999999999e-12 < x Initial program 60.5%
Taylor expanded in x around inf 93.7%
mul-1-neg93.7%
log-rec93.7%
mul-1-neg93.7%
distribute-neg-frac93.7%
mul-1-neg93.7%
remove-double-neg93.7%
*-commutative93.7%
Simplified93.7%
*-un-lft-identity93.7%
associate-/r*95.2%
div-inv95.2%
pow-to-exp95.2%
pow195.2%
pow-div94.8%
Applied egg-rr94.8%
*-lft-identity94.8%
sub-neg94.8%
metadata-eval94.8%
Simplified94.8%
Final simplification79.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 1.75e-282)
t_0
(if (<= x 6.2e-271)
t_1
(if (<= x 3.65e-214)
t_0
(if (<= x 1.76e-199) t_1 (if (<= x 0.00145) t_0 (/ (/ 1.0 x) n))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 1.75e-282) {
tmp = t_0;
} else if (x <= 6.2e-271) {
tmp = t_1;
} else if (x <= 3.65e-214) {
tmp = t_0;
} else if (x <= 1.76e-199) {
tmp = t_1;
} else if (x <= 0.00145) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log(x) / -n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 1.75d-282) then
tmp = t_0
else if (x <= 6.2d-271) then
tmp = t_1
else if (x <= 3.65d-214) then
tmp = t_0
else if (x <= 1.76d-199) then
tmp = t_1
else if (x <= 0.00145d0) then
tmp = t_0
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.75e-282) {
tmp = t_0;
} else if (x <= 6.2e-271) {
tmp = t_1;
} else if (x <= 3.65e-214) {
tmp = t_0;
} else if (x <= 1.76e-199) {
tmp = t_1;
} else if (x <= 0.00145) {
tmp = t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.75e-282: tmp = t_0 elif x <= 6.2e-271: tmp = t_1 elif x <= 3.65e-214: tmp = t_0 elif x <= 1.76e-199: tmp = t_1 elif x <= 0.00145: tmp = t_0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 1.75e-282) tmp = t_0; elseif (x <= 6.2e-271) tmp = t_1; elseif (x <= 3.65e-214) tmp = t_0; elseif (x <= 1.76e-199) tmp = t_1; elseif (x <= 0.00145) tmp = t_0; else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 1.75e-282) tmp = t_0; elseif (x <= 6.2e-271) tmp = t_1; elseif (x <= 3.65e-214) tmp = t_0; elseif (x <= 1.76e-199) tmp = t_1; elseif (x <= 0.00145) tmp = t_0; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.75e-282], t$95$0, If[LessEqual[x, 6.2e-271], t$95$1, If[LessEqual[x, 3.65e-214], t$95$0, If[LessEqual[x, 1.76e-199], t$95$1, If[LessEqual[x, 0.00145], t$95$0, N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.75 \cdot 10^{-282}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-271}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.65 \cdot 10^{-214}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.76 \cdot 10^{-199}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.00145:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1.75000000000000003e-282 or 6.1999999999999998e-271 < x < 3.65000000000000015e-214 or 1.76000000000000011e-199 < x < 0.00145Initial program 30.1%
Taylor expanded in x around 0 29.4%
Taylor expanded in n around inf 65.0%
associate-*r/65.0%
neg-mul-165.0%
Simplified65.0%
if 1.75000000000000003e-282 < x < 6.1999999999999998e-271 or 3.65000000000000015e-214 < x < 1.76000000000000011e-199Initial program 92.6%
Taylor expanded in x around 0 92.6%
if 0.00145 < x Initial program 60.7%
Taylor expanded in x around inf 95.2%
mul-1-neg95.2%
log-rec95.2%
mul-1-neg95.2%
distribute-neg-frac95.2%
mul-1-neg95.2%
remove-double-neg95.2%
*-commutative95.2%
Simplified95.2%
Taylor expanded in n around inf 64.0%
*-commutative64.0%
Simplified64.0%
*-un-lft-identity64.0%
associate-/r*65.5%
Applied egg-rr65.5%
Final simplification66.6%
(FPCore (x n) :precision binary64 (if (<= x 0.00145) (/ (log x) (- n)) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.00145) {
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.00145d0) 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.00145) {
tmp = Math.log(x) / -n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.00145: tmp = math.log(x) / -n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.00145) tmp = Float64(log(x) / Float64(-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.00145) tmp = log(x) / -n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.00145], 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.00145:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 0.00145Initial program 35.4%
Taylor expanded in x around 0 34.8%
Taylor expanded in n around inf 60.6%
associate-*r/60.6%
neg-mul-160.6%
Simplified60.6%
if 0.00145 < x Initial program 60.7%
Taylor expanded in x around inf 95.2%
mul-1-neg95.2%
log-rec95.2%
mul-1-neg95.2%
distribute-neg-frac95.2%
mul-1-neg95.2%
remove-double-neg95.2%
*-commutative95.2%
Simplified95.2%
Taylor expanded in n around inf 64.0%
*-commutative64.0%
Simplified64.0%
*-un-lft-identity64.0%
associate-/r*65.5%
Applied egg-rr65.5%
Final simplification62.6%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 45.7%
Taylor expanded in x around inf 53.1%
mul-1-neg53.1%
log-rec53.1%
mul-1-neg53.1%
distribute-neg-frac53.1%
mul-1-neg53.1%
remove-double-neg53.1%
*-commutative53.1%
Simplified53.1%
Taylor expanded in n around inf 37.6%
*-commutative37.6%
Simplified37.6%
Final simplification37.6%
(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 45.7%
Taylor expanded in x around inf 53.1%
mul-1-neg53.1%
log-rec53.1%
mul-1-neg53.1%
distribute-neg-frac53.1%
mul-1-neg53.1%
remove-double-neg53.1%
*-commutative53.1%
Simplified53.1%
Taylor expanded in n around inf 37.6%
*-commutative37.6%
Simplified37.6%
*-un-lft-identity37.6%
associate-/r*38.2%
Applied egg-rr38.2%
Final simplification38.2%
herbie shell --seed 2024071
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))