
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(fma
(pow x (/ 0.6666666666666666 n))
(cbrt (- t_0))
(exp (/ (log1p x) n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = fma(pow(x, (0.6666666666666666 / n)), cbrt(-t_0), exp((log1p(x) / n)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); else tmp = fma((x ^ Float64(0.6666666666666666 / n)), cbrt(Float64(-t_0)), exp(Float64(log1p(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[(1.0 / n), $MachinePrecision], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, N[(0.6666666666666666 / n), $MachinePrecision]], $MachinePrecision] * N[Power[(-t$95$0), 1/3], $MachinePrecision] + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({x}^{\left(\frac{0.6666666666666666}{n}\right)}, \sqrt[3]{-t_0}, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) Initial program 58.4%
sub-neg58.4%
+-commutative58.4%
add-cube-cbrt58.2%
fma-def58.4%
add-exp-log58.4%
log-pow58.4%
+-commutative58.4%
log1p-udef95.4%
*-commutative95.4%
un-div-inv95.4%
Applied egg-rr95.4%
expm1-log1p-u95.2%
expm1-udef95.3%
cbrt-unprod95.5%
sqr-neg95.5%
pow-sqr95.5%
div-inv95.5%
Applied egg-rr95.5%
expm1-def95.3%
expm1-log1p95.4%
Simplified95.4%
pow1/395.4%
pow-pow95.4%
Applied egg-rr95.4%
associate-*l/95.5%
metadata-eval95.5%
Simplified95.5%
Final simplification91.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / 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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / 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) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / 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) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / 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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $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 -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) Initial program 58.4%
add-exp-log58.5%
add-exp-log58.5%
log-pow58.5%
+-commutative58.5%
log1p-udef95.4%
*-commutative95.4%
un-div-inv95.4%
Applied egg-rr95.4%
Final simplification91.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(- (sqrt (exp (* (log1p x) (/ 2.0 n)))) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = sqrt(exp((log1p(x) * (2.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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = Math.sqrt(Math.exp((Math.log1p(x) * (2.0 / n)))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n else: tmp = math.sqrt(math.exp((math.log1p(x) * (2.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) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(sqrt(exp(Float64(log1p(x) * Float64(2.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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[Sqrt[N[Exp[N[(N[Log[1 + x], $MachinePrecision] * N[(2.0 / n), $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 -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{e^{\mathsf{log1p}\left(x\right) \cdot \frac{2}{n}}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) Initial program 58.4%
Taylor expanded in n around 0 58.4%
log1p-def95.4%
Simplified95.4%
add-sqr-sqrt95.3%
sqrt-prod95.4%
unpow295.4%
pow-exp95.4%
div-inv95.4%
associate-*l*95.4%
associate-/r/95.4%
clear-num95.4%
Applied egg-rr95.4%
Final simplification91.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / 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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / 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) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / 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) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / 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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $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 -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) Initial program 58.4%
Taylor expanded in n around 0 58.4%
log1p-def95.4%
Simplified95.4%
Final simplification91.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 4e+149)
(- (pow (+ 1.0 x) (/ 1.0 n)) t_0)
(log (pow (/ (+ 1.0 x) x) (/ 1.0 n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e+149) {
tmp = pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = log(pow(((1.0 + x) / x), (1.0 / n)));
}
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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e+149) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = Math.log(Math.pow(((1.0 + x) / x), (1.0 / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 4e+149: tmp = math.pow((1.0 + x), (1.0 / n)) - t_0 else: tmp = math.log(math.pow(((1.0 + x) / x), (1.0 / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 4e+149) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0); else tmp = log((Float64(Float64(1.0 + x) / x) ^ Float64(1.0 / n))); 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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+149], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[N[Power[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+149}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{else}:\\
\;\;\;\;\log \left({\left(\frac{1 + x}{x}\right)}^{\left(\frac{1}{n}\right)}\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) < 4.0000000000000002e149Initial program 77.5%
if 4.0000000000000002e149 < (/.f64 1 n) Initial program 25.5%
Taylor expanded in n around inf 6.1%
log1p-def6.1%
Simplified6.1%
add-log-exp78.5%
div-inv78.5%
exp-prod78.5%
exp-diff78.5%
add-exp-log78.5%
log1p-udef78.5%
rem-exp-log78.5%
+-commutative78.5%
Applied egg-rr78.5%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 4e+149)
(- (+ 1.0 (/ x n)) t_0)
(log (pow (/ (+ 1.0 x) x) (/ 1.0 n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e+149) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log(pow(((1.0 + x) / x), (1.0 / n)));
}
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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e+149) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log(Math.pow(((1.0 + x) / x), (1.0 / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 4e+149: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log(math.pow(((1.0 + x) / x), (1.0 / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 4e+149) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log((Float64(Float64(1.0 + x) / x) ^ Float64(1.0 / n))); 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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+149], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[N[Power[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+149}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\log \left({\left(\frac{1 + x}{x}\right)}^{\left(\frac{1}{n}\right)}\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) < 4.0000000000000002e149Initial program 77.5%
Taylor expanded in x around 0 74.3%
if 4.0000000000000002e149 < (/.f64 1 n) Initial program 25.5%
Taylor expanded in n around inf 6.1%
log1p-def6.1%
Simplified6.1%
add-log-exp78.5%
div-inv78.5%
exp-prod78.5%
exp-diff78.5%
add-exp-log78.5%
log1p-udef78.5%
rem-exp-log78.5%
+-commutative78.5%
Applied egg-rr78.5%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e+193)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e+193: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e+193) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); 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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 76.7%
Taylor expanded in x around 0 70.9%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification87.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 x) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -5e+214)
0.0
(if (<= (/ 1.0 n) -5000.0)
t_1
(if (<= (/ 1.0 n) -2e-134)
(/ (- x (log x)) n)
(if (<= (/ 1.0 n) -5e-251)
t_0
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
t_0
(if (<= (/ 1.0 n) 5e+193) t_1 (/ 1.0 (* n x)))))))))))
double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = 0.0;
} else if ((1.0 / n) <= -5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= -2e-134) {
tmp = (x - log(x)) / n;
} else if ((1.0 / n) <= -5e-251) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = -log(x) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = t_0;
} else if ((1.0 / n) <= 5e+193) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (1.0d0 / x) / n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-5d+214)) then
tmp = 0.0d0
else if ((1.0d0 / n) <= (-5000.0d0)) then
tmp = t_1
else if ((1.0d0 / n) <= (-2d-134)) then
tmp = (x - log(x)) / n
else if ((1.0d0 / n) <= (-5d-251)) then
tmp = t_0
else if ((1.0d0 / n) <= 2d-69) then
tmp = -log(x) / n
else if ((1.0d0 / n) <= 5d-21) then
tmp = t_0
else if ((1.0d0 / n) <= 5d+193) then
tmp = t_1
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = 0.0;
} else if ((1.0 / n) <= -5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= -2e-134) {
tmp = (x - Math.log(x)) / n;
} else if ((1.0 / n) <= -5e-251) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = -Math.log(x) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = t_0;
} else if ((1.0 / n) <= 5e+193) {
tmp = t_1;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = (1.0 / x) / n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e+214: tmp = 0.0 elif (1.0 / n) <= -5000.0: tmp = t_1 elif (1.0 / n) <= -2e-134: tmp = (x - math.log(x)) / n elif (1.0 / n) <= -5e-251: tmp = t_0 elif (1.0 / n) <= 2e-69: tmp = -math.log(x) / n elif (1.0 / n) <= 5e-21: tmp = t_0 elif (1.0 / n) <= 5e+193: tmp = t_1 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(Float64(1.0 / x) / n) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -5e+214) tmp = 0.0; elseif (Float64(1.0 / n) <= -5000.0) tmp = t_1; elseif (Float64(1.0 / n) <= -2e-134) tmp = Float64(Float64(x - log(x)) / n); elseif (Float64(1.0 / n) <= -5e-251) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(-log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = t_0; elseif (Float64(1.0 / n) <= 5e+193) tmp = t_1; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = (1.0 / x) / n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -5e+214) tmp = 0.0; elseif ((1.0 / n) <= -5000.0) tmp = t_1; elseif ((1.0 / n) <= -2e-134) tmp = (x - log(x)) / n; elseif ((1.0 / n) <= -5e-251) tmp = t_0; elseif ((1.0 / n) <= 2e-69) tmp = -log(x) / n; elseif ((1.0 / n) <= 5e-21) tmp = t_0; elseif ((1.0 / n) <= 5e+193) tmp = t_1; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+214], 0.0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-134], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-251], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], t$95$1, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+214}:\\
\;\;\;\;0\\
\mathbf{elif}\;\frac{1}{n} \leq -5000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-134}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-251}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999953e214Initial program 100.0%
add-log-exp100.0%
add-exp-log100.0%
log-pow100.0%
+-commutative100.0%
log1p-udef100.0%
*-commutative100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 32.3%
Taylor expanded in n around inf 69.2%
if -4.99999999999999953e214 < (/.f64 1 n) < -5e3 or 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 90.7%
Taylor expanded in x around 0 66.7%
if -5e3 < (/.f64 1 n) < -2.00000000000000008e-134Initial program 14.3%
Taylor expanded in n around inf 73.6%
log1p-def73.7%
Simplified73.7%
Taylor expanded in x around 0 59.7%
neg-mul-159.7%
+-commutative59.7%
sub-neg59.7%
div-sub59.7%
Simplified59.7%
if -2.00000000000000008e-134 < (/.f64 1 n) < -5.0000000000000003e-251 or 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 38.7%
Taylor expanded in n around inf 65.8%
log1p-def65.9%
Simplified65.9%
Taylor expanded in x around inf 73.1%
if -5.0000000000000003e-251 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 30.3%
Taylor expanded in x around 0 30.3%
Taylor expanded in n around inf 64.7%
associate-*r/64.7%
mul-1-neg64.7%
Simplified64.7%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification67.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -5e+214)
t_1
(if (<= (/ 1.0 n) -5e+29)
t_0
(if (<= (/ 1.0 n) 2e-69)
t_1
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e+193) t_0 (/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = t_1;
} else if ((1.0 / n) <= -5e+29) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-5d+214)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d+29)) then
tmp = t_0
else if ((1.0d0 / n) <= 2d-69) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-21) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 5d+193) then
tmp = t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = t_1;
} else if ((1.0 / n) <= -5e+29) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -5e+214: tmp = t_1 elif (1.0 / n) <= -5e+29: tmp = t_0 elif (1.0 / n) <= 2e-69: tmp = t_1 elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e+193: tmp = t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+214) tmp = t_1; elseif (Float64(1.0 / n) <= -5e+29) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-69) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e+193) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -5e+214) tmp = t_1; elseif ((1.0 / n) <= -5e+29) tmp = t_0; elseif ((1.0 / n) <= 2e-69) tmp = t_1; elseif ((1.0 / n) <= 5e-21) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 5e+193) tmp = t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+214], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+29], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+214}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999953e214 or -5.0000000000000001e29 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 43.5%
Taylor expanded in n around inf 80.1%
log1p-def80.1%
Simplified80.1%
log1p-udef80.1%
diff-log80.1%
+-commutative80.1%
Applied egg-rr80.1%
if -4.99999999999999953e214 < (/.f64 1 n) < -5.0000000000000001e29 or 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 89.6%
Taylor expanded in x around 0 69.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification76.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e+193)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = (1.0 + (x / n)) - t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-16)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d-69) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d-21) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 5d+193) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-69: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e+193: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e+193) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-16) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e-69) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e-21) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 5e+193) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (n * x); end tmp_2 = 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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
log1p-udef86.1%
diff-log86.1%
+-commutative86.1%
Applied egg-rr86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 76.7%
Taylor expanded in x around 0 70.9%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification87.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e+193) (- 1.0 t_0) (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = 1.0 - t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-16)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d-69) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d-21) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 5d+193) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-69: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e+193: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e+193) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-16) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e-69) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e-21) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 5e+193) tmp = 1.0 - t_0; else tmp = 1.0 / (n * x); end tmp_2 = 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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
add-log-exp94.6%
add-exp-log94.6%
log-pow94.6%
+-commutative94.6%
log1p-udef94.6%
*-commutative94.6%
un-div-inv94.6%
Applied egg-rr94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-*r/99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
log1p-udef86.1%
diff-log86.1%
+-commutative86.1%
Applied egg-rr86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 76.7%
Taylor expanded in x around 0 70.8%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification87.0%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- x (log x)) n) (if (<= x 7.5e+57) 0.0 (if (<= x 1.9e+183) (/ (/ 1.0 x) n) 0.0))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 7.5e+57) {
tmp = 0.0;
} else if (x <= 1.9e+183) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 7.5d+57) then
tmp = 0.0d0
else if (x <= 1.9d+183) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 7.5e+57) {
tmp = 0.0;
} else if (x <= 1.9e+183) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 7.5e+57: tmp = 0.0 elif x <= 1.9e+183: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 7.5e+57) tmp = 0.0; elseif (x <= 1.9e+183) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 7.5e+57) tmp = 0.0; elseif (x <= 1.9e+183) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 7.5e+57], 0.0, If[LessEqual[x, 1.9e+183], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+57}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+183}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 44.6%
Taylor expanded in n around inf 49.5%
log1p-def49.5%
Simplified49.5%
Taylor expanded in x around 0 48.2%
neg-mul-148.2%
+-commutative48.2%
sub-neg48.2%
div-sub48.2%
Simplified48.2%
if 1 < x < 7.5000000000000006e57 or 1.9e183 < x Initial program 81.8%
add-log-exp81.8%
add-exp-log81.8%
log-pow81.8%
+-commutative81.8%
log1p-udef81.8%
*-commutative81.8%
un-div-inv81.8%
Applied egg-rr81.8%
Taylor expanded in x around 0 13.5%
Taylor expanded in n around inf 81.8%
if 7.5000000000000006e57 < x < 1.9e183Initial program 50.3%
Taylor expanded in n around inf 50.3%
log1p-def50.3%
Simplified50.3%
Taylor expanded in x around inf 74.5%
Final simplification60.2%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- (log x)) n) (if (<= x 2e+59) 0.0 (if (<= x 1.25e+181) (/ (/ 1.0 x) n) 0.0))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = -log(x) / n;
} else if (x <= 2e+59) {
tmp = 0.0;
} else if (x <= 1.25e+181) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.0d0) then
tmp = -log(x) / n
else if (x <= 2d+59) then
tmp = 0.0d0
else if (x <= 1.25d+181) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = -Math.log(x) / n;
} else if (x <= 2e+59) {
tmp = 0.0;
} else if (x <= 1.25e+181) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = -math.log(x) / n elif x <= 2e+59: tmp = 0.0 elif x <= 1.25e+181: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2e+59) tmp = 0.0; elseif (x <= 1.25e+181) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = -log(x) / n; elseif (x <= 2e+59) tmp = 0.0; elseif (x <= 1.25e+181) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2e+59], 0.0, If[LessEqual[x, 1.25e+181], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+59}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+181}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 44.6%
Taylor expanded in x around 0 42.7%
Taylor expanded in n around inf 47.8%
associate-*r/47.8%
mul-1-neg47.8%
Simplified47.8%
if 1 < x < 1.99999999999999994e59 or 1.2500000000000001e181 < x Initial program 81.8%
add-log-exp81.8%
add-exp-log81.8%
log-pow81.8%
+-commutative81.8%
log1p-udef81.8%
*-commutative81.8%
un-div-inv81.8%
Applied egg-rr81.8%
Taylor expanded in x around 0 13.5%
Taylor expanded in n around inf 81.8%
if 1.99999999999999994e59 < x < 1.2500000000000001e181Initial program 50.3%
Taylor expanded in n around inf 50.3%
log1p-def50.3%
Simplified50.3%
Taylor expanded in x around inf 74.5%
Final simplification59.9%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -10000000000000.0) 0.0 (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -10000000000000.0) {
tmp = 0.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) :: tmp
if ((1.0d0 / n) <= (-10000000000000.0d0)) then
tmp = 0.0d0
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -10000000000000.0) {
tmp = 0.0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -10000000000000.0: tmp = 0.0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -10000000000000.0) tmp = 0.0; else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -10000000000000.0) tmp = 0.0; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -10000000000000.0], 0.0, N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10000000000000:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e13Initial program 100.0%
add-log-exp100.0%
add-exp-log100.0%
log-pow100.0%
+-commutative100.0%
log1p-udef100.0%
*-commutative100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 54.6%
Taylor expanded in n around inf 47.0%
if -1e13 < (/.f64 1 n) Initial program 38.6%
Taylor expanded in n around inf 60.3%
log1p-def60.3%
Simplified60.3%
Taylor expanded in x around inf 43.5%
Final simplification44.4%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 54.2%
Taylor expanded in n around inf 56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around inf 38.5%
*-commutative38.5%
Simplified38.5%
Final simplification38.5%
(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 54.2%
Taylor expanded in n around inf 56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around inf 38.5%
associate-/r*39.2%
Simplified39.2%
Final simplification39.2%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 54.2%
Taylor expanded in n around inf 56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around inf 39.2%
Final simplification39.2%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 54.2%
add-log-exp54.2%
add-exp-log54.2%
log-pow54.2%
+-commutative54.2%
log1p-udef60.5%
*-commutative60.5%
un-div-inv60.5%
Applied egg-rr60.5%
Taylor expanded in x around 0 40.7%
Taylor expanded in x around inf 4.5%
Final simplification4.5%
herbie shell --seed 2024024
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))