
(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 14 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) -1e-8)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-10) (/ (log1p (/ 1.0 x)) n) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-10) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-10) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-8: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-10: tmp = math.log1p((1.0 / x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-8) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-10) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-10], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $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 -1 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-8Initial program 99.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
pow-to-exp100.0%
*-un-lft-identity100.0%
times-frac100.0%
Applied egg-rr100.0%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
if -1e-8 < (/.f64 1 n) < 1.00000000000000004e-10Initial program 30.8%
Taylor expanded in n around inf 72.7%
+-rgt-identity72.7%
+-rgt-identity72.7%
log1p-def72.7%
Simplified72.7%
log1p-udef72.7%
diff-log72.7%
+-commutative72.7%
Applied egg-rr72.7%
log-div72.7%
+-commutative72.7%
log1p-udef72.7%
log1p-expm1-u72.7%
expm1-udef72.7%
log1p-udef72.7%
+-commutative72.7%
log-div72.7%
add-exp-log72.7%
+-commutative72.7%
Applied egg-rr72.7%
*-lft-identity72.7%
associate-*l/70.8%
distribute-rgt-in70.8%
*-lft-identity70.8%
rgt-mult-inverse72.7%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 1.00000000000000004e-10 < (/.f64 1 n) Initial program 52.6%
Taylor expanded in n around 0 52.6%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-8)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-10)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 1e+190)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ x n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-10) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+190) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1((x / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-10) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+190) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1((x / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-8: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-10: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 1e+190: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1((x / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-8) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-10) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 1e+190) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(x / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-10], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+190], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+190}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-8Initial program 99.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
pow-to-exp100.0%
*-un-lft-identity100.0%
times-frac100.0%
Applied egg-rr100.0%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
if -1e-8 < (/.f64 1 n) < 1.00000000000000004e-10Initial program 30.8%
Taylor expanded in n around inf 72.7%
+-rgt-identity72.7%
+-rgt-identity72.7%
log1p-def72.7%
Simplified72.7%
log1p-udef72.7%
diff-log72.7%
+-commutative72.7%
Applied egg-rr72.7%
log-div72.7%
+-commutative72.7%
log1p-udef72.7%
log1p-expm1-u72.7%
expm1-udef72.7%
log1p-udef72.7%
+-commutative72.7%
log-div72.7%
add-exp-log72.7%
+-commutative72.7%
Applied egg-rr72.7%
*-lft-identity72.7%
associate-*l/70.8%
distribute-rgt-in70.8%
*-lft-identity70.8%
rgt-mult-inverse72.7%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 1.00000000000000004e-10 < (/.f64 1 n) < 1.0000000000000001e190Initial program 86.6%
Taylor expanded in x around 0 88.9%
if 1.0000000000000001e190 < (/.f64 1 n) Initial program 30.8%
Taylor expanded in x around inf 0.3%
mul-1-neg0.3%
log-rec0.3%
mul-1-neg0.3%
distribute-neg-frac0.3%
mul-1-neg0.3%
remove-double-neg0.3%
*-commutative0.3%
Simplified0.3%
div-inv0.3%
pow-to-exp0.3%
*-un-lft-identity0.3%
times-frac1.8%
Applied egg-rr1.8%
Taylor expanded in n around inf 63.1%
associate-/r*63.1%
Simplified63.1%
associate-/l/63.1%
inv-pow63.1%
metadata-eval63.1%
sqrt-pow263.1%
log1p-expm1-u82.7%
sqrt-pow282.7%
metadata-eval82.7%
inv-pow82.7%
associate-/r*82.7%
add-exp-log82.7%
neg-log82.7%
add-sqr-sqrt82.7%
sqrt-unprod82.7%
sqr-neg82.7%
sqrt-unprod0.0%
add-sqr-sqrt83.5%
add-exp-log83.5%
Applied egg-rr83.5%
Final simplification97.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ (+ 1.0 x) x)) n))
(t_1 (/ 1.0 (* n x)))
(t_2 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -2e+93)
(/ 0.0 n)
(if (<= (/ 1.0 n) -5e+75)
t_2
(if (<= (/ 1.0 n) -5e-47)
t_0
(if (<= (/ 1.0 n) -4e-119)
t_1
(if (<= (/ 1.0 n) 1e-10)
t_0
(if (<= (/ 1.0 n) 2e+219) t_2 t_1))))))))
double code(double x, double n) {
double t_0 = log(((1.0 + x) / x)) / n;
double t_1 = 1.0 / (n * x);
double t_2 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+93) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -5e+75) {
tmp = t_2;
} else if ((1.0 / n) <= -5e-47) {
tmp = t_0;
} else if ((1.0 / n) <= -4e-119) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-10) {
tmp = t_0;
} else if ((1.0 / n) <= 2e+219) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = log(((1.0d0 + x) / x)) / n
t_1 = 1.0d0 / (n * x)
t_2 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-2d+93)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= (-5d+75)) then
tmp = t_2
else if ((1.0d0 / n) <= (-5d-47)) then
tmp = t_0
else if ((1.0d0 / n) <= (-4d-119)) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-10) then
tmp = t_0
else if ((1.0d0 / n) <= 2d+219) then
tmp = t_2
else
tmp = t_1
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 / (n * x);
double t_2 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+93) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -5e+75) {
tmp = t_2;
} else if ((1.0 / n) <= -5e-47) {
tmp = t_0;
} else if ((1.0 / n) <= -4e-119) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-10) {
tmp = t_0;
} else if ((1.0 / n) <= 2e+219) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = math.log(((1.0 + x) / x)) / n t_1 = 1.0 / (n * x) t_2 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e+93: tmp = 0.0 / n elif (1.0 / n) <= -5e+75: tmp = t_2 elif (1.0 / n) <= -5e-47: tmp = t_0 elif (1.0 / n) <= -4e-119: tmp = t_1 elif (1.0 / n) <= 1e-10: tmp = t_0 elif (1.0 / n) <= 2e+219: tmp = t_2 else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) t_1 = Float64(1.0 / Float64(n * x)) t_2 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -2e+93) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -5e+75) tmp = t_2; elseif (Float64(1.0 / n) <= -5e-47) tmp = t_0; elseif (Float64(1.0 / n) <= -4e-119) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-10) tmp = t_0; elseif (Float64(1.0 / n) <= 2e+219) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, n) t_0 = log(((1.0 + x) / x)) / n; t_1 = 1.0 / (n * x); t_2 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -2e+93) tmp = 0.0 / n; elseif ((1.0 / n) <= -5e+75) tmp = t_2; elseif ((1.0 / n) <= -5e-47) tmp = t_0; elseif ((1.0 / n) <= -4e-119) tmp = t_1; elseif ((1.0 / n) <= 1e-10) tmp = t_0; elseif ((1.0 / n) <= 2e+219) tmp = t_2; else tmp = t_1; 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[(n * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+93], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+75], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-47], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-119], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-10], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+219], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
t_1 := \frac{1}{n \cdot x}\\
t_2 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+93}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+75}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-47}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -4 \cdot 10^{-119}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-10}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+219}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.00000000000000009e93Initial program 100.0%
Taylor expanded in n around inf 63.6%
+-rgt-identity63.6%
+-rgt-identity63.6%
log1p-def63.6%
Simplified63.6%
log1p-udef63.6%
diff-log62.2%
+-commutative62.2%
Applied egg-rr62.2%
Taylor expanded in x around inf 63.3%
if -2.00000000000000009e93 < (/.f64 1 n) < -5.0000000000000002e75 or 1.00000000000000004e-10 < (/.f64 1 n) < 1.99999999999999993e219Initial program 85.0%
Taylor expanded in x around 0 81.6%
if -5.0000000000000002e75 < (/.f64 1 n) < -5.00000000000000011e-47 or -4.00000000000000005e-119 < (/.f64 1 n) < 1.00000000000000004e-10Initial program 43.7%
Taylor expanded in n around inf 75.1%
+-rgt-identity75.1%
+-rgt-identity75.1%
log1p-def75.1%
Simplified75.1%
log1p-udef75.1%
diff-log75.1%
+-commutative75.1%
Applied egg-rr75.1%
if -5.00000000000000011e-47 < (/.f64 1 n) < -4.00000000000000005e-119 or 1.99999999999999993e219 < (/.f64 1 n) Initial program 19.9%
Taylor expanded in n around inf 20.2%
+-rgt-identity20.2%
+-rgt-identity20.2%
log1p-def20.2%
Simplified20.2%
Taylor expanded in x around inf 76.7%
*-commutative76.7%
Simplified76.7%
Final simplification73.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -2e+93)
(/ 0.0 n)
(if (<= (/ 1.0 n) -5e+75)
t_0
(if (<= (/ 1.0 n) -100.0)
(/ 0.0 n)
(if (<= (/ 1.0 n) 1e-10)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+219) t_0 (/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+93) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -5e+75) {
tmp = t_0;
} else if ((1.0 / n) <= -100.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= 1e-10) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+219) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+93) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -5e+75) {
tmp = t_0;
} else if ((1.0 / n) <= -100.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= 1e-10) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+219) {
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)) tmp = 0 if (1.0 / n) <= -2e+93: tmp = 0.0 / n elif (1.0 / n) <= -5e+75: tmp = t_0 elif (1.0 / n) <= -100.0: tmp = 0.0 / n elif (1.0 / n) <= 1e-10: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+219: 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))) tmp = 0.0 if (Float64(1.0 / n) <= -2e+93) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -5e+75) tmp = t_0; elseif (Float64(1.0 / n) <= -100.0) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= 1e-10) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+219) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+93], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+75], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -100.0], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-10], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+219], 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)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+93}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -100:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+219}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.00000000000000009e93 or -5.0000000000000002e75 < (/.f64 1 n) < -100Initial program 100.0%
Taylor expanded in n around inf 64.6%
+-rgt-identity64.6%
+-rgt-identity64.6%
log1p-def64.6%
Simplified64.6%
log1p-udef64.6%
diff-log63.5%
+-commutative63.5%
Applied egg-rr63.5%
Taylor expanded in x around inf 65.3%
if -2.00000000000000009e93 < (/.f64 1 n) < -5.0000000000000002e75 or 1.00000000000000004e-10 < (/.f64 1 n) < 1.99999999999999993e219Initial program 85.0%
Taylor expanded in x around 0 81.6%
if -100 < (/.f64 1 n) < 1.00000000000000004e-10Initial program 30.6%
Taylor expanded in n around inf 72.1%
+-rgt-identity72.1%
+-rgt-identity72.1%
log1p-def72.1%
Simplified72.1%
log1p-udef72.1%
diff-log72.2%
+-commutative72.2%
Applied egg-rr72.2%
log-div72.1%
+-commutative72.1%
log1p-udef72.1%
log1p-expm1-u72.1%
expm1-udef72.1%
log1p-udef72.1%
+-commutative72.1%
log-div72.2%
add-exp-log72.2%
+-commutative72.2%
Applied egg-rr72.2%
*-lft-identity72.2%
associate-*l/70.3%
distribute-rgt-in70.3%
*-lft-identity70.3%
rgt-mult-inverse72.2%
associate--l+98.7%
metadata-eval98.7%
Simplified98.7%
if 1.99999999999999993e219 < (/.f64 1 n) Initial program 20.7%
Taylor expanded in n around inf 8.1%
+-rgt-identity8.1%
+-rgt-identity8.1%
log1p-def8.1%
Simplified8.1%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification83.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-8)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-10)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+219) (- (+ 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) <= -1e-8) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-10) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+219) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 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) <= -1e-8) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-10) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+219) {
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) <= -1e-8: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-10: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+219: 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) <= -1e-8) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-10) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+219) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = 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], -1e-8], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-10], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+219], 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 -1 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+219}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-8Initial program 99.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
pow-to-exp100.0%
*-un-lft-identity100.0%
times-frac100.0%
Applied egg-rr100.0%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
if -1e-8 < (/.f64 1 n) < 1.00000000000000004e-10Initial program 30.8%
Taylor expanded in n around inf 72.7%
+-rgt-identity72.7%
+-rgt-identity72.7%
log1p-def72.7%
Simplified72.7%
log1p-udef72.7%
diff-log72.7%
+-commutative72.7%
Applied egg-rr72.7%
log-div72.7%
+-commutative72.7%
log1p-udef72.7%
log1p-expm1-u72.7%
expm1-udef72.7%
log1p-udef72.7%
+-commutative72.7%
log-div72.7%
add-exp-log72.7%
+-commutative72.7%
Applied egg-rr72.7%
*-lft-identity72.7%
associate-*l/70.8%
distribute-rgt-in70.8%
*-lft-identity70.8%
rgt-mult-inverse72.7%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 1.00000000000000004e-10 < (/.f64 1 n) < 1.99999999999999993e219Initial program 81.8%
Taylor expanded in x around 0 79.7%
if 1.99999999999999993e219 < (/.f64 1 n) Initial program 20.7%
Taylor expanded in n around inf 8.1%
+-rgt-identity8.1%
+-rgt-identity8.1%
log1p-def8.1%
Simplified8.1%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification95.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-8)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-10)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+219) (- 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) <= -1e-8) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-10) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+219) {
tmp = 1.0 - t_0;
} else {
tmp = 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) <= -1e-8) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-10) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+219) {
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) <= -1e-8: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-10: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+219: 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) <= -1e-8) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-10) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+219) tmp = Float64(1.0 - t_0); else tmp = 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], -1e-8], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-10], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+219], 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 -1 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+219}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-8Initial program 99.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
pow-to-exp100.0%
*-un-lft-identity100.0%
times-frac100.0%
Applied egg-rr100.0%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
if -1e-8 < (/.f64 1 n) < 1.00000000000000004e-10Initial program 30.8%
Taylor expanded in n around inf 72.7%
+-rgt-identity72.7%
+-rgt-identity72.7%
log1p-def72.7%
Simplified72.7%
log1p-udef72.7%
diff-log72.7%
+-commutative72.7%
Applied egg-rr72.7%
log-div72.7%
+-commutative72.7%
log1p-udef72.7%
log1p-expm1-u72.7%
expm1-udef72.7%
log1p-udef72.7%
+-commutative72.7%
log-div72.7%
add-exp-log72.7%
+-commutative72.7%
Applied egg-rr72.7%
*-lft-identity72.7%
associate-*l/70.8%
distribute-rgt-in70.8%
*-lft-identity70.8%
rgt-mult-inverse72.7%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 1.00000000000000004e-10 < (/.f64 1 n) < 1.99999999999999993e219Initial program 81.8%
Taylor expanded in x around 0 77.8%
if 1.99999999999999993e219 < (/.f64 1 n) Initial program 20.7%
Taylor expanded in n around inf 8.1%
+-rgt-identity8.1%
+-rgt-identity8.1%
log1p-def8.1%
Simplified8.1%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification95.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (- (log x)) n)))
(if (<= x 1.05e-236)
t_0
(if (<= x 3.5e-184)
t_1
(if (<= x 1.5e-136)
t_0
(if (<= x 2.3e-90)
t_1
(if (<= x 6.8e-19)
t_0
(if (<= x 1.25e-5)
(/ (- x (log x)) n)
(if (<= x 2.7e+115) (/ (/ 1.0 x) n) (/ 0.0 n))))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = -log(x) / n;
double tmp;
if (x <= 1.05e-236) {
tmp = t_0;
} else if (x <= 3.5e-184) {
tmp = t_1;
} else if (x <= 1.5e-136) {
tmp = t_0;
} else if (x <= 2.3e-90) {
tmp = t_1;
} else if (x <= 6.8e-19) {
tmp = t_0;
} else if (x <= 1.25e-5) {
tmp = (x - log(x)) / n;
} else if (x <= 2.7e+115) {
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = -log(x) / n
if (x <= 1.05d-236) then
tmp = t_0
else if (x <= 3.5d-184) then
tmp = t_1
else if (x <= 1.5d-136) then
tmp = t_0
else if (x <= 2.3d-90) then
tmp = t_1
else if (x <= 6.8d-19) then
tmp = t_0
else if (x <= 1.25d-5) then
tmp = (x - log(x)) / n
else if (x <= 2.7d+115) 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 t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = -Math.log(x) / n;
double tmp;
if (x <= 1.05e-236) {
tmp = t_0;
} else if (x <= 3.5e-184) {
tmp = t_1;
} else if (x <= 1.5e-136) {
tmp = t_0;
} else if (x <= 2.3e-90) {
tmp = t_1;
} else if (x <= 6.8e-19) {
tmp = t_0;
} else if (x <= 1.25e-5) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.7e+115) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = -math.log(x) / n tmp = 0 if x <= 1.05e-236: tmp = t_0 elif x <= 3.5e-184: tmp = t_1 elif x <= 1.5e-136: tmp = t_0 elif x <= 2.3e-90: tmp = t_1 elif x <= 6.8e-19: tmp = t_0 elif x <= 1.25e-5: tmp = (x - math.log(x)) / n elif x <= 2.7e+115: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 1.05e-236) tmp = t_0; elseif (x <= 3.5e-184) tmp = t_1; elseif (x <= 1.5e-136) tmp = t_0; elseif (x <= 2.3e-90) tmp = t_1; elseif (x <= 6.8e-19) tmp = t_0; elseif (x <= 1.25e-5) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.7e+115) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = -log(x) / n; tmp = 0.0; if (x <= 1.05e-236) tmp = t_0; elseif (x <= 3.5e-184) tmp = t_1; elseif (x <= 1.5e-136) tmp = t_0; elseif (x <= 2.3e-90) tmp = t_1; elseif (x <= 6.8e-19) tmp = t_0; elseif (x <= 1.25e-5) tmp = (x - log(x)) / n; elseif (x <= 2.7e+115) tmp = (1.0 / x) / n; else tmp = 0.0 / n; 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[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 1.05e-236], t$95$0, If[LessEqual[x, 3.5e-184], t$95$1, If[LessEqual[x, 1.5e-136], t$95$0, If[LessEqual[x, 2.3e-90], t$95$1, If[LessEqual[x, 6.8e-19], t$95$0, If[LessEqual[x, 1.25e-5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.7e+115], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 1.05 \cdot 10^{-236}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-184}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-136}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-90}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-19}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+115}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.04999999999999989e-236 or 3.49999999999999981e-184 < x < 1.4999999999999999e-136 or 2.2999999999999998e-90 < x < 6.8000000000000004e-19Initial program 59.3%
Taylor expanded in x around 0 59.3%
if 1.04999999999999989e-236 < x < 3.49999999999999981e-184 or 1.4999999999999999e-136 < x < 2.2999999999999998e-90Initial program 24.4%
Taylor expanded in x around 0 24.4%
Taylor expanded in n around inf 60.9%
neg-mul-160.9%
distribute-neg-frac60.9%
Simplified60.9%
if 6.8000000000000004e-19 < x < 1.25000000000000006e-5Initial program 5.5%
Taylor expanded in x around 0 5.5%
Taylor expanded in n around inf 99.5%
if 1.25000000000000006e-5 < x < 2.70000000000000004e115Initial program 55.8%
Taylor expanded in n around inf 46.0%
+-rgt-identity46.0%
+-rgt-identity46.0%
log1p-def46.0%
Simplified46.0%
Taylor expanded in x around inf 58.3%
if 2.70000000000000004e115 < x Initial program 88.6%
Taylor expanded in n around inf 88.6%
+-rgt-identity88.6%
+-rgt-identity88.6%
log1p-def88.6%
Simplified88.6%
log1p-udef88.6%
diff-log88.6%
+-commutative88.6%
Applied egg-rr88.6%
Taylor expanded in x around inf 88.6%
Final simplification68.3%
(FPCore (x n)
:precision binary64
(if (<= x 4.8e-184)
(/ (- (log x)) n)
(if (<= x 5.2e-169)
(/ 1.0 (* n x))
(if (<= x 1.25e-5)
(/ (- x (log x)) n)
(if (<= x 2.4e+115) (/ (/ 1.0 x) n) (/ 0.0 n))))))
double code(double x, double n) {
double tmp;
if (x <= 4.8e-184) {
tmp = -log(x) / n;
} else if (x <= 5.2e-169) {
tmp = 1.0 / (n * x);
} else if (x <= 1.25e-5) {
tmp = (x - log(x)) / n;
} else if (x <= 2.4e+115) {
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 <= 4.8d-184) then
tmp = -log(x) / n
else if (x <= 5.2d-169) then
tmp = 1.0d0 / (n * x)
else if (x <= 1.25d-5) then
tmp = (x - log(x)) / n
else if (x <= 2.4d+115) 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 <= 4.8e-184) {
tmp = -Math.log(x) / n;
} else if (x <= 5.2e-169) {
tmp = 1.0 / (n * x);
} else if (x <= 1.25e-5) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.4e+115) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.8e-184: tmp = -math.log(x) / n elif x <= 5.2e-169: tmp = 1.0 / (n * x) elif x <= 1.25e-5: tmp = (x - math.log(x)) / n elif x <= 2.4e+115: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 4.8e-184) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 5.2e-169) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 1.25e-5) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.4e+115) 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 <= 4.8e-184) tmp = -log(x) / n; elseif (x <= 5.2e-169) tmp = 1.0 / (n * x); elseif (x <= 1.25e-5) tmp = (x - log(x)) / n; elseif (x <= 2.4e+115) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.8e-184], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 5.2e-169], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25e-5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.4e+115], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-184}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-169}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+115}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 4.80000000000000049e-184Initial program 47.3%
Taylor expanded in x around 0 47.3%
Taylor expanded in n around inf 44.7%
neg-mul-144.7%
distribute-neg-frac44.7%
Simplified44.7%
if 4.80000000000000049e-184 < x < 5.20000000000000028e-169Initial program 48.1%
Taylor expanded in n around inf 23.9%
+-rgt-identity23.9%
+-rgt-identity23.9%
log1p-def23.9%
Simplified23.9%
Taylor expanded in x around inf 65.3%
*-commutative65.3%
Simplified65.3%
if 5.20000000000000028e-169 < x < 1.25000000000000006e-5Initial program 43.8%
Taylor expanded in x around 0 44.8%
Taylor expanded in n around inf 45.8%
if 1.25000000000000006e-5 < x < 2.4e115Initial program 55.8%
Taylor expanded in n around inf 46.0%
+-rgt-identity46.0%
+-rgt-identity46.0%
log1p-def46.0%
Simplified46.0%
Taylor expanded in x around inf 58.3%
if 2.4e115 < x Initial program 88.6%
Taylor expanded in n around inf 88.6%
+-rgt-identity88.6%
+-rgt-identity88.6%
log1p-def88.6%
Simplified88.6%
log1p-udef88.6%
diff-log88.6%
+-commutative88.6%
Applied egg-rr88.6%
Taylor expanded in x around inf 88.6%
Final simplification61.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 4.8e-184)
t_0
(if (<= x 4.2e-171)
(/ 1.0 (* n x))
(if (<= x 1.25e-5)
t_0
(if (<= x 7.5e+114) (/ (/ 1.0 x) n) (/ 0.0 n)))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 4.8e-184) {
tmp = t_0;
} else if (x <= 4.2e-171) {
tmp = 1.0 / (n * x);
} else if (x <= 1.25e-5) {
tmp = t_0;
} else if (x <= 7.5e+114) {
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) :: t_0
real(8) :: tmp
t_0 = -log(x) / n
if (x <= 4.8d-184) then
tmp = t_0
else if (x <= 4.2d-171) then
tmp = 1.0d0 / (n * x)
else if (x <= 1.25d-5) then
tmp = t_0
else if (x <= 7.5d+114) 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 t_0 = -Math.log(x) / n;
double tmp;
if (x <= 4.8e-184) {
tmp = t_0;
} else if (x <= 4.2e-171) {
tmp = 1.0 / (n * x);
} else if (x <= 1.25e-5) {
tmp = t_0;
} else if (x <= 7.5e+114) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 4.8e-184: tmp = t_0 elif x <= 4.2e-171: tmp = 1.0 / (n * x) elif x <= 1.25e-5: tmp = t_0 elif x <= 7.5e+114: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 4.8e-184) tmp = t_0; elseif (x <= 4.2e-171) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 1.25e-5) tmp = t_0; elseif (x <= 7.5e+114) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (x <= 4.8e-184) tmp = t_0; elseif (x <= 4.2e-171) tmp = 1.0 / (n * x); elseif (x <= 1.25e-5) tmp = t_0; elseif (x <= 7.5e+114) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 4.8e-184], t$95$0, If[LessEqual[x, 4.2e-171], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25e-5], t$95$0, If[LessEqual[x, 7.5e+114], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 4.8 \cdot 10^{-184}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-171}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+114}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 4.80000000000000049e-184 or 4.2e-171 < x < 1.25000000000000006e-5Initial program 45.5%
Taylor expanded in x around 0 45.5%
Taylor expanded in n around inf 44.6%
neg-mul-144.6%
distribute-neg-frac44.6%
Simplified44.6%
if 4.80000000000000049e-184 < x < 4.2e-171Initial program 48.1%
Taylor expanded in n around inf 23.9%
+-rgt-identity23.9%
+-rgt-identity23.9%
log1p-def23.9%
Simplified23.9%
Taylor expanded in x around inf 65.3%
*-commutative65.3%
Simplified65.3%
if 1.25000000000000006e-5 < x < 7.5000000000000001e114Initial program 55.8%
Taylor expanded in n around inf 46.0%
+-rgt-identity46.0%
+-rgt-identity46.0%
log1p-def46.0%
Simplified46.0%
Taylor expanded in x around inf 58.3%
if 7.5000000000000001e114 < x Initial program 88.6%
Taylor expanded in n around inf 88.6%
+-rgt-identity88.6%
+-rgt-identity88.6%
log1p-def88.6%
Simplified88.6%
log1p-udef88.6%
diff-log88.6%
+-commutative88.6%
Applied egg-rr88.6%
Taylor expanded in x around inf 88.6%
Final simplification60.6%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -100.0) (/ 0.0 n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -100.0) {
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) <= (-100.0d0)) 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) <= -100.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -100.0: tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -100.0) 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) <= -100.0) 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], -100.0], 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 -100:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -100Initial program 100.0%
Taylor expanded in n around inf 61.4%
+-rgt-identity61.4%
+-rgt-identity61.4%
log1p-def61.4%
Simplified61.4%
log1p-udef61.4%
diff-log60.3%
+-commutative60.3%
Applied egg-rr60.3%
Taylor expanded in x around inf 61.9%
if -100 < (/.f64 1 n) Initial program 36.8%
Taylor expanded in n around inf 53.8%
+-rgt-identity53.8%
+-rgt-identity53.8%
log1p-def53.8%
Simplified53.8%
Taylor expanded in x around inf 52.1%
Final simplification55.7%
(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 59.8%
Taylor expanded in n around inf 56.5%
+-rgt-identity56.5%
+-rgt-identity56.5%
log1p-def56.5%
Simplified56.5%
Taylor expanded in x around inf 41.5%
*-commutative41.5%
Simplified41.5%
Final simplification41.5%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 59.8%
Taylor expanded in x around inf 62.5%
mul-1-neg62.5%
log-rec62.5%
mul-1-neg62.5%
distribute-neg-frac62.5%
mul-1-neg62.5%
remove-double-neg62.5%
*-commutative62.5%
Simplified62.5%
div-inv62.5%
pow-to-exp62.5%
*-un-lft-identity62.5%
times-frac63.1%
Applied egg-rr63.1%
Taylor expanded in n around inf 41.5%
associate-/r*41.8%
Simplified41.8%
Final simplification41.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 59.8%
Taylor expanded in n around inf 56.5%
+-rgt-identity56.5%
+-rgt-identity56.5%
log1p-def56.5%
Simplified56.5%
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 59.8%
Taylor expanded in x around inf 62.5%
mul-1-neg62.5%
log-rec62.5%
mul-1-neg62.5%
distribute-neg-frac62.5%
mul-1-neg62.5%
remove-double-neg62.5%
*-commutative62.5%
Simplified62.5%
div-inv62.5%
pow-to-exp62.5%
*-un-lft-identity62.5%
times-frac63.1%
Applied egg-rr63.1%
Taylor expanded in n around inf 41.5%
associate-/r*41.8%
Simplified41.8%
expm1-log1p-u33.5%
expm1-udef31.4%
associate-/l/31.4%
associate-/r*31.4%
add-exp-log31.4%
neg-log31.4%
add-sqr-sqrt8.0%
sqrt-unprod14.6%
sqr-neg14.6%
sqrt-unprod6.5%
add-sqr-sqrt8.5%
add-exp-log8.5%
Applied egg-rr8.5%
expm1-def3.3%
expm1-log1p4.2%
Simplified4.2%
Final simplification4.2%
herbie shell --seed 2023334
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))