
(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 24 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 (/ 0.5 (pow n 2.0)))
(t_1 (pow x (/ 1.0 n)))
(t_2 (/ t_1 n))
(t_3
(/
(-
(* -0.5 (/ (- (pow (log x) 2.0) (pow (log1p x) 2.0)) n))
(log (/ x (+ 1.0 x))))
n)))
(if (<= (/ 1.0 n) -1e-160)
(/ t_2 x)
(if (<= (/ 1.0 n) 2e-54)
t_3
(if (<= (/ 1.0 n) 1e-11)
(/
(-
t_2
(*
t_1
(-
(/
(-
(- t_0 (/ 0.16666666666666666 (pow n 3.0)))
(/ 0.3333333333333333 n))
(pow x 2.0))
(/ (+ t_0 (/ -0.5 n)) x))))
x)
(if (<= (/ 1.0 n) 2e-10) t_3 (- (exp (/ (log1p x) n)) t_1)))))))
double code(double x, double n) {
double t_0 = 0.5 / pow(n, 2.0);
double t_1 = pow(x, (1.0 / n));
double t_2 = t_1 / n;
double t_3 = ((-0.5 * ((pow(log(x), 2.0) - pow(log1p(x), 2.0)) / n)) - log((x / (1.0 + x)))) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = t_2 / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_3;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_2 - (t_1 * ((((t_0 - (0.16666666666666666 / pow(n, 3.0))) - (0.3333333333333333 / n)) / pow(x, 2.0)) - ((t_0 + (-0.5 / n)) / x)))) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_3;
} else {
tmp = exp((log1p(x) / n)) - t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = 0.5 / Math.pow(n, 2.0);
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = t_1 / n;
double t_3 = ((-0.5 * ((Math.pow(Math.log(x), 2.0) - Math.pow(Math.log1p(x), 2.0)) / n)) - Math.log((x / (1.0 + x)))) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = t_2 / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_3;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_2 - (t_1 * ((((t_0 - (0.16666666666666666 / Math.pow(n, 3.0))) - (0.3333333333333333 / n)) / Math.pow(x, 2.0)) - ((t_0 + (-0.5 / n)) / x)))) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_3;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_1;
}
return tmp;
}
def code(x, n): t_0 = 0.5 / math.pow(n, 2.0) t_1 = math.pow(x, (1.0 / n)) t_2 = t_1 / n t_3 = ((-0.5 * ((math.pow(math.log(x), 2.0) - math.pow(math.log1p(x), 2.0)) / n)) - math.log((x / (1.0 + x)))) / n tmp = 0 if (1.0 / n) <= -1e-160: tmp = t_2 / x elif (1.0 / n) <= 2e-54: tmp = t_3 elif (1.0 / n) <= 1e-11: tmp = (t_2 - (t_1 * ((((t_0 - (0.16666666666666666 / math.pow(n, 3.0))) - (0.3333333333333333 / n)) / math.pow(x, 2.0)) - ((t_0 + (-0.5 / n)) / x)))) / x elif (1.0 / n) <= 2e-10: tmp = t_3 else: tmp = math.exp((math.log1p(x) / n)) - t_1 return tmp
function code(x, n) t_0 = Float64(0.5 / (n ^ 2.0)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(t_1 / n) t_3 = Float64(Float64(Float64(-0.5 * Float64(Float64((log(x) ^ 2.0) - (log1p(x) ^ 2.0)) / n)) - log(Float64(x / Float64(1.0 + x)))) / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(t_2 / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = t_3; elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(t_2 - Float64(t_1 * Float64(Float64(Float64(Float64(t_0 - Float64(0.16666666666666666 / (n ^ 3.0))) - Float64(0.3333333333333333 / n)) / (x ^ 2.0)) - Float64(Float64(t_0 + Float64(-0.5 / n)) / x)))) / x); elseif (Float64(1.0 / n) <= 2e-10) tmp = t_3; else tmp = Float64(exp(Float64(log1p(x) / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(0.5 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / n), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(-0.5 * N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(t$95$2 / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], t$95$3, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(t$95$2 - N[(t$95$1 * N[(N[(N[(N[(t$95$0 - N[(0.16666666666666666 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], t$95$3, N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{{n}^{2}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{t\_1}{n}\\
t_3 := \frac{-0.5 \cdot \frac{{\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n} - \log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{t\_2}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_2 - t\_1 \cdot \left(\frac{\left(t\_0 - \frac{0.16666666666666666}{{n}^{3}}\right) - \frac{0.3333333333333333}{n}}{{x}^{2}} - \frac{t\_0 + \frac{-0.5}{n}}{x}\right)}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.7%
Taylor expanded in n around -inf 90.4%
mul-1-neg90.4%
distribute-neg-frac290.4%
Simplified90.4%
log1p-undefine90.4%
diff-log90.5%
Applied egg-rr90.5%
+-commutative90.5%
Simplified90.5%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in x around inf 85.6%
Simplified85.6%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) Initial program 43.1%
Taylor expanded in n around 0 43.1%
log1p-define95.5%
*-rgt-identity95.5%
associate-/l*95.5%
exp-to-pow95.5%
Simplified95.5%
Final simplification90.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ 0.5 (pow n 2.0))) (t_1 (pow x (/ 1.0 n))) (t_2 (/ t_1 n)))
(if (<= (/ 1.0 n) -1e-160)
(/ t_2 x)
(if (<= (/ 1.0 n) 2e-54)
(/
(-
(* -0.5 (/ (- (pow (log x) 2.0) (pow (log1p x) 2.0)) n))
(log (/ x (+ 1.0 x))))
n)
(if (<= (/ 1.0 n) 1e-5)
(/
(-
(fma t_1 (/ (+ t_0 (/ -0.5 n)) x) t_2)
(*
t_1
(-
(/
(-
(- t_0 (/ 0.16666666666666666 (pow n 3.0)))
(/ 0.3333333333333333 n))
(pow x 2.0))
(/
(+
(/ 0.041666666666666664 (pow n 4.0))
(+
(+ (/ 0.4583333333333333 (pow n 2.0)) (/ -0.25 n))
(/ -0.25 (pow n 3.0))))
(pow x 3.0)))))
x)
(- (exp (/ (log1p x) n)) t_1))))))
double code(double x, double n) {
double t_0 = 0.5 / pow(n, 2.0);
double t_1 = pow(x, (1.0 / n));
double t_2 = t_1 / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = t_2 / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = ((-0.5 * ((pow(log(x), 2.0) - pow(log1p(x), 2.0)) / n)) - log((x / (1.0 + x)))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = (fma(t_1, ((t_0 + (-0.5 / n)) / x), t_2) - (t_1 * ((((t_0 - (0.16666666666666666 / pow(n, 3.0))) - (0.3333333333333333 / n)) / pow(x, 2.0)) - (((0.041666666666666664 / pow(n, 4.0)) + (((0.4583333333333333 / pow(n, 2.0)) + (-0.25 / n)) + (-0.25 / pow(n, 3.0)))) / pow(x, 3.0))))) / x;
} else {
tmp = exp((log1p(x) / n)) - t_1;
}
return tmp;
}
function code(x, n) t_0 = Float64(0.5 / (n ^ 2.0)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(t_1 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(t_2 / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = Float64(Float64(Float64(-0.5 * Float64(Float64((log(x) ^ 2.0) - (log1p(x) ^ 2.0)) / n)) - log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(Float64(fma(t_1, Float64(Float64(t_0 + Float64(-0.5 / n)) / x), t_2) - Float64(t_1 * Float64(Float64(Float64(Float64(t_0 - Float64(0.16666666666666666 / (n ^ 3.0))) - Float64(0.3333333333333333 / n)) / (x ^ 2.0)) - Float64(Float64(Float64(0.041666666666666664 / (n ^ 4.0)) + Float64(Float64(Float64(0.4583333333333333 / (n ^ 2.0)) + Float64(-0.25 / n)) + Float64(-0.25 / (n ^ 3.0)))) / (x ^ 3.0))))) / x); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(0.5 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(t$95$2 / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], N[(N[(N[(-0.5 * N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(N[(N[(t$95$1 * N[(N[(t$95$0 + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + t$95$2), $MachinePrecision] - N[(t$95$1 * N[(N[(N[(N[(t$95$0 - N[(0.16666666666666666 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.041666666666666664 / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.4583333333333333 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-0.25 / n), $MachinePrecision]), $MachinePrecision] + N[(-0.25 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{{n}^{2}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{t\_1}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{t\_2}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{{\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n} - \log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_1, \frac{t\_0 + \frac{-0.5}{n}}{x}, t\_2\right) - t\_1 \cdot \left(\frac{\left(t\_0 - \frac{0.16666666666666666}{{n}^{3}}\right) - \frac{0.3333333333333333}{n}}{{x}^{2}} - \frac{\frac{0.041666666666666664}{{n}^{4}} + \left(\left(\frac{0.4583333333333333}{{n}^{2}} + \frac{-0.25}{n}\right) + \frac{-0.25}{{n}^{3}}\right)}{{x}^{3}}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54Initial program 33.7%
Taylor expanded in n around -inf 90.5%
mul-1-neg90.5%
distribute-neg-frac290.5%
Simplified90.5%
log1p-undefine90.5%
diff-log90.5%
Applied egg-rr90.5%
+-commutative90.5%
Simplified90.5%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000008e-5Initial program 15.6%
Taylor expanded in x around inf 77.3%
Simplified77.5%
if 1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n) Initial program 43.0%
Taylor expanded in n around 0 43.0%
log1p-define97.7%
*-rgt-identity97.7%
associate-/l*97.7%
exp-to-pow97.7%
Simplified97.7%
Final simplification90.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ 0.5 (pow n 2.0))))
(if (<= n -5.6e+159)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= n -13000.0)
(/
(-
(/ t_0 n)
(*
t_0
(-
(/
(-
(- t_1 (/ 0.16666666666666666 (pow n 3.0)))
(/ 0.3333333333333333 n))
(pow x 2.0))
(/ (+ t_1 (/ -0.5 n)) x))))
x)
(if (<= n 8500000.0)
(- (exp (/ (log1p x) n)) t_0)
(/
(+
(log (/ x (+ 1.0 x)))
(*
-0.5
(log (exp (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)))))
(- n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 0.5 / pow(n, 2.0);
double tmp;
if (n <= -5.6e+159) {
tmp = log(((1.0 + x) / x)) / n;
} else if (n <= -13000.0) {
tmp = ((t_0 / n) - (t_0 * ((((t_1 - (0.16666666666666666 / pow(n, 3.0))) - (0.3333333333333333 / n)) / pow(x, 2.0)) - ((t_1 + (-0.5 / n)) / x)))) / x;
} else if (n <= 8500000.0) {
tmp = exp((log1p(x) / n)) - t_0;
} else {
tmp = (log((x / (1.0 + x))) + (-0.5 * log(exp(((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n))))) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = 0.5 / Math.pow(n, 2.0);
double tmp;
if (n <= -5.6e+159) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if (n <= -13000.0) {
tmp = ((t_0 / n) - (t_0 * ((((t_1 - (0.16666666666666666 / Math.pow(n, 3.0))) - (0.3333333333333333 / n)) / Math.pow(x, 2.0)) - ((t_1 + (-0.5 / n)) / x)))) / x;
} else if (n <= 8500000.0) {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
} else {
tmp = (Math.log((x / (1.0 + x))) + (-0.5 * Math.log(Math.exp(((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n))))) / -n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 0.5 / math.pow(n, 2.0) tmp = 0 if n <= -5.6e+159: tmp = math.log(((1.0 + x) / x)) / n elif n <= -13000.0: tmp = ((t_0 / n) - (t_0 * ((((t_1 - (0.16666666666666666 / math.pow(n, 3.0))) - (0.3333333333333333 / n)) / math.pow(x, 2.0)) - ((t_1 + (-0.5 / n)) / x)))) / x elif n <= 8500000.0: tmp = math.exp((math.log1p(x) / n)) - t_0 else: tmp = (math.log((x / (1.0 + x))) + (-0.5 * math.log(math.exp(((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n))))) / -n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(0.5 / (n ^ 2.0)) tmp = 0.0 if (n <= -5.6e+159) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (n <= -13000.0) tmp = Float64(Float64(Float64(t_0 / n) - Float64(t_0 * Float64(Float64(Float64(Float64(t_1 - Float64(0.16666666666666666 / (n ^ 3.0))) - Float64(0.3333333333333333 / n)) / (x ^ 2.0)) - Float64(Float64(t_1 + Float64(-0.5 / n)) / x)))) / x); elseif (n <= 8500000.0) tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); else tmp = Float64(Float64(log(Float64(x / Float64(1.0 + x))) + Float64(-0.5 * log(exp(Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n))))) / Float64(-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[(0.5 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -5.6e+159], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, -13000.0], N[(N[(N[(t$95$0 / n), $MachinePrecision] - N[(t$95$0 * N[(N[(N[(N[(t$95$1 - N[(0.16666666666666666 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision] / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$1 + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[n, 8500000.0], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[Log[N[Exp[N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{0.5}{{n}^{2}}\\
\mathbf{if}\;n \leq -5.6 \cdot 10^{+159}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;n \leq -13000:\\
\;\;\;\;\frac{\frac{t\_0}{n} - t\_0 \cdot \left(\frac{\left(t\_1 - \frac{0.16666666666666666}{{n}^{3}}\right) - \frac{0.3333333333333333}{n}}{{x}^{2}} - \frac{t\_1 + \frac{-0.5}{n}}{x}\right)}{x}\\
\mathbf{elif}\;n \leq 8500000:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right) + -0.5 \cdot \log \left(e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}\right)}{-n}\\
\end{array}
\end{array}
if n < -5.6000000000000002e159Initial program 28.0%
Taylor expanded in n around inf 93.9%
log1p-define93.9%
Simplified93.9%
log1p-undefine93.9%
+-commutative93.9%
diff-log93.9%
Applied egg-rr93.9%
if -5.6000000000000002e159 < n < -13000Initial program 16.0%
Taylor expanded in x around inf 65.7%
Simplified65.7%
if -13000 < n < 8.5e6Initial program 78.2%
Taylor expanded in n around 0 78.2%
log1p-define98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.3%
Simplified98.3%
if 8.5e6 < n Initial program 33.4%
Taylor expanded in n around -inf 82.2%
mul-1-neg82.2%
distribute-neg-frac282.2%
Simplified82.2%
log1p-undefine82.2%
diff-log82.4%
Applied egg-rr82.4%
+-commutative82.4%
Simplified82.4%
add-log-exp82.5%
Applied egg-rr82.5%
Final simplification89.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n)))
(t_1
(/
(-
(* -0.5 (/ (- (pow (log x) 2.0) (pow (log1p x) 2.0)) n))
(log (/ x (+ 1.0 x))))
n)))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-54)
t_1
(if (<= (/ 1.0 n) 1e-11)
(/
(- (* -0.5 (/ (/ (* (log x) -2.0) x) n)) (/ (+ (/ 0.5 x) -1.0) x))
n)
(if (<= (/ 1.0 n) 2e-10) t_1 (- (exp (/ (log1p x) n)) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = ((-0.5 * ((pow(log(x), 2.0) - pow(log1p(x), 2.0)) / n)) - log((x / (1.0 + x)))) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_1;
} 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 t_1 = ((-0.5 * ((Math.pow(Math.log(x), 2.0) - Math.pow(Math.log1p(x), 2.0)) / n)) - Math.log((x / (1.0 + x)))) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((Math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_1;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = ((-0.5 * ((math.pow(math.log(x), 2.0) - math.pow(math.log1p(x), 2.0)) / n)) - math.log((x / (1.0 + x)))) / n tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-54: tmp = t_1 elif (1.0 / n) <= 1e-11: tmp = ((-0.5 * (((math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = t_1 else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(Float64(-0.5 * Float64(Float64((log(x) ^ 2.0) - (log1p(x) ^ 2.0)) / n)) - log(Float64(x / Float64(1.0 + x)))) / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(N[(-0.5 * N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], t$95$1, 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)}\\
t_1 := \frac{-0.5 \cdot \frac{{\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n} - \log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n} - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.7%
Taylor expanded in n around -inf 90.4%
mul-1-neg90.4%
distribute-neg-frac290.4%
Simplified90.4%
log1p-undefine90.4%
diff-log90.5%
Applied egg-rr90.5%
+-commutative90.5%
Simplified90.5%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) Initial program 43.1%
Taylor expanded in n around 0 43.1%
log1p-define95.5%
*-rgt-identity95.5%
associate-/l*95.5%
exp-to-pow95.5%
Simplified95.5%
Final simplification90.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (log (/ 1.0 x))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_1 n) x)
(if (<= (/ 1.0 n) 2e-54)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-11)
(/
(- (* -0.5 (/ (/ (* (log x) -2.0) x) n)) (/ (+ (/ 0.5 x) -1.0) x))
n)
(if (<= (/ 1.0 n) 2e-10)
(/
(-
(* -0.5 (/ (/ (- (- (/ -1.0 x) (/ t_0 x)) (* -2.0 t_0)) x) n))
(log (/ x (+ 1.0 x))))
n)
(- (exp (/ (log1p x) n)) t_1)))))))
double code(double x, double n) {
double t_0 = log((1.0 / x));
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = ((-0.5 * (((((-1.0 / x) - (t_0 / x)) - (-2.0 * t_0)) / x) / n)) - log((x / (1.0 + x)))) / n;
} else {
tmp = exp((log1p(x) / n)) - t_1;
}
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 ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((Math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = ((-0.5 * (((((-1.0 / x) - (t_0 / x)) - (-2.0 * t_0)) / x) / n)) - Math.log((x / (1.0 + x)))) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_1;
}
return tmp;
}
def code(x, n): t_0 = math.log((1.0 / x)) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_1 / n) / x elif (1.0 / n) <= 2e-54: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-11: tmp = ((-0.5 * (((math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = ((-0.5 * (((((-1.0 / x) - (t_0 / x)) - (-2.0 * t_0)) / x) / n)) - math.log((x / (1.0 + x)))) / n else: tmp = math.exp((math.log1p(x) / n)) - t_1 return tmp
function code(x, n) t_0 = log(Float64(1.0 / x)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_1 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(Float64(Float64(-0.5 * Float64(Float64(Float64(Float64(Float64(-1.0 / x) - Float64(t_0 / x)) - Float64(-2.0 * t_0)) / x) / n)) - log(Float64(x / Float64(1.0 + x)))) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_1); 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[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[(N[(-0.5 * N[(N[(N[(N[(N[(-1.0 / x), $MachinePrecision] - N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision] - N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{1}{x}\right)\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n} - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{\frac{\left(\frac{-1}{x} - \frac{t\_0}{x}\right) - -2 \cdot t\_0}{x}}{n} - \log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54Initial program 33.7%
Taylor expanded in n around inf 90.5%
log1p-define90.5%
Simplified90.5%
log1p-undefine90.5%
+-commutative90.5%
diff-log90.5%
Applied egg-rr90.5%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.8%
Taylor expanded in n around -inf 82.2%
mul-1-neg82.2%
distribute-neg-frac282.2%
Simplified82.9%
log1p-undefine82.9%
diff-log88.7%
Applied egg-rr88.7%
+-commutative88.7%
Simplified88.7%
Taylor expanded in x around inf 88.6%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) Initial program 43.1%
Taylor expanded in n around 0 43.1%
log1p-define95.5%
*-rgt-identity95.5%
associate-/l*95.5%
exp-to-pow95.5%
Simplified95.5%
Final simplification90.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* -0.5 (/ (/ (* (log x) -2.0) x) n))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_1 n) x)
(if (<= (/ 1.0 n) 2e-54)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-11)
(/ (- t_0 (/ (+ (/ 0.5 x) -1.0) x)) n)
(if (<= (/ 1.0 n) 2e-10)
(/ (+ t_0 (- (log1p x) (log x))) n)
(- (exp (/ (log1p x) n)) t_1)))))))
double code(double x, double n) {
double t_0 = -0.5 * (((log(x) * -2.0) / x) / n);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = (t_0 + (log1p(x) - log(x))) / n;
} else {
tmp = exp((log1p(x) / n)) - t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = -0.5 * (((Math.log(x) * -2.0) / x) / n);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = (t_0 + (Math.log1p(x) - Math.log(x))) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_1;
}
return tmp;
}
def code(x, n): t_0 = -0.5 * (((math.log(x) * -2.0) / x) / n) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_1 / n) / x elif (1.0 / n) <= 2e-54: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-11: tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = (t_0 + (math.log1p(x) - math.log(x))) / n else: tmp = math.exp((math.log1p(x) / n)) - t_1 return tmp
function code(x, n) t_0 = Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_1 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(t_0 - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(Float64(t_0 + Float64(log1p(x) - log(x))) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(t$95$0 - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[(t$95$0 + N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_0 - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0 + \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54Initial program 33.7%
Taylor expanded in n around inf 90.5%
log1p-define90.5%
Simplified90.5%
log1p-undefine90.5%
+-commutative90.5%
diff-log90.5%
Applied egg-rr90.5%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.8%
Taylor expanded in n around -inf 82.2%
mul-1-neg82.2%
distribute-neg-frac282.2%
Simplified82.9%
Taylor expanded in x around inf 82.0%
associate-*r/47.3%
*-commutative47.3%
log-rec47.3%
Simplified82.0%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) Initial program 43.1%
Taylor expanded in n around 0 43.1%
log1p-define95.5%
*-rgt-identity95.5%
associate-/l*95.5%
exp-to-pow95.5%
Simplified95.5%
Final simplification90.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* -0.5 (/ (/ (* (log x) -2.0) x) n))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_1 n) x)
(if (<= (/ 1.0 n) 2e-54)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-11)
(/ (- t_0 (/ (+ (/ 0.5 x) -1.0) x)) n)
(if (<= (/ 1.0 n) 2e-10)
(/ (- t_0 (log (/ x (+ 1.0 x)))) n)
(- (exp (/ (log1p x) n)) t_1)))))))
double code(double x, double n) {
double t_0 = -0.5 * (((log(x) * -2.0) / x) / n);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = (t_0 - log((x / (1.0 + x)))) / n;
} else {
tmp = exp((log1p(x) / n)) - t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = -0.5 * (((Math.log(x) * -2.0) / x) / n);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = (t_0 - Math.log((x / (1.0 + x)))) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_1;
}
return tmp;
}
def code(x, n): t_0 = -0.5 * (((math.log(x) * -2.0) / x) / n) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_1 / n) / x elif (1.0 / n) <= 2e-54: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-11: tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = (t_0 - math.log((x / (1.0 + x)))) / n else: tmp = math.exp((math.log1p(x) / n)) - t_1 return tmp
function code(x, n) t_0 = Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_1 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(t_0 - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(Float64(t_0 - log(Float64(x / Float64(1.0 + x)))) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(t$95$0 - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[(t$95$0 - N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_0 - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0 - \log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54Initial program 33.7%
Taylor expanded in n around inf 90.5%
log1p-define90.5%
Simplified90.5%
log1p-undefine90.5%
+-commutative90.5%
diff-log90.5%
Applied egg-rr90.5%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.8%
Taylor expanded in n around -inf 82.2%
mul-1-neg82.2%
distribute-neg-frac282.2%
Simplified82.9%
log1p-undefine82.9%
diff-log88.7%
Applied egg-rr88.7%
+-commutative88.7%
Simplified88.7%
Taylor expanded in x around inf 80.9%
associate-*r/47.3%
*-commutative47.3%
log-rec47.3%
Simplified80.9%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) Initial program 43.1%
Taylor expanded in n around 0 43.1%
log1p-define95.5%
*-rgt-identity95.5%
associate-/l*95.5%
exp-to-pow95.5%
Simplified95.5%
Final simplification90.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* -0.5 (/ (/ (* (log x) -2.0) x) n))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_1 n) x)
(if (<= (/ 1.0 n) 2e-54)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-11)
(/ (- t_0 (/ (+ (/ 0.5 x) -1.0) x)) n)
(if (<= (/ 1.0 n) 2e-10)
(/ (- t_0 (log (/ x (+ 1.0 x)))) n)
(-
(-
1.0
(*
x
(-
(/ -1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n)))))))
t_1)))))))
double code(double x, double n) {
double t_0 = -0.5 * (((log(x) * -2.0) / x) / n);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = (t_0 - log((x / (1.0 + 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_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 = (-0.5d0) * (((log(x) * (-2.0d0)) / x) / n)
t_1 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-1d-160)) then
tmp = (t_1 / n) / x
else if ((1.0d0 / n) <= 2d-54) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d-11) then
tmp = (t_0 - (((0.5d0 / x) + (-1.0d0)) / x)) / n
else if ((1.0d0 / n) <= 2d-10) then
tmp = (t_0 - log((x / (1.0d0 + x)))) / n
else
tmp = (1.0d0 - (x * (((-1.0d0) / n) - (x * ((0.5d0 * (1.0d0 / (n ** 2.0d0))) + (0.5d0 * ((-1.0d0) / n))))))) - t_1
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -0.5 * (((Math.log(x) * -2.0) / x) / n);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = (t_0 - Math.log((x / (1.0 + 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_1;
}
return tmp;
}
def code(x, n): t_0 = -0.5 * (((math.log(x) * -2.0) / x) / n) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_1 / n) / x elif (1.0 / n) <= 2e-54: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-11: tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = (t_0 - math.log((x / (1.0 + 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_1 return tmp
function code(x, n) t_0 = Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_1 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(t_0 - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(Float64(t_0 - log(Float64(x / Float64(1.0 + 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_1); end return tmp end
function tmp_2 = code(x, n) t_0 = -0.5 * (((log(x) * -2.0) / x) / n); t_1 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1e-160) tmp = (t_1 / n) / x; elseif ((1.0 / n) <= 2e-54) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e-11) tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n; elseif ((1.0 / n) <= 2e-10) tmp = (t_0 - log((x / (1.0 + x)))) / n; else tmp = (1.0 - (x * ((-1.0 / n) - (x * ((0.5 * (1.0 / (n ^ 2.0))) + (0.5 * (-1.0 / n))))))) - t_1; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(t$95$0 - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[(t$95$0 - N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $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$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_0 - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0 - \log \left(\frac{x}{1 + x}\right)}{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\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54Initial program 33.7%
Taylor expanded in n around inf 90.5%
log1p-define90.5%
Simplified90.5%
log1p-undefine90.5%
+-commutative90.5%
diff-log90.5%
Applied egg-rr90.5%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.8%
Taylor expanded in n around -inf 82.2%
mul-1-neg82.2%
distribute-neg-frac282.2%
Simplified82.9%
log1p-undefine82.9%
diff-log88.7%
Applied egg-rr88.7%
+-commutative88.7%
Simplified88.7%
Taylor expanded in x around inf 80.9%
associate-*r/47.3%
*-commutative47.3%
log-rec47.3%
Simplified80.9%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) Initial program 43.1%
Taylor expanded in x around 0 70.7%
Final simplification85.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-54)
t_1
(if (<= (/ 1.0 n) 1e-11)
(/
(- (* -0.5 (/ (/ (* (log x) -2.0) x) n)) (/ (+ (/ 0.5 x) -1.0) x))
n)
(if (<= (/ 1.0 n) 2e-10)
t_1
(if (<= (/ 1.0 n) 5e+181)
(- (pow (+ 1.0 x) (/ 1.0 n)) t_0)
(log1p (expm1 (/ (/ 1.0 x) n))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+181) {
tmp = pow((1.0 + x), (1.0 / 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 t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((Math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+181) {
tmp = Math.pow((1.0 + x), (1.0 / 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)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-54: tmp = t_1 elif (1.0 / n) <= 1e-11: tmp = ((-0.5 * (((math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = t_1 elif (1.0 / n) <= 5e+181: tmp = math.pow((1.0 + x), (1.0 / 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) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+181) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0); else tmp = log1p(expm1(Float64(Float64(1.0 / 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[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n} - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.7%
Taylor expanded in n around inf 90.2%
log1p-define90.2%
Simplified90.2%
log1p-undefine90.2%
+-commutative90.2%
diff-log90.2%
Applied egg-rr90.2%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181Initial program 67.6%
if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n) Initial program 3.5%
Taylor expanded in x around inf 0.3%
mul-1-neg0.3%
log-rec0.3%
mul-1-neg0.3%
distribute-neg-frac0.3%
mul-1-neg0.3%
remove-double-neg0.3%
*-commutative0.3%
Simplified0.3%
Taylor expanded in n around inf 84.6%
*-commutative84.6%
Simplified84.6%
log1p-expm1-u94.6%
associate-/r*94.6%
Applied egg-rr94.6%
Final simplification87.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* -0.5 (/ (/ (* (log x) -2.0) x) n))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_1 n) x)
(if (<= (/ 1.0 n) 2e-54)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-11)
(/ (- t_0 (/ (+ (/ 0.5 x) -1.0) x)) n)
(if (<= (/ 1.0 n) 2e-10)
(/ (- t_0 (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 5e+181)
(- (pow (+ 1.0 x) (/ 1.0 n)) t_1)
(log1p (expm1 (/ (/ 1.0 x) n))))))))))
double code(double x, double n) {
double t_0 = -0.5 * (((log(x) * -2.0) / x) / n);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = (t_0 - log((x / (1.0 + x)))) / n;
} else if ((1.0 / n) <= 5e+181) {
tmp = pow((1.0 + x), (1.0 / n)) - t_1;
} else {
tmp = log1p(expm1(((1.0 / x) / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = -0.5 * (((Math.log(x) * -2.0) / x) / n);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-11) {
tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = (t_0 - Math.log((x / (1.0 + x)))) / n;
} else if ((1.0 / n) <= 5e+181) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - t_1;
} else {
tmp = Math.log1p(Math.expm1(((1.0 / x) / n)));
}
return tmp;
}
def code(x, n): t_0 = -0.5 * (((math.log(x) * -2.0) / x) / n) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_1 / n) / x elif (1.0 / n) <= 2e-54: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-11: tmp = (t_0 - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = (t_0 - math.log((x / (1.0 + x)))) / n elif (1.0 / n) <= 5e+181: tmp = math.pow((1.0 + x), (1.0 / n)) - t_1 else: tmp = math.log1p(math.expm1(((1.0 / x) / n))) return tmp
function code(x, n) t_0 = Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_1 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(t_0 - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(Float64(t_0 - log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 5e+181) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_1); else tmp = log1p(expm1(Float64(Float64(1.0 / x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(t$95$0 - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[(t$95$0 - N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_0 - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0 - \log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54Initial program 33.7%
Taylor expanded in n around inf 90.5%
log1p-define90.5%
Simplified90.5%
log1p-undefine90.5%
+-commutative90.5%
diff-log90.5%
Applied egg-rr90.5%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.8%
Taylor expanded in n around -inf 82.2%
mul-1-neg82.2%
distribute-neg-frac282.2%
Simplified82.9%
log1p-undefine82.9%
diff-log88.7%
Applied egg-rr88.7%
+-commutative88.7%
Simplified88.7%
Taylor expanded in x around inf 80.9%
associate-*r/47.3%
*-commutative47.3%
log-rec47.3%
Simplified80.9%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181Initial program 67.6%
if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n) Initial program 3.5%
Taylor expanded in x around inf 0.3%
mul-1-neg0.3%
log-rec0.3%
mul-1-neg0.3%
distribute-neg-frac0.3%
mul-1-neg0.3%
remove-double-neg0.3%
*-commutative0.3%
Simplified0.3%
Taylor expanded in n around inf 84.6%
*-commutative84.6%
Simplified84.6%
log1p-expm1-u94.6%
associate-/r*94.6%
Applied egg-rr94.6%
Final simplification87.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-54)
t_1
(if (<= (/ 1.0 n) 1e-11)
(/
(- (* -0.5 (/ (/ (* (log x) -2.0) x) n)) (/ (+ (/ 0.5 x) -1.0) x))
n)
(if (<= (/ 1.0 n) 2e-10)
t_1
(if (<= (/ 1.0 n) 5e+181)
(- (+ 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 t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+181) {
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 t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((Math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+181) {
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)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-54: tmp = t_1 elif (1.0 / n) <= 1e-11: tmp = ((-0.5 * (((math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = t_1 elif (1.0 / n) <= 5e+181: 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) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+181) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(Float64(1.0 / 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[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n} - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.7%
Taylor expanded in n around inf 90.2%
log1p-define90.2%
Simplified90.2%
log1p-undefine90.2%
+-commutative90.2%
diff-log90.2%
Applied egg-rr90.2%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181Initial program 67.6%
Taylor expanded in x around 0 63.2%
*-rgt-identity63.2%
associate-/l*63.2%
exp-to-pow63.2%
Simplified63.2%
if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n) Initial program 3.5%
Taylor expanded in x around inf 0.3%
mul-1-neg0.3%
log-rec0.3%
mul-1-neg0.3%
distribute-neg-frac0.3%
mul-1-neg0.3%
remove-double-neg0.3%
*-commutative0.3%
Simplified0.3%
Taylor expanded in n around inf 84.6%
*-commutative84.6%
Simplified84.6%
log1p-expm1-u94.6%
associate-/r*94.6%
Applied egg-rr94.6%
Final simplification86.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-54)
t_1
(if (<= (/ 1.0 n) 1e-11)
(/
(- (* -0.5 (/ (/ (* (log x) -2.0) x) n)) (/ (+ (/ 0.5 x) -1.0) x))
n)
(if (<= (/ 1.0 n) 2e-10)
t_1
(if (<= (/ 1.0 n) 5e+181)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+181) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-1d-160)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-54) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-11) then
tmp = (((-0.5d0) * (((log(x) * (-2.0d0)) / x) / n)) - (((0.5d0 / x) + (-1.0d0)) / x)) / n
else if ((1.0d0 / n) <= 2d-10) then
tmp = t_1
else if ((1.0d0 / n) <= 5d+181) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
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(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-54) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-11) {
tmp = ((-0.5 * (((Math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+181) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-54: tmp = t_1 elif (1.0 / n) <= 1e-11: tmp = ((-0.5 * (((math.log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n elif (1.0 / n) <= 2e-10: tmp = t_1 elif (1.0 / n) <= 5e+181: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n return tmp
function code(x, n) t_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) <= -1e-160) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-54) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-11) tmp = Float64(Float64(Float64(-0.5 * Float64(Float64(Float64(log(x) * -2.0) / x) / n)) - Float64(Float64(Float64(0.5 / x) + -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e-10) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+181) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -1e-160) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-54) tmp = t_1; elseif ((1.0 / n) <= 1e-11) tmp = ((-0.5 * (((log(x) * -2.0) / x) / n)) - (((0.5 / x) + -1.0) / x)) / n; elseif ((1.0 / n) <= 2e-10) tmp = t_1; elseif ((1.0 / n) <= 5e+181) tmp = (1.0 + (x / n)) - t_0; else tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; 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[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-54], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-11], N[(N[(N[(-0.5 * N[(N[(N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.5 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n} - \frac{\frac{0.5}{x} + -1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 33.7%
Taylor expanded in n around inf 90.2%
log1p-define90.2%
Simplified90.2%
log1p-undefine90.2%
+-commutative90.2%
diff-log90.2%
Applied egg-rr90.2%
if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12Initial program 4.8%
Taylor expanded in n around -inf 26.2%
mul-1-neg26.2%
distribute-neg-frac226.2%
Simplified26.2%
Taylor expanded in x around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in x around inf 84.7%
associate-*r/84.7%
*-commutative84.7%
log-rec84.7%
Simplified84.7%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181Initial program 67.6%
Taylor expanded in x around 0 63.2%
*-rgt-identity63.2%
associate-/l*63.2%
exp-to-pow63.2%
Simplified63.2%
if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n) Initial program 3.5%
Taylor expanded in n around inf 8.3%
log1p-define8.3%
Simplified8.3%
Taylor expanded in x around inf 94.6%
Simplified94.6%
Final simplification86.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n))))
(t_1 (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))
(t_2 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -2e+179)
t_2
(if (<= (/ 1.0 n) -2e-6)
t_0
(if (<= (/ 1.0 n) -1e-160)
t_1
(if (<= (/ 1.0 n) 2e-10) t_2 (if (<= (/ 1.0 n) 5e+181) t_0 t_1)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
double t_2 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -2e+179) {
tmp = t_2;
} else if ((1.0 / n) <= -2e-6) {
tmp = t_0;
} else if ((1.0 / n) <= -1e-160) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_2;
} else if ((1.0 / n) <= 5e+181) {
tmp = t_0;
} 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) :: t_2
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
t_2 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-2d+179)) then
tmp = t_2
else if ((1.0d0 / n) <= (-2d-6)) then
tmp = t_0
else if ((1.0d0 / n) <= (-1d-160)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-10) then
tmp = t_2
else if ((1.0d0 / n) <= 5d+181) then
tmp = t_0
else
tmp = t_1
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 = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
double t_2 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -2e+179) {
tmp = t_2;
} else if ((1.0 / n) <= -2e-6) {
tmp = t_0;
} else if ((1.0 / n) <= -1e-160) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-10) {
tmp = t_2;
} else if ((1.0 / n) <= 5e+181) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n t_2 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -2e+179: tmp = t_2 elif (1.0 / n) <= -2e-6: tmp = t_0 elif (1.0 / n) <= -1e-160: tmp = t_1 elif (1.0 / n) <= 2e-10: tmp = t_2 elif (1.0 / n) <= 5e+181: tmp = t_0 else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n) t_2 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e+179) tmp = t_2; elseif (Float64(1.0 / n) <= -2e-6) tmp = t_0; elseif (Float64(1.0 / n) <= -1e-160) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-10) tmp = t_2; elseif (Float64(1.0 / n) <= 5e+181) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; t_2 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -2e+179) tmp = t_2; elseif ((1.0 / n) <= -2e-6) tmp = t_0; elseif ((1.0 / n) <= -1e-160) tmp = t_1; elseif ((1.0 / n) <= 2e-10) tmp = t_2; elseif ((1.0 / n) <= 5e+181) tmp = t_0; else tmp = t_1; 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[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+179], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-6], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
t_2 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+179}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.99999999999999996e179 or -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 49.5%
Taylor expanded in n around inf 78.2%
log1p-define78.2%
Simplified78.2%
log1p-undefine78.2%
+-commutative78.2%
diff-log78.3%
Applied egg-rr78.3%
if -1.99999999999999996e179 < (/.f64 #s(literal 1 binary64) n) < -1.99999999999999991e-6 or 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181Initial program 85.4%
Taylor expanded in x around 0 58.3%
*-rgt-identity58.3%
associate-/l*58.3%
exp-to-pow58.3%
Simplified58.3%
if -1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161 or 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n) Initial program 10.4%
Taylor expanded in n around inf 34.1%
log1p-define34.1%
Simplified34.1%
Taylor expanded in x around inf 75.3%
Simplified75.3%
Final simplification72.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-10)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+181)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+181) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-1d-160)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-10) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d+181) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
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) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+181) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-10: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+181: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+181) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1e-160) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-10) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e+181) tmp = (1.0 + (x / n)) - t_0; else tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; 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], -1e-160], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 31.7%
Taylor expanded in n around inf 85.7%
log1p-define85.7%
Simplified85.7%
log1p-undefine85.7%
+-commutative85.7%
diff-log85.7%
Applied egg-rr85.7%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181Initial program 67.6%
Taylor expanded in x around 0 63.2%
*-rgt-identity63.2%
associate-/l*63.2%
exp-to-pow63.2%
Simplified63.2%
if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n) Initial program 3.5%
Taylor expanded in n around inf 8.3%
log1p-define8.3%
Simplified8.3%
Taylor expanded in x around inf 94.6%
Simplified94.6%
Final simplification85.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-160)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-10)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+181)
(- 1.0 t_0)
(/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+181) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-1d-160)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-10) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d+181) then
tmp = 1.0d0 - t_0
else
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
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) <= -1e-160) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+181) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-160: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-10: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+181: tmp = 1.0 - t_0 else: tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-160) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+181) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1e-160) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-10) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e+181) tmp = 1.0 - t_0; else tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; 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], -1e-160], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161Initial program 74.0%
Taylor expanded in x around inf 88.5%
associate-/r*88.5%
mul-1-neg88.5%
log-rec88.5%
mul-1-neg88.5%
distribute-neg-frac88.5%
mul-1-neg88.5%
remove-double-neg88.5%
*-rgt-identity88.5%
associate-/l*88.5%
exp-to-pow88.5%
Simplified88.5%
if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 31.7%
Taylor expanded in n around inf 85.7%
log1p-define85.7%
Simplified85.7%
log1p-undefine85.7%
+-commutative85.7%
diff-log85.7%
Applied egg-rr85.7%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181Initial program 67.6%
Taylor expanded in x around 0 60.6%
*-rgt-identity60.6%
associate-/l*60.6%
exp-to-pow60.6%
Simplified60.6%
if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n) Initial program 3.5%
Taylor expanded in n around inf 8.3%
log1p-define8.3%
Simplified8.3%
Taylor expanded in x around inf 94.6%
Simplified94.6%
Final simplification84.7%
(FPCore (x n)
:precision binary64
(if (<= x 1.32e-220)
(/ (log x) (- n))
(if (<= x 5.2e-181)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.88)
(/ (- x (log x)) n)
(if (<= x 1.2e+178)
(/
(/ (+ 1.0 (/ (- -0.5 (/ (+ -0.3333333333333333 (/ 0.25 x)) x)) x)) x)
n)
(/ -0.5 (* n (pow x 2.0))))))))
double code(double x, double n) {
double tmp;
if (x <= 1.32e-220) {
tmp = log(x) / -n;
} else if (x <= 5.2e-181) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else if (x <= 1.2e+178) {
tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = -0.5 / (n * pow(x, 2.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.32d-220) then
tmp = log(x) / -n
else if (x <= 5.2d-181) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.88d0) then
tmp = (x - log(x)) / n
else if (x <= 1.2d+178) then
tmp = ((1.0d0 + (((-0.5d0) - (((-0.3333333333333333d0) + (0.25d0 / x)) / x)) / x)) / x) / n
else
tmp = (-0.5d0) / (n * (x ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.32e-220) {
tmp = Math.log(x) / -n;
} else if (x <= 5.2e-181) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.2e+178) {
tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = -0.5 / (n * Math.pow(x, 2.0));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.32e-220: tmp = math.log(x) / -n elif x <= 5.2e-181: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.88: tmp = (x - math.log(x)) / n elif x <= 1.2e+178: tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n else: tmp = -0.5 / (n * math.pow(x, 2.0)) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.32e-220) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 5.2e-181) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.2e+178) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 - Float64(Float64(-0.3333333333333333 + Float64(0.25 / x)) / x)) / x)) / x) / n); else tmp = Float64(-0.5 / Float64(n * (x ^ 2.0))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.32e-220) tmp = log(x) / -n; elseif (x <= 5.2e-181) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.88) tmp = (x - log(x)) / n; elseif (x <= 1.2e+178) tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n; else tmp = -0.5 / (n * (x ^ 2.0)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.32e-220], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 5.2e-181], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.2e+178], N[(N[(N[(1.0 + N[(N[(-0.5 - N[(N[(-0.3333333333333333 + N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(-0.5 / N[(n * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.32 \cdot 10^{-220}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-181}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+178}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\
\end{array}
\end{array}
if x < 1.31999999999999996e-220Initial program 42.4%
Taylor expanded in x around 0 42.4%
*-rgt-identity42.4%
associate-/l*42.4%
exp-to-pow42.4%
Simplified42.4%
Taylor expanded in n around inf 57.0%
associate-*r/57.0%
neg-mul-157.0%
Simplified57.0%
if 1.31999999999999996e-220 < x < 5.19999999999999998e-181Initial program 61.5%
Taylor expanded in x around 0 61.5%
*-rgt-identity61.5%
associate-/l*61.5%
exp-to-pow61.5%
Simplified61.5%
if 5.19999999999999998e-181 < x < 0.880000000000000004Initial program 36.5%
Taylor expanded in n around inf 48.8%
log1p-define48.8%
Simplified48.8%
Taylor expanded in x around 0 47.0%
if 0.880000000000000004 < x < 1.2e178Initial program 53.9%
Taylor expanded in n around inf 52.3%
log1p-define52.3%
Simplified52.3%
Taylor expanded in x around inf 59.6%
Simplified59.6%
if 1.2e178 < x Initial program 87.3%
Taylor expanded in n around -inf 87.3%
mul-1-neg87.3%
distribute-neg-frac287.3%
Simplified87.3%
Taylor expanded in x around inf 62.0%
sub-neg62.0%
associate-*r/62.0%
metadata-eval62.0%
metadata-eval62.0%
Simplified62.0%
Taylor expanded in x around 0 87.3%
*-commutative87.3%
Simplified87.3%
Final simplification59.5%
(FPCore (x n)
:precision binary64
(if (<= x 4.9e-201)
(/ (log x) (- n))
(if (<= x 7.5e-181)
(/ 1.0 (* n x))
(if (<= x 0.9)
(/ (- x (log x)) n)
(/
(/ (+ 1.0 (/ (- -0.5 (/ (+ -0.3333333333333333 (/ 0.25 x)) x)) x)) x)
n)))))
double code(double x, double n) {
double tmp;
if (x <= 4.9e-201) {
tmp = log(x) / -n;
} else if (x <= 7.5e-181) {
tmp = 1.0 / (n * x);
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / 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 <= 4.9d-201) then
tmp = log(x) / -n
else if (x <= 7.5d-181) then
tmp = 1.0d0 / (n * x)
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + (((-0.5d0) - (((-0.3333333333333333d0) + (0.25d0 / x)) / x)) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 4.9e-201) {
tmp = Math.log(x) / -n;
} else if (x <= 7.5e-181) {
tmp = 1.0 / (n * x);
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.9e-201: tmp = math.log(x) / -n elif x <= 7.5e-181: tmp = 1.0 / (n * x) elif x <= 0.9: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 4.9e-201) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 7.5e-181) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 - Float64(Float64(-0.3333333333333333 + Float64(0.25 / x)) / x)) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.9e-201) tmp = log(x) / -n; elseif (x <= 7.5e-181) tmp = 1.0 / (n * x); elseif (x <= 0.9) tmp = (x - log(x)) / n; else tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.9e-201], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 7.5e-181], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(-0.5 - N[(N[(-0.3333333333333333 + N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.9 \cdot 10^{-201}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-181}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 4.8999999999999997e-201Initial program 44.4%
Taylor expanded in x around 0 44.4%
*-rgt-identity44.4%
associate-/l*44.4%
exp-to-pow44.4%
Simplified44.4%
Taylor expanded in n around inf 55.9%
associate-*r/55.9%
neg-mul-155.9%
Simplified55.9%
if 4.8999999999999997e-201 < x < 7.5000000000000002e-181Initial program 61.4%
Taylor expanded in x around inf 43.9%
mul-1-neg43.9%
log-rec43.9%
mul-1-neg43.9%
distribute-neg-frac43.9%
mul-1-neg43.9%
remove-double-neg43.9%
*-commutative43.9%
Simplified43.9%
Taylor expanded in n around inf 65.6%
*-commutative65.6%
Simplified65.6%
if 7.5000000000000002e-181 < x < 0.900000000000000022Initial program 36.5%
Taylor expanded in n around inf 48.8%
log1p-define48.8%
Simplified48.8%
Taylor expanded in x around 0 47.0%
if 0.900000000000000022 < x Initial program 66.8%
Taylor expanded in n around inf 65.8%
log1p-define65.8%
Simplified65.8%
Taylor expanded in x around inf 60.5%
Simplified60.5%
Final simplification55.4%
(FPCore (x n)
:precision binary64
(if (<= x 2.15e-220)
(/ (log x) (- n))
(if (<= x 2.4e-181)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.9)
(/ (- x (log x)) n)
(/
(/ (+ 1.0 (/ (- -0.5 (/ (+ -0.3333333333333333 (/ 0.25 x)) x)) x)) x)
n)))))
double code(double x, double n) {
double tmp;
if (x <= 2.15e-220) {
tmp = log(x) / -n;
} else if (x <= 2.4e-181) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / 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 <= 2.15d-220) then
tmp = log(x) / -n
else if (x <= 2.4d-181) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + (((-0.5d0) - (((-0.3333333333333333d0) + (0.25d0 / x)) / x)) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.15e-220) {
tmp = Math.log(x) / -n;
} else if (x <= 2.4e-181) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.15e-220: tmp = math.log(x) / -n elif x <= 2.4e-181: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.9: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 2.15e-220) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 2.4e-181) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 - Float64(Float64(-0.3333333333333333 + Float64(0.25 / x)) / x)) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.15e-220) tmp = log(x) / -n; elseif (x <= 2.4e-181) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.9) tmp = (x - log(x)) / n; else tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.15e-220], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.4e-181], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(-0.5 - N[(N[(-0.3333333333333333 + N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.15 \cdot 10^{-220}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-181}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 2.1499999999999999e-220Initial program 42.4%
Taylor expanded in x around 0 42.4%
*-rgt-identity42.4%
associate-/l*42.4%
exp-to-pow42.4%
Simplified42.4%
Taylor expanded in n around inf 57.0%
associate-*r/57.0%
neg-mul-157.0%
Simplified57.0%
if 2.1499999999999999e-220 < x < 2.4000000000000001e-181Initial program 61.5%
Taylor expanded in x around 0 61.5%
*-rgt-identity61.5%
associate-/l*61.5%
exp-to-pow61.5%
Simplified61.5%
if 2.4000000000000001e-181 < x < 0.900000000000000022Initial program 36.5%
Taylor expanded in n around inf 48.8%
log1p-define48.8%
Simplified48.8%
Taylor expanded in x around 0 47.0%
if 0.900000000000000022 < x Initial program 66.8%
Taylor expanded in n around inf 65.8%
log1p-define65.8%
Simplified65.8%
Taylor expanded in x around inf 60.5%
Simplified60.5%
Final simplification55.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.95e-199)
t_0
(if (<= x 2.25e-181)
(/ 1.0 (* n x))
(if (<= x 4.5e-59)
t_0
(/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.95e-199) {
tmp = t_0;
} else if (x <= 2.25e-181) {
tmp = 1.0 / (n * x);
} else if (x <= 4.5e-59) {
tmp = t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 1.95d-199) then
tmp = t_0
else if (x <= 2.25d-181) then
tmp = 1.0d0 / (n * x)
else if (x <= 4.5d-59) then
tmp = t_0
else
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
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.95e-199) {
tmp = t_0;
} else if (x <= 2.25e-181) {
tmp = 1.0 / (n * x);
} else if (x <= 4.5e-59) {
tmp = t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.95e-199: tmp = t_0 elif x <= 2.25e-181: tmp = 1.0 / (n * x) elif x <= 4.5e-59: tmp = t_0 else: tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.95e-199) tmp = t_0; elseif (x <= 2.25e-181) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 4.5e-59) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.95e-199) tmp = t_0; elseif (x <= 2.25e-181) tmp = 1.0 / (n * x); elseif (x <= 4.5e-59) tmp = t_0; else tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.95e-199], t$95$0, If[LessEqual[x, 2.25e-181], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.5e-59], t$95$0, N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.95 \cdot 10^{-199}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{-181}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-59}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 1.9500000000000001e-199 or 2.2499999999999999e-181 < x < 4.50000000000000012e-59Initial program 38.7%
Taylor expanded in x around 0 38.7%
*-rgt-identity38.7%
associate-/l*38.7%
exp-to-pow38.7%
Simplified38.7%
Taylor expanded in n around inf 55.5%
associate-*r/55.5%
neg-mul-155.5%
Simplified55.5%
if 1.9500000000000001e-199 < x < 2.2499999999999999e-181Initial program 61.4%
Taylor expanded in x around inf 43.9%
mul-1-neg43.9%
log-rec43.9%
mul-1-neg43.9%
distribute-neg-frac43.9%
mul-1-neg43.9%
remove-double-neg43.9%
*-commutative43.9%
Simplified43.9%
Taylor expanded in n around inf 65.6%
*-commutative65.6%
Simplified65.6%
if 4.50000000000000012e-59 < x Initial program 61.6%
Taylor expanded in n around inf 59.5%
log1p-define59.5%
Simplified59.5%
Taylor expanded in x around inf 54.2%
Simplified54.2%
Final simplification55.4%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ (/ -0.5 n) (/ 0.3333333333333333 (* n x))) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((-0.5 / n) + (0.3333333333333333 / (n * x))) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + ((((-0.5d0) / n) + (0.3333333333333333d0 / (n * x))) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((-0.5 / n) + (0.3333333333333333 / (n * x))) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((-0.5 / n) + (0.3333333333333333 / (n * x))) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(-0.5 / n) + Float64(0.3333333333333333 / Float64(n * x))) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((-0.5 / n) + (0.3333333333333333 / (n * x))) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(-0.5 / n), $MachinePrecision] + N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{-0.5}{n} + \frac{0.3333333333333333}{n \cdot x}}{x}}{x}
\end{array}
Initial program 52.0%
Taylor expanded in n around inf 55.7%
log1p-define55.7%
Simplified55.7%
Taylor expanded in x around -inf 45.3%
associate-*r/45.3%
Simplified45.3%
Final simplification45.3%
(FPCore (x n) :precision binary64 (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))
double code(double x, double n) {
return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
def code(x, n): return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Initial program 52.0%
Taylor expanded in n around inf 55.7%
log1p-define55.7%
Simplified55.7%
Taylor expanded in x around inf 45.3%
Simplified45.3%
Final simplification45.3%
(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 52.0%
Taylor expanded in x around inf 56.2%
mul-1-neg56.2%
log-rec56.2%
mul-1-neg56.2%
distribute-neg-frac56.2%
mul-1-neg56.2%
remove-double-neg56.2%
*-commutative56.2%
Simplified56.2%
Taylor expanded in n around inf 40.5%
*-commutative40.5%
Simplified40.5%
Final simplification40.5%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 52.0%
Taylor expanded in x around inf 56.2%
mul-1-neg56.2%
log-rec56.2%
mul-1-neg56.2%
distribute-neg-frac56.2%
mul-1-neg56.2%
remove-double-neg56.2%
*-commutative56.2%
Simplified56.2%
Taylor expanded in n around inf 40.5%
*-commutative40.5%
Simplified40.5%
associate-/r*40.7%
div-inv40.7%
Applied egg-rr40.7%
Taylor expanded in x around 0 40.5%
associate-/r*40.7%
Simplified40.7%
Final simplification40.7%
(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.0%
Taylor expanded in n around inf 55.7%
log1p-define55.7%
Simplified55.7%
Taylor expanded in x around inf 40.7%
Final simplification40.7%
herbie shell --seed 2024100
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))