
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-105)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-135)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-12)
(/ 1.0 (* n (+ x 0.5)))
(- (exp (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-105)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-135) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d-12) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else
tmp = exp((x / n)) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-105: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-135: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-12: tmp = 1.0 / (n * (x + 0.5)) else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-105) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-135) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-12) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-105) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-135) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e-12) tmp = 1.0 / (n * (x + 0.5)); else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-105], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-135], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999963e-105Initial program 76.0%
Taylor expanded in n around 0 76.0%
log1p-def76.0%
Simplified76.0%
Taylor expanded in x around inf 88.8%
mul-1-neg88.8%
log-rec88.8%
distribute-neg-frac88.8%
remove-double-neg88.8%
*-rgt-identity88.8%
associate-*r/88.8%
exp-to-pow88.8%
*-commutative88.8%
Simplified88.8%
*-un-lft-identity88.8%
times-frac89.2%
Applied egg-rr89.2%
if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135Initial program 43.8%
Taylor expanded in n around inf 89.8%
+-rgt-identity89.8%
+-rgt-identity89.8%
log1p-def89.8%
Simplified89.8%
log1p-udef89.8%
diff-log89.9%
Applied egg-rr89.9%
if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13Initial program 18.5%
Taylor expanded in n around inf 43.7%
+-rgt-identity43.7%
+-rgt-identity43.7%
log1p-def43.7%
Simplified43.7%
clear-num43.7%
inv-pow43.7%
Applied egg-rr43.7%
unpow-143.7%
Simplified43.7%
Taylor expanded in x around inf 77.5%
*-commutative77.5%
distribute-lft-out77.5%
Simplified77.5%
if 9.9999999999999998e-13 < (/.f64 1 n) Initial program 49.2%
Taylor expanded in n around 0 49.2%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification90.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-105)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-135)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-12)
(/ 1.0 (* n (+ x 0.5)))
(if (<= (/ 1.0 n) 2e+251)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ 1.0 (* n x))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1((1.0 / (n * x))));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1((1.0 / (n * x))));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-105: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-135: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-12: tmp = 1.0 / (n * (x + 0.5)) elif (1.0 / n) <= 2e+251: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1((1.0 / (n * x)))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-105) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-135) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-12) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); elseif (Float64(1.0 / n) <= 2e+251) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(1.0 / Float64(n * x)))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-105], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-135], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+251], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n \cdot x}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999963e-105Initial program 76.0%
Taylor expanded in n around 0 76.0%
log1p-def76.0%
Simplified76.0%
Taylor expanded in x around inf 88.8%
mul-1-neg88.8%
log-rec88.8%
distribute-neg-frac88.8%
remove-double-neg88.8%
*-rgt-identity88.8%
associate-*r/88.8%
exp-to-pow88.8%
*-commutative88.8%
Simplified88.8%
*-un-lft-identity88.8%
times-frac89.2%
Applied egg-rr89.2%
if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135Initial program 43.8%
Taylor expanded in n around inf 89.8%
+-rgt-identity89.8%
+-rgt-identity89.8%
log1p-def89.8%
Simplified89.8%
log1p-udef89.8%
diff-log89.9%
Applied egg-rr89.9%
if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13Initial program 18.5%
Taylor expanded in n around inf 43.7%
+-rgt-identity43.7%
+-rgt-identity43.7%
log1p-def43.7%
Simplified43.7%
clear-num43.7%
inv-pow43.7%
Applied egg-rr43.7%
unpow-143.7%
Simplified43.7%
Taylor expanded in x around inf 77.5%
*-commutative77.5%
distribute-lft-out77.5%
Simplified77.5%
if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251Initial program 68.4%
Taylor expanded in x around 0 67.8%
if 2.0000000000000001e251 < (/.f64 1 n) Initial program 4.0%
Taylor expanded in n around inf 16.9%
+-rgt-identity16.9%
+-rgt-identity16.9%
log1p-def16.9%
Simplified16.9%
Taylor expanded in x around inf 83.0%
associate-/l/83.0%
log1p-expm1-u91.2%
associate-/r*91.2%
Applied egg-rr91.2%
Final simplification86.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ 1.0 (* n (+ x 0.5)))))
(if (<= (/ 1.0 n) -2e-13)
t_0
(if (<= (/ 1.0 n) -1e-115)
t_1
(if (<= (/ 1.0 n) -2e-140)
(/ (- x (log x)) n)
(if (<= (/ 1.0 n) 5e-308)
t_1
(if (<= (/ 1.0 n) 1e-202)
(/ (- (log x)) n)
(if (<= (/ 1.0 n) 1e-12)
t_1
(if (<= (/ 1.0 n) 2e+251) t_0 (/ 1.0 (* n x)))))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = 1.0 / (n * (x + 0.5));
double tmp;
if ((1.0 / n) <= -2e-13) {
tmp = t_0;
} else if ((1.0 / n) <= -1e-115) {
tmp = t_1;
} else if ((1.0 / n) <= -2e-140) {
tmp = (x - log(x)) / n;
} else if ((1.0 / n) <= 5e-308) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-202) {
tmp = -log(x) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+251) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = 1.0d0 / (n * (x + 0.5d0))
if ((1.0d0 / n) <= (-2d-13)) then
tmp = t_0
else if ((1.0d0 / n) <= (-1d-115)) then
tmp = t_1
else if ((1.0d0 / n) <= (-2d-140)) then
tmp = (x - log(x)) / n
else if ((1.0d0 / n) <= 5d-308) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-202) then
tmp = -log(x) / n
else if ((1.0d0 / n) <= 1d-12) then
tmp = t_1
else if ((1.0d0 / n) <= 2d+251) then
tmp = t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = 1.0 / (n * (x + 0.5));
double tmp;
if ((1.0 / n) <= -2e-13) {
tmp = t_0;
} else if ((1.0 / n) <= -1e-115) {
tmp = t_1;
} else if ((1.0 / n) <= -2e-140) {
tmp = (x - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-308) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-202) {
tmp = -Math.log(x) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+251) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = 1.0 / (n * (x + 0.5)) tmp = 0 if (1.0 / n) <= -2e-13: tmp = t_0 elif (1.0 / n) <= -1e-115: tmp = t_1 elif (1.0 / n) <= -2e-140: tmp = (x - math.log(x)) / n elif (1.0 / n) <= 5e-308: tmp = t_1 elif (1.0 / n) <= 1e-202: tmp = -math.log(x) / n elif (1.0 / n) <= 1e-12: tmp = t_1 elif (1.0 / n) <= 2e+251: tmp = t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(1.0 / Float64(n * Float64(x + 0.5))) tmp = 0.0 if (Float64(1.0 / n) <= -2e-13) tmp = t_0; elseif (Float64(1.0 / n) <= -1e-115) tmp = t_1; elseif (Float64(1.0 / n) <= -2e-140) tmp = Float64(Float64(x - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-308) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-202) tmp = Float64(Float64(-log(x)) / n); elseif (Float64(1.0 / n) <= 1e-12) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+251) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = 1.0 / (n * (x + 0.5)); tmp = 0.0; if ((1.0 / n) <= -2e-13) tmp = t_0; elseif ((1.0 / n) <= -1e-115) tmp = t_1; elseif ((1.0 / n) <= -2e-140) tmp = (x - log(x)) / n; elseif ((1.0 / n) <= 5e-308) tmp = t_1; elseif ((1.0 / n) <= 1e-202) tmp = -log(x) / n; elseif ((1.0 / n) <= 1e-12) tmp = t_1; elseif ((1.0 / n) <= 2e+251) tmp = t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-13], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-115], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-140], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-308], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-202], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+251], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-13}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-115}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-140}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-308}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-202}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-13 or 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251Initial program 90.7%
Taylor expanded in x around 0 58.0%
if -2.0000000000000001e-13 < (/.f64 1 n) < -1.0000000000000001e-115 or -2e-140 < (/.f64 1 n) < 4.99999999999999955e-308 or 1e-202 < (/.f64 1 n) < 9.9999999999999998e-13Initial program 36.4%
Taylor expanded in n around inf 68.2%
+-rgt-identity68.2%
+-rgt-identity68.2%
log1p-def68.2%
Simplified68.2%
clear-num68.2%
inv-pow68.2%
Applied egg-rr68.2%
unpow-168.2%
Simplified68.2%
Taylor expanded in x around inf 69.4%
*-commutative69.4%
distribute-lft-out69.4%
Simplified69.4%
if -1.0000000000000001e-115 < (/.f64 1 n) < -2e-140Initial program 4.4%
Taylor expanded in n around inf 100.0%
+-rgt-identity100.0%
+-rgt-identity100.0%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
if 4.99999999999999955e-308 < (/.f64 1 n) < 1e-202Initial program 34.1%
Taylor expanded in x around 0 34.1%
Taylor expanded in n around inf 68.9%
neg-mul-168.9%
distribute-neg-frac68.9%
Simplified68.9%
if 2.0000000000000001e251 < (/.f64 1 n) Initial program 4.0%
Taylor expanded in n around inf 16.9%
+-rgt-identity16.9%
+-rgt-identity16.9%
log1p-def16.9%
Simplified16.9%
Taylor expanded in x around inf 83.0%
Final simplification66.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ (+ 1.0 x) x)) n))
(t_1 (- 1.0 (pow x (/ 1.0 n))))
(t_2 (/ 1.0 (* n (+ x 0.5)))))
(if (<= (/ 1.0 n) -2e+181)
t_1
(if (<= (/ 1.0 n) -2e+65)
t_0
(if (<= (/ 1.0 n) -2e-13)
t_1
(if (<= (/ 1.0 n) -1e-115)
t_2
(if (<= (/ 1.0 n) 1e-135)
t_0
(if (<= (/ 1.0 n) 1e-12)
t_2
(if (<= (/ 1.0 n) 2e+251) t_1 (/ 1.0 (* n x)))))))))))
double code(double x, double n) {
double t_0 = log(((1.0 + x) / x)) / n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double t_2 = 1.0 / (n * (x + 0.5));
double tmp;
if ((1.0 / n) <= -2e+181) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+65) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-13) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-115) {
tmp = t_2;
} else if ((1.0 / n) <= 1e-135) {
tmp = t_0;
} else if ((1.0 / n) <= 1e-12) {
tmp = t_2;
} else if ((1.0 / n) <= 2e+251) {
tmp = t_1;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = log(((1.0d0 + x) / x)) / n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
t_2 = 1.0d0 / (n * (x + 0.5d0))
if ((1.0d0 / n) <= (-2d+181)) then
tmp = t_1
else if ((1.0d0 / n) <= (-2d+65)) then
tmp = t_0
else if ((1.0d0 / n) <= (-2d-13)) then
tmp = t_1
else if ((1.0d0 / n) <= (-1d-115)) then
tmp = t_2
else if ((1.0d0 / n) <= 1d-135) then
tmp = t_0
else if ((1.0d0 / n) <= 1d-12) then
tmp = t_2
else if ((1.0d0 / n) <= 2d+251) then
tmp = t_1
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(((1.0 + x) / x)) / n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double t_2 = 1.0 / (n * (x + 0.5));
double tmp;
if ((1.0 / n) <= -2e+181) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+65) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-13) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-115) {
tmp = t_2;
} else if ((1.0 / n) <= 1e-135) {
tmp = t_0;
} else if ((1.0 / n) <= 1e-12) {
tmp = t_2;
} else if ((1.0 / n) <= 2e+251) {
tmp = t_1;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.log(((1.0 + x) / x)) / n t_1 = 1.0 - math.pow(x, (1.0 / n)) t_2 = 1.0 / (n * (x + 0.5)) tmp = 0 if (1.0 / n) <= -2e+181: tmp = t_1 elif (1.0 / n) <= -2e+65: tmp = t_0 elif (1.0 / n) <= -2e-13: tmp = t_1 elif (1.0 / n) <= -1e-115: tmp = t_2 elif (1.0 / n) <= 1e-135: tmp = t_0 elif (1.0 / n) <= 1e-12: tmp = t_2 elif (1.0 / n) <= 2e+251: tmp = t_1 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_2 = Float64(1.0 / Float64(n * Float64(x + 0.5))) tmp = 0.0 if (Float64(1.0 / n) <= -2e+181) tmp = t_1; elseif (Float64(1.0 / n) <= -2e+65) tmp = t_0; elseif (Float64(1.0 / n) <= -2e-13) tmp = t_1; elseif (Float64(1.0 / n) <= -1e-115) tmp = t_2; elseif (Float64(1.0 / n) <= 1e-135) tmp = t_0; elseif (Float64(1.0 / n) <= 1e-12) tmp = t_2; elseif (Float64(1.0 / n) <= 2e+251) tmp = t_1; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = log(((1.0 + x) / x)) / n; t_1 = 1.0 - (x ^ (1.0 / n)); t_2 = 1.0 / (n * (x + 0.5)); tmp = 0.0; if ((1.0 / n) <= -2e+181) tmp = t_1; elseif ((1.0 / n) <= -2e+65) tmp = t_0; elseif ((1.0 / n) <= -2e-13) tmp = t_1; elseif ((1.0 / n) <= -1e-115) tmp = t_2; elseif ((1.0 / n) <= 1e-135) tmp = t_0; elseif ((1.0 / n) <= 1e-12) tmp = t_2; elseif ((1.0 / n) <= 2e+251) tmp = t_1; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+181], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+65], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-13], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-115], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-135], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+251], t$95$1, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+181}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+65}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-115}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.9999999999999998e181 or -2e65 < (/.f64 1 n) < -2.0000000000000001e-13 or 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251Initial program 86.5%
Taylor expanded in x around 0 67.6%
if -1.9999999999999998e181 < (/.f64 1 n) < -2e65 or -1.0000000000000001e-115 < (/.f64 1 n) < 1e-135Initial program 59.1%
Taylor expanded in n around inf 84.4%
+-rgt-identity84.4%
+-rgt-identity84.4%
log1p-def84.4%
Simplified84.4%
log1p-udef84.4%
diff-log84.6%
Applied egg-rr84.6%
if -2.0000000000000001e-13 < (/.f64 1 n) < -1.0000000000000001e-115 or 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13Initial program 15.8%
Taylor expanded in n around inf 44.9%
+-rgt-identity44.9%
+-rgt-identity44.9%
log1p-def44.9%
Simplified44.9%
clear-num44.9%
inv-pow44.9%
Applied egg-rr44.9%
unpow-144.9%
Simplified44.9%
Taylor expanded in x around inf 72.2%
*-commutative72.2%
distribute-lft-out72.2%
Simplified72.2%
if 2.0000000000000001e251 < (/.f64 1 n) Initial program 4.0%
Taylor expanded in n around inf 16.9%
+-rgt-identity16.9%
+-rgt-identity16.9%
log1p-def16.9%
Simplified16.9%
Taylor expanded in x around inf 83.0%
Final simplification77.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-105)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-135)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-12)
(/ 1.0 (* n (+ x 0.5)))
(if (<= (/ 1.0 n) 2e+251)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-105)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-135) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d-12) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else if ((1.0d0 / n) <= 2d+251) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-105: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-135: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-12: tmp = 1.0 / (n * (x + 0.5)) elif (1.0 / n) <= 2e+251: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-105) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-135) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-12) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); elseif (Float64(1.0 / n) <= 2e+251) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-105) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-135) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e-12) tmp = 1.0 / (n * (x + 0.5)); elseif ((1.0 / n) <= 2e+251) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-105], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-135], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+251], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999963e-105Initial program 76.0%
Taylor expanded in n around 0 76.0%
log1p-def76.0%
Simplified76.0%
Taylor expanded in x around inf 88.8%
mul-1-neg88.8%
log-rec88.8%
distribute-neg-frac88.8%
remove-double-neg88.8%
*-rgt-identity88.8%
associate-*r/88.8%
exp-to-pow88.8%
*-commutative88.8%
Simplified88.8%
*-un-lft-identity88.8%
times-frac89.2%
Applied egg-rr89.2%
if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135Initial program 43.8%
Taylor expanded in n around inf 89.8%
+-rgt-identity89.8%
+-rgt-identity89.8%
log1p-def89.8%
Simplified89.8%
log1p-udef89.8%
diff-log89.9%
Applied egg-rr89.9%
if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13Initial program 18.5%
Taylor expanded in n around inf 43.7%
+-rgt-identity43.7%
+-rgt-identity43.7%
log1p-def43.7%
Simplified43.7%
clear-num43.7%
inv-pow43.7%
Applied egg-rr43.7%
unpow-143.7%
Simplified43.7%
Taylor expanded in x around inf 77.5%
*-commutative77.5%
distribute-lft-out77.5%
Simplified77.5%
if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251Initial program 68.4%
Taylor expanded in x around 0 67.8%
if 2.0000000000000001e251 < (/.f64 1 n) Initial program 4.0%
Taylor expanded in n around inf 16.9%
+-rgt-identity16.9%
+-rgt-identity16.9%
log1p-def16.9%
Simplified16.9%
Taylor expanded in x around inf 83.0%
Final simplification86.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-105)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-135)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-12)
(/ 1.0 (* n (+ x 0.5)))
(if (<= (/ 1.0 n) 2e+251)
(- (+ 1.0 (/ x n)) t_0)
(/ (+ (/ 0.5 (pow x 2.0)) (/ -1.0 x)) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((0.5 / pow(x, 2.0)) + (-1.0 / 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) <= (-5d-105)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-135) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d-12) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else if ((1.0d0 / n) <= 2d+251) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = ((0.5d0 / (x ** 2.0d0)) + ((-1.0d0) / 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) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((0.5 / Math.pow(x, 2.0)) + (-1.0 / x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-105: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-135: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-12: tmp = 1.0 / (n * (x + 0.5)) elif (1.0 / n) <= 2e+251: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((0.5 / math.pow(x, 2.0)) + (-1.0 / x)) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-105) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-135) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-12) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); elseif (Float64(1.0 / n) <= 2e+251) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(0.5 / (x ^ 2.0)) + Float64(-1.0 / 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) <= -5e-105) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-135) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e-12) tmp = 1.0 / (n * (x + 0.5)); elseif ((1.0 / n) <= 2e+251) tmp = (1.0 + (x / n)) - t_0; else tmp = ((0.5 / (x ^ 2.0)) + (-1.0 / 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], -5e-105], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-135], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+251], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{{x}^{2}} + \frac{-1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999963e-105Initial program 76.0%
Taylor expanded in n around 0 76.0%
log1p-def76.0%
Simplified76.0%
Taylor expanded in x around inf 88.8%
mul-1-neg88.8%
log-rec88.8%
distribute-neg-frac88.8%
remove-double-neg88.8%
*-rgt-identity88.8%
associate-*r/88.8%
exp-to-pow88.8%
*-commutative88.8%
Simplified88.8%
*-un-lft-identity88.8%
times-frac89.2%
Applied egg-rr89.2%
if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135Initial program 43.8%
Taylor expanded in n around inf 89.8%
+-rgt-identity89.8%
+-rgt-identity89.8%
log1p-def89.8%
Simplified89.8%
log1p-udef89.8%
diff-log89.9%
Applied egg-rr89.9%
if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13Initial program 18.5%
Taylor expanded in n around inf 43.7%
+-rgt-identity43.7%
+-rgt-identity43.7%
log1p-def43.7%
Simplified43.7%
clear-num43.7%
inv-pow43.7%
Applied egg-rr43.7%
unpow-143.7%
Simplified43.7%
Taylor expanded in x around inf 77.5%
*-commutative77.5%
distribute-lft-out77.5%
Simplified77.5%
if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251Initial program 68.4%
Taylor expanded in x around 0 67.8%
if 2.0000000000000001e251 < (/.f64 1 n) Initial program 4.0%
Taylor expanded in n around inf 16.9%
+-rgt-identity16.9%
+-rgt-identity16.9%
log1p-def16.9%
Simplified16.9%
Taylor expanded in x around inf 0.1%
associate-*r/0.1%
metadata-eval0.1%
Simplified0.1%
frac-2neg0.1%
div-inv0.1%
sub-neg0.1%
distribute-neg-frac0.1%
metadata-eval0.1%
add-sqr-sqrt0.0%
sqrt-unprod91.2%
sqr-neg91.2%
sqrt-unprod91.2%
add-sqr-sqrt91.2%
Applied egg-rr91.2%
associate-*r/91.2%
*-rgt-identity91.2%
+-commutative91.2%
distribute-neg-in91.2%
distribute-neg-frac91.2%
metadata-eval91.2%
distribute-neg-frac91.2%
metadata-eval91.2%
Simplified91.2%
Final simplification86.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-105)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 1e-135)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-12)
(/ 1.0 (* n (+ x 0.5)))
(if (<= (/ 1.0 n) 2e+251) (- 1.0 t_0) (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 1e-135) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-105)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 1d-135) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d-12) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else if ((1.0d0 / n) <= 2d+251) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 1e-135) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-105: tmp = t_0 / (n * x) elif (1.0 / n) <= 1e-135: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-12: tmp = 1.0 / (n * (x + 0.5)) elif (1.0 / n) <= 2e+251: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-105) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 1e-135) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-12) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); elseif (Float64(1.0 / n) <= 2e+251) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-105) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 1e-135) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e-12) tmp = 1.0 / (n * (x + 0.5)); elseif ((1.0 / n) <= 2e+251) tmp = 1.0 - t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-105], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-135], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+251], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999963e-105Initial program 76.0%
Taylor expanded in n around 0 76.0%
log1p-def76.0%
Simplified76.0%
Taylor expanded in x around inf 88.8%
mul-1-neg88.8%
log-rec88.8%
distribute-neg-frac88.8%
remove-double-neg88.8%
*-rgt-identity88.8%
associate-*r/88.8%
exp-to-pow88.8%
*-commutative88.8%
Simplified88.8%
if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135Initial program 43.8%
Taylor expanded in n around inf 89.8%
+-rgt-identity89.8%
+-rgt-identity89.8%
log1p-def89.8%
Simplified89.8%
log1p-udef89.8%
diff-log89.9%
Applied egg-rr89.9%
if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13Initial program 18.5%
Taylor expanded in n around inf 43.7%
+-rgt-identity43.7%
+-rgt-identity43.7%
log1p-def43.7%
Simplified43.7%
clear-num43.7%
inv-pow43.7%
Applied egg-rr43.7%
unpow-143.7%
Simplified43.7%
Taylor expanded in x around inf 77.5%
*-commutative77.5%
distribute-lft-out77.5%
Simplified77.5%
if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251Initial program 68.4%
Taylor expanded in x around 0 64.6%
if 2.0000000000000001e251 < (/.f64 1 n) Initial program 4.0%
Taylor expanded in n around inf 16.9%
+-rgt-identity16.9%
+-rgt-identity16.9%
log1p-def16.9%
Simplified16.9%
Taylor expanded in x around inf 83.0%
Final simplification85.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-105)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-135)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e-12)
(/ 1.0 (* n (+ x 0.5)))
(if (<= (/ 1.0 n) 2e+251) (- 1.0 t_0) (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-105)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-135) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d-12) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else if ((1.0d0 / n) <= 2d+251) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-105) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-135) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e-12) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 2e+251) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-105: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-135: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e-12: tmp = 1.0 / (n * (x + 0.5)) elif (1.0 / n) <= 2e+251: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-105) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-135) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e-12) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); elseif (Float64(1.0 / n) <= 2e+251) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-105) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-135) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e-12) tmp = 1.0 / (n * (x + 0.5)); elseif ((1.0 / n) <= 2e+251) tmp = 1.0 - t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-105], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-135], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+251], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999963e-105Initial program 76.0%
Taylor expanded in n around 0 76.0%
log1p-def76.0%
Simplified76.0%
Taylor expanded in x around inf 88.8%
mul-1-neg88.8%
log-rec88.8%
distribute-neg-frac88.8%
remove-double-neg88.8%
*-rgt-identity88.8%
associate-*r/88.8%
exp-to-pow88.8%
*-commutative88.8%
Simplified88.8%
*-un-lft-identity88.8%
times-frac89.2%
Applied egg-rr89.2%
if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135Initial program 43.8%
Taylor expanded in n around inf 89.8%
+-rgt-identity89.8%
+-rgt-identity89.8%
log1p-def89.8%
Simplified89.8%
log1p-udef89.8%
diff-log89.9%
Applied egg-rr89.9%
if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13Initial program 18.5%
Taylor expanded in n around inf 43.7%
+-rgt-identity43.7%
+-rgt-identity43.7%
log1p-def43.7%
Simplified43.7%
clear-num43.7%
inv-pow43.7%
Applied egg-rr43.7%
unpow-143.7%
Simplified43.7%
Taylor expanded in x around inf 77.5%
*-commutative77.5%
distribute-lft-out77.5%
Simplified77.5%
if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251Initial program 68.4%
Taylor expanded in x around 0 64.6%
if 2.0000000000000001e251 < (/.f64 1 n) Initial program 4.0%
Taylor expanded in n around inf 16.9%
+-rgt-identity16.9%
+-rgt-identity16.9%
log1p-def16.9%
Simplified16.9%
Taylor expanded in x around inf 83.0%
Final simplification85.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 5.7e-195)
t_0
(if (<= x 8.5e-168)
t_1
(if (<= x 8.5e-135)
t_0
(if (<= x 6e-119)
t_1
(if (<= x 1.02e-37)
t_0
(if (<= x 1.0)
t_1
(if (<= x 7.6e+232)
(/ (/ 1.0 x) n)
(/ -0.5 (* n (pow x 2.0))))))))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 5.7e-195) {
tmp = t_0;
} else if (x <= 8.5e-168) {
tmp = t_1;
} else if (x <= 8.5e-135) {
tmp = t_0;
} else if (x <= 6e-119) {
tmp = t_1;
} else if (x <= 1.02e-37) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = t_1;
} else if (x <= 7.6e+232) {
tmp = (1.0 / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -log(x) / n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 5.7d-195) then
tmp = t_0
else if (x <= 8.5d-168) then
tmp = t_1
else if (x <= 8.5d-135) then
tmp = t_0
else if (x <= 6d-119) then
tmp = t_1
else if (x <= 1.02d-37) then
tmp = t_0
else if (x <= 1.0d0) then
tmp = t_1
else if (x <= 7.6d+232) then
tmp = (1.0d0 / 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 t_0 = -Math.log(x) / n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 5.7e-195) {
tmp = t_0;
} else if (x <= 8.5e-168) {
tmp = t_1;
} else if (x <= 8.5e-135) {
tmp = t_0;
} else if (x <= 6e-119) {
tmp = t_1;
} else if (x <= 1.02e-37) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = t_1;
} else if (x <= 7.6e+232) {
tmp = (1.0 / x) / n;
} else {
tmp = -0.5 / (n * Math.pow(x, 2.0));
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 5.7e-195: tmp = t_0 elif x <= 8.5e-168: tmp = t_1 elif x <= 8.5e-135: tmp = t_0 elif x <= 6e-119: tmp = t_1 elif x <= 1.02e-37: tmp = t_0 elif x <= 1.0: tmp = t_1 elif x <= 7.6e+232: tmp = (1.0 / x) / n else: tmp = -0.5 / (n * math.pow(x, 2.0)) return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 5.7e-195) tmp = t_0; elseif (x <= 8.5e-168) tmp = t_1; elseif (x <= 8.5e-135) tmp = t_0; elseif (x <= 6e-119) tmp = t_1; elseif (x <= 1.02e-37) tmp = t_0; elseif (x <= 1.0) tmp = t_1; elseif (x <= 7.6e+232) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(-0.5 / Float64(n * (x ^ 2.0))); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 5.7e-195) tmp = t_0; elseif (x <= 8.5e-168) tmp = t_1; elseif (x <= 8.5e-135) tmp = t_0; elseif (x <= 6e-119) tmp = t_1; elseif (x <= 1.02e-37) tmp = t_0; elseif (x <= 1.0) tmp = t_1; elseif (x <= 7.6e+232) tmp = (1.0 / x) / n; else tmp = -0.5 / (n * (x ^ 2.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5.7e-195], t$95$0, If[LessEqual[x, 8.5e-168], t$95$1, If[LessEqual[x, 8.5e-135], t$95$0, If[LessEqual[x, 6e-119], t$95$1, If[LessEqual[x, 1.02e-37], t$95$0, If[LessEqual[x, 1.0], t$95$1, If[LessEqual[x, 7.6e+232], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(-0.5 / N[(n * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 5.7 \cdot 10^{-195}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-168}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-135}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-119}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{-37}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{+232}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\
\end{array}
\end{array}
if x < 5.7e-195 or 8.4999999999999994e-168 < x < 8.49999999999999942e-135 or 6.0000000000000004e-119 < x < 1.02000000000000006e-37Initial program 36.0%
Taylor expanded in x around 0 36.0%
Taylor expanded in n around inf 56.4%
neg-mul-156.4%
distribute-neg-frac56.4%
Simplified56.4%
if 5.7e-195 < x < 8.4999999999999994e-168 or 8.49999999999999942e-135 < x < 6.0000000000000004e-119 or 1.02000000000000006e-37 < x < 1Initial program 70.1%
Taylor expanded in x around 0 67.7%
if 1 < x < 7.6000000000000002e232Initial program 58.8%
Taylor expanded in n around inf 58.8%
+-rgt-identity58.8%
+-rgt-identity58.8%
log1p-def58.8%
Simplified58.8%
Taylor expanded in x around inf 71.5%
if 7.6000000000000002e232 < x Initial program 91.4%
Taylor expanded in n around inf 91.4%
+-rgt-identity91.4%
+-rgt-identity91.4%
log1p-def91.4%
Simplified91.4%
Taylor expanded in x around inf 65.7%
associate-*r/65.7%
metadata-eval65.7%
Simplified65.7%
Taylor expanded in x around 0 91.4%
Final simplification67.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 6.3e-195)
t_0
(if (<= x 1.35e-165)
t_1
(if (<= x 8e-138)
(/ 1.0 (/ (- n) (log x)))
(if (<= x 8e-119)
t_1
(if (<= x 1.02e-37)
t_0
(if (<= x 0.95)
t_1
(if (<= x 3.5e+232)
(/ (/ 1.0 x) n)
(/ -0.5 (* n (pow x 2.0))))))))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 6.3e-195) {
tmp = t_0;
} else if (x <= 1.35e-165) {
tmp = t_1;
} else if (x <= 8e-138) {
tmp = 1.0 / (-n / log(x));
} else if (x <= 8e-119) {
tmp = t_1;
} else if (x <= 1.02e-37) {
tmp = t_0;
} else if (x <= 0.95) {
tmp = t_1;
} else if (x <= 3.5e+232) {
tmp = (1.0 / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -log(x) / n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 6.3d-195) then
tmp = t_0
else if (x <= 1.35d-165) then
tmp = t_1
else if (x <= 8d-138) then
tmp = 1.0d0 / (-n / log(x))
else if (x <= 8d-119) then
tmp = t_1
else if (x <= 1.02d-37) then
tmp = t_0
else if (x <= 0.95d0) then
tmp = t_1
else if (x <= 3.5d+232) then
tmp = (1.0d0 / 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 t_0 = -Math.log(x) / n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 6.3e-195) {
tmp = t_0;
} else if (x <= 1.35e-165) {
tmp = t_1;
} else if (x <= 8e-138) {
tmp = 1.0 / (-n / Math.log(x));
} else if (x <= 8e-119) {
tmp = t_1;
} else if (x <= 1.02e-37) {
tmp = t_0;
} else if (x <= 0.95) {
tmp = t_1;
} else if (x <= 3.5e+232) {
tmp = (1.0 / x) / n;
} else {
tmp = -0.5 / (n * Math.pow(x, 2.0));
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 6.3e-195: tmp = t_0 elif x <= 1.35e-165: tmp = t_1 elif x <= 8e-138: tmp = 1.0 / (-n / math.log(x)) elif x <= 8e-119: tmp = t_1 elif x <= 1.02e-37: tmp = t_0 elif x <= 0.95: tmp = t_1 elif x <= 3.5e+232: tmp = (1.0 / x) / n else: tmp = -0.5 / (n * math.pow(x, 2.0)) return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 6.3e-195) tmp = t_0; elseif (x <= 1.35e-165) tmp = t_1; elseif (x <= 8e-138) tmp = Float64(1.0 / Float64(Float64(-n) / log(x))); elseif (x <= 8e-119) tmp = t_1; elseif (x <= 1.02e-37) tmp = t_0; elseif (x <= 0.95) tmp = t_1; elseif (x <= 3.5e+232) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(-0.5 / Float64(n * (x ^ 2.0))); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 6.3e-195) tmp = t_0; elseif (x <= 1.35e-165) tmp = t_1; elseif (x <= 8e-138) tmp = 1.0 / (-n / log(x)); elseif (x <= 8e-119) tmp = t_1; elseif (x <= 1.02e-37) tmp = t_0; elseif (x <= 0.95) tmp = t_1; elseif (x <= 3.5e+232) tmp = (1.0 / x) / n; else tmp = -0.5 / (n * (x ^ 2.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 6.3e-195], t$95$0, If[LessEqual[x, 1.35e-165], t$95$1, If[LessEqual[x, 8e-138], N[(1.0 / N[((-n) / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e-119], t$95$1, If[LessEqual[x, 1.02e-37], t$95$0, If[LessEqual[x, 0.95], t$95$1, If[LessEqual[x, 3.5e+232], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(-0.5 / N[(n * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 6.3 \cdot 10^{-195}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-165}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-138}:\\
\;\;\;\;\frac{1}{\frac{-n}{\log x}}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-119}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{-37}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+232}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\
\end{array}
\end{array}
if x < 6.3e-195 or 8.0000000000000001e-119 < x < 1.02000000000000006e-37Initial program 36.8%
Taylor expanded in x around 0 36.8%
Taylor expanded in n around inf 54.2%
neg-mul-154.2%
distribute-neg-frac54.2%
Simplified54.2%
if 6.3e-195 < x < 1.3499999999999999e-165 or 8.00000000000000054e-138 < x < 8.0000000000000001e-119 or 1.02000000000000006e-37 < x < 0.94999999999999996Initial program 70.1%
Taylor expanded in x around 0 67.7%
if 1.3499999999999999e-165 < x < 8.00000000000000054e-138Initial program 31.1%
Taylor expanded in n around inf 68.2%
+-rgt-identity68.2%
+-rgt-identity68.2%
log1p-def68.2%
Simplified68.2%
clear-num68.5%
inv-pow68.5%
Applied egg-rr68.5%
unpow-168.5%
Simplified68.5%
Taylor expanded in x around 0 68.5%
associate-*r/68.5%
neg-mul-168.5%
Simplified68.5%
if 0.94999999999999996 < x < 3.50000000000000013e232Initial program 58.8%
Taylor expanded in n around inf 58.8%
+-rgt-identity58.8%
+-rgt-identity58.8%
log1p-def58.8%
Simplified58.8%
Taylor expanded in x around inf 71.5%
if 3.50000000000000013e232 < x Initial program 91.4%
Taylor expanded in n around inf 91.4%
+-rgt-identity91.4%
+-rgt-identity91.4%
log1p-def91.4%
Simplified91.4%
Taylor expanded in x around inf 65.7%
associate-*r/65.7%
metadata-eval65.7%
Simplified65.7%
Taylor expanded in x around 0 91.4%
Final simplification67.5%
(FPCore (x n) :precision binary64 (if (<= x 3.5e-8) (/ (- x (log x)) n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (x <= 3.5e-8) {
tmp = (x - log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.5d-8) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.5e-8) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.5e-8: tmp = (x - math.log(x)) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 3.5e-8) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.5e-8) tmp = (x - log(x)) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.5e-8], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 3.50000000000000024e-8Initial program 45.2%
Taylor expanded in n around inf 47.4%
+-rgt-identity47.4%
+-rgt-identity47.4%
log1p-def47.4%
Simplified47.4%
Taylor expanded in x around 0 47.4%
neg-mul-147.4%
unsub-neg47.4%
Simplified47.4%
if 3.50000000000000024e-8 < x Initial program 68.0%
Taylor expanded in n around inf 66.4%
+-rgt-identity66.4%
+-rgt-identity66.4%
log1p-def66.4%
Simplified66.4%
Taylor expanded in x around inf 68.9%
Final simplification57.4%
(FPCore (x n) :precision binary64 (if (<= x 3.5e-8) (/ (- (log x)) n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (x <= 3.5e-8) {
tmp = -log(x) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.5d-8) then
tmp = -log(x) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.5e-8) {
tmp = -Math.log(x) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.5e-8: tmp = -math.log(x) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 3.5e-8) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.5e-8) tmp = -log(x) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.5e-8], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 3.50000000000000024e-8Initial program 45.2%
Taylor expanded in x around 0 44.5%
Taylor expanded in n around inf 47.2%
neg-mul-147.2%
distribute-neg-frac47.2%
Simplified47.2%
if 3.50000000000000024e-8 < x Initial program 68.0%
Taylor expanded in n around inf 66.4%
+-rgt-identity66.4%
+-rgt-identity66.4%
log1p-def66.4%
Simplified66.4%
Taylor expanded in x around inf 68.9%
Final simplification57.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 55.8%
Taylor expanded in n around inf 56.2%
+-rgt-identity56.2%
+-rgt-identity56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around inf 44.2%
Final simplification44.2%
(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 55.8%
Taylor expanded in n around inf 56.2%
+-rgt-identity56.2%
+-rgt-identity56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around inf 44.2%
associate-/r*44.8%
Simplified44.8%
Final simplification44.8%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 55.8%
Taylor expanded in n around inf 56.2%
+-rgt-identity56.2%
+-rgt-identity56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around inf 44.8%
Final simplification44.8%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 55.8%
Taylor expanded in x around 0 32.7%
Taylor expanded in x around inf 4.3%
Final simplification4.3%
herbie shell --seed 2023339
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))