
(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 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 x) n)))
(if (<= (/ 1.0 n) -5e-88)
t_1
(if (<= (/ 1.0 n) 5e-101)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2e-33)
(/
(+
(/ 1.0 x)
(+ (/ 0.3333333333333333 (pow x 3.0)) (/ -0.5 (pow x 2.0))))
n)
(if (<= (/ 1.0 n) 2e-12)
(-
(log1p (- (pow (/ (- (log1p x) (log x)) n) 2.0)))
(log1p (/ (- (log x) (log1p x)) n)))
(if (<= (/ 1.0 n) 200000.0) 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 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-101) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2e-33) {
tmp = ((1.0 / x) + ((0.3333333333333333 / pow(x, 3.0)) + (-0.5 / pow(x, 2.0)))) / n;
} else if ((1.0 / n) <= 2e-12) {
tmp = log1p(-pow(((log1p(x) - log(x)) / n), 2.0)) - log1p(((log(x) - log1p(x)) / n));
} else if ((1.0 / n) <= 200000.0) {
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 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-101) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2e-33) {
tmp = ((1.0 / x) + ((0.3333333333333333 / Math.pow(x, 3.0)) + (-0.5 / Math.pow(x, 2.0)))) / n;
} else if ((1.0 / n) <= 2e-12) {
tmp = Math.log1p(-Math.pow(((Math.log1p(x) - Math.log(x)) / n), 2.0)) - Math.log1p(((Math.log(x) - Math.log1p(x)) / n));
} else if ((1.0 / n) <= 200000.0) {
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 = (t_0 / x) / n tmp = 0 if (1.0 / n) <= -5e-88: tmp = t_1 elif (1.0 / n) <= 5e-101: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2e-33: tmp = ((1.0 / x) + ((0.3333333333333333 / math.pow(x, 3.0)) + (-0.5 / math.pow(x, 2.0)))) / n elif (1.0 / n) <= 2e-12: tmp = math.log1p(-math.pow(((math.log1p(x) - math.log(x)) / n), 2.0)) - math.log1p(((math.log(x) - math.log1p(x)) / n)) elif (1.0 / n) <= 200000.0: 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(t_0 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-88) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-101) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2e-33) tmp = Float64(Float64(Float64(1.0 / x) + Float64(Float64(0.3333333333333333 / (x ^ 3.0)) + Float64(-0.5 / (x ^ 2.0)))) / n); elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(log1p(Float64(-(Float64(Float64(log1p(x) - log(x)) / n) ^ 2.0))) - log1p(Float64(Float64(log(x) - log1p(x)) / n))); elseif (Float64(1.0 / n) <= 200000.0) 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[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-88], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-101], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-33], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[(N[Log[1 + (-N[Power[N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], 2.0], $MachinePrecision])], $MachinePrecision] - N[Log[1 + N[(N[(N[Log[x], $MachinePrecision] - N[Log[1 + x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], 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{\frac{t\_0}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-101}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\frac{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{{x}^{2}}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{log1p}\left(-{\left(\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right)}^{2}\right) - \mathsf{log1p}\left(\frac{\log x - \mathsf{log1p}\left(x\right)}{n}\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000009e-88 or 1.99999999999999996e-12 < (/.f64 1 n) < 2e5Initial program 71.0%
Taylor expanded in x around inf 90.2%
log-rec90.2%
mul-1-neg90.2%
associate-*r/90.2%
associate-*r*90.2%
metadata-eval90.2%
*-commutative90.2%
associate-/l*90.2%
exp-to-pow90.3%
*-commutative90.3%
Simplified90.3%
*-un-lft-identity90.3%
associate-/r*91.3%
pow191.3%
pow-div90.9%
Applied egg-rr90.9%
*-lft-identity90.9%
sub-neg90.9%
metadata-eval90.9%
Simplified90.9%
+-commutative90.9%
unpow-prod-up91.3%
inv-pow91.3%
Applied egg-rr91.3%
associate-*l/91.3%
*-lft-identity91.3%
Simplified91.3%
if -5.00000000000000009e-88 < (/.f64 1 n) < 5.0000000000000001e-101Initial program 38.2%
Taylor expanded in n around inf 90.1%
+-rgt-identity90.1%
+-rgt-identity90.1%
log1p-define90.1%
Simplified90.1%
log1p-undefine90.1%
diff-log90.2%
Applied egg-rr90.2%
clear-num90.2%
log-rec90.3%
Applied egg-rr90.3%
if 5.0000000000000001e-101 < (/.f64 1 n) < 2.0000000000000001e-33Initial program 4.6%
Taylor expanded in n around inf 39.1%
+-rgt-identity39.1%
+-rgt-identity39.1%
log1p-define39.1%
Simplified39.1%
Taylor expanded in x around inf 71.4%
+-commutative71.4%
associate--l+71.4%
sub-neg71.4%
associate-*r/71.4%
metadata-eval71.4%
associate-*r/71.4%
metadata-eval71.4%
distribute-neg-frac71.4%
metadata-eval71.4%
Simplified71.4%
if 2.0000000000000001e-33 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 15.9%
Taylor expanded in n around inf 78.8%
+-rgt-identity78.8%
+-rgt-identity78.8%
log1p-define78.8%
Simplified78.8%
add-log-exp14.8%
div-inv14.8%
exp-prod14.8%
exp-diff14.8%
add-exp-log14.8%
log1p-undefine14.8%
rem-exp-log14.8%
Applied egg-rr14.8%
Taylor expanded in n around inf 14.8%
flip-+14.6%
log-div15.9%
metadata-eval15.9%
pow215.9%
log-div15.9%
log1p-define15.9%
log-div15.9%
log1p-define15.9%
Applied egg-rr15.9%
sub-neg15.9%
log1p-define15.2%
sub-neg15.2%
distribute-neg-frac15.2%
neg-sub015.2%
associate--r-15.2%
metadata-eval15.2%
log1p-undefine15.2%
+-commutative15.2%
log-div15.2%
+-commutative15.2%
log-rec15.2%
+-commutative15.2%
log1p-undefine15.2%
sub-neg15.2%
log1p-undefine15.2%
log-div15.2%
Simplified84.4%
if 2e5 < (/.f64 1 n) Initial program 49.8%
Taylor expanded in n around 0 49.8%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification90.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 x) n)))
(if (<= (/ 1.0 n) -5e-88)
t_1
(if (<= (/ 1.0 n) 5e-101)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2e-33)
(/
(+
(/ 1.0 x)
(+ (/ 0.3333333333333333 (pow x 3.0)) (/ -0.5 (pow x 2.0))))
n)
(if (<= (/ 1.0 n) 1e-18)
(/ (* n (log (+ 1.0 (/ 1.0 x)))) (pow n 2.0))
(if (<= (/ 1.0 n) 200000.0) 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 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-101) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2e-33) {
tmp = ((1.0 / x) + ((0.3333333333333333 / pow(x, 3.0)) + (-0.5 / pow(x, 2.0)))) / n;
} else if ((1.0 / n) <= 1e-18) {
tmp = (n * log((1.0 + (1.0 / x)))) / pow(n, 2.0);
} else if ((1.0 / n) <= 200000.0) {
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 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-101) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2e-33) {
tmp = ((1.0 / x) + ((0.3333333333333333 / Math.pow(x, 3.0)) + (-0.5 / Math.pow(x, 2.0)))) / n;
} else if ((1.0 / n) <= 1e-18) {
tmp = (n * Math.log((1.0 + (1.0 / x)))) / Math.pow(n, 2.0);
} else if ((1.0 / n) <= 200000.0) {
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 = (t_0 / x) / n tmp = 0 if (1.0 / n) <= -5e-88: tmp = t_1 elif (1.0 / n) <= 5e-101: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2e-33: tmp = ((1.0 / x) + ((0.3333333333333333 / math.pow(x, 3.0)) + (-0.5 / math.pow(x, 2.0)))) / n elif (1.0 / n) <= 1e-18: tmp = (n * math.log((1.0 + (1.0 / x)))) / math.pow(n, 2.0) elif (1.0 / n) <= 200000.0: 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(t_0 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-88) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-101) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2e-33) tmp = Float64(Float64(Float64(1.0 / x) + Float64(Float64(0.3333333333333333 / (x ^ 3.0)) + Float64(-0.5 / (x ^ 2.0)))) / n); elseif (Float64(1.0 / n) <= 1e-18) tmp = Float64(Float64(n * log(Float64(1.0 + Float64(1.0 / x)))) / (n ^ 2.0)); elseif (Float64(1.0 / n) <= 200000.0) 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[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-88], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-101], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-33], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-18], N[(N[(n * N[Log[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], 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{\frac{t\_0}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-101}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\frac{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{{x}^{2}}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-18}:\\
\;\;\;\;\frac{n \cdot \log \left(1 + \frac{1}{x}\right)}{{n}^{2}}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000009e-88 or 1.0000000000000001e-18 < (/.f64 1 n) < 2e5Initial program 70.2%
Taylor expanded in x around inf 89.4%
log-rec89.4%
mul-1-neg89.4%
associate-*r/89.4%
associate-*r*89.4%
metadata-eval89.4%
*-commutative89.4%
associate-/l*89.5%
exp-to-pow89.5%
*-commutative89.5%
Simplified89.5%
*-un-lft-identity89.5%
associate-/r*90.5%
pow190.5%
pow-div90.1%
Applied egg-rr90.1%
*-lft-identity90.1%
sub-neg90.1%
metadata-eval90.1%
Simplified90.1%
+-commutative90.1%
unpow-prod-up90.5%
inv-pow90.5%
Applied egg-rr90.5%
associate-*l/90.5%
*-lft-identity90.5%
Simplified90.5%
if -5.00000000000000009e-88 < (/.f64 1 n) < 5.0000000000000001e-101Initial program 38.2%
Taylor expanded in n around inf 90.1%
+-rgt-identity90.1%
+-rgt-identity90.1%
log1p-define90.1%
Simplified90.1%
log1p-undefine90.1%
diff-log90.2%
Applied egg-rr90.2%
clear-num90.2%
log-rec90.3%
Applied egg-rr90.3%
if 5.0000000000000001e-101 < (/.f64 1 n) < 2.0000000000000001e-33Initial program 4.6%
Taylor expanded in n around inf 39.1%
+-rgt-identity39.1%
+-rgt-identity39.1%
log1p-define39.1%
Simplified39.1%
Taylor expanded in x around inf 71.4%
+-commutative71.4%
associate--l+71.4%
sub-neg71.4%
associate-*r/71.4%
metadata-eval71.4%
associate-*r/71.4%
metadata-eval71.4%
distribute-neg-frac71.4%
metadata-eval71.4%
Simplified71.4%
if 2.0000000000000001e-33 < (/.f64 1 n) < 1.0000000000000001e-18Initial program 8.2%
Taylor expanded in n around inf 99.6%
+-rgt-identity99.6%
+-rgt-identity99.6%
log1p-define99.6%
Simplified99.6%
add-log-exp7.2%
div-inv7.2%
exp-prod7.2%
exp-diff7.2%
add-exp-log7.2%
log1p-undefine7.2%
rem-exp-log7.2%
Applied egg-rr7.2%
pow-to-exp7.2%
div-inv7.2%
add-log-exp99.6%
log-div99.6%
log1p-undefine99.6%
div-sub99.6%
frac-sub100.0%
pow2100.0%
Applied egg-rr100.0%
*-commutative100.0%
distribute-lft-out--100.0%
log1p-define100.0%
log-div100.0%
*-lft-identity100.0%
associate-*l/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
rgt-mult-inverse100.0%
*-lft-identity100.0%
Simplified100.0%
if 2e5 < (/.f64 1 n) Initial program 49.8%
Taylor expanded in n around 0 49.8%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification90.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 x) n)))
(if (<= (/ 1.0 n) -5e-88)
t_1
(if (<= (/ 1.0 n) 5e-101)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2e-39)
(/ (- (/ 1.0 x) (/ 0.5 (pow x 2.0))) n)
(if (<= (/ 1.0 n) 1e-18)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 200000.0)
t_1
(if (<= (/ 1.0 n) 2e+78)
(- 1.0 t_0)
(log1p (expm1 (/ 1.0 (* n x))))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-101) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2e-39) {
tmp = ((1.0 / x) - (0.5 / pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 1e-18) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+78) {
tmp = 1.0 - 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 t_1 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-101) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2e-39) {
tmp = ((1.0 / x) - (0.5 / Math.pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 1e-18) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+78) {
tmp = 1.0 - 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)) t_1 = (t_0 / x) / n tmp = 0 if (1.0 / n) <= -5e-88: tmp = t_1 elif (1.0 / n) <= 5e-101: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2e-39: tmp = ((1.0 / x) - (0.5 / math.pow(x, 2.0))) / n elif (1.0 / n) <= 1e-18: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 200000.0: tmp = t_1 elif (1.0 / n) <= 2e+78: tmp = 1.0 - 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) t_1 = Float64(Float64(t_0 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-88) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-101) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2e-39) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / (x ^ 2.0))) / n); elseif (Float64(1.0 / n) <= 1e-18) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 200000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+78) tmp = Float64(1.0 - 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]}, Block[{t$95$1 = N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-88], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-101], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-39], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-18], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+78], N[(1.0 - 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)}\\
t_1 := \frac{\frac{t\_0}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-101}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{{x}^{2}}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+78}:\\
\;\;\;\;1 - 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) < -5.00000000000000009e-88 or 1.0000000000000001e-18 < (/.f64 1 n) < 2e5Initial program 70.2%
Taylor expanded in x around inf 89.4%
log-rec89.4%
mul-1-neg89.4%
associate-*r/89.4%
associate-*r*89.4%
metadata-eval89.4%
*-commutative89.4%
associate-/l*89.5%
exp-to-pow89.5%
*-commutative89.5%
Simplified89.5%
*-un-lft-identity89.5%
associate-/r*90.5%
pow190.5%
pow-div90.1%
Applied egg-rr90.1%
*-lft-identity90.1%
sub-neg90.1%
metadata-eval90.1%
Simplified90.1%
+-commutative90.1%
unpow-prod-up90.5%
inv-pow90.5%
Applied egg-rr90.5%
associate-*l/90.5%
*-lft-identity90.5%
Simplified90.5%
if -5.00000000000000009e-88 < (/.f64 1 n) < 5.0000000000000001e-101Initial program 38.2%
Taylor expanded in n around inf 90.1%
+-rgt-identity90.1%
+-rgt-identity90.1%
log1p-define90.1%
Simplified90.1%
log1p-undefine90.1%
diff-log90.2%
Applied egg-rr90.2%
clear-num90.2%
log-rec90.3%
Applied egg-rr90.3%
if 5.0000000000000001e-101 < (/.f64 1 n) < 1.99999999999999986e-39Initial program 4.7%
Taylor expanded in n around inf 37.3%
+-rgt-identity37.3%
+-rgt-identity37.3%
log1p-define37.3%
Simplified37.3%
Taylor expanded in x around inf 72.9%
associate-*r/72.9%
metadata-eval72.9%
Simplified72.9%
if 1.99999999999999986e-39 < (/.f64 1 n) < 1.0000000000000001e-18Initial program 6.9%
Taylor expanded in n around inf 83.9%
+-rgt-identity83.9%
+-rgt-identity83.9%
log1p-define83.9%
Simplified83.9%
log1p-undefine83.9%
diff-log83.9%
Applied egg-rr83.9%
if 2e5 < (/.f64 1 n) < 2.00000000000000002e78Initial program 100.0%
Taylor expanded in x around 0 100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if 2.00000000000000002e78 < (/.f64 1 n) Initial program 26.1%
Taylor expanded in n around inf 5.9%
+-rgt-identity5.9%
+-rgt-identity5.9%
log1p-define5.9%
Simplified5.9%
Taylor expanded in x around inf 35.4%
*-commutative35.4%
Simplified35.4%
log1p-expm1-u79.6%
Applied egg-rr79.6%
Final simplification88.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 x) n)))
(if (<= (/ 1.0 n) -5e-88)
t_1
(if (<= (/ 1.0 n) 5e-101)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2e-33)
(/
(+
(/ 1.0 x)
(+ (/ 0.3333333333333333 (pow x 3.0)) (/ -0.5 (pow x 2.0))))
n)
(if (<= (/ 1.0 n) 1e-18)
(/ (* n (log (+ 1.0 (/ 1.0 x)))) (pow n 2.0))
(if (<= (/ 1.0 n) 200000.0)
t_1
(if (<= (/ 1.0 n) 2e+78)
(- 1.0 t_0)
(log1p (expm1 (/ 1.0 (* n x))))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-101) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2e-33) {
tmp = ((1.0 / x) + ((0.3333333333333333 / pow(x, 3.0)) + (-0.5 / pow(x, 2.0)))) / n;
} else if ((1.0 / n) <= 1e-18) {
tmp = (n * log((1.0 + (1.0 / x)))) / pow(n, 2.0);
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+78) {
tmp = 1.0 - 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 t_1 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-101) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2e-33) {
tmp = ((1.0 / x) + ((0.3333333333333333 / Math.pow(x, 3.0)) + (-0.5 / Math.pow(x, 2.0)))) / n;
} else if ((1.0 / n) <= 1e-18) {
tmp = (n * Math.log((1.0 + (1.0 / x)))) / Math.pow(n, 2.0);
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+78) {
tmp = 1.0 - 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)) t_1 = (t_0 / x) / n tmp = 0 if (1.0 / n) <= -5e-88: tmp = t_1 elif (1.0 / n) <= 5e-101: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2e-33: tmp = ((1.0 / x) + ((0.3333333333333333 / math.pow(x, 3.0)) + (-0.5 / math.pow(x, 2.0)))) / n elif (1.0 / n) <= 1e-18: tmp = (n * math.log((1.0 + (1.0 / x)))) / math.pow(n, 2.0) elif (1.0 / n) <= 200000.0: tmp = t_1 elif (1.0 / n) <= 2e+78: tmp = 1.0 - 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) t_1 = Float64(Float64(t_0 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-88) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-101) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2e-33) tmp = Float64(Float64(Float64(1.0 / x) + Float64(Float64(0.3333333333333333 / (x ^ 3.0)) + Float64(-0.5 / (x ^ 2.0)))) / n); elseif (Float64(1.0 / n) <= 1e-18) tmp = Float64(Float64(n * log(Float64(1.0 + Float64(1.0 / x)))) / (n ^ 2.0)); elseif (Float64(1.0 / n) <= 200000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+78) tmp = Float64(1.0 - 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]}, Block[{t$95$1 = N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-88], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-101], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-33], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-18], N[(N[(n * N[Log[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+78], N[(1.0 - 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)}\\
t_1 := \frac{\frac{t\_0}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-101}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\frac{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{{x}^{2}}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-18}:\\
\;\;\;\;\frac{n \cdot \log \left(1 + \frac{1}{x}\right)}{{n}^{2}}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+78}:\\
\;\;\;\;1 - 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) < -5.00000000000000009e-88 or 1.0000000000000001e-18 < (/.f64 1 n) < 2e5Initial program 70.2%
Taylor expanded in x around inf 89.4%
log-rec89.4%
mul-1-neg89.4%
associate-*r/89.4%
associate-*r*89.4%
metadata-eval89.4%
*-commutative89.4%
associate-/l*89.5%
exp-to-pow89.5%
*-commutative89.5%
Simplified89.5%
*-un-lft-identity89.5%
associate-/r*90.5%
pow190.5%
pow-div90.1%
Applied egg-rr90.1%
*-lft-identity90.1%
sub-neg90.1%
metadata-eval90.1%
Simplified90.1%
+-commutative90.1%
unpow-prod-up90.5%
inv-pow90.5%
Applied egg-rr90.5%
associate-*l/90.5%
*-lft-identity90.5%
Simplified90.5%
if -5.00000000000000009e-88 < (/.f64 1 n) < 5.0000000000000001e-101Initial program 38.2%
Taylor expanded in n around inf 90.1%
+-rgt-identity90.1%
+-rgt-identity90.1%
log1p-define90.1%
Simplified90.1%
log1p-undefine90.1%
diff-log90.2%
Applied egg-rr90.2%
clear-num90.2%
log-rec90.3%
Applied egg-rr90.3%
if 5.0000000000000001e-101 < (/.f64 1 n) < 2.0000000000000001e-33Initial program 4.6%
Taylor expanded in n around inf 39.1%
+-rgt-identity39.1%
+-rgt-identity39.1%
log1p-define39.1%
Simplified39.1%
Taylor expanded in x around inf 71.4%
+-commutative71.4%
associate--l+71.4%
sub-neg71.4%
associate-*r/71.4%
metadata-eval71.4%
associate-*r/71.4%
metadata-eval71.4%
distribute-neg-frac71.4%
metadata-eval71.4%
Simplified71.4%
if 2.0000000000000001e-33 < (/.f64 1 n) < 1.0000000000000001e-18Initial program 8.2%
Taylor expanded in n around inf 99.6%
+-rgt-identity99.6%
+-rgt-identity99.6%
log1p-define99.6%
Simplified99.6%
add-log-exp7.2%
div-inv7.2%
exp-prod7.2%
exp-diff7.2%
add-exp-log7.2%
log1p-undefine7.2%
rem-exp-log7.2%
Applied egg-rr7.2%
pow-to-exp7.2%
div-inv7.2%
add-log-exp99.6%
log-div99.6%
log1p-undefine99.6%
div-sub99.6%
frac-sub100.0%
pow2100.0%
Applied egg-rr100.0%
*-commutative100.0%
distribute-lft-out--100.0%
log1p-define100.0%
log-div100.0%
*-lft-identity100.0%
associate-*l/100.0%
+-commutative100.0%
distribute-rgt-in100.0%
rgt-mult-inverse100.0%
*-lft-identity100.0%
Simplified100.0%
if 2e5 < (/.f64 1 n) < 2.00000000000000002e78Initial program 100.0%
Taylor expanded in x around 0 100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if 2.00000000000000002e78 < (/.f64 1 n) Initial program 26.1%
Taylor expanded in n around inf 5.9%
+-rgt-identity5.9%
+-rgt-identity5.9%
log1p-define5.9%
Simplified5.9%
Taylor expanded in x around inf 35.4%
*-commutative35.4%
Simplified35.4%
log1p-expm1-u79.6%
Applied egg-rr79.6%
Final simplification88.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))) (t_1 (pow x (/ 1.0 n))) (t_2 (/ (/ t_1 x) n)))
(if (<= (/ 1.0 n) -5e-88)
t_2
(if (<= (/ 1.0 n) 5e-101)
(/ (log t_0) (- n))
(if (<= (/ 1.0 n) 2e-39)
(/ (- (/ 1.0 x) (/ 0.5 (pow x 2.0))) n)
(if (<= (/ 1.0 n) 1e-18)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 200000.0)
t_2
(if (<= (/ 1.0 n) 2e+78)
(- 1.0 t_1)
(/ (log1p (+ t_0 -1.0)) (- n))))))))))
double code(double x, double n) {
double t_0 = x / (1.0 + x);
double t_1 = pow(x, (1.0 / n));
double t_2 = (t_1 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_2;
} else if ((1.0 / n) <= 5e-101) {
tmp = log(t_0) / -n;
} else if ((1.0 / n) <= 2e-39) {
tmp = ((1.0 / x) - (0.5 / pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 1e-18) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_2;
} else if ((1.0 / n) <= 2e+78) {
tmp = 1.0 - t_1;
} else {
tmp = log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = x / (1.0 + x);
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = (t_1 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_2;
} else if ((1.0 / n) <= 5e-101) {
tmp = Math.log(t_0) / -n;
} else if ((1.0 / n) <= 2e-39) {
tmp = ((1.0 / x) - (0.5 / Math.pow(x, 2.0))) / n;
} else if ((1.0 / n) <= 1e-18) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_2;
} else if ((1.0 / n) <= 2e+78) {
tmp = 1.0 - t_1;
} else {
tmp = Math.log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = x / (1.0 + x) t_1 = math.pow(x, (1.0 / n)) t_2 = (t_1 / x) / n tmp = 0 if (1.0 / n) <= -5e-88: tmp = t_2 elif (1.0 / n) <= 5e-101: tmp = math.log(t_0) / -n elif (1.0 / n) <= 2e-39: tmp = ((1.0 / x) - (0.5 / math.pow(x, 2.0))) / n elif (1.0 / n) <= 1e-18: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 200000.0: tmp = t_2 elif (1.0 / n) <= 2e+78: tmp = 1.0 - t_1 else: tmp = math.log1p((t_0 + -1.0)) / -n return tmp
function code(x, n) t_0 = Float64(x / Float64(1.0 + x)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(Float64(t_1 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-88) tmp = t_2; elseif (Float64(1.0 / n) <= 5e-101) tmp = Float64(log(t_0) / Float64(-n)); elseif (Float64(1.0 / n) <= 2e-39) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / (x ^ 2.0))) / n); elseif (Float64(1.0 / n) <= 1e-18) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 200000.0) tmp = t_2; elseif (Float64(1.0 / n) <= 2e+78) tmp = Float64(1.0 - t_1); else tmp = Float64(log1p(Float64(t_0 + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-88], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-101], N[(N[Log[t$95$0], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-39], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-18], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+78], N[(1.0 - t$95$1), $MachinePrecision], N[(N[Log[1 + N[(t$95$0 + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{\frac{t\_1}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-88}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-101}:\\
\;\;\;\;\frac{\log t\_0}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{{x}^{2}}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+78}:\\
\;\;\;\;1 - t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(t\_0 + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000009e-88 or 1.0000000000000001e-18 < (/.f64 1 n) < 2e5Initial program 70.2%
Taylor expanded in x around inf 89.4%
log-rec89.4%
mul-1-neg89.4%
associate-*r/89.4%
associate-*r*89.4%
metadata-eval89.4%
*-commutative89.4%
associate-/l*89.5%
exp-to-pow89.5%
*-commutative89.5%
Simplified89.5%
*-un-lft-identity89.5%
associate-/r*90.5%
pow190.5%
pow-div90.1%
Applied egg-rr90.1%
*-lft-identity90.1%
sub-neg90.1%
metadata-eval90.1%
Simplified90.1%
+-commutative90.1%
unpow-prod-up90.5%
inv-pow90.5%
Applied egg-rr90.5%
associate-*l/90.5%
*-lft-identity90.5%
Simplified90.5%
if -5.00000000000000009e-88 < (/.f64 1 n) < 5.0000000000000001e-101Initial program 38.2%
Taylor expanded in n around inf 90.1%
+-rgt-identity90.1%
+-rgt-identity90.1%
log1p-define90.1%
Simplified90.1%
log1p-undefine90.1%
diff-log90.2%
Applied egg-rr90.2%
clear-num90.2%
log-rec90.3%
Applied egg-rr90.3%
if 5.0000000000000001e-101 < (/.f64 1 n) < 1.99999999999999986e-39Initial program 4.7%
Taylor expanded in n around inf 37.3%
+-rgt-identity37.3%
+-rgt-identity37.3%
log1p-define37.3%
Simplified37.3%
Taylor expanded in x around inf 72.9%
associate-*r/72.9%
metadata-eval72.9%
Simplified72.9%
if 1.99999999999999986e-39 < (/.f64 1 n) < 1.0000000000000001e-18Initial program 6.9%
Taylor expanded in n around inf 83.9%
+-rgt-identity83.9%
+-rgt-identity83.9%
log1p-define83.9%
Simplified83.9%
log1p-undefine83.9%
diff-log83.9%
Applied egg-rr83.9%
if 2e5 < (/.f64 1 n) < 2.00000000000000002e78Initial program 100.0%
Taylor expanded in x around 0 100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if 2.00000000000000002e78 < (/.f64 1 n) Initial program 26.1%
Taylor expanded in n around inf 5.9%
+-rgt-identity5.9%
+-rgt-identity5.9%
log1p-define5.9%
Simplified5.9%
log1p-undefine5.9%
diff-log5.9%
Applied egg-rr5.9%
clear-num5.9%
log-rec5.9%
Applied egg-rr5.9%
add-sqr-sqrt0.0%
sqrt-unprod0.4%
sqr-neg0.4%
neg-log0.4%
clear-num0.4%
neg-log0.4%
clear-num0.4%
sqrt-unprod0.4%
add-sqr-sqrt0.4%
log1p-expm1-u0.4%
add-sqr-sqrt0.4%
sqrt-unprod0.4%
clear-num0.4%
neg-log0.4%
clear-num0.4%
neg-log0.4%
Applied egg-rr74.5%
Final simplification88.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ x (+ 1.0 x))) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= n -4.5e+87)
t_0
(if (<= n -1400.0)
(* (/ 1.0 n) (/ 1.0 x))
(if (<= n -4.5e-150)
t_1
(if (<= n -1.2e-275)
(/ 0.0 n)
(if (<= n 1.52e-217)
(/ 1.0 (* n x))
(if (<= n 1350000000.0) t_1 t_0))))))))
double code(double x, double n) {
double t_0 = log((x / (1.0 + x))) / -n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (n <= -4.5e+87) {
tmp = t_0;
} else if (n <= -1400.0) {
tmp = (1.0 / n) * (1.0 / x);
} else if (n <= -4.5e-150) {
tmp = t_1;
} else if (n <= -1.2e-275) {
tmp = 0.0 / n;
} else if (n <= 1.52e-217) {
tmp = 1.0 / (n * x);
} else if (n <= 1350000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log((x / (1.0d0 + x))) / -n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (n <= (-4.5d+87)) then
tmp = t_0
else if (n <= (-1400.0d0)) then
tmp = (1.0d0 / n) * (1.0d0 / x)
else if (n <= (-4.5d-150)) then
tmp = t_1
else if (n <= (-1.2d-275)) then
tmp = 0.0d0 / n
else if (n <= 1.52d-217) then
tmp = 1.0d0 / (n * x)
else if (n <= 1350000000.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log((x / (1.0 + x))) / -n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (n <= -4.5e+87) {
tmp = t_0;
} else if (n <= -1400.0) {
tmp = (1.0 / n) * (1.0 / x);
} else if (n <= -4.5e-150) {
tmp = t_1;
} else if (n <= -1.2e-275) {
tmp = 0.0 / n;
} else if (n <= 1.52e-217) {
tmp = 1.0 / (n * x);
} else if (n <= 1350000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.log((x / (1.0 + x))) / -n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if n <= -4.5e+87: tmp = t_0 elif n <= -1400.0: tmp = (1.0 / n) * (1.0 / x) elif n <= -4.5e-150: tmp = t_1 elif n <= -1.2e-275: tmp = 0.0 / n elif n <= 1.52e-217: tmp = 1.0 / (n * x) elif n <= 1350000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (n <= -4.5e+87) tmp = t_0; elseif (n <= -1400.0) tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); elseif (n <= -4.5e-150) tmp = t_1; elseif (n <= -1.2e-275) tmp = Float64(0.0 / n); elseif (n <= 1.52e-217) tmp = Float64(1.0 / Float64(n * x)); elseif (n <= 1350000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = log((x / (1.0 + x))) / -n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (n <= -4.5e+87) tmp = t_0; elseif (n <= -1400.0) tmp = (1.0 / n) * (1.0 / x); elseif (n <= -4.5e-150) tmp = t_1; elseif (n <= -1.2e-275) tmp = 0.0 / n; elseif (n <= 1.52e-217) tmp = 1.0 / (n * x); elseif (n <= 1350000000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -4.5e+87], t$95$0, If[LessEqual[n, -1400.0], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -4.5e-150], t$95$1, If[LessEqual[n, -1.2e-275], N[(0.0 / n), $MachinePrecision], If[LessEqual[n, 1.52e-217], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1350000000.0], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;n \leq -4.5 \cdot 10^{+87}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -1400:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;n \leq -4.5 \cdot 10^{-150}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq -1.2 \cdot 10^{-275}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;n \leq 1.52 \cdot 10^{-217}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;n \leq 1350000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -4.5000000000000003e87 or 1.35e9 < n Initial program 32.9%
Taylor expanded in n around inf 82.2%
+-rgt-identity82.2%
+-rgt-identity82.2%
log1p-define82.2%
Simplified82.2%
log1p-undefine82.2%
diff-log82.5%
Applied egg-rr82.5%
clear-num82.5%
log-rec82.6%
Applied egg-rr82.6%
if -4.5000000000000003e87 < n < -1400Initial program 12.8%
Taylor expanded in n around inf 36.9%
+-rgt-identity36.9%
+-rgt-identity36.9%
log1p-define36.9%
Simplified36.9%
Taylor expanded in x around inf 64.2%
*-commutative64.2%
Simplified64.2%
inv-pow64.2%
unpow-prod-down64.5%
inv-pow64.5%
inv-pow64.5%
Applied egg-rr64.5%
if -1400 < n < -4.5000000000000002e-150 or 1.5199999999999999e-217 < n < 1.35e9Initial program 80.6%
Taylor expanded in x around 0 58.2%
*-rgt-identity58.2%
associate-/l*58.2%
exp-to-pow58.2%
Simplified58.2%
if -4.5000000000000002e-150 < n < -1.19999999999999995e-275Initial program 100.0%
Taylor expanded in n around inf 60.5%
+-rgt-identity60.5%
+-rgt-identity60.5%
log1p-define60.5%
Simplified60.5%
log1p-undefine60.5%
diff-log60.5%
Applied egg-rr60.5%
Taylor expanded in x around inf 67.2%
if -1.19999999999999995e-275 < n < 1.5199999999999999e-217Initial program 63.7%
Taylor expanded in n around inf 32.7%
+-rgt-identity32.7%
+-rgt-identity32.7%
log1p-define32.7%
Simplified32.7%
Taylor expanded in x around inf 69.6%
*-commutative69.6%
Simplified69.6%
Final simplification73.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 x) n)))
(if (<= (/ 1.0 n) -5e-88)
t_1
(if (<= (/ 1.0 n) 2e-73)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 200000.0)
t_1
(if (<= (/ 1.0 n) 2e+233)
(- (+ 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 t_1 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-73) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+233) {
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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / x) / n
if ((1.0d0 / n) <= (-5d-88)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-73) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 200000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 2d+233) 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 t_1 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-73) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+233) {
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)) t_1 = (t_0 / x) / n tmp = 0 if (1.0 / n) <= -5e-88: tmp = t_1 elif (1.0 / n) <= 2e-73: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 200000.0: tmp = t_1 elif (1.0 / n) <= 2e+233: 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) t_1 = Float64(Float64(t_0 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-88) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-73) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 200000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+233) 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); t_1 = (t_0 / x) / n; tmp = 0.0; if ((1.0 / n) <= -5e-88) tmp = t_1; elseif ((1.0 / n) <= 2e-73) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 200000.0) tmp = t_1; elseif ((1.0 / n) <= 2e+233) 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]}, Block[{t$95$1 = N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-88], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-73], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+233], 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)}\\
t_1 := \frac{\frac{t\_0}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-73}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+233}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000009e-88 or 1.99999999999999999e-73 < (/.f64 1 n) < 2e5Initial program 62.1%
Taylor expanded in x around inf 85.3%
log-rec85.3%
mul-1-neg85.3%
associate-*r/85.3%
associate-*r*85.3%
metadata-eval85.3%
*-commutative85.3%
associate-/l*85.4%
exp-to-pow85.4%
*-commutative85.4%
Simplified85.4%
*-un-lft-identity85.4%
associate-/r*86.3%
pow186.3%
pow-div85.9%
Applied egg-rr85.9%
*-lft-identity85.9%
sub-neg85.9%
metadata-eval85.9%
Simplified85.9%
+-commutative85.9%
unpow-prod-up86.2%
inv-pow86.3%
Applied egg-rr86.3%
associate-*l/86.3%
*-lft-identity86.3%
Simplified86.3%
if -5.00000000000000009e-88 < (/.f64 1 n) < 1.99999999999999999e-73Initial program 36.2%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.1%
Applied egg-rr88.1%
clear-num88.1%
log-rec88.1%
Applied egg-rr88.1%
if 2e5 < (/.f64 1 n) < 1.99999999999999995e233Initial program 62.6%
Taylor expanded in x around 0 60.6%
if 1.99999999999999995e233 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 8.7%
+-rgt-identity8.7%
+-rgt-identity8.7%
log1p-define8.7%
Simplified8.7%
Taylor expanded in x around inf 85.1%
*-commutative85.1%
Simplified85.1%
Final simplification84.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))) (t_1 (pow x (/ 1.0 n))) (t_2 (/ (/ t_1 x) n)))
(if (<= (/ 1.0 n) -5e-88)
t_2
(if (<= (/ 1.0 n) 2e-73)
(/ (log t_0) (- n))
(if (<= (/ 1.0 n) 200000.0)
t_2
(if (<= (/ 1.0 n) 2e+78)
(- 1.0 t_1)
(/ (log1p (+ t_0 -1.0)) (- n))))))))
double code(double x, double n) {
double t_0 = x / (1.0 + x);
double t_1 = pow(x, (1.0 / n));
double t_2 = (t_1 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_2;
} else if ((1.0 / n) <= 2e-73) {
tmp = log(t_0) / -n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_2;
} else if ((1.0 / n) <= 2e+78) {
tmp = 1.0 - t_1;
} else {
tmp = log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = x / (1.0 + x);
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = (t_1 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_2;
} else if ((1.0 / n) <= 2e-73) {
tmp = Math.log(t_0) / -n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_2;
} else if ((1.0 / n) <= 2e+78) {
tmp = 1.0 - t_1;
} else {
tmp = Math.log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = x / (1.0 + x) t_1 = math.pow(x, (1.0 / n)) t_2 = (t_1 / x) / n tmp = 0 if (1.0 / n) <= -5e-88: tmp = t_2 elif (1.0 / n) <= 2e-73: tmp = math.log(t_0) / -n elif (1.0 / n) <= 200000.0: tmp = t_2 elif (1.0 / n) <= 2e+78: tmp = 1.0 - t_1 else: tmp = math.log1p((t_0 + -1.0)) / -n return tmp
function code(x, n) t_0 = Float64(x / Float64(1.0 + x)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(Float64(t_1 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-88) tmp = t_2; elseif (Float64(1.0 / n) <= 2e-73) tmp = Float64(log(t_0) / Float64(-n)); elseif (Float64(1.0 / n) <= 200000.0) tmp = t_2; elseif (Float64(1.0 / n) <= 2e+78) tmp = Float64(1.0 - t_1); else tmp = Float64(log1p(Float64(t_0 + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-88], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-73], N[(N[Log[t$95$0], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+78], N[(1.0 - t$95$1), $MachinePrecision], N[(N[Log[1 + N[(t$95$0 + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{\frac{t\_1}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-88}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-73}:\\
\;\;\;\;\frac{\log t\_0}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+78}:\\
\;\;\;\;1 - t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(t\_0 + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000009e-88 or 1.99999999999999999e-73 < (/.f64 1 n) < 2e5Initial program 62.1%
Taylor expanded in x around inf 85.3%
log-rec85.3%
mul-1-neg85.3%
associate-*r/85.3%
associate-*r*85.3%
metadata-eval85.3%
*-commutative85.3%
associate-/l*85.4%
exp-to-pow85.4%
*-commutative85.4%
Simplified85.4%
*-un-lft-identity85.4%
associate-/r*86.3%
pow186.3%
pow-div85.9%
Applied egg-rr85.9%
*-lft-identity85.9%
sub-neg85.9%
metadata-eval85.9%
Simplified85.9%
+-commutative85.9%
unpow-prod-up86.2%
inv-pow86.3%
Applied egg-rr86.3%
associate-*l/86.3%
*-lft-identity86.3%
Simplified86.3%
if -5.00000000000000009e-88 < (/.f64 1 n) < 1.99999999999999999e-73Initial program 36.2%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.1%
Applied egg-rr88.1%
clear-num88.1%
log-rec88.1%
Applied egg-rr88.1%
if 2e5 < (/.f64 1 n) < 2.00000000000000002e78Initial program 100.0%
Taylor expanded in x around 0 100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if 2.00000000000000002e78 < (/.f64 1 n) Initial program 26.1%
Taylor expanded in n around inf 5.9%
+-rgt-identity5.9%
+-rgt-identity5.9%
log1p-define5.9%
Simplified5.9%
log1p-undefine5.9%
diff-log5.9%
Applied egg-rr5.9%
clear-num5.9%
log-rec5.9%
Applied egg-rr5.9%
add-sqr-sqrt0.0%
sqrt-unprod0.4%
sqr-neg0.4%
neg-log0.4%
clear-num0.4%
neg-log0.4%
clear-num0.4%
sqrt-unprod0.4%
add-sqr-sqrt0.4%
log1p-expm1-u0.4%
add-sqr-sqrt0.4%
sqrt-unprod0.4%
clear-num0.4%
neg-log0.4%
clear-num0.4%
neg-log0.4%
Applied egg-rr74.5%
Final simplification86.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= n -1.5e+88)
t_1
(if (<= n -1400.0)
(* (/ 1.0 n) (/ 1.0 x))
(if (<= n -3.15e-145)
t_0
(if (<= n -9e-276)
(/ 0.0 n)
(if (<= n 1.9e-223)
(/ 1.0 (* n x))
(if (<= n 1900000000.0) t_0 t_1))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if (n <= -1.5e+88) {
tmp = t_1;
} else if (n <= -1400.0) {
tmp = (1.0 / n) * (1.0 / x);
} else if (n <= -3.15e-145) {
tmp = t_0;
} else if (n <= -9e-276) {
tmp = 0.0 / n;
} else if (n <= 1.9e-223) {
tmp = 1.0 / (n * x);
} else if (n <= 1900000000.0) {
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) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
if (n <= (-1.5d+88)) then
tmp = t_1
else if (n <= (-1400.0d0)) then
tmp = (1.0d0 / n) * (1.0d0 / x)
else if (n <= (-3.15d-145)) then
tmp = t_0
else if (n <= (-9d-276)) then
tmp = 0.0d0 / n
else if (n <= 1.9d-223) then
tmp = 1.0d0 / (n * x)
else if (n <= 1900000000.0d0) 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 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if (n <= -1.5e+88) {
tmp = t_1;
} else if (n <= -1400.0) {
tmp = (1.0 / n) * (1.0 / x);
} else if (n <= -3.15e-145) {
tmp = t_0;
} else if (n <= -9e-276) {
tmp = 0.0 / n;
} else if (n <= 1.9e-223) {
tmp = 1.0 / (n * x);
} else if (n <= 1900000000.0) {
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 = math.log(((1.0 + x) / x)) / n tmp = 0 if n <= -1.5e+88: tmp = t_1 elif n <= -1400.0: tmp = (1.0 / n) * (1.0 / x) elif n <= -3.15e-145: tmp = t_0 elif n <= -9e-276: tmp = 0.0 / n elif n <= 1.9e-223: tmp = 1.0 / (n * x) elif n <= 1900000000.0: 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(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (n <= -1.5e+88) tmp = t_1; elseif (n <= -1400.0) tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); elseif (n <= -3.15e-145) tmp = t_0; elseif (n <= -9e-276) tmp = Float64(0.0 / n); elseif (n <= 1.9e-223) tmp = Float64(1.0 / Float64(n * x)); elseif (n <= 1900000000.0) 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 = log(((1.0 + x) / x)) / n; tmp = 0.0; if (n <= -1.5e+88) tmp = t_1; elseif (n <= -1400.0) tmp = (1.0 / n) * (1.0 / x); elseif (n <= -3.15e-145) tmp = t_0; elseif (n <= -9e-276) tmp = 0.0 / n; elseif (n <= 1.9e-223) tmp = 1.0 / (n * x); elseif (n <= 1900000000.0) 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[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -1.5e+88], t$95$1, If[LessEqual[n, -1400.0], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -3.15e-145], t$95$0, If[LessEqual[n, -9e-276], N[(0.0 / n), $MachinePrecision], If[LessEqual[n, 1.9e-223], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1900000000.0], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;n \leq -1.5 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq -1400:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;n \leq -3.15 \cdot 10^{-145}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -9 \cdot 10^{-276}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;n \leq 1.9 \cdot 10^{-223}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;n \leq 1900000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if n < -1.50000000000000003e88 or 1.9e9 < n Initial program 32.9%
Taylor expanded in n around inf 82.2%
+-rgt-identity82.2%
+-rgt-identity82.2%
log1p-define82.2%
Simplified82.2%
log1p-undefine82.2%
diff-log82.5%
Applied egg-rr82.5%
if -1.50000000000000003e88 < n < -1400Initial program 12.8%
Taylor expanded in n around inf 36.9%
+-rgt-identity36.9%
+-rgt-identity36.9%
log1p-define36.9%
Simplified36.9%
Taylor expanded in x around inf 64.2%
*-commutative64.2%
Simplified64.2%
inv-pow64.2%
unpow-prod-down64.5%
inv-pow64.5%
inv-pow64.5%
Applied egg-rr64.5%
if -1400 < n < -3.15e-145 or 1.90000000000000006e-223 < n < 1.9e9Initial program 80.6%
Taylor expanded in x around 0 58.2%
*-rgt-identity58.2%
associate-/l*58.2%
exp-to-pow58.2%
Simplified58.2%
if -3.15e-145 < n < -8.99999999999999925e-276Initial program 100.0%
Taylor expanded in n around inf 60.5%
+-rgt-identity60.5%
+-rgt-identity60.5%
log1p-define60.5%
Simplified60.5%
log1p-undefine60.5%
diff-log60.5%
Applied egg-rr60.5%
Taylor expanded in x around inf 67.2%
if -8.99999999999999925e-276 < n < 1.90000000000000006e-223Initial program 63.7%
Taylor expanded in n around inf 32.7%
+-rgt-identity32.7%
+-rgt-identity32.7%
log1p-define32.7%
Simplified32.7%
Taylor expanded in x around inf 69.6%
*-commutative69.6%
Simplified69.6%
Final simplification73.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 x) n)))
(if (<= (/ 1.0 n) -5e-88)
t_1
(if (<= (/ 1.0 n) 2e-73)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 200000.0)
t_1
(if (<= (/ 1.0 n) 5e+211) (- 1.0 t_0) (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-73) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+211) {
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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / x) / n
if ((1.0d0 / n) <= (-5d-88)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-73) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 200000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 5d+211) 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 t_1 = (t_0 / x) / n;
double tmp;
if ((1.0 / n) <= -5e-88) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-73) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+211) {
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)) t_1 = (t_0 / x) / n tmp = 0 if (1.0 / n) <= -5e-88: tmp = t_1 elif (1.0 / n) <= 2e-73: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 200000.0: tmp = t_1 elif (1.0 / n) <= 5e+211: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-88) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-73) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 200000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+211) 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); t_1 = (t_0 / x) / n; tmp = 0.0; if ((1.0 / n) <= -5e-88) tmp = t_1; elseif ((1.0 / n) <= 2e-73) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 200000.0) tmp = t_1; elseif ((1.0 / n) <= 5e+211) 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]}, Block[{t$95$1 = N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-88], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-73], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+211], 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)}\\
t_1 := \frac{\frac{t\_0}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-73}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+211}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000009e-88 or 1.99999999999999999e-73 < (/.f64 1 n) < 2e5Initial program 62.1%
Taylor expanded in x around inf 85.3%
log-rec85.3%
mul-1-neg85.3%
associate-*r/85.3%
associate-*r*85.3%
metadata-eval85.3%
*-commutative85.3%
associate-/l*85.4%
exp-to-pow85.4%
*-commutative85.4%
Simplified85.4%
*-un-lft-identity85.4%
associate-/r*86.3%
pow186.3%
pow-div85.9%
Applied egg-rr85.9%
*-lft-identity85.9%
sub-neg85.9%
metadata-eval85.9%
Simplified85.9%
+-commutative85.9%
unpow-prod-up86.2%
inv-pow86.3%
Applied egg-rr86.3%
associate-*l/86.3%
*-lft-identity86.3%
Simplified86.3%
if -5.00000000000000009e-88 < (/.f64 1 n) < 1.99999999999999999e-73Initial program 36.2%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.1%
Applied egg-rr88.1%
clear-num88.1%
log-rec88.1%
Applied egg-rr88.1%
if 2e5 < (/.f64 1 n) < 4.9999999999999995e211Initial program 64.2%
Taylor expanded in x around 0 59.4%
*-rgt-identity59.4%
associate-/l*59.4%
exp-to-pow59.4%
Simplified59.4%
if 4.9999999999999995e211 < (/.f64 1 n) Initial program 13.8%
Taylor expanded in n around inf 7.8%
+-rgt-identity7.8%
+-rgt-identity7.8%
log1p-define7.8%
Simplified7.8%
Taylor expanded in x around inf 76.7%
*-commutative76.7%
Simplified76.7%
Final simplification84.7%
(FPCore (x n)
:precision binary64
(if (<= x 2.1e-248)
(/ (log x) (- n))
(if (<= x 4e-230)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 2.05e-7)
(/ (- x (log x)) n)
(if (<= x 1.5e+185) (/ (/ 1.0 x) n) (/ 0.0 n))))))
double code(double x, double n) {
double tmp;
if (x <= 2.1e-248) {
tmp = log(x) / -n;
} else if (x <= 4e-230) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 2.05e-7) {
tmp = (x - log(x)) / n;
} else if (x <= 1.5e+185) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / 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.1d-248) then
tmp = log(x) / -n
else if (x <= 4d-230) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 2.05d-7) then
tmp = (x - log(x)) / n
else if (x <= 1.5d+185) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.1e-248) {
tmp = Math.log(x) / -n;
} else if (x <= 4e-230) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 2.05e-7) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.5e+185) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.1e-248: tmp = math.log(x) / -n elif x <= 4e-230: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 2.05e-7: tmp = (x - math.log(x)) / n elif x <= 1.5e+185: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 2.1e-248) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 4e-230) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 2.05e-7) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.5e+185) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.1e-248) tmp = log(x) / -n; elseif (x <= 4e-230) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 2.05e-7) tmp = (x - log(x)) / n; elseif (x <= 1.5e+185) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.1e-248], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 4e-230], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.05e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.5e+185], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.1 \cdot 10^{-248}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-230}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.1e-248Initial program 27.4%
Taylor expanded in n around inf 81.4%
+-rgt-identity81.4%
+-rgt-identity81.4%
log1p-define81.4%
Simplified81.4%
Taylor expanded in x around 0 81.4%
neg-mul-181.4%
Simplified81.4%
if 2.1e-248 < x < 4.00000000000000019e-230Initial program 84.8%
Taylor expanded in x around 0 84.8%
*-rgt-identity84.8%
associate-/l*84.8%
exp-to-pow84.8%
Simplified84.8%
if 4.00000000000000019e-230 < x < 2.05e-7Initial program 36.9%
Taylor expanded in n around inf 54.9%
+-rgt-identity54.9%
+-rgt-identity54.9%
log1p-define54.9%
Simplified54.9%
Taylor expanded in x around 0 54.9%
neg-mul-154.9%
sub-neg54.9%
Simplified54.9%
if 2.05e-7 < x < 1.49999999999999997e185Initial program 48.8%
Taylor expanded in n around inf 46.5%
+-rgt-identity46.5%
+-rgt-identity46.5%
log1p-define46.5%
Simplified46.5%
Taylor expanded in x around inf 65.2%
if 1.49999999999999997e185 < x Initial program 83.9%
Taylor expanded in n around inf 83.9%
+-rgt-identity83.9%
+-rgt-identity83.9%
log1p-define83.9%
Simplified83.9%
log1p-undefine83.9%
diff-log83.9%
Applied egg-rr83.9%
Taylor expanded in x around inf 83.9%
Final simplification67.1%
(FPCore (x n) :precision binary64 (if (<= x 2.05e-7) (/ (- x (log x)) n) (if (<= x 1.7e+186) (/ (/ 1.0 x) n) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 2.05e-7) {
tmp = (x - log(x)) / n;
} else if (x <= 1.7e+186) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / 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.05d-7) then
tmp = (x - log(x)) / n
else if (x <= 1.7d+186) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.05e-7) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.7e+186) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.05e-7: tmp = (x - math.log(x)) / n elif x <= 1.7e+186: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 2.05e-7) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.7e+186) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.05e-7) tmp = (x - log(x)) / n; elseif (x <= 1.7e+186) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.05e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.7e+186], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.05 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+186}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.05e-7Initial program 37.3%
Taylor expanded in n around inf 59.0%
+-rgt-identity59.0%
+-rgt-identity59.0%
log1p-define59.0%
Simplified59.0%
Taylor expanded in x around 0 59.0%
neg-mul-159.0%
sub-neg59.0%
Simplified59.0%
if 2.05e-7 < x < 1.70000000000000003e186Initial program 48.8%
Taylor expanded in n around inf 46.5%
+-rgt-identity46.5%
+-rgt-identity46.5%
log1p-define46.5%
Simplified46.5%
Taylor expanded in x around inf 65.2%
if 1.70000000000000003e186 < x Initial program 83.9%
Taylor expanded in n around inf 83.9%
+-rgt-identity83.9%
+-rgt-identity83.9%
log1p-define83.9%
Simplified83.9%
log1p-undefine83.9%
diff-log83.9%
Applied egg-rr83.9%
Taylor expanded in x around inf 83.9%
Final simplification65.3%
(FPCore (x n) :precision binary64 (if (<= x 2.05e-7) (/ (log x) (- n)) (if (<= x 1e+182) (/ (/ 1.0 x) n) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 2.05e-7) {
tmp = log(x) / -n;
} else if (x <= 1e+182) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / 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.05d-7) then
tmp = log(x) / -n
else if (x <= 1d+182) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.05e-7) {
tmp = Math.log(x) / -n;
} else if (x <= 1e+182) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.05e-7: tmp = math.log(x) / -n elif x <= 1e+182: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 2.05e-7) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1e+182) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.05e-7) tmp = log(x) / -n; elseif (x <= 1e+182) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.05e-7], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1e+182], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.05 \cdot 10^{-7}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 10^{+182}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.05e-7Initial program 37.3%
Taylor expanded in n around inf 59.0%
+-rgt-identity59.0%
+-rgt-identity59.0%
log1p-define59.0%
Simplified59.0%
Taylor expanded in x around 0 58.4%
neg-mul-158.4%
Simplified58.4%
if 2.05e-7 < x < 1.0000000000000001e182Initial program 48.8%
Taylor expanded in n around inf 46.5%
+-rgt-identity46.5%
+-rgt-identity46.5%
log1p-define46.5%
Simplified46.5%
Taylor expanded in x around inf 65.2%
if 1.0000000000000001e182 < x Initial program 83.9%
Taylor expanded in n around inf 83.9%
+-rgt-identity83.9%
+-rgt-identity83.9%
log1p-define83.9%
Simplified83.9%
log1p-undefine83.9%
diff-log83.9%
Applied egg-rr83.9%
Taylor expanded in x around inf 83.9%
Final simplification65.0%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -2e+14) (/ 0.0 n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e+14) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-2d+14)) then
tmp = 0.0d0 / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e+14) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e+14: tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e+14) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -2e+14) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+14], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+14}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e14Initial program 100.0%
Taylor expanded in n around inf 49.6%
+-rgt-identity49.6%
+-rgt-identity49.6%
log1p-define49.6%
Simplified49.6%
log1p-undefine49.6%
diff-log49.6%
Applied egg-rr49.6%
Taylor expanded in x around inf 50.8%
if -2e14 < (/.f64 1 n) Initial program 32.7%
Taylor expanded in n around inf 63.0%
+-rgt-identity63.0%
+-rgt-identity63.0%
log1p-define63.0%
Simplified63.0%
Taylor expanded in x around inf 46.9%
Final simplification47.8%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 49.0%
Taylor expanded in n around inf 59.8%
+-rgt-identity59.8%
+-rgt-identity59.8%
log1p-define59.8%
Simplified59.8%
Taylor expanded in x around inf 41.1%
*-commutative41.1%
Simplified41.1%
Final simplification41.1%
(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 49.0%
Taylor expanded in n around inf 59.8%
+-rgt-identity59.8%
+-rgt-identity59.8%
log1p-define59.8%
Simplified59.8%
Taylor expanded in x around inf 41.8%
Final simplification41.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 49.0%
Taylor expanded in x around 0 28.2%
Taylor expanded in x around inf 4.4%
Final simplification4.4%
herbie shell --seed 2024044
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))