
(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 15 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 1500.0)
(/
(log
(/
x
(exp
(+
(log1p x)
(/
(fma
(- (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)))))
(- n))
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 1500.0) {
tmp = log((x / exp((log1p(x) + (fma((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))))) / -n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1500.0) tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), 0.5, Float64(Float64(0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / n)) / n))))) / Float64(-n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 1500.0], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $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[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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 1500:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n}\right)}{n}}}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 1500Initial program 41.5%
Taylor expanded in n around -inf 76.4%
Simplified76.4%
add-log-exp84.3%
diff-log84.3%
Applied egg-rr84.3%
if 1500 < x Initial program 66.3%
Taylor expanded in x around inf 95.7%
associate-/r*98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-rgt-identity98.0%
associate-/l*98.0%
exp-to-pow98.0%
Simplified98.0%
(FPCore (x n)
:precision binary64
(if (<= x 14500.0)
(/
(-
(+
(log1p x)
(/
(-
(* 0.16666666666666666 (/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n))
(* 0.5 (- (pow (log x) 2.0) (pow (log1p x) 2.0))))
n))
(log x))
n)
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 14500.0) {
tmp = ((log1p(x) + (((0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n)) - (0.5 * (pow(log(x), 2.0) - pow(log1p(x), 2.0)))) / 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 <= 14500.0) {
tmp = ((Math.log1p(x) + (((0.16666666666666666 * ((Math.pow(Math.log1p(x), 3.0) - Math.pow(Math.log(x), 3.0)) / n)) - (0.5 * (Math.pow(Math.log(x), 2.0) - Math.pow(Math.log1p(x), 2.0)))) / 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 <= 14500.0: tmp = ((math.log1p(x) + (((0.16666666666666666 * ((math.pow(math.log1p(x), 3.0) - math.pow(math.log(x), 3.0)) / n)) - (0.5 * (math.pow(math.log(x), 2.0) - math.pow(math.log1p(x), 2.0)))) / 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 <= 14500.0) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n)) - Float64(0.5 * Float64((log(x) ^ 2.0) - (log1p(x) ^ 2.0)))) / 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, 14500.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(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] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision]), $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 14500:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n} - 0.5 \cdot \left({\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right)}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 14500Initial program 41.5%
Taylor expanded in n around -inf 76.4%
Simplified76.4%
if 14500 < x Initial program 66.3%
Taylor expanded in x around inf 95.7%
associate-/r*98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-rgt-identity98.0%
associate-/l*98.0%
exp-to-pow98.0%
Simplified98.0%
Final simplification86.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-125)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-24)
(/ (- (log1p x) (log x)) n)
(exp (log (- (exp (/ (log1p x) n)) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-125) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-24) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp(log((exp((log1p(x) / n)) - t_0)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-125) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-24) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp(Math.log((Math.exp((Math.log1p(x) / n)) - t_0)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-125: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-24: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp(math.log((math.exp((math.log1p(x) / n)) - t_0))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-125) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-24) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = exp(log(Float64(exp(Float64(log1p(x) / n)) - t_0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-125], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-24], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[Exp[N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-125}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-24}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000002e-125Initial program 75.9%
Taylor expanded in x around inf 88.9%
associate-/r*88.9%
mul-1-neg88.9%
log-rec88.9%
mul-1-neg88.9%
distribute-neg-frac88.9%
mul-1-neg88.9%
remove-double-neg88.9%
*-rgt-identity88.9%
associate-/l*88.9%
exp-to-pow88.9%
Simplified88.9%
if -2.00000000000000002e-125 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999924e-25Initial program 33.0%
Taylor expanded in n around inf 81.0%
log1p-define81.0%
Simplified81.0%
if 9.99999999999999924e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 52.2%
add-exp-log52.2%
pow-to-exp52.2%
un-div-inv52.2%
+-commutative52.2%
log1p-define98.9%
Applied egg-rr98.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-125)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-24)
(/ (- (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-125) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-24) {
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-125) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-24) {
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-125: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-24: 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-125) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-24) 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-125], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-24], 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^{-125}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-24}:\\
\;\;\;\;\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) < -2.00000000000000002e-125Initial program 75.9%
Taylor expanded in x around inf 88.9%
associate-/r*88.9%
mul-1-neg88.9%
log-rec88.9%
mul-1-neg88.9%
distribute-neg-frac88.9%
mul-1-neg88.9%
remove-double-neg88.9%
*-rgt-identity88.9%
associate-/l*88.9%
exp-to-pow88.9%
Simplified88.9%
if -2.00000000000000002e-125 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999924e-25Initial program 33.0%
Taylor expanded in n around inf 81.0%
log1p-define81.0%
Simplified81.0%
if 9.99999999999999924e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 52.2%
Taylor expanded in n around 0 52.2%
log1p-define98.9%
*-rgt-identity98.9%
associate-*l/98.9%
associate-/l*98.9%
exp-to-pow98.9%
Simplified98.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-125)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-24)
(/ (- (log1p x) (log x)) n)
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n)))))))
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-125) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-24) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-125) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-24) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-125: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-24: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-125) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-24) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) + Float64(0.5 * Float64(-1.0 / n))))))) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-125], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-24], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-125}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-24}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000002e-125Initial program 75.9%
Taylor expanded in x around inf 88.9%
associate-/r*88.9%
mul-1-neg88.9%
log-rec88.9%
mul-1-neg88.9%
distribute-neg-frac88.9%
mul-1-neg88.9%
remove-double-neg88.9%
*-rgt-identity88.9%
associate-/l*88.9%
exp-to-pow88.9%
Simplified88.9%
if -2.00000000000000002e-125 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999924e-25Initial program 33.0%
Taylor expanded in n around inf 81.0%
log1p-define81.0%
Simplified81.0%
if 9.99999999999999924e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 52.2%
Taylor expanded in x around 0 91.6%
Final simplification85.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n)))
(t_1 (/ (log x) (- n)))
(t_2 (log1p (expm1 (/ 1.0 (* x n))))))
(if (<= x 1.045e-286)
t_1
(if (<= x 8.2e-209)
(- (+ 1.0 (/ x n)) t_0)
(if (<= x 6.2e-149)
t_1
(if (<= x 2.7e-117)
t_2
(if (<= x 1.7e-85)
t_1
(if (<= x 1.72e-26)
t_2
(if (<= x 0.0135) t_1 (/ (/ t_0 n) x))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(x) / -n;
double t_2 = log1p(expm1((1.0 / (x * n))));
double tmp;
if (x <= 1.045e-286) {
tmp = t_1;
} else if (x <= 8.2e-209) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 6.2e-149) {
tmp = t_1;
} else if (x <= 2.7e-117) {
tmp = t_2;
} else if (x <= 1.7e-85) {
tmp = t_1;
} else if (x <= 1.72e-26) {
tmp = t_2;
} else if (x <= 0.0135) {
tmp = t_1;
} 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 t_1 = Math.log(x) / -n;
double t_2 = Math.log1p(Math.expm1((1.0 / (x * n))));
double tmp;
if (x <= 1.045e-286) {
tmp = t_1;
} else if (x <= 8.2e-209) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 6.2e-149) {
tmp = t_1;
} else if (x <= 2.7e-117) {
tmp = t_2;
} else if (x <= 1.7e-85) {
tmp = t_1;
} else if (x <= 1.72e-26) {
tmp = t_2;
} else if (x <= 0.0135) {
tmp = t_1;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(x) / -n t_2 = math.log1p(math.expm1((1.0 / (x * n)))) tmp = 0 if x <= 1.045e-286: tmp = t_1 elif x <= 8.2e-209: tmp = (1.0 + (x / n)) - t_0 elif x <= 6.2e-149: tmp = t_1 elif x <= 2.7e-117: tmp = t_2 elif x <= 1.7e-85: tmp = t_1 elif x <= 1.72e-26: tmp = t_2 elif x <= 0.0135: tmp = t_1 else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(x) / Float64(-n)) t_2 = log1p(expm1(Float64(1.0 / Float64(x * n)))) tmp = 0.0 if (x <= 1.045e-286) tmp = t_1; elseif (x <= 8.2e-209) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif (x <= 6.2e-149) tmp = t_1; elseif (x <= 2.7e-117) tmp = t_2; elseif (x <= 1.7e-85) tmp = t_1; elseif (x <= 1.72e-26) tmp = t_2; elseif (x <= 0.0135) tmp = t_1; 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]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$2 = N[Log[1 + N[(Exp[N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.045e-286], t$95$1, If[LessEqual[x, 8.2e-209], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 6.2e-149], t$95$1, If[LessEqual[x, 2.7e-117], t$95$2, If[LessEqual[x, 1.7e-85], t$95$1, If[LessEqual[x, 1.72e-26], t$95$2, If[LessEqual[x, 0.0135], t$95$1, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log x}{-n}\\
t_2 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\
\mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-209}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-149}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-117}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-85}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-26}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 0.0135:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.04500000000000002e-286 or 8.19999999999999955e-209 < x < 6.19999999999999974e-149 or 2.70000000000000003e-117 < x < 1.7e-85 or 1.72000000000000001e-26 < x < 0.0134999999999999998Initial program 26.7%
Taylor expanded in x around 0 26.7%
*-rgt-identity26.7%
associate-*l/26.7%
associate-/l*26.7%
exp-to-pow26.7%
Simplified26.7%
Taylor expanded in n around inf 71.6%
associate-*r/71.6%
neg-mul-171.6%
Simplified71.6%
if 1.04500000000000002e-286 < x < 8.19999999999999955e-209Initial program 61.4%
Taylor expanded in x around 0 61.5%
if 6.19999999999999974e-149 < x < 2.70000000000000003e-117 or 1.7e-85 < x < 1.72000000000000001e-26Initial program 45.5%
Taylor expanded in x around inf 34.9%
mul-1-neg34.9%
log-rec34.9%
mul-1-neg34.9%
distribute-neg-frac34.9%
mul-1-neg34.9%
remove-double-neg34.9%
*-commutative34.9%
Simplified34.9%
Taylor expanded in n around inf 22.9%
log1p-expm1-u64.5%
Applied egg-rr64.5%
if 0.0134999999999999998 < x Initial program 66.3%
Taylor expanded in x around inf 95.7%
associate-/r*98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-rgt-identity98.0%
associate-/l*98.0%
exp-to-pow98.0%
Simplified98.0%
Final simplification80.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-125)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-24)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e+141)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ 1.0 (* x n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-125) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-24) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e+141) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1((1.0 / (x * 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-125) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-24) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e+141) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1((1.0 / (x * n))));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-125: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-24: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e+141: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1((1.0 / (x * n)))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-125) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-24) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e+141) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(1.0 / Float64(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-125], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-24], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+141], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]] - 1), $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^{-125}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-24}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+141}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000002e-125Initial program 75.9%
Taylor expanded in x around inf 88.9%
associate-/r*88.9%
mul-1-neg88.9%
log-rec88.9%
mul-1-neg88.9%
distribute-neg-frac88.9%
mul-1-neg88.9%
remove-double-neg88.9%
*-rgt-identity88.9%
associate-/l*88.9%
exp-to-pow88.9%
Simplified88.9%
if -2.00000000000000002e-125 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999924e-25Initial program 33.0%
Taylor expanded in n around inf 81.0%
log1p-define81.0%
Simplified81.0%
if 9.99999999999999924e-25 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000025e141Initial program 88.3%
Taylor expanded in x around 0 91.0%
if 5.00000000000000025e141 < (/.f64 #s(literal 1 binary64) n) Initial program 8.5%
Taylor expanded in x around inf 0.7%
mul-1-neg0.7%
log-rec0.7%
mul-1-neg0.7%
distribute-neg-frac0.7%
mul-1-neg0.7%
remove-double-neg0.7%
*-commutative0.7%
Simplified0.7%
Taylor expanded in n around inf 51.3%
log1p-expm1-u89.8%
Applied egg-rr89.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n)))
(t_1 (/ (log x) (- n)))
(t_2 (- (+ 1.0 (/ x n)) t_0)))
(if (<= x 1.045e-286)
t_1
(if (<= x 2.4e-209)
t_2
(if (<= x 7.5e-148)
t_1
(if (<= x 5.2e-114)
(/
(+ 1.0 (+ (/ 0.3333333333333333 (pow x 2.0)) (/ -0.5 x)))
(* x n))
(if (<= x 3.4e-44)
t_1
(if (<= x 2.25e-30)
t_2
(if (<= x 0.013) t_1 (/ (/ t_0 n) x))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(x) / -n;
double t_2 = (1.0 + (x / n)) - t_0;
double tmp;
if (x <= 1.045e-286) {
tmp = t_1;
} else if (x <= 2.4e-209) {
tmp = t_2;
} else if (x <= 7.5e-148) {
tmp = t_1;
} else if (x <= 5.2e-114) {
tmp = (1.0 + ((0.3333333333333333 / pow(x, 2.0)) + (-0.5 / x))) / (x * n);
} else if (x <= 3.4e-44) {
tmp = t_1;
} else if (x <= 2.25e-30) {
tmp = t_2;
} else if (x <= 0.013) {
tmp = t_1;
} else {
tmp = (t_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) :: t_2
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(x) / -n
t_2 = (1.0d0 + (x / n)) - t_0
if (x <= 1.045d-286) then
tmp = t_1
else if (x <= 2.4d-209) then
tmp = t_2
else if (x <= 7.5d-148) then
tmp = t_1
else if (x <= 5.2d-114) then
tmp = (1.0d0 + ((0.3333333333333333d0 / (x ** 2.0d0)) + ((-0.5d0) / x))) / (x * n)
else if (x <= 3.4d-44) then
tmp = t_1
else if (x <= 2.25d-30) then
tmp = t_2
else if (x <= 0.013d0) then
tmp = t_1
else
tmp = (t_0 / 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 t_1 = Math.log(x) / -n;
double t_2 = (1.0 + (x / n)) - t_0;
double tmp;
if (x <= 1.045e-286) {
tmp = t_1;
} else if (x <= 2.4e-209) {
tmp = t_2;
} else if (x <= 7.5e-148) {
tmp = t_1;
} else if (x <= 5.2e-114) {
tmp = (1.0 + ((0.3333333333333333 / Math.pow(x, 2.0)) + (-0.5 / x))) / (x * n);
} else if (x <= 3.4e-44) {
tmp = t_1;
} else if (x <= 2.25e-30) {
tmp = t_2;
} else if (x <= 0.013) {
tmp = t_1;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(x) / -n t_2 = (1.0 + (x / n)) - t_0 tmp = 0 if x <= 1.045e-286: tmp = t_1 elif x <= 2.4e-209: tmp = t_2 elif x <= 7.5e-148: tmp = t_1 elif x <= 5.2e-114: tmp = (1.0 + ((0.3333333333333333 / math.pow(x, 2.0)) + (-0.5 / x))) / (x * n) elif x <= 3.4e-44: tmp = t_1 elif x <= 2.25e-30: tmp = t_2 elif x <= 0.013: tmp = t_1 else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(x) / Float64(-n)) t_2 = Float64(Float64(1.0 + Float64(x / n)) - t_0) tmp = 0.0 if (x <= 1.045e-286) tmp = t_1; elseif (x <= 2.4e-209) tmp = t_2; elseif (x <= 7.5e-148) tmp = t_1; elseif (x <= 5.2e-114) tmp = Float64(Float64(1.0 + Float64(Float64(0.3333333333333333 / (x ^ 2.0)) + Float64(-0.5 / x))) / Float64(x * n)); elseif (x <= 3.4e-44) tmp = t_1; elseif (x <= 2.25e-30) tmp = t_2; elseif (x <= 0.013) tmp = t_1; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(x) / -n; t_2 = (1.0 + (x / n)) - t_0; tmp = 0.0; if (x <= 1.045e-286) tmp = t_1; elseif (x <= 2.4e-209) tmp = t_2; elseif (x <= 7.5e-148) tmp = t_1; elseif (x <= 5.2e-114) tmp = (1.0 + ((0.3333333333333333 / (x ^ 2.0)) + (-0.5 / x))) / (x * n); elseif (x <= 3.4e-44) tmp = t_1; elseif (x <= 2.25e-30) tmp = t_2; elseif (x <= 0.013) tmp = t_1; else tmp = (t_0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[x, 1.045e-286], t$95$1, If[LessEqual[x, 2.4e-209], t$95$2, If[LessEqual[x, 7.5e-148], t$95$1, If[LessEqual[x, 5.2e-114], N[(N[(1.0 + N[(N[(0.3333333333333333 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.4e-44], t$95$1, If[LessEqual[x, 2.25e-30], t$95$2, If[LessEqual[x, 0.013], t$95$1, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log x}{-n}\\
t_2 := \left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-209}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-148}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-114}:\\
\;\;\;\;\frac{1 + \left(\frac{0.3333333333333333}{{x}^{2}} + \frac{-0.5}{x}\right)}{x \cdot n}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{-30}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 0.013:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.04500000000000002e-286 or 2.4000000000000001e-209 < x < 7.5000000000000005e-148 or 5.20000000000000026e-114 < x < 3.40000000000000016e-44 or 2.24999999999999984e-30 < x < 0.0129999999999999994Initial program 28.5%
Taylor expanded in x around 0 28.5%
*-rgt-identity28.5%
associate-*l/28.5%
associate-/l*28.5%
exp-to-pow28.5%
Simplified28.5%
Taylor expanded in n around inf 64.6%
associate-*r/64.6%
neg-mul-164.6%
Simplified64.6%
if 1.04500000000000002e-286 < x < 2.4000000000000001e-209 or 3.40000000000000016e-44 < x < 2.24999999999999984e-30Initial program 60.9%
Taylor expanded in x around 0 61.3%
if 7.5000000000000005e-148 < x < 5.20000000000000026e-114Initial program 49.3%
Taylor expanded in x around inf 0.8%
Simplified23.7%
Taylor expanded in n around inf 70.1%
associate-*r/70.1%
metadata-eval70.1%
associate-*r/70.1%
metadata-eval70.1%
Simplified70.1%
Taylor expanded in n around inf 70.1%
associate--l+70.1%
associate-*r/70.1%
metadata-eval70.1%
sub-neg70.1%
associate-*r/70.1%
metadata-eval70.1%
distribute-neg-frac70.1%
metadata-eval70.1%
*-commutative70.1%
Simplified70.1%
if 0.0129999999999999994 < x Initial program 66.3%
Taylor expanded in x around inf 95.7%
associate-/r*98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-rgt-identity98.0%
associate-/l*98.0%
exp-to-pow98.0%
Simplified98.0%
Final simplification79.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log x) (- n))))
(if (<= x 1.045e-286)
t_1
(if (<= x 2.25e-209)
(- (+ 1.0 (/ x n)) t_0)
(if (<= x 1.5e-147)
t_1
(if (<= x 5.8e-119)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= x 0.0145) t_1 (/ (/ t_0 n) x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(x) / -n;
double tmp;
if (x <= 1.045e-286) {
tmp = t_1;
} else if (x <= 2.25e-209) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 1.5e-147) {
tmp = t_1;
} else if (x <= 5.8e-119) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if (x <= 0.0145) {
tmp = t_1;
} else {
tmp = (t_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 = x ** (1.0d0 / n)
t_1 = log(x) / -n
if (x <= 1.045d-286) then
tmp = t_1
else if (x <= 2.25d-209) then
tmp = (1.0d0 + (x / n)) - t_0
else if (x <= 1.5d-147) then
tmp = t_1
else if (x <= 5.8d-119) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if (x <= 0.0145d0) then
tmp = t_1
else
tmp = (t_0 / 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 t_1 = Math.log(x) / -n;
double tmp;
if (x <= 1.045e-286) {
tmp = t_1;
} else if (x <= 2.25e-209) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 1.5e-147) {
tmp = t_1;
} else if (x <= 5.8e-119) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if (x <= 0.0145) {
tmp = t_1;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(x) / -n tmp = 0 if x <= 1.045e-286: tmp = t_1 elif x <= 2.25e-209: tmp = (1.0 + (x / n)) - t_0 elif x <= 1.5e-147: tmp = t_1 elif x <= 5.8e-119: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif x <= 0.0145: tmp = t_1 else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.045e-286) tmp = t_1; elseif (x <= 2.25e-209) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif (x <= 1.5e-147) tmp = t_1; elseif (x <= 5.8e-119) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (x <= 0.0145) tmp = t_1; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(x) / -n; tmp = 0.0; if (x <= 1.045e-286) tmp = t_1; elseif (x <= 2.25e-209) tmp = (1.0 + (x / n)) - t_0; elseif (x <= 1.5e-147) tmp = t_1; elseif (x <= 5.8e-119) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif (x <= 0.0145) tmp = t_1; else tmp = (t_0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.045e-286], t$95$1, If[LessEqual[x, 2.25e-209], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 1.5e-147], t$95$1, If[LessEqual[x, 5.8e-119], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0145], t$95$1, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{-209}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-147}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-119}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;x \leq 0.0145:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.04500000000000002e-286 or 2.2499999999999999e-209 < x < 1.5000000000000001e-147 or 5.8e-119 < x < 0.0145000000000000007Initial program 31.9%
Taylor expanded in x around 0 31.9%
*-rgt-identity31.9%
associate-*l/31.9%
associate-/l*31.9%
exp-to-pow31.9%
Simplified31.9%
Taylor expanded in n around inf 59.4%
associate-*r/59.4%
neg-mul-159.4%
Simplified59.4%
if 1.04500000000000002e-286 < x < 2.2499999999999999e-209Initial program 61.4%
Taylor expanded in x around 0 61.5%
if 1.5000000000000001e-147 < x < 5.8e-119Initial program 49.3%
Taylor expanded in x around inf 0.8%
Simplified23.7%
Taylor expanded in n around inf 70.1%
associate-*r/70.1%
metadata-eval70.1%
associate-*r/70.1%
metadata-eval70.1%
Simplified70.1%
Taylor expanded in x around 0 69.9%
if 0.0145000000000000007 < x Initial program 66.3%
Taylor expanded in x around inf 95.7%
associate-/r*98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-rgt-identity98.0%
associate-/l*98.0%
exp-to-pow98.0%
Simplified98.0%
Final simplification77.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (pow x (/ 1.0 n))))
(if (<= x 1.045e-286)
t_0
(if (<= x 6.6e-209)
(- 1.0 t_1)
(if (<= x 1.5e-147)
t_0
(if (<= x 6e-119)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= x 0.013) 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.045e-286) {
tmp = t_0;
} else if (x <= 6.6e-209) {
tmp = 1.0 - t_1;
} else if (x <= 1.5e-147) {
tmp = t_0;
} else if (x <= 6e-119) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if (x <= 0.013) {
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.045d-286) then
tmp = t_0
else if (x <= 6.6d-209) then
tmp = 1.0d0 - t_1
else if (x <= 1.5d-147) then
tmp = t_0
else if (x <= 6d-119) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if (x <= 0.013d0) 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.045e-286) {
tmp = t_0;
} else if (x <= 6.6e-209) {
tmp = 1.0 - t_1;
} else if (x <= 1.5e-147) {
tmp = t_0;
} else if (x <= 6e-119) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if (x <= 0.013) {
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.045e-286: tmp = t_0 elif x <= 6.6e-209: tmp = 1.0 - t_1 elif x <= 1.5e-147: tmp = t_0 elif x <= 6e-119: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif x <= 0.013: 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.045e-286) tmp = t_0; elseif (x <= 6.6e-209) tmp = Float64(1.0 - t_1); elseif (x <= 1.5e-147) tmp = t_0; elseif (x <= 6e-119) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (x <= 0.013) 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.045e-286) tmp = t_0; elseif (x <= 6.6e-209) tmp = 1.0 - t_1; elseif (x <= 1.5e-147) tmp = t_0; elseif (x <= 6e-119) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif (x <= 0.013) 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.045e-286], t$95$0, If[LessEqual[x, 6.6e-209], N[(1.0 - t$95$1), $MachinePrecision], If[LessEqual[x, 1.5e-147], t$95$0, If[LessEqual[x, 6e-119], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.013], 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.045 \cdot 10^{-286}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{-209}:\\
\;\;\;\;1 - t\_1\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-119}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;x \leq 0.013:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{n}}{x}\\
\end{array}
\end{array}
if x < 1.04500000000000002e-286 or 6.59999999999999948e-209 < x < 1.5000000000000001e-147 or 6.0000000000000004e-119 < x < 0.0129999999999999994Initial program 31.9%
Taylor expanded in x around 0 31.9%
*-rgt-identity31.9%
associate-*l/31.9%
associate-/l*31.9%
exp-to-pow31.9%
Simplified31.9%
Taylor expanded in n around inf 59.4%
associate-*r/59.4%
neg-mul-159.4%
Simplified59.4%
if 1.04500000000000002e-286 < x < 6.59999999999999948e-209Initial program 61.4%
Taylor expanded in x around 0 61.4%
*-rgt-identity61.4%
associate-*l/61.4%
associate-/l*61.4%
exp-to-pow61.4%
Simplified61.4%
if 1.5000000000000001e-147 < x < 6.0000000000000004e-119Initial program 49.3%
Taylor expanded in x around inf 0.8%
Simplified23.7%
Taylor expanded in n around inf 70.1%
associate-*r/70.1%
metadata-eval70.1%
associate-*r/70.1%
metadata-eval70.1%
Simplified70.1%
Taylor expanded in x around 0 69.9%
if 0.0129999999999999994 < x Initial program 66.3%
Taylor expanded in x around inf 95.7%
associate-/r*98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-rgt-identity98.0%
associate-/l*98.0%
exp-to-pow98.0%
Simplified98.0%
Final simplification77.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 1.045e-286)
t_0
(if (<= x 2.35e-209)
t_1
(if (<= x 3.4e-44)
t_0
(if (<= x 1.02e-30)
t_1
(if (<= x 0.68) t_0 (/ (/ (- 1.0 (/ 0.5 x)) n) x))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 1.045e-286) {
tmp = t_0;
} else if (x <= 2.35e-209) {
tmp = t_1;
} else if (x <= 3.4e-44) {
tmp = t_0;
} else if (x <= 1.02e-30) {
tmp = t_1;
} else if (x <= 0.68) {
tmp = t_0;
} else {
tmp = ((1.0 - (0.5 / x)) / 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 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 1.045d-286) then
tmp = t_0
else if (x <= 2.35d-209) then
tmp = t_1
else if (x <= 3.4d-44) then
tmp = t_0
else if (x <= 1.02d-30) then
tmp = t_1
else if (x <= 0.68d0) then
tmp = t_0
else
tmp = ((1.0d0 - (0.5d0 / x)) / 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 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.045e-286) {
tmp = t_0;
} else if (x <= 2.35e-209) {
tmp = t_1;
} else if (x <= 3.4e-44) {
tmp = t_0;
} else if (x <= 1.02e-30) {
tmp = t_1;
} else if (x <= 0.68) {
tmp = t_0;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.045e-286: tmp = t_0 elif x <= 2.35e-209: tmp = t_1 elif x <= 3.4e-44: tmp = t_0 elif x <= 1.02e-30: tmp = t_1 elif x <= 0.68: tmp = t_0 else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 1.045e-286) tmp = t_0; elseif (x <= 2.35e-209) tmp = t_1; elseif (x <= 3.4e-44) tmp = t_0; elseif (x <= 1.02e-30) tmp = t_1; elseif (x <= 0.68) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 1.045e-286) tmp = t_0; elseif (x <= 2.35e-209) tmp = t_1; elseif (x <= 3.4e-44) tmp = t_0; elseif (x <= 1.02e-30) tmp = t_1; elseif (x <= 0.68) tmp = t_0; else tmp = ((1.0 - (0.5 / x)) / 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[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.045e-286], t$95$0, If[LessEqual[x, 2.35e-209], t$95$1, If[LessEqual[x, 3.4e-44], t$95$0, If[LessEqual[x, 1.02e-30], t$95$1, If[LessEqual[x, 0.68], t$95$0, N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{-209}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{-30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 1.04500000000000002e-286 or 2.35e-209 < x < 3.40000000000000016e-44 or 1.0199999999999999e-30 < x < 0.680000000000000049Initial program 31.4%
Taylor expanded in x around 0 31.4%
*-rgt-identity31.4%
associate-*l/31.4%
associate-/l*31.4%
exp-to-pow31.4%
Simplified31.4%
Taylor expanded in n around inf 59.3%
associate-*r/59.3%
neg-mul-159.3%
Simplified59.3%
if 1.04500000000000002e-286 < x < 2.35e-209 or 3.40000000000000016e-44 < x < 1.0199999999999999e-30Initial program 60.9%
Taylor expanded in x around 0 60.9%
*-rgt-identity60.9%
associate-*l/60.9%
associate-/l*60.9%
exp-to-pow60.9%
Simplified60.9%
if 0.680000000000000049 < x Initial program 66.3%
Taylor expanded in x around inf 75.7%
Simplified75.7%
Taylor expanded in n around inf 77.7%
associate-*r/77.7%
metadata-eval77.7%
associate-*r/77.7%
metadata-eval77.7%
Simplified77.7%
Taylor expanded in x around inf 77.6%
Taylor expanded in n around inf 66.6%
associate-*r/66.6%
metadata-eval66.6%
Simplified66.6%
Final simplification62.9%
(FPCore (x n)
:precision binary64
(if (<= n -5.8)
(* (/ 1.0 n) (/ 1.0 x))
(if (<= n 1e-163)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= n 1.4e+15) (- 1.0 (pow x (/ 1.0 n))) (/ (/ 1.0 x) n)))))
double code(double x, double n) {
double tmp;
if (n <= -5.8) {
tmp = (1.0 / n) * (1.0 / x);
} else if (n <= 1e-163) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if (n <= 1.4e+15) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-5.8d0)) then
tmp = (1.0d0 / n) * (1.0d0 / x)
else if (n <= 1d-163) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if (n <= 1.4d+15) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -5.8) {
tmp = (1.0 / n) * (1.0 / x);
} else if (n <= 1e-163) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if (n <= 1.4e+15) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -5.8: tmp = (1.0 / n) * (1.0 / x) elif n <= 1e-163: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif n <= 1.4e+15: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (n <= -5.8) tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); elseif (n <= 1e-163) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (n <= 1.4e+15) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -5.8) tmp = (1.0 / n) * (1.0 / x); elseif (n <= 1e-163) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif (n <= 1.4e+15) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -5.8], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1e-163], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.4e+15], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.8:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;n \leq 10^{-163}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;n \leq 1.4 \cdot 10^{+15}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if n < -5.79999999999999982Initial program 31.0%
Taylor expanded in x around inf 55.5%
mul-1-neg55.5%
log-rec55.5%
mul-1-neg55.5%
distribute-neg-frac55.5%
mul-1-neg55.5%
remove-double-neg55.5%
*-commutative55.5%
Simplified55.5%
Taylor expanded in n around inf 54.4%
inv-pow54.4%
unpow-prod-down56.1%
inv-pow56.1%
inv-pow56.1%
Applied egg-rr56.1%
if -5.79999999999999982 < n < 9.99999999999999923e-164Initial program 80.5%
Taylor expanded in x around inf 12.4%
Simplified22.5%
Taylor expanded in n around inf 67.0%
associate-*r/67.0%
metadata-eval67.0%
associate-*r/67.0%
metadata-eval67.0%
Simplified67.0%
Taylor expanded in x around 0 80.8%
if 9.99999999999999923e-164 < n < 1.4e15Initial program 88.3%
Taylor expanded in x around 0 88.3%
*-rgt-identity88.3%
associate-*l/88.3%
associate-/l*88.3%
exp-to-pow88.3%
Simplified88.3%
if 1.4e15 < n Initial program 28.8%
Taylor expanded in x around inf 49.8%
mul-1-neg49.8%
log-rec49.8%
mul-1-neg49.8%
distribute-neg-frac49.8%
mul-1-neg49.8%
remove-double-neg49.8%
*-commutative49.8%
Simplified49.8%
Taylor expanded in n around inf 49.8%
*-commutative49.8%
associate-/r*51.7%
Simplified51.7%
Final simplification66.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.045e-286)
t_0
(if (<= x 7.2e-281)
(/ 1.0 (* x n))
(if (<= x 0.68) t_0 (/ (/ (- 1.0 (/ 0.5 x)) n) x))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.045e-286) {
tmp = t_0;
} else if (x <= 7.2e-281) {
tmp = 1.0 / (x * n);
} else if (x <= 0.68) {
tmp = t_0;
} else {
tmp = ((1.0 - (0.5 / x)) / 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 = log(x) / -n
if (x <= 1.045d-286) then
tmp = t_0
else if (x <= 7.2d-281) then
tmp = 1.0d0 / (x * n)
else if (x <= 0.68d0) then
tmp = t_0
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
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.045e-286) {
tmp = t_0;
} else if (x <= 7.2e-281) {
tmp = 1.0 / (x * n);
} else if (x <= 0.68) {
tmp = t_0;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.045e-286: tmp = t_0 elif x <= 7.2e-281: tmp = 1.0 / (x * n) elif x <= 0.68: tmp = t_0 else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.045e-286) tmp = t_0; elseif (x <= 7.2e-281) tmp = Float64(1.0 / Float64(x * n)); elseif (x <= 0.68) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.045e-286) tmp = t_0; elseif (x <= 7.2e-281) tmp = 1.0 / (x * n); elseif (x <= 0.68) tmp = t_0; else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.045e-286], t$95$0, If[LessEqual[x, 7.2e-281], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.68], t$95$0, N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-281}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 1.04500000000000002e-286 or 7.20000000000000013e-281 < x < 0.680000000000000049Initial program 38.9%
Taylor expanded in x around 0 38.9%
*-rgt-identity38.9%
associate-*l/38.9%
associate-/l*38.9%
exp-to-pow38.9%
Simplified38.9%
Taylor expanded in n around inf 51.3%
associate-*r/51.3%
neg-mul-151.3%
Simplified51.3%
if 1.04500000000000002e-286 < x < 7.20000000000000013e-281Initial program 100.0%
Taylor expanded in x around inf 83.3%
mul-1-neg83.3%
log-rec83.3%
mul-1-neg83.3%
distribute-neg-frac83.3%
mul-1-neg83.3%
remove-double-neg83.3%
*-commutative83.3%
Simplified83.3%
Taylor expanded in n around inf 83.9%
if 0.680000000000000049 < x Initial program 66.3%
Taylor expanded in x around inf 75.7%
Simplified75.7%
Taylor expanded in n around inf 77.7%
associate-*r/77.7%
metadata-eval77.7%
associate-*r/77.7%
metadata-eval77.7%
Simplified77.7%
Taylor expanded in x around inf 77.6%
Taylor expanded in n around inf 66.6%
associate-*r/66.6%
metadata-eval66.6%
Simplified66.6%
Final simplification59.0%
(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 52.8%
Taylor expanded in x around inf 57.3%
mul-1-neg57.3%
log-rec57.3%
mul-1-neg57.3%
distribute-neg-frac57.3%
mul-1-neg57.3%
remove-double-neg57.3%
*-commutative57.3%
Simplified57.3%
Taylor expanded in n around inf 41.0%
*-commutative41.0%
associate-/r*42.0%
Simplified42.0%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 52.8%
Taylor expanded in x around inf 57.3%
mul-1-neg57.3%
log-rec57.3%
mul-1-neg57.3%
distribute-neg-frac57.3%
mul-1-neg57.3%
remove-double-neg57.3%
*-commutative57.3%
Simplified57.3%
Taylor expanded in n around inf 41.0%
herbie shell --seed 2024086
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))