
(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 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n)))
(t_1 (log (+ 1.0 x)))
(t_2 (* 0.5 (/ (pow t_1 2.0) (pow n 2.0))))
(t_3 (* 0.5 (/ (pow (log x) 2.0) (pow n 2.0)))))
(if (<= n -5500000.0)
(-
(+
(/ (- t_1 (log x)) n)
(+
(/
(-
(* -0.16666666666666666 (pow (log x) 3.0))
(* -0.16666666666666666 (pow t_1 3.0)))
(pow n 3.0))
(+ (* 0.041666666666666664 (/ (pow t_1 4.0) (pow n 4.0))) t_2)))
(+ (* 0.041666666666666664 (/ (pow (log x) 4.0) (pow n 4.0))) t_3))
(if (<= n 0.0126)
(* 2.0 (log (sqrt (exp (- (exp (/ (log1p x) n)) t_0)))))
(if (<= n 1e+59)
(* (/ 1.0 x) (/ t_0 n))
(- (+ t_2 (/ t_1 n)) (+ t_3 (/ (log x) n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log((1.0 + x));
double t_2 = 0.5 * (pow(t_1, 2.0) / pow(n, 2.0));
double t_3 = 0.5 * (pow(log(x), 2.0) / pow(n, 2.0));
double tmp;
if (n <= -5500000.0) {
tmp = (((t_1 - log(x)) / n) + ((((-0.16666666666666666 * pow(log(x), 3.0)) - (-0.16666666666666666 * pow(t_1, 3.0))) / pow(n, 3.0)) + ((0.041666666666666664 * (pow(t_1, 4.0) / pow(n, 4.0))) + t_2))) - ((0.041666666666666664 * (pow(log(x), 4.0) / pow(n, 4.0))) + t_3);
} else if (n <= 0.0126) {
tmp = 2.0 * log(sqrt(exp((exp((log1p(x) / n)) - t_0))));
} else if (n <= 1e+59) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = (t_2 + (t_1 / n)) - (t_3 + (log(x) / n));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.log((1.0 + x));
double t_2 = 0.5 * (Math.pow(t_1, 2.0) / Math.pow(n, 2.0));
double t_3 = 0.5 * (Math.pow(Math.log(x), 2.0) / Math.pow(n, 2.0));
double tmp;
if (n <= -5500000.0) {
tmp = (((t_1 - Math.log(x)) / n) + ((((-0.16666666666666666 * Math.pow(Math.log(x), 3.0)) - (-0.16666666666666666 * Math.pow(t_1, 3.0))) / Math.pow(n, 3.0)) + ((0.041666666666666664 * (Math.pow(t_1, 4.0) / Math.pow(n, 4.0))) + t_2))) - ((0.041666666666666664 * (Math.pow(Math.log(x), 4.0) / Math.pow(n, 4.0))) + t_3);
} else if (n <= 0.0126) {
tmp = 2.0 * Math.log(Math.sqrt(Math.exp((Math.exp((Math.log1p(x) / n)) - t_0))));
} else if (n <= 1e+59) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = (t_2 + (t_1 / n)) - (t_3 + (Math.log(x) / n));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log((1.0 + x)) t_2 = 0.5 * (math.pow(t_1, 2.0) / math.pow(n, 2.0)) t_3 = 0.5 * (math.pow(math.log(x), 2.0) / math.pow(n, 2.0)) tmp = 0 if n <= -5500000.0: tmp = (((t_1 - math.log(x)) / n) + ((((-0.16666666666666666 * math.pow(math.log(x), 3.0)) - (-0.16666666666666666 * math.pow(t_1, 3.0))) / math.pow(n, 3.0)) + ((0.041666666666666664 * (math.pow(t_1, 4.0) / math.pow(n, 4.0))) + t_2))) - ((0.041666666666666664 * (math.pow(math.log(x), 4.0) / math.pow(n, 4.0))) + t_3) elif n <= 0.0126: tmp = 2.0 * math.log(math.sqrt(math.exp((math.exp((math.log1p(x) / n)) - t_0)))) elif n <= 1e+59: tmp = (1.0 / x) * (t_0 / n) else: tmp = (t_2 + (t_1 / n)) - (t_3 + (math.log(x) / n)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = log(Float64(1.0 + x)) t_2 = Float64(0.5 * Float64((t_1 ^ 2.0) / (n ^ 2.0))) t_3 = Float64(0.5 * Float64((log(x) ^ 2.0) / (n ^ 2.0))) tmp = 0.0 if (n <= -5500000.0) tmp = Float64(Float64(Float64(Float64(t_1 - log(x)) / n) + Float64(Float64(Float64(Float64(-0.16666666666666666 * (log(x) ^ 3.0)) - Float64(-0.16666666666666666 * (t_1 ^ 3.0))) / (n ^ 3.0)) + Float64(Float64(0.041666666666666664 * Float64((t_1 ^ 4.0) / (n ^ 4.0))) + t_2))) - Float64(Float64(0.041666666666666664 * Float64((log(x) ^ 4.0) / (n ^ 4.0))) + t_3)); elseif (n <= 0.0126) tmp = Float64(2.0 * log(sqrt(exp(Float64(exp(Float64(log1p(x) / n)) - t_0))))); elseif (n <= 1e+59) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); else tmp = Float64(Float64(t_2 + Float64(t_1 / n)) - Float64(t_3 + Float64(log(x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(N[Power[t$95$1, 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -5500000.0], N[(N[(N[(N[(t$95$1 - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(N[(N[(-0.16666666666666666 * N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] - N[(-0.16666666666666666 * N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.041666666666666664 * N[(N[Power[t$95$1, 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.041666666666666664 * N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.0126], N[(2.0 * N[Log[N[Sqrt[N[Exp[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1e+59], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 + N[(t$95$1 / n), $MachinePrecision]), $MachinePrecision] - N[(t$95$3 + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \log \left(1 + x\right)\\
t_2 := 0.5 \cdot \frac{{t_1}^{2}}{{n}^{2}}\\
t_3 := 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\\
\mathbf{if}\;n \leq -5500000:\\
\;\;\;\;\left(\frac{t_1 - \log x}{n} + \left(\frac{-0.16666666666666666 \cdot {\log x}^{3} - -0.16666666666666666 \cdot {t_1}^{3}}{{n}^{3}} + \left(0.041666666666666664 \cdot \frac{{t_1}^{4}}{{n}^{4}} + t_2\right)\right)\right) - \left(0.041666666666666664 \cdot \frac{{\log x}^{4}}{{n}^{4}} + t_3\right)\\
\mathbf{elif}\;n \leq 0.0126:\\
\;\;\;\;2 \cdot \log \left(\sqrt{e^{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0}}\right)\\
\mathbf{elif}\;n \leq 10^{+59}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(t_2 + \frac{t_1}{n}\right) - \left(t_3 + \frac{\log x}{n}\right)\\
\end{array}
\end{array}
if n < -5.5e6Initial program 26.5%
Taylor expanded in n around -inf 77.8%
if -5.5e6 < n < 0.0126Initial program 91.7%
add-log-exp91.7%
add-sqr-sqrt91.7%
log-prod91.7%
add-exp-log91.7%
log-pow91.7%
+-commutative91.7%
log1p-udef99.2%
*-commutative99.2%
un-div-inv99.2%
Applied egg-rr99.2%
count-299.2%
Simplified99.2%
if 0.0126 < n < 9.99999999999999972e58Initial program 9.3%
Taylor expanded in x around inf 69.1%
mul-1-neg69.1%
log-rec69.1%
mul-1-neg69.1%
distribute-neg-frac69.1%
mul-1-neg69.1%
remove-double-neg69.1%
*-commutative69.1%
Simplified69.1%
div-inv69.1%
pow-to-exp69.0%
*-un-lft-identity69.0%
times-frac74.4%
Applied egg-rr74.4%
if 9.99999999999999972e58 < n Initial program 31.8%
Taylor expanded in n around inf 85.2%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (log (+ 1.0 x)))
(t_1 (pow x (/ 1.0 n)))
(t_2 (/ (pow (log x) 2.0) (pow n 2.0))))
(if (<= n -5500000.0)
(+
(/ (- (log1p x) (log x)) n)
(+
(/
0.16666666666666666
(/ (pow n 3.0) (- (pow (log1p x) 3.0) (pow (log x) 3.0))))
(* 0.5 (- (/ (pow (log1p x) 2.0) (pow n 2.0)) t_2))))
(if (<= n 2.7e-5)
(* 2.0 (log (sqrt (exp (- (exp (/ (log1p x) n)) t_1)))))
(if (<= n 2.4e+61)
(* (/ 1.0 x) (/ t_1 n))
(-
(+ (* 0.5 (/ (pow t_0 2.0) (pow n 2.0))) (/ t_0 n))
(+ (* 0.5 t_2) (/ (log x) n))))))))
double code(double x, double n) {
double t_0 = log((1.0 + x));
double t_1 = pow(x, (1.0 / n));
double t_2 = pow(log(x), 2.0) / pow(n, 2.0);
double tmp;
if (n <= -5500000.0) {
tmp = ((log1p(x) - log(x)) / n) + ((0.16666666666666666 / (pow(n, 3.0) / (pow(log1p(x), 3.0) - pow(log(x), 3.0)))) + (0.5 * ((pow(log1p(x), 2.0) / pow(n, 2.0)) - t_2)));
} else if (n <= 2.7e-5) {
tmp = 2.0 * log(sqrt(exp((exp((log1p(x) / n)) - t_1))));
} else if (n <= 2.4e+61) {
tmp = (1.0 / x) * (t_1 / n);
} else {
tmp = ((0.5 * (pow(t_0, 2.0) / pow(n, 2.0))) + (t_0 / n)) - ((0.5 * t_2) + (log(x) / n));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log((1.0 + x));
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = Math.pow(Math.log(x), 2.0) / Math.pow(n, 2.0);
double tmp;
if (n <= -5500000.0) {
tmp = ((Math.log1p(x) - Math.log(x)) / n) + ((0.16666666666666666 / (Math.pow(n, 3.0) / (Math.pow(Math.log1p(x), 3.0) - Math.pow(Math.log(x), 3.0)))) + (0.5 * ((Math.pow(Math.log1p(x), 2.0) / Math.pow(n, 2.0)) - t_2)));
} else if (n <= 2.7e-5) {
tmp = 2.0 * Math.log(Math.sqrt(Math.exp((Math.exp((Math.log1p(x) / n)) - t_1))));
} else if (n <= 2.4e+61) {
tmp = (1.0 / x) * (t_1 / n);
} else {
tmp = ((0.5 * (Math.pow(t_0, 2.0) / Math.pow(n, 2.0))) + (t_0 / n)) - ((0.5 * t_2) + (Math.log(x) / n));
}
return tmp;
}
def code(x, n): t_0 = math.log((1.0 + x)) t_1 = math.pow(x, (1.0 / n)) t_2 = math.pow(math.log(x), 2.0) / math.pow(n, 2.0) tmp = 0 if n <= -5500000.0: tmp = ((math.log1p(x) - math.log(x)) / n) + ((0.16666666666666666 / (math.pow(n, 3.0) / (math.pow(math.log1p(x), 3.0) - math.pow(math.log(x), 3.0)))) + (0.5 * ((math.pow(math.log1p(x), 2.0) / math.pow(n, 2.0)) - t_2))) elif n <= 2.7e-5: tmp = 2.0 * math.log(math.sqrt(math.exp((math.exp((math.log1p(x) / n)) - t_1)))) elif n <= 2.4e+61: tmp = (1.0 / x) * (t_1 / n) else: tmp = ((0.5 * (math.pow(t_0, 2.0) / math.pow(n, 2.0))) + (t_0 / n)) - ((0.5 * t_2) + (math.log(x) / n)) return tmp
function code(x, n) t_0 = log(Float64(1.0 + x)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64((log(x) ^ 2.0) / (n ^ 2.0)) tmp = 0.0 if (n <= -5500000.0) tmp = Float64(Float64(Float64(log1p(x) - log(x)) / n) + Float64(Float64(0.16666666666666666 / Float64((n ^ 3.0) / Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)))) + Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) / (n ^ 2.0)) - t_2)))); elseif (n <= 2.7e-5) tmp = Float64(2.0 * log(sqrt(exp(Float64(exp(Float64(log1p(x) / n)) - t_1))))); elseif (n <= 2.4e+61) tmp = Float64(Float64(1.0 / x) * Float64(t_1 / n)); else tmp = Float64(Float64(Float64(0.5 * Float64((t_0 ^ 2.0) / (n ^ 2.0))) + Float64(t_0 / n)) - Float64(Float64(0.5 * t_2) + Float64(log(x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -5500000.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(0.16666666666666666 / N[(N[Power[n, 3.0], $MachinePrecision] / N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.7e-5], N[(2.0 * N[Log[N[Sqrt[N[Exp[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.4e+61], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$1 / n), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * N[(N[Power[t$95$0, 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 * t$95$2), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(1 + x\right)\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{{\log x}^{2}}{{n}^{2}}\\
\mathbf{if}\;n \leq -5500000:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n} + \left(\frac{0.16666666666666666}{\frac{{n}^{3}}{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}} + 0.5 \cdot \left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{{n}^{2}} - t_2\right)\right)\\
\mathbf{elif}\;n \leq 2.7 \cdot 10^{-5}:\\
\;\;\;\;2 \cdot \log \left(\sqrt{e^{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_1}}\right)\\
\mathbf{elif}\;n \leq 2.4 \cdot 10^{+61}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_1}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \frac{{t_0}^{2}}{{n}^{2}} + \frac{t_0}{n}\right) - \left(0.5 \cdot t_2 + \frac{\log x}{n}\right)\\
\end{array}
\end{array}
if n < -5.5e6Initial program 26.5%
Taylor expanded in n around -inf 77.8%
associate--l+77.8%
associate-*r/77.8%
distribute-lft-out--77.8%
associate-*r*77.8%
metadata-eval77.8%
*-lft-identity77.8%
log1p-def77.8%
associate--l+77.8%
Simplified77.8%
if -5.5e6 < n < 2.6999999999999999e-5Initial program 91.7%
add-log-exp91.7%
add-sqr-sqrt91.7%
log-prod91.7%
add-exp-log91.7%
log-pow91.7%
+-commutative91.7%
log1p-udef99.2%
*-commutative99.2%
un-div-inv99.2%
Applied egg-rr99.2%
count-299.2%
Simplified99.2%
if 2.6999999999999999e-5 < n < 2.3999999999999999e61Initial program 9.3%
Taylor expanded in x around inf 69.1%
mul-1-neg69.1%
log-rec69.1%
mul-1-neg69.1%
distribute-neg-frac69.1%
mul-1-neg69.1%
remove-double-neg69.1%
*-commutative69.1%
Simplified69.1%
div-inv69.1%
pow-to-exp69.0%
*-un-lft-identity69.0%
times-frac74.4%
Applied egg-rr74.4%
if 2.3999999999999999e61 < n Initial program 31.8%
Taylor expanded in n around inf 85.2%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (log (+ 1.0 x))) (t_1 (pow x (/ 1.0 n))))
(if (<= n -40000000000.0)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= n 62.0)
(log1p (expm1 (- (exp (/ (log1p x) n)) t_1)))
(if (<= n 5.2e+58)
(* (/ 1.0 x) (/ t_1 n))
(-
(+ (* 0.5 (/ (pow t_0 2.0) (pow n 2.0))) (/ t_0 n))
(+ (* 0.5 (/ (pow (log x) 2.0) (pow n 2.0))) (/ (log x) n))))))))
double code(double x, double n) {
double t_0 = log((1.0 + x));
double t_1 = pow(x, (1.0 / n));
double tmp;
if (n <= -40000000000.0) {
tmp = log(((1.0 + x) / x)) / n;
} else if (n <= 62.0) {
tmp = log1p(expm1((exp((log1p(x) / n)) - t_1)));
} else if (n <= 5.2e+58) {
tmp = (1.0 / x) * (t_1 / n);
} else {
tmp = ((0.5 * (pow(t_0, 2.0) / pow(n, 2.0))) + (t_0 / n)) - ((0.5 * (pow(log(x), 2.0) / pow(n, 2.0))) + (log(x) / n));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log((1.0 + x));
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if (n <= -40000000000.0) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if (n <= 62.0) {
tmp = Math.log1p(Math.expm1((Math.exp((Math.log1p(x) / n)) - t_1)));
} else if (n <= 5.2e+58) {
tmp = (1.0 / x) * (t_1 / n);
} else {
tmp = ((0.5 * (Math.pow(t_0, 2.0) / Math.pow(n, 2.0))) + (t_0 / n)) - ((0.5 * (Math.pow(Math.log(x), 2.0) / Math.pow(n, 2.0))) + (Math.log(x) / n));
}
return tmp;
}
def code(x, n): t_0 = math.log((1.0 + x)) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if n <= -40000000000.0: tmp = math.log(((1.0 + x) / x)) / n elif n <= 62.0: tmp = math.log1p(math.expm1((math.exp((math.log1p(x) / n)) - t_1))) elif n <= 5.2e+58: tmp = (1.0 / x) * (t_1 / n) else: tmp = ((0.5 * (math.pow(t_0, 2.0) / math.pow(n, 2.0))) + (t_0 / n)) - ((0.5 * (math.pow(math.log(x), 2.0) / math.pow(n, 2.0))) + (math.log(x) / n)) return tmp
function code(x, n) t_0 = log(Float64(1.0 + x)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (n <= -40000000000.0) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (n <= 62.0) tmp = log1p(expm1(Float64(exp(Float64(log1p(x) / n)) - t_1))); elseif (n <= 5.2e+58) tmp = Float64(Float64(1.0 / x) * Float64(t_1 / n)); else tmp = Float64(Float64(Float64(0.5 * Float64((t_0 ^ 2.0) / (n ^ 2.0))) + Float64(t_0 / n)) - Float64(Float64(0.5 * Float64((log(x) ^ 2.0) / (n ^ 2.0))) + Float64(log(x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -40000000000.0], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 62.0], N[Log[1 + N[(Exp[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 5.2e+58], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$1 / n), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * N[(N[Power[t$95$0, 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(1 + x\right)\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;n \leq -40000000000:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;n \leq 62:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_1\right)\right)\\
\mathbf{elif}\;n \leq 5.2 \cdot 10^{+58}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_1}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \frac{{t_0}^{2}}{{n}^{2}} + \frac{t_0}{n}\right) - \left(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)\\
\end{array}
\end{array}
if n < -4e10Initial program 25.8%
Taylor expanded in n around inf 77.4%
log1p-def77.4%
Simplified77.4%
log1p-udef77.4%
diff-log77.7%
+-commutative77.7%
Applied egg-rr77.7%
if -4e10 < n < 62Initial program 91.6%
log1p-expm1-u91.6%
add-exp-log91.6%
log-pow91.6%
+-commutative91.6%
log1p-udef99.0%
*-commutative99.0%
un-div-inv99.0%
Applied egg-rr99.0%
if 62 < n < 5.19999999999999976e58Initial program 9.3%
Taylor expanded in x around inf 69.1%
mul-1-neg69.1%
log-rec69.1%
mul-1-neg69.1%
distribute-neg-frac69.1%
mul-1-neg69.1%
remove-double-neg69.1%
*-commutative69.1%
Simplified69.1%
div-inv69.1%
pow-to-exp69.0%
*-un-lft-identity69.0%
times-frac74.4%
Applied egg-rr74.4%
if 5.19999999999999976e58 < n Initial program 31.8%
Taylor expanded in n around inf 85.2%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-8)
(log1p (expm1 (- (exp (/ (log1p x) n)) t_0)))
(if (<= (/ 1.0 n) 2e-63)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 0.005)
(* (/ 1.0 x) (/ t_0 n))
(- (exp (/ 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-8) {
tmp = log1p(expm1((exp((log1p(x) / n)) - t_0)));
} else if ((1.0 / n) <= 2e-63) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = exp((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-8) {
tmp = Math.log1p(Math.expm1((Math.exp((Math.log1p(x) / n)) - t_0)));
} else if ((1.0 / n) <= 2e-63) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = Math.exp((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-8: tmp = math.log1p(math.expm1((math.exp((math.log1p(x) / n)) - t_0))) elif (1.0 / n) <= 2e-63: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 0.005: tmp = (1.0 / x) * (t_0 / n) else: tmp = math.exp((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-8) tmp = log1p(expm1(Float64(exp(Float64(log1p(x) / n)) - t_0))); elseif (Float64(1.0 / n) <= 2e-63) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 0.005) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-8], N[Log[1 + N[(Exp[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-63], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.005], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / 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^{-8}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\right)\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-63}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.005:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-8Initial program 98.7%
log1p-expm1-u98.7%
add-exp-log98.7%
log-pow98.7%
+-commutative98.7%
log1p-udef98.7%
*-commutative98.7%
un-div-inv98.7%
Applied egg-rr98.7%
if -2e-8 < (/.f64 1 n) < 2.00000000000000013e-63Initial program 28.0%
Taylor expanded in n around inf 80.3%
log1p-def80.3%
Simplified80.3%
log1p-udef80.3%
diff-log80.5%
+-commutative80.5%
Applied egg-rr80.5%
if 2.00000000000000013e-63 < (/.f64 1 n) < 0.0050000000000000001Initial program 9.3%
Taylor expanded in x around inf 69.1%
mul-1-neg69.1%
log-rec69.1%
mul-1-neg69.1%
distribute-neg-frac69.1%
mul-1-neg69.1%
remove-double-neg69.1%
*-commutative69.1%
Simplified69.1%
div-inv69.1%
pow-to-exp69.0%
*-un-lft-identity69.0%
times-frac74.4%
Applied egg-rr74.4%
if 0.0050000000000000001 < (/.f64 1 n) Initial program 69.9%
Taylor expanded in n around 0 69.9%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (* (/ 1.0 x) (/ t_0 n))))
(if (<= (/ 1.0 n) -1e-7)
t_1
(if (<= (/ 1.0 n) 2e-63)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 0.005)
t_1
(if (<= (/ 1.0 n) 1e+242)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (1.0 / x) * (t_0 / n);
double tmp;
if ((1.0 / n) <= -1e-7) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+242) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (1.0d0 / x) * (t_0 / n)
if ((1.0d0 / n) <= (-1d-7)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-63) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 0.005d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+242) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = sqrt(((n * x) ** (-2.0d0)))
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 = (1.0 / x) * (t_0 / n);
double tmp;
if ((1.0 / n) <= -1e-7) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+242) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (1.0 / x) * (t_0 / n) tmp = 0 if (1.0 / n) <= -1e-7: tmp = t_1 elif (1.0 / n) <= 2e-63: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 0.005: tmp = t_1 elif (1.0 / n) <= 1e+242: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(1.0 / x) * Float64(t_0 / n)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-7) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-63) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 0.005) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+242) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (1.0 / x) * (t_0 / n); tmp = 0.0; if ((1.0 / n) <= -1e-7) tmp = t_1; elseif ((1.0 / n) <= 2e-63) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 0.005) tmp = t_1; elseif ((1.0 / n) <= 1e+242) tmp = (1.0 + (x / n)) - t_0; else tmp = sqrt(((n * x) ^ -2.0)); 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[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-7], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-63], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.005], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+242], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-63}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.005:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+242}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.9999999999999995e-8 or 2.00000000000000013e-63 < (/.f64 1 n) < 0.0050000000000000001Initial program 82.9%
Taylor expanded in x around inf 93.5%
mul-1-neg93.5%
log-rec93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
mul-1-neg93.5%
remove-double-neg93.5%
*-commutative93.5%
Simplified93.5%
div-inv93.5%
pow-to-exp93.5%
*-un-lft-identity93.5%
times-frac94.5%
Applied egg-rr94.5%
if -9.9999999999999995e-8 < (/.f64 1 n) < 2.00000000000000013e-63Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-def80.0%
Simplified80.0%
log1p-udef80.0%
diff-log80.2%
+-commutative80.2%
Applied egg-rr80.2%
if 0.0050000000000000001 < (/.f64 1 n) < 1.00000000000000005e242Initial program 79.8%
Taylor expanded in x around 0 75.9%
if 1.00000000000000005e242 < (/.f64 1 n) Initial program 22.5%
Taylor expanded in n around inf 27.2%
log1p-def27.2%
Simplified27.2%
Taylor expanded in x around inf 63.9%
*-commutative63.9%
Simplified63.9%
add-sqr-sqrt63.9%
sqrt-unprod100.0%
inv-pow100.0%
inv-pow100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification86.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (exp (/ x n)) t_0)))
(if (<= (/ 1.0 n) -2e-8)
t_1
(if (<= (/ 1.0 n) 2e-63)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 0.005) (* (/ 1.0 x) (/ t_0 n)) t_1)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = exp((x / n)) - t_0;
double tmp;
if ((1.0 / n) <= -2e-8) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = exp((x / n)) - t_0
if ((1.0d0 / n) <= (-2d-8)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-63) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 0.005d0) then
tmp = (1.0d0 / x) * (t_0 / n)
else
tmp = t_1
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.exp((x / n)) - t_0;
double tmp;
if ((1.0 / n) <= -2e-8) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.exp((x / n)) - t_0 tmp = 0 if (1.0 / n) <= -2e-8: tmp = t_1 elif (1.0 / n) <= 2e-63: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 0.005: tmp = (1.0 / x) * (t_0 / n) else: tmp = t_1 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(exp(Float64(x / n)) - t_0) tmp = 0.0 if (Float64(1.0 / n) <= -2e-8) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-63) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 0.005) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = exp((x / n)) - t_0; tmp = 0.0; if ((1.0 / n) <= -2e-8) tmp = t_1; elseif ((1.0 / n) <= 2e-63) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 0.005) tmp = (1.0 / x) * (t_0 / n); else tmp = t_1; 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[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-8], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-63], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.005], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := e^{\frac{x}{n}} - t_0\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-63}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.005:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-8 or 0.0050000000000000001 < (/.f64 1 n) Initial program 91.6%
Taylor expanded in n around 0 91.6%
log1p-def99.0%
Simplified99.0%
Taylor expanded in x around 0 99.0%
if -2e-8 < (/.f64 1 n) < 2.00000000000000013e-63Initial program 28.0%
Taylor expanded in n around inf 80.3%
log1p-def80.3%
Simplified80.3%
log1p-udef80.3%
diff-log80.5%
+-commutative80.5%
Applied egg-rr80.5%
if 2.00000000000000013e-63 < (/.f64 1 n) < 0.0050000000000000001Initial program 9.3%
Taylor expanded in x around inf 69.1%
mul-1-neg69.1%
log-rec69.1%
mul-1-neg69.1%
distribute-neg-frac69.1%
mul-1-neg69.1%
remove-double-neg69.1%
*-commutative69.1%
Simplified69.1%
div-inv69.1%
pow-to-exp69.0%
*-un-lft-identity69.0%
times-frac74.4%
Applied egg-rr74.4%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-8)
(- (pow (+ 1.0 x) (/ 1.0 n)) t_0)
(if (<= (/ 1.0 n) 2e-63)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 0.005)
(* (/ 1.0 x) (/ t_0 n))
(- (exp (/ 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-8) {
tmp = pow((1.0 + x), (1.0 / n)) - t_0;
} else if ((1.0 / n) <= 2e-63) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = exp((x / n)) - t_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 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-8)) then
tmp = ((1.0d0 + x) ** (1.0d0 / n)) - t_0
else if ((1.0d0 / n) <= 2d-63) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 0.005d0) then
tmp = (1.0d0 / x) * (t_0 / n)
else
tmp = exp((x / n)) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-8) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - t_0;
} else if ((1.0 / n) <= 2e-63) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = Math.exp((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-8: tmp = math.pow((1.0 + x), (1.0 / n)) - t_0 elif (1.0 / n) <= 2e-63: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 0.005: tmp = (1.0 / x) * (t_0 / n) else: tmp = math.exp((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-8) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0); elseif (Float64(1.0 / n) <= 2e-63) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 0.005) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-8) tmp = ((1.0 + x) ^ (1.0 / n)) - t_0; elseif ((1.0 / n) <= 2e-63) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 0.005) tmp = (1.0 / x) * (t_0 / n); else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-8], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-63], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.005], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / 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^{-8}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-63}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.005:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-8Initial program 98.7%
if -2e-8 < (/.f64 1 n) < 2.00000000000000013e-63Initial program 28.0%
Taylor expanded in n around inf 80.3%
log1p-def80.3%
Simplified80.3%
log1p-udef80.3%
diff-log80.5%
+-commutative80.5%
Applied egg-rr80.5%
if 2.00000000000000013e-63 < (/.f64 1 n) < 0.0050000000000000001Initial program 9.3%
Taylor expanded in x around inf 69.1%
mul-1-neg69.1%
log-rec69.1%
mul-1-neg69.1%
distribute-neg-frac69.1%
mul-1-neg69.1%
remove-double-neg69.1%
*-commutative69.1%
Simplified69.1%
div-inv69.1%
pow-to-exp69.0%
*-un-lft-identity69.0%
times-frac74.4%
Applied egg-rr74.4%
if 0.0050000000000000001 < (/.f64 1 n) Initial program 69.9%
Taylor expanded in n around 0 69.9%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -2e+53)
t_1
(if (<= (/ 1.0 n) -20000000000.0)
t_0
(if (<= (/ 1.0 n) 2e-63)
t_1
(if (<= (/ 1.0 n) 0.005) (/ (/ 1.0 x) n) t_0))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -2e+53) {
tmp = t_1;
} else if ((1.0 / n) <= -20000000000.0) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-63) {
tmp = t_1;
} else if ((1.0 / n) <= 0.005) {
tmp = (1.0 / x) / n;
} else {
tmp = t_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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-2d+53)) then
tmp = t_1
else if ((1.0d0 / n) <= (-20000000000.0d0)) then
tmp = t_0
else if ((1.0d0 / n) <= 2d-63) then
tmp = t_1
else if ((1.0d0 / n) <= 0.005d0) then
tmp = (1.0d0 / x) / n
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -2e+53) {
tmp = t_1;
} else if ((1.0 / n) <= -20000000000.0) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-63) {
tmp = t_1;
} else if ((1.0 / n) <= 0.005) {
tmp = (1.0 / x) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -2e+53: tmp = t_1 elif (1.0 / n) <= -20000000000.0: tmp = t_0 elif (1.0 / n) <= 2e-63: tmp = t_1 elif (1.0 / n) <= 0.005: tmp = (1.0 / x) / n else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e+53) tmp = t_1; elseif (Float64(1.0 / n) <= -20000000000.0) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-63) tmp = t_1; elseif (Float64(1.0 / n) <= 0.005) tmp = Float64(Float64(1.0 / x) / n); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -2e+53) tmp = t_1; elseif ((1.0 / n) <= -20000000000.0) tmp = t_0; elseif ((1.0 / n) <= 2e-63) tmp = t_1; elseif ((1.0 / n) <= 0.005) tmp = (1.0 / x) / n; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+53], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -20000000000.0], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-63], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.005], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+53}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -20000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-63}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 0.005:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e53 or -2e10 < (/.f64 1 n) < 2.00000000000000013e-63Initial program 54.6%
Taylor expanded in n around inf 74.3%
log1p-def74.3%
Simplified74.3%
log1p-udef74.3%
diff-log74.4%
+-commutative74.4%
Applied egg-rr74.4%
if -2e53 < (/.f64 1 n) < -2e10 or 0.0050000000000000001 < (/.f64 1 n) Initial program 80.2%
Taylor expanded in x around 0 69.2%
if 2.00000000000000013e-63 < (/.f64 1 n) < 0.0050000000000000001Initial program 9.3%
Taylor expanded in n around inf 34.5%
log1p-def34.5%
Simplified34.5%
Taylor expanded in x around inf 67.7%
Final simplification73.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (* (/ 1.0 x) (/ t_0 n))))
(if (<= (/ 1.0 n) -1e-7)
t_1
(if (<= (/ 1.0 n) 2e-63)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 0.005) t_1 (- 1.0 t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (1.0 / x) * (t_0 / n);
double tmp;
if ((1.0 / n) <= -1e-7) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = t_1;
} else {
tmp = 1.0 - t_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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (1.0d0 / x) * (t_0 / n)
if ((1.0d0 / n) <= (-1d-7)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-63) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 0.005d0) then
tmp = t_1
else
tmp = 1.0d0 - t_0
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 = (1.0 / x) * (t_0 / n);
double tmp;
if ((1.0 / n) <= -1e-7) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (1.0 / x) * (t_0 / n) tmp = 0 if (1.0 / n) <= -1e-7: tmp = t_1 elif (1.0 / n) <= 2e-63: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 0.005: tmp = t_1 else: tmp = 1.0 - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(1.0 / x) * Float64(t_0 / n)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-7) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-63) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 0.005) tmp = t_1; else tmp = Float64(1.0 - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (1.0 / x) * (t_0 / n); tmp = 0.0; if ((1.0 / n) <= -1e-7) tmp = t_1; elseif ((1.0 / n) <= 2e-63) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 0.005) tmp = t_1; else tmp = 1.0 - t_0; 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[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-7], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-63], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.005], t$95$1, N[(1.0 - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-63}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.005:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.9999999999999995e-8 or 2.00000000000000013e-63 < (/.f64 1 n) < 0.0050000000000000001Initial program 82.9%
Taylor expanded in x around inf 93.5%
mul-1-neg93.5%
log-rec93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
mul-1-neg93.5%
remove-double-neg93.5%
*-commutative93.5%
Simplified93.5%
div-inv93.5%
pow-to-exp93.5%
*-un-lft-identity93.5%
times-frac94.5%
Applied egg-rr94.5%
if -9.9999999999999995e-8 < (/.f64 1 n) < 2.00000000000000013e-63Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-def80.0%
Simplified80.0%
log1p-udef80.0%
diff-log80.2%
+-commutative80.2%
Applied egg-rr80.2%
if 0.0050000000000000001 < (/.f64 1 n) Initial program 69.9%
Taylor expanded in x around 0 63.3%
Final simplification84.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (* (/ 1.0 x) (/ t_0 n))))
(if (<= (/ 1.0 n) -1e-7)
t_1
(if (<= (/ 1.0 n) 2e-63)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 0.005) t_1 (- (+ 1.0 (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (1.0 / x) * (t_0 / n);
double tmp;
if ((1.0 / n) <= -1e-7) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = t_1;
} else {
tmp = (1.0 + (x / n)) - t_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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (1.0d0 / x) * (t_0 / n)
if ((1.0d0 / n) <= (-1d-7)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-63) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 0.005d0) then
tmp = t_1
else
tmp = (1.0d0 + (x / n)) - t_0
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 = (1.0 / x) * (t_0 / n);
double tmp;
if ((1.0 / n) <= -1e-7) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = t_1;
} else {
tmp = (1.0 + (x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (1.0 / x) * (t_0 / n) tmp = 0 if (1.0 / n) <= -1e-7: tmp = t_1 elif (1.0 / n) <= 2e-63: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 0.005: tmp = t_1 else: tmp = (1.0 + (x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(1.0 / x) * Float64(t_0 / n)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-7) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-63) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 0.005) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (1.0 / x) * (t_0 / n); tmp = 0.0; if ((1.0 / n) <= -1e-7) tmp = t_1; elseif ((1.0 / n) <= 2e-63) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 0.005) tmp = t_1; else tmp = (1.0 + (x / n)) - t_0; 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[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-7], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-63], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.005], t$95$1, N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-63}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.005:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.9999999999999995e-8 or 2.00000000000000013e-63 < (/.f64 1 n) < 0.0050000000000000001Initial program 82.9%
Taylor expanded in x around inf 93.5%
mul-1-neg93.5%
log-rec93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
mul-1-neg93.5%
remove-double-neg93.5%
*-commutative93.5%
Simplified93.5%
div-inv93.5%
pow-to-exp93.5%
*-un-lft-identity93.5%
times-frac94.5%
Applied egg-rr94.5%
if -9.9999999999999995e-8 < (/.f64 1 n) < 2.00000000000000013e-63Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-def80.0%
Simplified80.0%
log1p-udef80.0%
diff-log80.2%
+-commutative80.2%
Applied egg-rr80.2%
if 0.0050000000000000001 < (/.f64 1 n) Initial program 69.9%
Taylor expanded in x around 0 63.9%
Final simplification84.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -1e-7)
t_1
(if (<= (/ 1.0 n) 2e-63)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 0.005) t_1 (- 1.0 t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -1e-7) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = t_1;
} else {
tmp = 1.0 - t_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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-1d-7)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-63) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 0.005d0) then
tmp = t_1
else
tmp = 1.0d0 - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -1e-7) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-63) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 0.005) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -1e-7: tmp = t_1 elif (1.0 / n) <= 2e-63: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 0.005: tmp = t_1 else: tmp = 1.0 - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-7) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-63) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 0.005) tmp = t_1; else tmp = Float64(1.0 - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -1e-7) tmp = t_1; elseif ((1.0 / n) <= 2e-63) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 0.005) tmp = t_1; else tmp = 1.0 - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-7], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-63], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.005], t$95$1, N[(1.0 - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-63}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.005:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.9999999999999995e-8 or 2.00000000000000013e-63 < (/.f64 1 n) < 0.0050000000000000001Initial program 82.9%
Taylor expanded in x around inf 93.5%
mul-1-neg93.5%
log-rec93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
mul-1-neg93.5%
remove-double-neg93.5%
*-commutative93.5%
Simplified93.5%
Taylor expanded in x around 0 93.5%
*-rgt-identity93.5%
associate-*r/93.5%
exp-to-pow93.5%
*-commutative93.5%
Simplified93.5%
if -9.9999999999999995e-8 < (/.f64 1 n) < 2.00000000000000013e-63Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-def80.0%
Simplified80.0%
log1p-udef80.0%
diff-log80.2%
+-commutative80.2%
Applied egg-rr80.2%
if 0.0050000000000000001 < (/.f64 1 n) Initial program 69.9%
Taylor expanded in x around 0 63.3%
Final simplification83.8%
(FPCore (x n)
:precision binary64
(if (<= x 1.05e-245)
(/ (- (log x)) n)
(if (<= x 2.1e-141)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (or (<= x 5.5e+58) (not (<= x 6.5e+184)))
(/ 0.0 n)
(/ (/ 1.0 x) n))))))
double code(double x, double n) {
double tmp;
if (x <= 1.05e-245) {
tmp = -log(x) / n;
} else if (x <= 2.1e-141) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if ((x <= 5.5e+58) || !(x <= 6.5e+184)) {
tmp = 0.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 (x <= 1.05d-245) then
tmp = -log(x) / n
else if (x <= 2.1d-141) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if ((x <= 5.5d+58) .or. (.not. (x <= 6.5d+184))) then
tmp = 0.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 (x <= 1.05e-245) {
tmp = -Math.log(x) / n;
} else if (x <= 2.1e-141) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if ((x <= 5.5e+58) || !(x <= 6.5e+184)) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.05e-245: tmp = -math.log(x) / n elif x <= 2.1e-141: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.0: tmp = (x - math.log(x)) / n elif (x <= 5.5e+58) or not (x <= 6.5e+184): tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.05e-245) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.1e-141) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif ((x <= 5.5e+58) || !(x <= 6.5e+184)) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.05e-245) tmp = -log(x) / n; elseif (x <= 2.1e-141) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.0) tmp = (x - log(x)) / n; elseif ((x <= 5.5e+58) || ~((x <= 6.5e+184))) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.05e-245], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.1e-141], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[x, 5.5e+58], N[Not[LessEqual[x, 6.5e+184]], $MachinePrecision]], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{-245}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-141}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+58} \lor \neg \left(x \leq 6.5 \cdot 10^{+184}\right):\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1.05000000000000005e-245Initial program 42.8%
Taylor expanded in n around inf 65.4%
log1p-def65.4%
Simplified65.4%
Taylor expanded in x around 0 65.4%
neg-mul-165.4%
Simplified65.4%
if 1.05000000000000005e-245 < x < 2.0999999999999999e-141Initial program 64.5%
Taylor expanded in x around 0 64.5%
if 2.0999999999999999e-141 < x < 1Initial program 38.8%
Taylor expanded in n around inf 59.8%
log1p-def59.8%
Simplified59.8%
Taylor expanded in x around 0 59.8%
neg-mul-159.8%
unsub-neg59.8%
Simplified59.8%
if 1 < x < 5.4999999999999999e58 or 6.50000000000000002e184 < x Initial program 79.2%
Taylor expanded in n around inf 79.3%
log1p-def79.3%
Simplified79.3%
log1p-udef79.3%
diff-log79.6%
+-commutative79.6%
Applied egg-rr79.6%
Taylor expanded in x around inf 79.2%
if 5.4999999999999999e58 < x < 6.50000000000000002e184Initial program 50.4%
Taylor expanded in n around inf 50.4%
log1p-def50.4%
Simplified50.4%
Taylor expanded in x around inf 70.7%
Final simplification68.4%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- x (log x)) n) (if (or (<= x 3.1e+58) (not (<= x 5.3e+184))) (/ 0.0 n) (/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if ((x <= 3.1e+58) || !(x <= 5.3e+184)) {
tmp = 0.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 (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if ((x <= 3.1d+58) .or. (.not. (x <= 5.3d+184))) then
tmp = 0.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 (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if ((x <= 3.1e+58) || !(x <= 5.3e+184)) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x - math.log(x)) / n elif (x <= 3.1e+58) or not (x <= 5.3e+184): tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif ((x <= 3.1e+58) || !(x <= 5.3e+184)) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = (x - log(x)) / n; elseif ((x <= 3.1e+58) || ~((x <= 5.3e+184))) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[x, 3.1e+58], N[Not[LessEqual[x, 5.3e+184]], $MachinePrecision]], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+58} \lor \neg \left(x \leq 5.3 \cdot 10^{+184}\right):\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1Initial program 46.2%
Taylor expanded in n around inf 55.8%
log1p-def55.8%
Simplified55.8%
Taylor expanded in x around 0 55.8%
neg-mul-155.8%
unsub-neg55.8%
Simplified55.8%
if 1 < x < 3.0999999999999999e58 or 5.30000000000000022e184 < x Initial program 79.2%
Taylor expanded in n around inf 79.3%
log1p-def79.3%
Simplified79.3%
log1p-udef79.3%
diff-log79.6%
+-commutative79.6%
Applied egg-rr79.6%
Taylor expanded in x around inf 79.2%
if 3.0999999999999999e58 < x < 5.30000000000000022e184Initial program 50.4%
Taylor expanded in n around inf 50.4%
log1p-def50.4%
Simplified50.4%
Taylor expanded in x around inf 70.7%
Final simplification64.7%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- (log x)) n) (if (or (<= x 2.4e+58) (not (<= x 2.45e+185))) (/ 0.0 n) (/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = -log(x) / n;
} else if ((x <= 2.4e+58) || !(x <= 2.45e+185)) {
tmp = 0.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 (x <= 1.0d0) then
tmp = -log(x) / n
else if ((x <= 2.4d+58) .or. (.not. (x <= 2.45d+185))) then
tmp = 0.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 (x <= 1.0) {
tmp = -Math.log(x) / n;
} else if ((x <= 2.4e+58) || !(x <= 2.45e+185)) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = -math.log(x) / n elif (x <= 2.4e+58) or not (x <= 2.45e+185): tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(-log(x)) / n); elseif ((x <= 2.4e+58) || !(x <= 2.45e+185)) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = -log(x) / n; elseif ((x <= 2.4e+58) || ~((x <= 2.45e+185))) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[Or[LessEqual[x, 2.4e+58], N[Not[LessEqual[x, 2.45e+185]], $MachinePrecision]], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+58} \lor \neg \left(x \leq 2.45 \cdot 10^{+185}\right):\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1Initial program 46.2%
Taylor expanded in n around inf 55.8%
log1p-def55.8%
Simplified55.8%
Taylor expanded in x around 0 55.5%
neg-mul-155.5%
Simplified55.5%
if 1 < x < 2.4e58 or 2.44999999999999992e185 < x Initial program 79.2%
Taylor expanded in n around inf 79.3%
log1p-def79.3%
Simplified79.3%
log1p-udef79.3%
diff-log79.6%
+-commutative79.6%
Applied egg-rr79.6%
Taylor expanded in x around inf 79.2%
if 2.4e58 < x < 2.44999999999999992e185Initial program 50.4%
Taylor expanded in n around inf 50.4%
log1p-def50.4%
Simplified50.4%
Taylor expanded in x around inf 70.7%
Final simplification64.5%
(FPCore (x n) :precision binary64 (if (<= n -1.5) (/ 1.0 (* n (+ x 0.5))) (if (<= n -2.05e-306) (/ 0.0 n) (/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (n <= -1.5) {
tmp = 1.0 / (n * (x + 0.5));
} else if (n <= -2.05e-306) {
tmp = 0.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 <= (-1.5d0)) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else if (n <= (-2.05d-306)) then
tmp = 0.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 <= -1.5) {
tmp = 1.0 / (n * (x + 0.5));
} else if (n <= -2.05e-306) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -1.5: tmp = 1.0 / (n * (x + 0.5)) elif n <= -2.05e-306: tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (n <= -1.5) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); elseif (n <= -2.05e-306) tmp = Float64(0.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 <= -1.5) tmp = 1.0 / (n * (x + 0.5)); elseif (n <= -2.05e-306) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -1.5], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -2.05e-306], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.5:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{elif}\;n \leq -2.05 \cdot 10^{-306}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if n < -1.5Initial program 27.1%
Taylor expanded in n around inf 75.4%
log1p-def75.4%
Simplified75.4%
clear-num75.3%
inv-pow75.3%
Applied egg-rr75.3%
unpow-175.3%
Simplified75.3%
Taylor expanded in x around inf 51.9%
*-commutative51.9%
distribute-lft-out51.9%
Simplified51.9%
if -1.5 < n < -2.04999999999999992e-306Initial program 100.0%
Taylor expanded in n around inf 56.9%
log1p-def56.9%
Simplified56.9%
log1p-udef56.9%
diff-log56.9%
+-commutative56.9%
Applied egg-rr56.9%
Taylor expanded in x around inf 56.8%
if -2.04999999999999992e-306 < n Initial program 41.1%
Taylor expanded in n around inf 52.4%
log1p-def52.4%
Simplified52.4%
Taylor expanded in x around inf 44.5%
Final simplification50.7%
(FPCore (x n) :precision binary64 (if (<= n -2.0) (/ 1.0 (* n (+ x 0.5))) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (n <= -2.0) {
tmp = 1.0 / (n * (x + 0.5));
} 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 <= (-2.0d0)) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -2.0) {
tmp = 1.0 / (n * (x + 0.5));
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -2.0: tmp = 1.0 / (n * (x + 0.5)) else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (n <= -2.0) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -2.0) tmp = 1.0 / (n * (x + 0.5)); else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -2.0], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if n < -2Initial program 27.1%
Taylor expanded in n around inf 75.4%
log1p-def75.4%
Simplified75.4%
clear-num75.3%
inv-pow75.3%
Applied egg-rr75.3%
unpow-175.3%
Simplified75.3%
Taylor expanded in x around inf 51.9%
*-commutative51.9%
distribute-lft-out51.9%
Simplified51.9%
if -2 < n Initial program 68.4%
Taylor expanded in n around inf 54.5%
log1p-def54.5%
Simplified54.5%
Taylor expanded in x around inf 32.9%
Final simplification38.8%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 55.7%
Taylor expanded in n around inf 61.0%
log1p-def61.0%
Simplified61.0%
Taylor expanded in x around inf 36.6%
*-commutative36.6%
Simplified36.6%
Final simplification36.6%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 55.7%
Taylor expanded in n around inf 61.0%
log1p-def61.0%
Simplified61.0%
Taylor expanded in x around inf 37.1%
Final simplification37.1%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 55.7%
Taylor expanded in n around inf 61.0%
log1p-def61.0%
Simplified61.0%
Taylor expanded in x around 0 32.1%
neg-mul-132.1%
unsub-neg32.1%
Simplified32.1%
Taylor expanded in x around inf 4.3%
Final simplification4.3%
herbie shell --seed 2024021
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))