
(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 320.0)
(/
(-
(cbrt
(pow
(-
(- (log x) (log1p x))
(/
(fma
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
0.5
(/ (* 0.16666666666666666 (pow (- (log x)) 3.0)) n))
n))
3.0)))
n)
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 320.0) {
tmp = -cbrt(pow(((log(x) - log1p(x)) - (fma((pow(log1p(x), 2.0) - pow(log(x), 2.0)), 0.5, ((0.16666666666666666 * pow(-log(x), 3.0)) / n)) / n)), 3.0)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 320.0) tmp = Float64(Float64(-cbrt((Float64(Float64(log(x) - log1p(x)) - Float64(fma(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), 0.5, Float64(Float64(0.16666666666666666 * (Float64(-log(x)) ^ 3.0)) / n)) / n)) ^ 3.0))) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 320.0], N[((-N[Power[N[Power[N[(N[(N[Log[x], $MachinePrecision] - N[Log[1 + x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(0.16666666666666666 * N[Power[(-N[Log[x], $MachinePrecision]), 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]) / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 320:\\
\;\;\;\;\frac{-\sqrt[3]{{\left(\left(\log x - \mathsf{log1p}\left(x\right)\right) - \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, \frac{0.16666666666666666 \cdot {\left(-\log x\right)}^{3}}{n}\right)}{n}\right)}^{3}}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 320Initial program 40.1%
Taylor expanded in n around -inf 80.4%
Simplified80.4%
add-cbrt-cube84.6%
pow384.6%
Applied egg-rr84.6%
Taylor expanded in x around 0 84.6%
neg-mul-184.6%
cube-neg84.6%
Simplified84.6%
if 320 < x Initial program 61.7%
Taylor expanded in x around inf 97.8%
associate-/r*99.4%
mul-1-neg99.4%
log-rec99.4%
mul-1-neg99.4%
distribute-neg-frac99.4%
mul-1-neg99.4%
remove-double-neg99.4%
*-rgt-identity99.4%
associate-/l*99.4%
exp-to-pow99.4%
Simplified99.4%
Final simplification91.0%
(FPCore (x n)
:precision binary64
(if (<= x 250.0)
(/
(-
(+
(log1p x)
(/
(+
(* (- (pow (log1p x) 2.0) (pow (log x) 2.0)) 0.5)
(*
0.16666666666666666
(/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)))
n))
(log x))
n)
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 250.0) {
tmp = ((log1p(x) + ((((pow(log1p(x), 2.0) - pow(log(x), 2.0)) * 0.5) + (0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n))) / n)) - log(x)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 250.0) {
tmp = ((Math.log1p(x) + ((((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) * 0.5) + (0.16666666666666666 * ((Math.pow(Math.log1p(x), 3.0) - Math.pow(Math.log(x), 3.0)) / n))) / n)) - Math.log(x)) / n;
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 250.0: tmp = ((math.log1p(x) + ((((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) * 0.5) + (0.16666666666666666 * ((math.pow(math.log1p(x), 3.0) - math.pow(math.log(x), 3.0)) / n))) / n)) - math.log(x)) / n else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 250.0) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) * 0.5) + Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n)) - log(x)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 250.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] + N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 250:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) \cdot 0.5 + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 250Initial program 40.1%
Taylor expanded in n around -inf 80.4%
Simplified80.4%
if 250 < x Initial program 61.7%
Taylor expanded in x around inf 97.8%
associate-/r*99.4%
mul-1-neg99.4%
log-rec99.4%
mul-1-neg99.4%
distribute-neg-frac99.4%
mul-1-neg99.4%
remove-double-neg99.4%
*-rgt-identity99.4%
associate-/l*99.4%
exp-to-pow99.4%
Simplified99.4%
Final simplification88.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 1.9e-158)
(* x (- (/ 1.0 n) (/ (log x) (* x n))))
(if (<= x 2.1e-61)
(*
(- (/ 1.0 (* x n)) (+ (/ 0.5 n) (/ (log x) (* n (pow x 2.0)))))
(pow x 2.0))
(if (<= x 1.3e-35)
(- (exp (/ (log1p x) n)) t_0)
(if (<= x 2.4e-17) (/ (log x) (- n)) (/ (/ t_0 n) x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 1.9e-158) {
tmp = x * ((1.0 / n) - (log(x) / (x * n)));
} else if (x <= 2.1e-61) {
tmp = ((1.0 / (x * n)) - ((0.5 / n) + (log(x) / (n * pow(x, 2.0))))) * pow(x, 2.0);
} else if (x <= 1.3e-35) {
tmp = exp((log1p(x) / n)) - t_0;
} else if (x <= 2.4e-17) {
tmp = log(x) / -n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.9e-158) {
tmp = x * ((1.0 / n) - (Math.log(x) / (x * n)));
} else if (x <= 2.1e-61) {
tmp = ((1.0 / (x * n)) - ((0.5 / n) + (Math.log(x) / (n * Math.pow(x, 2.0))))) * Math.pow(x, 2.0);
} else if (x <= 1.3e-35) {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
} else if (x <= 2.4e-17) {
tmp = Math.log(x) / -n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.9e-158: tmp = x * ((1.0 / n) - (math.log(x) / (x * n))) elif x <= 2.1e-61: tmp = ((1.0 / (x * n)) - ((0.5 / n) + (math.log(x) / (n * math.pow(x, 2.0))))) * math.pow(x, 2.0) elif x <= 1.3e-35: tmp = math.exp((math.log1p(x) / n)) - t_0 elif x <= 2.4e-17: tmp = math.log(x) / -n else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1.9e-158) tmp = Float64(x * Float64(Float64(1.0 / n) - Float64(log(x) / Float64(x * n)))); elseif (x <= 2.1e-61) tmp = Float64(Float64(Float64(1.0 / Float64(x * n)) - Float64(Float64(0.5 / n) + Float64(log(x) / Float64(n * (x ^ 2.0))))) * (x ^ 2.0)); elseif (x <= 1.3e-35) tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); elseif (x <= 2.4e-17) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.9e-158], N[(x * N[(N[(1.0 / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.1e-61], N[(N[(N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 / n), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / N[(n * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3e-35], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 2.4e-17], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.9 \cdot 10^{-158}:\\
\;\;\;\;x \cdot \left(\frac{1}{n} - \frac{\log x}{x \cdot n}\right)\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-61}:\\
\;\;\;\;\left(\frac{1}{x \cdot n} - \left(\frac{0.5}{n} + \frac{\log x}{n \cdot {x}^{2}}\right)\right) \cdot {x}^{2}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-35}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-17}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.8999999999999999e-158Initial program 41.7%
Taylor expanded in x around 0 41.7%
Taylor expanded in x around inf 41.7%
associate--l+41.7%
mul-1-neg41.7%
distribute-neg-frac41.7%
log-rec41.7%
remove-double-neg41.7%
Simplified41.7%
Taylor expanded in n around inf 82.2%
associate-*r/82.2%
neg-mul-182.2%
*-commutative82.2%
Simplified82.2%
if 1.8999999999999999e-158 < x < 2.0999999999999999e-61Initial program 33.3%
Taylor expanded in x around 0 39.8%
Taylor expanded in n around inf 53.0%
*-commutative53.0%
Simplified53.0%
Taylor expanded in x around inf 80.3%
associate--l+80.3%
*-commutative80.3%
log-rec80.3%
*-commutative80.3%
associate-*r/80.3%
metadata-eval80.3%
Simplified80.3%
if 2.0999999999999999e-61 < x < 1.30000000000000002e-35Initial program 51.1%
Taylor expanded in n around 0 51.1%
log1p-define75.3%
*-rgt-identity75.3%
associate-*l/75.3%
associate-/l*75.3%
exp-to-pow75.3%
Simplified75.3%
if 1.30000000000000002e-35 < x < 2.39999999999999986e-17Initial program 5.1%
Taylor expanded in x around 0 5.1%
*-rgt-identity5.1%
associate-*l/5.1%
associate-/l*5.1%
exp-to-pow5.1%
Simplified5.1%
Taylor expanded in n around inf 99.6%
associate-*r/99.6%
neg-mul-199.6%
Simplified99.6%
if 2.39999999999999986e-17 < x Initial program 62.7%
Taylor expanded in x around inf 94.2%
associate-/r*95.6%
mul-1-neg95.6%
log-rec95.6%
mul-1-neg95.6%
distribute-neg-frac95.6%
mul-1-neg95.6%
remove-double-neg95.6%
*-rgt-identity95.6%
associate-/l*95.6%
exp-to-pow95.6%
Simplified95.6%
Final simplification88.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-19)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-25)
(/ (- (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) <= -2e-19) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-25) {
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) <= -2e-19) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-25) {
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) <= -2e-19: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-25: 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) <= -2e-19) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-25) 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], -2e-19], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], 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 -2 \cdot 10^{-19}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\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) < -2e-19Initial program 92.5%
Taylor expanded in x around inf 96.0%
associate-/r*96.1%
mul-1-neg96.1%
log-rec96.1%
mul-1-neg96.1%
distribute-neg-frac96.1%
mul-1-neg96.1%
remove-double-neg96.1%
*-rgt-identity96.1%
associate-/l*96.1%
exp-to-pow96.1%
Simplified96.1%
if -2e-19 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 26.5%
Taylor expanded in n around inf 75.6%
log1p-define75.6%
Simplified75.6%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 50.1%
Taylor expanded in n around 0 50.1%
log1p-define94.8%
*-rgt-identity94.8%
associate-*l/94.8%
associate-/l*94.8%
exp-to-pow94.8%
Simplified94.8%
Final simplification84.5%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -2e-19)
(/ (pow E (/ (log x) n)) (* x n))
(if (<= (/ 1.0 n) 5e-25)
(/ (- (log1p x) (log x)) n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-19) {
tmp = pow(((double) M_E), (log(x) / n)) / (x * n);
} else if ((1.0 / n) <= 5e-25) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-19) {
tmp = Math.pow(Math.E, (Math.log(x) / n)) / (x * n);
} else if ((1.0 / n) <= 5e-25) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e-19: tmp = math.pow(math.e, (math.log(x) / n)) / (x * n) elif (1.0 / n) <= 5e-25: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-19) tmp = Float64((exp(1) ^ Float64(log(x) / n)) / Float64(x * n)); elseif (Float64(1.0 / n) <= 5e-25) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-19], N[(N[Power[E, N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], 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] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-19}:\\
\;\;\;\;\frac{{e}^{\left(\frac{\log x}{n}\right)}}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-19Initial program 92.5%
Taylor expanded in x around inf 96.0%
mul-1-neg96.0%
log-rec96.0%
mul-1-neg96.0%
distribute-neg-frac96.0%
mul-1-neg96.0%
remove-double-neg96.0%
*-commutative96.0%
Simplified96.0%
*-un-lft-identity96.0%
exp-prod96.1%
Applied egg-rr96.1%
if -2e-19 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 26.5%
Taylor expanded in n around inf 75.6%
log1p-define75.6%
Simplified75.6%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 50.1%
Taylor expanded in n around 0 50.1%
log1p-define94.8%
*-rgt-identity94.8%
associate-*l/94.8%
associate-/l*94.8%
exp-to-pow94.8%
Simplified94.8%
Final simplification84.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (pow x (/ 1.0 n))))
(if (<= x 1.5e-166)
t_0
(if (<= x 1.6e-108)
(- 1.0 t_1)
(if (<= x 9.6e-19) t_0 (/ (/ t_1 n) x))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = pow(x, (1.0 / n));
double tmp;
if (x <= 1.5e-166) {
tmp = t_0;
} else if (x <= 1.6e-108) {
tmp = 1.0 - t_1;
} else if (x <= 9.6e-19) {
tmp = t_0;
} else {
tmp = (t_1 / 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 = log(x) / -n
t_1 = x ** (1.0d0 / n)
if (x <= 1.5d-166) then
tmp = t_0
else if (x <= 1.6d-108) then
tmp = 1.0d0 - t_1
else if (x <= 9.6d-19) then
tmp = t_0
else
tmp = (t_1 / n) / x
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 tmp;
if (x <= 1.5e-166) {
tmp = t_0;
} else if (x <= 1.6e-108) {
tmp = 1.0 - t_1;
} else if (x <= 9.6e-19) {
tmp = t_0;
} else {
tmp = (t_1 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.5e-166: tmp = t_0 elif x <= 1.6e-108: tmp = 1.0 - t_1 elif x <= 9.6e-19: tmp = t_0 else: tmp = (t_1 / n) / x return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1.5e-166) tmp = t_0; elseif (x <= 1.6e-108) tmp = Float64(1.0 - t_1); elseif (x <= 9.6e-19) tmp = t_0; else tmp = Float64(Float64(t_1 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = x ^ (1.0 / n); tmp = 0.0; if (x <= 1.5e-166) tmp = t_0; elseif (x <= 1.6e-108) tmp = 1.0 - t_1; elseif (x <= 9.6e-19) tmp = t_0; else tmp = (t_1 / n) / x; 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]}, If[LessEqual[x, 1.5e-166], t$95$0, If[LessEqual[x, 1.6e-108], N[(1.0 - t$95$1), $MachinePrecision], If[LessEqual[x, 9.6e-19], t$95$0, N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.5 \cdot 10^{-166}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-108}:\\
\;\;\;\;1 - t\_1\\
\mathbf{elif}\;x \leq 9.6 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{n}}{x}\\
\end{array}
\end{array}
if x < 1.5000000000000001e-166 or 1.6e-108 < x < 9.60000000000000092e-19Initial program 34.0%
Taylor expanded in x around 0 34.0%
*-rgt-identity34.0%
associate-*l/34.0%
associate-/l*34.0%
exp-to-pow34.0%
Simplified34.0%
Taylor expanded in n around inf 61.0%
associate-*r/61.0%
neg-mul-161.0%
Simplified61.0%
if 1.5000000000000001e-166 < x < 1.6e-108Initial program 52.5%
Taylor expanded in x around 0 52.5%
*-rgt-identity52.5%
associate-*l/52.5%
associate-/l*52.5%
exp-to-pow52.5%
Simplified52.5%
if 9.60000000000000092e-19 < x Initial program 62.7%
Taylor expanded in x around inf 94.2%
associate-/r*95.6%
mul-1-neg95.6%
log-rec95.6%
mul-1-neg95.6%
distribute-neg-frac95.6%
mul-1-neg95.6%
remove-double-neg95.6%
*-rgt-identity95.6%
associate-/l*95.6%
exp-to-pow95.6%
Simplified95.6%
Final simplification76.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.5e-166)
t_0
(if (<= x 1.65e-108)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 2.9e-17) t_0 (if (<= x 8.7e+83) (/ (/ 1.0 x) n) 0.0))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.5e-166) {
tmp = t_0;
} else if (x <= 1.65e-108) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 2.9e-17) {
tmp = t_0;
} else if (x <= 8.7e+83) {
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) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 1.5d-166) then
tmp = t_0
else if (x <= 1.65d-108) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 2.9d-17) then
tmp = t_0
else if (x <= 8.7d+83) 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 t_0 = Math.log(x) / -n;
double tmp;
if (x <= 1.5e-166) {
tmp = t_0;
} else if (x <= 1.65e-108) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 2.9e-17) {
tmp = t_0;
} else if (x <= 8.7e+83) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.5e-166: tmp = t_0 elif x <= 1.65e-108: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 2.9e-17: tmp = t_0 elif x <= 8.7e+83: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.5e-166) tmp = t_0; elseif (x <= 1.65e-108) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 2.9e-17) tmp = t_0; elseif (x <= 8.7e+83) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.5e-166) tmp = t_0; elseif (x <= 1.65e-108) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 2.9e-17) tmp = t_0; elseif (x <= 8.7e+83) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.5e-166], t$95$0, If[LessEqual[x, 1.65e-108], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.9e-17], t$95$0, If[LessEqual[x, 8.7e+83], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.5 \cdot 10^{-166}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-108}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.7 \cdot 10^{+83}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.5000000000000001e-166 or 1.6500000000000001e-108 < x < 2.9000000000000003e-17Initial program 34.0%
Taylor expanded in x around 0 34.0%
*-rgt-identity34.0%
associate-*l/34.0%
associate-/l*34.0%
exp-to-pow34.0%
Simplified34.0%
Taylor expanded in n around inf 61.0%
associate-*r/61.0%
neg-mul-161.0%
Simplified61.0%
if 1.5000000000000001e-166 < x < 1.6500000000000001e-108Initial program 52.5%
Taylor expanded in x around 0 52.5%
*-rgt-identity52.5%
associate-*l/52.5%
associate-/l*52.5%
exp-to-pow52.5%
Simplified52.5%
if 2.9000000000000003e-17 < x < 8.7000000000000005e83Initial program 39.3%
Taylor expanded in x around inf 87.8%
mul-1-neg87.8%
log-rec87.8%
mul-1-neg87.8%
distribute-neg-frac87.8%
mul-1-neg87.8%
remove-double-neg87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in n around inf 64.8%
*-commutative64.8%
associate-/r*66.8%
Simplified66.8%
if 8.7000000000000005e83 < x Initial program 79.9%
sub-neg79.9%
+-commutative79.9%
add-cube-cbrt79.6%
fma-define79.6%
pow-to-exp79.6%
un-div-inv79.6%
+-commutative79.6%
log1p-define79.6%
Applied egg-rr79.6%
Taylor expanded in x around inf 79.9%
rem-cube-cbrt79.9%
distribute-rgt1-in79.9%
metadata-eval79.9%
associate-*r/79.9%
log-rec79.9%
neg-mul-179.9%
associate-*r*79.9%
metadata-eval79.9%
associate-*l/79.9%
*-commutative79.9%
metadata-eval79.9%
associate-*l/79.9%
associate-*l*79.9%
exp-prod79.9%
exp-to-pow79.9%
unpow1/379.9%
mul0-lft79.9%
Simplified79.9%
Final simplification66.2%
(FPCore (x n) :precision binary64 (if (<= x 2.9e-17) (* x (- (/ 1.0 n) (/ (log x) (* x n)))) (/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 2.9e-17) {
tmp = x * ((1.0 / n) - (log(x) / (x * n)));
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.9d-17) then
tmp = x * ((1.0d0 / n) - (log(x) / (x * n)))
else
tmp = ((x ** (1.0d0 / n)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.9e-17) {
tmp = x * ((1.0 / n) - (Math.log(x) / (x * n)));
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.9e-17: tmp = x * ((1.0 / n) - (math.log(x) / (x * n))) else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 2.9e-17) tmp = Float64(x * Float64(Float64(1.0 / n) - Float64(log(x) / Float64(x * n)))); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.9e-17) tmp = x * ((1.0 / n) - (log(x) / (x * n))); else tmp = ((x ^ (1.0 / n)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.9e-17], N[(x * N[(N[(1.0 / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9 \cdot 10^{-17}:\\
\;\;\;\;x \cdot \left(\frac{1}{n} - \frac{\log x}{x \cdot n}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 2.9000000000000003e-17Initial program 38.0%
Taylor expanded in x around 0 38.1%
Taylor expanded in x around inf 38.1%
associate--l+38.5%
mul-1-neg38.5%
distribute-neg-frac38.5%
log-rec38.5%
remove-double-neg38.5%
Simplified38.5%
Taylor expanded in n around inf 73.2%
associate-*r/73.2%
neg-mul-173.2%
*-commutative73.2%
Simplified73.2%
if 2.9000000000000003e-17 < x Initial program 62.7%
Taylor expanded in x around inf 94.2%
associate-/r*95.6%
mul-1-neg95.6%
log-rec95.6%
mul-1-neg95.6%
distribute-neg-frac95.6%
mul-1-neg95.6%
remove-double-neg95.6%
*-rgt-identity95.6%
associate-/l*95.6%
exp-to-pow95.6%
Simplified95.6%
Final simplification83.5%
(FPCore (x n) :precision binary64 (if (<= x 2.6e-17) (* x (/ (- 1.0 (/ (log x) x)) n)) (/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 2.6e-17) {
tmp = x * ((1.0 - (log(x) / x)) / n);
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.6d-17) then
tmp = x * ((1.0d0 - (log(x) / x)) / n)
else
tmp = ((x ** (1.0d0 / n)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.6e-17) {
tmp = x * ((1.0 - (Math.log(x) / x)) / n);
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.6e-17: tmp = x * ((1.0 - (math.log(x) / x)) / n) else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 2.6e-17) tmp = Float64(x * Float64(Float64(1.0 - Float64(log(x) / x)) / n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.6e-17) tmp = x * ((1.0 - (log(x) / x)) / n); else tmp = ((x ^ (1.0 / n)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.6e-17], N[(x * N[(N[(1.0 - N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6 \cdot 10^{-17}:\\
\;\;\;\;x \cdot \frac{1 - \frac{\log x}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 2.60000000000000003e-17Initial program 38.0%
Taylor expanded in x around 0 38.1%
Taylor expanded in x around inf 38.1%
associate--l+38.5%
mul-1-neg38.5%
distribute-neg-frac38.5%
log-rec38.5%
remove-double-neg38.5%
Simplified38.5%
Taylor expanded in n around inf 54.6%
associate-/l*72.5%
Simplified72.5%
if 2.60000000000000003e-17 < x Initial program 62.7%
Taylor expanded in x around inf 94.2%
associate-/r*95.6%
mul-1-neg95.6%
log-rec95.6%
mul-1-neg95.6%
distribute-neg-frac95.6%
mul-1-neg95.6%
remove-double-neg95.6%
*-rgt-identity95.6%
associate-/l*95.6%
exp-to-pow95.6%
Simplified95.6%
Final simplification83.2%
(FPCore (x n) :precision binary64 (if (<= x 2.9e-17) (/ (log x) (- n)) (if (<= x 7.5e+83) (/ (/ 1.0 x) n) 0.0)))
double code(double x, double n) {
double tmp;
if (x <= 2.9e-17) {
tmp = log(x) / -n;
} else if (x <= 7.5e+83) {
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 <= 2.9d-17) then
tmp = log(x) / -n
else if (x <= 7.5d+83) 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 <= 2.9e-17) {
tmp = Math.log(x) / -n;
} else if (x <= 7.5e+83) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.9e-17: tmp = math.log(x) / -n elif x <= 7.5e+83: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 2.9e-17) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 7.5e+83) 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 <= 2.9e-17) tmp = log(x) / -n; elseif (x <= 7.5e+83) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.9e-17], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 7.5e+83], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9 \cdot 10^{-17}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+83}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.9000000000000003e-17Initial program 38.0%
Taylor expanded in x around 0 38.0%
*-rgt-identity38.0%
associate-*l/38.0%
associate-/l*38.0%
exp-to-pow38.0%
Simplified38.0%
Taylor expanded in n around inf 55.3%
associate-*r/55.3%
neg-mul-155.3%
Simplified55.3%
if 2.9000000000000003e-17 < x < 7.49999999999999989e83Initial program 39.3%
Taylor expanded in x around inf 87.8%
mul-1-neg87.8%
log-rec87.8%
mul-1-neg87.8%
distribute-neg-frac87.8%
mul-1-neg87.8%
remove-double-neg87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in n around inf 64.8%
*-commutative64.8%
associate-/r*66.8%
Simplified66.8%
if 7.49999999999999989e83 < x Initial program 79.9%
sub-neg79.9%
+-commutative79.9%
add-cube-cbrt79.6%
fma-define79.6%
pow-to-exp79.6%
un-div-inv79.6%
+-commutative79.6%
log1p-define79.6%
Applied egg-rr79.6%
Taylor expanded in x around inf 79.9%
rem-cube-cbrt79.9%
distribute-rgt1-in79.9%
metadata-eval79.9%
associate-*r/79.9%
log-rec79.9%
neg-mul-179.9%
associate-*r*79.9%
metadata-eval79.9%
associate-*l/79.9%
*-commutative79.9%
metadata-eval79.9%
associate-*l/79.9%
associate-*l*79.9%
exp-prod79.9%
exp-to-pow79.9%
unpow1/379.9%
mul0-lft79.9%
Simplified79.9%
Final simplification64.1%
(FPCore (x n) :precision binary64 (if (or (<= n -4.1) (not (<= n -1.75e-196))) (/ 1.0 (* x n)) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -4.1) || !(n <= -1.75e-196)) {
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 ((n <= (-4.1d0)) .or. (.not. (n <= (-1.75d-196)))) 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 ((n <= -4.1) || !(n <= -1.75e-196)) {
tmp = 1.0 / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -4.1) or not (n <= -1.75e-196): tmp = 1.0 / (x * n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -4.1) || !(n <= -1.75e-196)) tmp = Float64(1.0 / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -4.1) || ~((n <= -1.75e-196))) tmp = 1.0 / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -4.1], N[Not[LessEqual[n, -1.75e-196]], $MachinePrecision]], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -4.1 \lor \neg \left(n \leq -1.75 \cdot 10^{-196}\right):\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -4.0999999999999996 or -1.75000000000000002e-196 < n Initial program 39.9%
Taylor expanded in x around inf 48.0%
mul-1-neg48.0%
log-rec48.0%
mul-1-neg48.0%
distribute-neg-frac48.0%
mul-1-neg48.0%
remove-double-neg48.0%
*-commutative48.0%
Simplified48.0%
Taylor expanded in n around inf 46.8%
if -4.0999999999999996 < n < -1.75000000000000002e-196Initial program 97.8%
sub-neg97.8%
+-commutative97.8%
add-cube-cbrt97.8%
fma-define97.8%
pow-to-exp97.8%
un-div-inv97.9%
+-commutative97.9%
log1p-define97.9%
Applied egg-rr97.9%
Taylor expanded in x around inf 55.0%
rem-cube-cbrt55.0%
distribute-rgt1-in55.0%
metadata-eval55.0%
associate-*r/55.0%
log-rec55.0%
neg-mul-155.0%
associate-*r*55.0%
metadata-eval55.0%
associate-*l/55.0%
*-commutative55.0%
metadata-eval55.0%
associate-*l/55.0%
associate-*l*55.0%
exp-prod55.0%
exp-to-pow55.0%
unpow1/355.0%
mul0-lft55.6%
Simplified55.6%
Final simplification48.3%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -10.0) 0.0 (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -10.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) <= (-10.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) <= -10.0) {
tmp = 0.0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -10.0: tmp = 0.0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -10.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) <= -10.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], -10.0], 0.0, N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10Initial program 98.6%
sub-neg98.6%
+-commutative98.6%
add-cube-cbrt98.6%
fma-define98.6%
pow-to-exp98.6%
un-div-inv98.7%
+-commutative98.7%
log1p-define98.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 50.9%
rem-cube-cbrt50.9%
distribute-rgt1-in50.9%
metadata-eval50.9%
associate-*r/50.9%
log-rec50.9%
neg-mul-150.9%
associate-*r*50.9%
metadata-eval50.9%
associate-*l/50.9%
*-commutative50.9%
metadata-eval50.9%
associate-*l/50.9%
associate-*l*50.9%
exp-prod50.9%
exp-to-pow50.9%
unpow1/350.9%
mul0-lft51.6%
Simplified51.6%
if -10 < (/.f64 #s(literal 1 binary64) n) Initial program 31.9%
Taylor expanded in x around inf 41.1%
mul-1-neg41.1%
log-rec41.1%
mul-1-neg41.1%
distribute-neg-frac41.1%
mul-1-neg41.1%
remove-double-neg41.1%
*-commutative41.1%
Simplified41.1%
Taylor expanded in n around inf 46.0%
*-commutative46.0%
associate-/r*46.9%
Simplified46.9%
Final simplification48.1%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 49.4%
sub-neg49.4%
+-commutative49.4%
add-cube-cbrt49.3%
fma-define49.3%
pow-to-exp49.3%
un-div-inv49.3%
+-commutative49.3%
log1p-define56.1%
Applied egg-rr56.1%
Taylor expanded in x around inf 28.5%
rem-cube-cbrt28.5%
distribute-rgt1-in28.5%
metadata-eval28.5%
associate-*r/28.5%
log-rec28.5%
neg-mul-128.5%
associate-*r*28.5%
metadata-eval28.5%
associate-*l/28.5%
*-commutative28.5%
metadata-eval28.5%
associate-*l/28.5%
associate-*l*28.5%
exp-prod28.5%
exp-to-pow28.5%
unpow1/328.5%
mul0-lft28.7%
Simplified28.7%
Final simplification28.7%
herbie shell --seed 2024077
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))