
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-56)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0)
(/ (pow x (log1p (expm1 (+ (/ 1.0 n) -1.0)))) n)
(- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = pow(x, log1p(expm1(((1.0 / n) + -1.0)))) / n;
} 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 tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = Math.pow(x, Math.log1p(Math.expm1(((1.0 / n) + -1.0)))) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-56: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = math.pow(x, math.log1p(math.expm1(((1.0 / n) + -1.0)))) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-56) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64((x ^ log1p(expm1(Float64(Float64(1.0 / n) + -1.0)))) / n); 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]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Power[x, N[Log[1 + N[(Exp[N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], 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)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{{x}^{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n} + -1\right)\right)\right)}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999997e-56Initial program 85.7%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
expm1-log1p-u54.6%
expm1-udef44.0%
associate-/r*44.0%
div-inv44.0%
pow-to-exp44.0%
pow144.0%
pow-div44.0%
Applied egg-rr44.0%
expm1-def54.0%
expm1-log1p95.1%
sub-neg95.1%
metadata-eval95.1%
Simplified95.1%
unpow-prod-up95.7%
inv-pow95.7%
*-un-lft-identity95.7%
times-frac95.8%
Applied egg-rr95.8%
/-rgt-identity95.8%
associate-/l/95.7%
associate-/r*95.7%
associate-*r/95.7%
associate-*r/95.8%
*-rgt-identity95.8%
Simplified95.8%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 8.7%
Taylor expanded in x around inf 68.3%
mul-1-neg68.3%
log-rec68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
mul-1-neg68.3%
remove-double-neg68.3%
*-commutative68.3%
Simplified68.3%
expm1-log1p-u68.3%
expm1-udef11.6%
associate-/r*11.6%
div-inv11.6%
pow-to-exp11.7%
pow111.7%
pow-div14.3%
Applied egg-rr14.3%
expm1-def72.3%
expm1-log1p72.3%
sub-neg72.3%
metadata-eval72.3%
Simplified72.3%
log1p-expm1-u72.3%
Applied egg-rr72.3%
if 10 < (/.f64 1 n) Initial program 54.3%
Taylor expanded in n around 0 54.3%
log1p-def96.7%
Simplified96.7%
Final simplification91.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-56)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0)
(/ (pow x (/ (- 1.0 (pow n -2.0)) (+ -1.0 (/ -1.0 n)))) n)
(- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = pow(x, ((1.0 - pow(n, -2.0)) / (-1.0 + (-1.0 / n)))) / n;
} 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 tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = Math.pow(x, ((1.0 - Math.pow(n, -2.0)) / (-1.0 + (-1.0 / n)))) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-56: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = math.pow(x, ((1.0 - math.pow(n, -2.0)) / (-1.0 + (-1.0 / n)))) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-56) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64((x ^ Float64(Float64(1.0 - (n ^ -2.0)) / Float64(-1.0 + Float64(-1.0 / n)))) / n); 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]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Power[x, N[(N[(1.0 - N[Power[n, -2.0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], 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)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{{x}^{\left(\frac{1 - {n}^{-2}}{-1 + \frac{-1}{n}}\right)}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999997e-56Initial program 85.7%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
expm1-log1p-u54.6%
expm1-udef44.0%
associate-/r*44.0%
div-inv44.0%
pow-to-exp44.0%
pow144.0%
pow-div44.0%
Applied egg-rr44.0%
expm1-def54.0%
expm1-log1p95.1%
sub-neg95.1%
metadata-eval95.1%
Simplified95.1%
unpow-prod-up95.7%
inv-pow95.7%
*-un-lft-identity95.7%
times-frac95.8%
Applied egg-rr95.8%
/-rgt-identity95.8%
associate-/l/95.7%
associate-/r*95.7%
associate-*r/95.7%
associate-*r/95.8%
*-rgt-identity95.8%
Simplified95.8%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 8.7%
Taylor expanded in x around inf 68.3%
mul-1-neg68.3%
log-rec68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
mul-1-neg68.3%
remove-double-neg68.3%
*-commutative68.3%
Simplified68.3%
expm1-log1p-u68.3%
expm1-udef11.6%
associate-/r*11.6%
div-inv11.6%
pow-to-exp11.7%
pow111.7%
pow-div14.3%
Applied egg-rr14.3%
expm1-def72.3%
expm1-log1p72.3%
sub-neg72.3%
metadata-eval72.3%
Simplified72.3%
flip-+72.2%
frac-2neg72.2%
metadata-eval72.2%
sub-neg72.2%
inv-pow72.2%
inv-pow72.2%
pow-prod-up72.3%
metadata-eval72.3%
metadata-eval72.3%
sub-neg72.3%
metadata-eval72.3%
Applied egg-rr72.3%
neg-sub072.3%
+-commutative72.3%
associate--r+72.3%
metadata-eval72.3%
+-commutative72.3%
distribute-neg-in72.3%
metadata-eval72.3%
distribute-neg-frac72.3%
metadata-eval72.3%
Simplified72.3%
if 10 < (/.f64 1 n) Initial program 54.3%
Taylor expanded in n around 0 54.3%
log1p-def96.7%
Simplified96.7%
Final simplification91.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-56)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0)
(/ (pow x (+ (/ 1.0 n) -1.0)) n)
(if (<= (/ 1.0 n) 2e+123)
(- (pow (+ 1.0 x) (/ 1.0 n)) t_0)
(/ (pow x (+ -1.0 (/ -1.0 n))) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = pow(x, ((1.0 / n) + -1.0)) / n;
} else if ((1.0 / n) <= 2e+123) {
tmp = pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = pow(x, (-1.0 + (-1.0 / n))) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-56)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-142) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 10.0d0) then
tmp = (x ** ((1.0d0 / n) + (-1.0d0))) / n
else if ((1.0d0 / n) <= 2d+123) then
tmp = ((1.0d0 + x) ** (1.0d0 / n)) - t_0
else
tmp = (x ** ((-1.0d0) + ((-1.0d0) / n))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
} else if ((1.0 / n) <= 2e+123) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = Math.pow(x, (-1.0 + (-1.0 / n))) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-56: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n elif (1.0 / n) <= 2e+123: tmp = math.pow((1.0 + x), (1.0 / n)) - t_0 else: tmp = math.pow(x, (-1.0 + (-1.0 / n))) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-56) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); elseif (Float64(1.0 / n) <= 2e+123) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0); else tmp = Float64((x ^ Float64(-1.0 + Float64(-1.0 / n))) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-56) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-142) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 10.0) tmp = (x ^ ((1.0 / n) + -1.0)) / n; elseif ((1.0 / n) <= 2e+123) tmp = ((1.0 + x) ^ (1.0 / n)) - t_0; else tmp = (x ^ (-1.0 + (-1.0 / n))) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+123], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Power[x, N[(-1.0 + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+123}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(-1 + \frac{-1}{n}\right)}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999997e-56Initial program 85.7%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
expm1-log1p-u54.6%
expm1-udef44.0%
associate-/r*44.0%
div-inv44.0%
pow-to-exp44.0%
pow144.0%
pow-div44.0%
Applied egg-rr44.0%
expm1-def54.0%
expm1-log1p95.1%
sub-neg95.1%
metadata-eval95.1%
Simplified95.1%
unpow-prod-up95.7%
inv-pow95.7%
*-un-lft-identity95.7%
times-frac95.8%
Applied egg-rr95.8%
/-rgt-identity95.8%
associate-/l/95.7%
associate-/r*95.7%
associate-*r/95.7%
associate-*r/95.8%
*-rgt-identity95.8%
Simplified95.8%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 8.7%
Taylor expanded in x around inf 68.3%
mul-1-neg68.3%
log-rec68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
mul-1-neg68.3%
remove-double-neg68.3%
*-commutative68.3%
Simplified68.3%
expm1-log1p-u68.3%
expm1-udef11.6%
associate-/r*11.6%
div-inv11.6%
pow-to-exp11.7%
pow111.7%
pow-div14.3%
Applied egg-rr14.3%
expm1-def72.3%
expm1-log1p72.3%
sub-neg72.3%
metadata-eval72.3%
Simplified72.3%
if 10 < (/.f64 1 n) < 1.99999999999999996e123Initial program 67.5%
if 1.99999999999999996e123 < (/.f64 1 n) Initial program 43.9%
Taylor expanded in x around inf 0.8%
mul-1-neg0.8%
log-rec0.8%
mul-1-neg0.8%
distribute-neg-frac0.8%
mul-1-neg0.8%
remove-double-neg0.8%
*-commutative0.8%
Simplified0.8%
expm1-log1p-u0.8%
expm1-udef0.8%
associate-/r*2.1%
div-inv2.1%
pow-to-exp2.1%
pow12.1%
pow-div2.1%
Applied egg-rr2.1%
expm1-def2.1%
expm1-log1p2.1%
sub-neg2.1%
metadata-eval2.1%
Simplified2.1%
flip-+2.1%
frac-2neg2.1%
metadata-eval2.1%
sub-neg2.1%
inv-pow2.1%
inv-pow2.1%
pow-prod-up2.1%
metadata-eval2.1%
metadata-eval2.1%
sub-neg2.1%
metadata-eval2.1%
Applied egg-rr2.1%
neg-sub02.1%
+-commutative2.1%
associate--r+2.1%
metadata-eval2.1%
+-commutative2.1%
distribute-neg-in2.1%
metadata-eval2.1%
distribute-neg-frac2.1%
metadata-eval2.1%
Simplified2.1%
sub-neg2.1%
metadata-eval2.1%
pow-prod-up2.1%
inv-pow2.1%
inv-pow2.1%
distribute-rgt-neg-in2.1%
metadata-eval2.1%
associate-*r/2.1%
mul-1-neg2.1%
mul-1-neg2.1%
div-inv2.1%
cancel-sign-sub-inv2.1%
metadata-eval2.1%
flip--2.1%
add-sqr-sqrt0.0%
sqrt-unprod64.3%
frac-times64.3%
metadata-eval64.3%
metadata-eval64.3%
frac-times64.3%
sqrt-prod64.3%
add-sqr-sqrt64.3%
Applied egg-rr64.3%
Final simplification87.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (+ -1.0 (/ -1.0 n))))
(if (<= (/ 1.0 n) -5e-56)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0)
(/ (pow x (/ (- 1.0 (pow n -2.0)) t_1)) n)
(if (<= (/ 1.0 n) 2e+123)
(- (pow (+ 1.0 x) (/ 1.0 n)) t_0)
(/ (pow x t_1) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = -1.0 + (-1.0 / n);
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = pow(x, ((1.0 - pow(n, -2.0)) / t_1)) / n;
} else if ((1.0 / n) <= 2e+123) {
tmp = pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = pow(x, t_1) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (-1.0d0) + ((-1.0d0) / n)
if ((1.0d0 / n) <= (-5d-56)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-142) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 10.0d0) then
tmp = (x ** ((1.0d0 - (n ** (-2.0d0))) / t_1)) / n
else if ((1.0d0 / n) <= 2d+123) then
tmp = ((1.0d0 + x) ** (1.0d0 / n)) - t_0
else
tmp = (x ** t_1) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = -1.0 + (-1.0 / n);
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = Math.pow(x, ((1.0 - Math.pow(n, -2.0)) / t_1)) / n;
} else if ((1.0 / n) <= 2e+123) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = Math.pow(x, t_1) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = -1.0 + (-1.0 / n) tmp = 0 if (1.0 / n) <= -5e-56: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = math.pow(x, ((1.0 - math.pow(n, -2.0)) / t_1)) / n elif (1.0 / n) <= 2e+123: tmp = math.pow((1.0 + x), (1.0 / n)) - t_0 else: tmp = math.pow(x, t_1) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(-1.0 + Float64(-1.0 / n)) tmp = 0.0 if (Float64(1.0 / n) <= -5e-56) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64((x ^ Float64(Float64(1.0 - (n ^ -2.0)) / t_1)) / n); elseif (Float64(1.0 / n) <= 2e+123) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0); else tmp = Float64((x ^ t_1) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = -1.0 + (-1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-56) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-142) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 10.0) tmp = (x ^ ((1.0 - (n ^ -2.0)) / t_1)) / n; elseif ((1.0 / n) <= 2e+123) tmp = ((1.0 + x) ^ (1.0 / n)) - t_0; else tmp = (x ^ t_1) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Power[x, N[(N[(1.0 - N[Power[n, -2.0], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+123], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Power[x, t$95$1], $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := -1 + \frac{-1}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{{x}^{\left(\frac{1 - {n}^{-2}}{t_1}\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+123}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{t_1}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999997e-56Initial program 85.7%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
expm1-log1p-u54.6%
expm1-udef44.0%
associate-/r*44.0%
div-inv44.0%
pow-to-exp44.0%
pow144.0%
pow-div44.0%
Applied egg-rr44.0%
expm1-def54.0%
expm1-log1p95.1%
sub-neg95.1%
metadata-eval95.1%
Simplified95.1%
unpow-prod-up95.7%
inv-pow95.7%
*-un-lft-identity95.7%
times-frac95.8%
Applied egg-rr95.8%
/-rgt-identity95.8%
associate-/l/95.7%
associate-/r*95.7%
associate-*r/95.7%
associate-*r/95.8%
*-rgt-identity95.8%
Simplified95.8%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 8.7%
Taylor expanded in x around inf 68.3%
mul-1-neg68.3%
log-rec68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
mul-1-neg68.3%
remove-double-neg68.3%
*-commutative68.3%
Simplified68.3%
expm1-log1p-u68.3%
expm1-udef11.6%
associate-/r*11.6%
div-inv11.6%
pow-to-exp11.7%
pow111.7%
pow-div14.3%
Applied egg-rr14.3%
expm1-def72.3%
expm1-log1p72.3%
sub-neg72.3%
metadata-eval72.3%
Simplified72.3%
flip-+72.2%
frac-2neg72.2%
metadata-eval72.2%
sub-neg72.2%
inv-pow72.2%
inv-pow72.2%
pow-prod-up72.3%
metadata-eval72.3%
metadata-eval72.3%
sub-neg72.3%
metadata-eval72.3%
Applied egg-rr72.3%
neg-sub072.3%
+-commutative72.3%
associate--r+72.3%
metadata-eval72.3%
+-commutative72.3%
distribute-neg-in72.3%
metadata-eval72.3%
distribute-neg-frac72.3%
metadata-eval72.3%
Simplified72.3%
if 10 < (/.f64 1 n) < 1.99999999999999996e123Initial program 67.5%
if 1.99999999999999996e123 < (/.f64 1 n) Initial program 43.9%
Taylor expanded in x around inf 0.8%
mul-1-neg0.8%
log-rec0.8%
mul-1-neg0.8%
distribute-neg-frac0.8%
mul-1-neg0.8%
remove-double-neg0.8%
*-commutative0.8%
Simplified0.8%
expm1-log1p-u0.8%
expm1-udef0.8%
associate-/r*2.1%
div-inv2.1%
pow-to-exp2.1%
pow12.1%
pow-div2.1%
Applied egg-rr2.1%
expm1-def2.1%
expm1-log1p2.1%
sub-neg2.1%
metadata-eval2.1%
Simplified2.1%
flip-+2.1%
frac-2neg2.1%
metadata-eval2.1%
sub-neg2.1%
inv-pow2.1%
inv-pow2.1%
pow-prod-up2.1%
metadata-eval2.1%
metadata-eval2.1%
sub-neg2.1%
metadata-eval2.1%
Applied egg-rr2.1%
neg-sub02.1%
+-commutative2.1%
associate--r+2.1%
metadata-eval2.1%
+-commutative2.1%
distribute-neg-in2.1%
metadata-eval2.1%
distribute-neg-frac2.1%
metadata-eval2.1%
Simplified2.1%
sub-neg2.1%
metadata-eval2.1%
pow-prod-up2.1%
inv-pow2.1%
inv-pow2.1%
distribute-rgt-neg-in2.1%
metadata-eval2.1%
associate-*r/2.1%
mul-1-neg2.1%
mul-1-neg2.1%
div-inv2.1%
cancel-sign-sub-inv2.1%
metadata-eval2.1%
flip--2.1%
add-sqr-sqrt0.0%
sqrt-unprod64.3%
frac-times64.3%
metadata-eval64.3%
metadata-eval64.3%
frac-times64.3%
sqrt-prod64.3%
add-sqr-sqrt64.3%
Applied egg-rr64.3%
Final simplification87.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ 1.0 (* n (+ x 0.5)))))
(if (<= (/ 1.0 n) -20000000.0)
(/ t_0 n)
(if (<= (/ 1.0 n) -5e-56)
t_1
(if (<= (/ 1.0 n) -2e-138)
(/ (- x (log x)) n)
(if (<= (/ 1.0 n) 1e-253)
t_1
(if (<= (/ 1.0 n) 1e-147)
(/ (- (log x)) n)
(if (<= (/ 1.0 n) 10.0) t_1 (- 1.0 t_0)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 / (n * (x + 0.5));
double tmp;
if ((1.0 / n) <= -20000000.0) {
tmp = t_0 / n;
} else if ((1.0 / n) <= -5e-56) {
tmp = t_1;
} else if ((1.0 / n) <= -2e-138) {
tmp = (x - log(x)) / n;
} else if ((1.0 / n) <= 1e-253) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-147) {
tmp = -log(x) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = 1.0d0 / (n * (x + 0.5d0))
if ((1.0d0 / n) <= (-20000000.0d0)) then
tmp = t_0 / n
else if ((1.0d0 / n) <= (-5d-56)) then
tmp = t_1
else if ((1.0d0 / n) <= (-2d-138)) then
tmp = (x - log(x)) / n
else if ((1.0d0 / n) <= 1d-253) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-147) then
tmp = -log(x) / n
else if ((1.0d0 / n) <= 10.0d0) then
tmp = t_1
else
tmp = 1.0d0 - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = 1.0 / (n * (x + 0.5));
double tmp;
if ((1.0 / n) <= -20000000.0) {
tmp = t_0 / n;
} else if ((1.0 / n) <= -5e-56) {
tmp = t_1;
} else if ((1.0 / n) <= -2e-138) {
tmp = (x - Math.log(x)) / n;
} else if ((1.0 / n) <= 1e-253) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-147) {
tmp = -Math.log(x) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 / (n * (x + 0.5)) tmp = 0 if (1.0 / n) <= -20000000.0: tmp = t_0 / n elif (1.0 / n) <= -5e-56: tmp = t_1 elif (1.0 / n) <= -2e-138: tmp = (x - math.log(x)) / n elif (1.0 / n) <= 1e-253: tmp = t_1 elif (1.0 / n) <= 1e-147: tmp = -math.log(x) / n elif (1.0 / n) <= 10.0: tmp = t_1 else: tmp = 1.0 - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 / Float64(n * Float64(x + 0.5))) tmp = 0.0 if (Float64(1.0 / n) <= -20000000.0) tmp = Float64(t_0 / n); elseif (Float64(1.0 / n) <= -5e-56) tmp = t_1; elseif (Float64(1.0 / n) <= -2e-138) tmp = Float64(Float64(x - log(x)) / n); elseif (Float64(1.0 / n) <= 1e-253) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-147) tmp = Float64(Float64(-log(x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = t_1; else tmp = Float64(1.0 - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = 1.0 / (n * (x + 0.5)); tmp = 0.0; if ((1.0 / n) <= -20000000.0) tmp = t_0 / n; elseif ((1.0 / n) <= -5e-56) tmp = t_1; elseif ((1.0 / n) <= -2e-138) tmp = (x - log(x)) / n; elseif ((1.0 / n) <= 1e-253) tmp = t_1; elseif ((1.0 / n) <= 1e-147) tmp = -log(x) / n; elseif ((1.0 / n) <= 10.0) tmp = t_1; else tmp = 1.0 - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -20000000.0], N[(t$95$0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-138], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-253], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-147], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], t$95$1, N[(1.0 - t$95$0), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -20000000:\\
\;\;\;\;\frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-138}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-253}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-147}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e7Initial program 100.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%
expm1-log1p-u50.7%
expm1-udef50.7%
associate-/r*50.7%
div-inv50.7%
pow-to-exp50.7%
pow150.7%
pow-div50.7%
Applied egg-rr50.7%
expm1-def50.7%
expm1-log1p100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in n around 0 100.0%
if -2e7 < (/.f64 1 n) < -4.99999999999999997e-56 or -2.00000000000000013e-138 < (/.f64 1 n) < 1.0000000000000001e-253 or 9.9999999999999997e-148 < (/.f64 1 n) < 10Initial program 37.3%
Taylor expanded in n around inf 69.1%
+-rgt-identity69.1%
+-rgt-identity69.1%
log1p-def69.1%
Simplified69.1%
clear-num69.1%
inv-pow69.1%
Applied egg-rr69.1%
unpow-169.1%
Simplified69.1%
Taylor expanded in x around inf 66.0%
+-commutative66.0%
*-commutative66.0%
distribute-lft-out66.0%
Simplified66.0%
if -4.99999999999999997e-56 < (/.f64 1 n) < -2.00000000000000013e-138Initial program 11.6%
Taylor expanded in n around inf 85.1%
+-rgt-identity85.1%
+-rgt-identity85.1%
log1p-def85.1%
Simplified85.1%
Taylor expanded in x around 0 77.5%
neg-mul-177.5%
unsub-neg77.5%
Simplified77.5%
if 1.0000000000000001e-253 < (/.f64 1 n) < 9.9999999999999997e-148Initial program 27.5%
Taylor expanded in x around 0 27.5%
Taylor expanded in n around inf 68.0%
neg-mul-168.0%
distribute-neg-frac68.0%
Simplified68.0%
if 10 < (/.f64 1 n) Initial program 54.3%
Taylor expanded in x around 0 48.6%
Final simplification74.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-56)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0)
(/ (pow x (+ (/ 1.0 n) -1.0)) n)
(if (<= (/ 1.0 n) 5e+182)
(- (+ 1.0 (/ x n)) t_0)
(/ (pow x (+ -1.0 (/ -1.0 n))) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = pow(x, ((1.0 / n) + -1.0)) / n;
} else if ((1.0 / n) <= 5e+182) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = pow(x, (-1.0 + (-1.0 / n))) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-56)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-142) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 10.0d0) then
tmp = (x ** ((1.0d0 / n) + (-1.0d0))) / n
else if ((1.0d0 / n) <= 5d+182) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (x ** ((-1.0d0) + ((-1.0d0) / n))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
} else if ((1.0 / n) <= 5e+182) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.pow(x, (-1.0 + (-1.0 / n))) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-56: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n elif (1.0 / n) <= 5e+182: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.pow(x, (-1.0 + (-1.0 / n))) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-56) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); elseif (Float64(1.0 / n) <= 5e+182) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64((x ^ Float64(-1.0 + Float64(-1.0 / n))) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-56) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-142) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 10.0) tmp = (x ^ ((1.0 / n) + -1.0)) / n; elseif ((1.0 / n) <= 5e+182) tmp = (1.0 + (x / n)) - t_0; else tmp = (x ^ (-1.0 + (-1.0 / n))) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+182], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Power[x, N[(-1.0 + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(-1 + \frac{-1}{n}\right)}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999997e-56Initial program 85.7%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
expm1-log1p-u54.6%
expm1-udef44.0%
associate-/r*44.0%
div-inv44.0%
pow-to-exp44.0%
pow144.0%
pow-div44.0%
Applied egg-rr44.0%
expm1-def54.0%
expm1-log1p95.1%
sub-neg95.1%
metadata-eval95.1%
Simplified95.1%
unpow-prod-up95.7%
inv-pow95.7%
*-un-lft-identity95.7%
times-frac95.8%
Applied egg-rr95.8%
/-rgt-identity95.8%
associate-/l/95.7%
associate-/r*95.7%
associate-*r/95.7%
associate-*r/95.8%
*-rgt-identity95.8%
Simplified95.8%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 8.7%
Taylor expanded in x around inf 68.3%
mul-1-neg68.3%
log-rec68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
mul-1-neg68.3%
remove-double-neg68.3%
*-commutative68.3%
Simplified68.3%
expm1-log1p-u68.3%
expm1-udef11.6%
associate-/r*11.6%
div-inv11.6%
pow-to-exp11.7%
pow111.7%
pow-div14.3%
Applied egg-rr14.3%
expm1-def72.3%
expm1-log1p72.3%
sub-neg72.3%
metadata-eval72.3%
Simplified72.3%
if 10 < (/.f64 1 n) < 4.99999999999999973e182Initial program 61.1%
Taylor expanded in x around 0 57.4%
if 4.99999999999999973e182 < (/.f64 1 n) Initial program 35.4%
Taylor expanded in x around inf 1.0%
mul-1-neg1.0%
log-rec1.0%
mul-1-neg1.0%
distribute-neg-frac1.0%
mul-1-neg1.0%
remove-double-neg1.0%
*-commutative1.0%
Simplified1.0%
expm1-log1p-u1.0%
expm1-udef1.0%
associate-/r*1.9%
div-inv1.9%
pow-to-exp1.9%
pow11.9%
pow-div1.9%
Applied egg-rr1.9%
expm1-def1.9%
expm1-log1p1.9%
sub-neg1.9%
metadata-eval1.9%
Simplified1.9%
flip-+1.9%
frac-2neg1.9%
metadata-eval1.9%
sub-neg1.9%
inv-pow1.9%
inv-pow1.9%
pow-prod-up1.9%
metadata-eval1.9%
metadata-eval1.9%
sub-neg1.9%
metadata-eval1.9%
Applied egg-rr1.9%
neg-sub01.9%
+-commutative1.9%
associate--r+1.9%
metadata-eval1.9%
+-commutative1.9%
distribute-neg-in1.9%
metadata-eval1.9%
distribute-neg-frac1.9%
metadata-eval1.9%
Simplified1.9%
sub-neg1.9%
metadata-eval1.9%
pow-prod-up1.9%
inv-pow1.9%
inv-pow1.9%
distribute-rgt-neg-in1.9%
metadata-eval1.9%
associate-*r/1.9%
mul-1-neg1.9%
mul-1-neg1.9%
div-inv1.9%
cancel-sign-sub-inv1.9%
metadata-eval1.9%
flip--1.9%
add-sqr-sqrt0.0%
sqrt-unprod78.5%
frac-times78.5%
metadata-eval78.5%
metadata-eval78.5%
frac-times78.5%
sqrt-prod78.5%
add-sqr-sqrt78.5%
Applied egg-rr78.5%
Final simplification86.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-56)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0)
(/ (pow x (+ (/ 1.0 n) -1.0)) n)
(if (<= (/ 1.0 n) 2e+123)
(- 1.0 t_0)
(/ (pow x (+ -1.0 (/ -1.0 n))) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = pow(x, ((1.0 / n) + -1.0)) / n;
} else if ((1.0 / n) <= 2e+123) {
tmp = 1.0 - t_0;
} else {
tmp = pow(x, (-1.0 + (-1.0 / n))) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-56)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-142) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 10.0d0) then
tmp = (x ** ((1.0d0 / n) + (-1.0d0))) / n
else if ((1.0d0 / n) <= 2d+123) then
tmp = 1.0d0 - t_0
else
tmp = (x ** ((-1.0d0) + ((-1.0d0) / n))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
} else if ((1.0 / n) <= 2e+123) {
tmp = 1.0 - t_0;
} else {
tmp = Math.pow(x, (-1.0 + (-1.0 / n))) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-56: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n elif (1.0 / n) <= 2e+123: tmp = 1.0 - t_0 else: tmp = math.pow(x, (-1.0 + (-1.0 / n))) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-56) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); elseif (Float64(1.0 / n) <= 2e+123) tmp = Float64(1.0 - t_0); else tmp = Float64((x ^ Float64(-1.0 + Float64(-1.0 / n))) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-56) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-142) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 10.0) tmp = (x ^ ((1.0 / n) + -1.0)) / n; elseif ((1.0 / n) <= 2e+123) tmp = 1.0 - t_0; else tmp = (x ^ (-1.0 + (-1.0 / n))) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+123], N[(1.0 - t$95$0), $MachinePrecision], N[(N[Power[x, N[(-1.0 + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+123}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(-1 + \frac{-1}{n}\right)}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999997e-56Initial program 85.7%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
expm1-log1p-u54.6%
expm1-udef44.0%
associate-/r*44.0%
div-inv44.0%
pow-to-exp44.0%
pow144.0%
pow-div44.0%
Applied egg-rr44.0%
expm1-def54.0%
expm1-log1p95.1%
sub-neg95.1%
metadata-eval95.1%
Simplified95.1%
unpow-prod-up95.7%
inv-pow95.7%
*-un-lft-identity95.7%
times-frac95.8%
Applied egg-rr95.8%
/-rgt-identity95.8%
associate-/l/95.7%
associate-/r*95.7%
associate-*r/95.7%
associate-*r/95.8%
*-rgt-identity95.8%
Simplified95.8%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 8.7%
Taylor expanded in x around inf 68.3%
mul-1-neg68.3%
log-rec68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
mul-1-neg68.3%
remove-double-neg68.3%
*-commutative68.3%
Simplified68.3%
expm1-log1p-u68.3%
expm1-udef11.6%
associate-/r*11.6%
div-inv11.6%
pow-to-exp11.7%
pow111.7%
pow-div14.3%
Applied egg-rr14.3%
expm1-def72.3%
expm1-log1p72.3%
sub-neg72.3%
metadata-eval72.3%
Simplified72.3%
if 10 < (/.f64 1 n) < 1.99999999999999996e123Initial program 67.5%
Taylor expanded in x around 0 61.1%
if 1.99999999999999996e123 < (/.f64 1 n) Initial program 43.9%
Taylor expanded in x around inf 0.8%
mul-1-neg0.8%
log-rec0.8%
mul-1-neg0.8%
distribute-neg-frac0.8%
mul-1-neg0.8%
remove-double-neg0.8%
*-commutative0.8%
Simplified0.8%
expm1-log1p-u0.8%
expm1-udef0.8%
associate-/r*2.1%
div-inv2.1%
pow-to-exp2.1%
pow12.1%
pow-div2.1%
Applied egg-rr2.1%
expm1-def2.1%
expm1-log1p2.1%
sub-neg2.1%
metadata-eval2.1%
Simplified2.1%
flip-+2.1%
frac-2neg2.1%
metadata-eval2.1%
sub-neg2.1%
inv-pow2.1%
inv-pow2.1%
pow-prod-up2.1%
metadata-eval2.1%
metadata-eval2.1%
sub-neg2.1%
metadata-eval2.1%
Applied egg-rr2.1%
neg-sub02.1%
+-commutative2.1%
associate--r+2.1%
metadata-eval2.1%
+-commutative2.1%
distribute-neg-in2.1%
metadata-eval2.1%
distribute-neg-frac2.1%
metadata-eval2.1%
Simplified2.1%
sub-neg2.1%
metadata-eval2.1%
pow-prod-up2.1%
inv-pow2.1%
inv-pow2.1%
distribute-rgt-neg-in2.1%
metadata-eval2.1%
associate-*r/2.1%
mul-1-neg2.1%
mul-1-neg2.1%
div-inv2.1%
cancel-sign-sub-inv2.1%
metadata-eval2.1%
flip--2.1%
add-sqr-sqrt0.0%
sqrt-unprod64.3%
frac-times64.3%
metadata-eval64.3%
metadata-eval64.3%
frac-times64.3%
sqrt-prod64.3%
add-sqr-sqrt64.3%
Applied egg-rr64.3%
Final simplification86.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ 1.0 (* n (+ x 0.5)))))
(if (<= (/ 1.0 n) -20000000.0)
(/ t_0 n)
(if (<= (/ 1.0 n) -5e-56)
t_1
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0) t_1 (- 1.0 t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 / (n * (x + 0.5));
double tmp;
if ((1.0 / n) <= -20000000.0) {
tmp = t_0 / n;
} else if ((1.0 / n) <= -5e-56) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = 1.0d0 / (n * (x + 0.5d0))
if ((1.0d0 / n) <= (-20000000.0d0)) then
tmp = t_0 / n
else if ((1.0d0 / n) <= (-5d-56)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-142) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 10.0d0) then
tmp = t_1
else
tmp = 1.0d0 - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = 1.0 / (n * (x + 0.5));
double tmp;
if ((1.0 / n) <= -20000000.0) {
tmp = t_0 / n;
} else if ((1.0 / n) <= -5e-56) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 / (n * (x + 0.5)) tmp = 0 if (1.0 / n) <= -20000000.0: tmp = t_0 / n elif (1.0 / n) <= -5e-56: tmp = t_1 elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = t_1 else: tmp = 1.0 - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 / Float64(n * Float64(x + 0.5))) tmp = 0.0 if (Float64(1.0 / n) <= -20000000.0) tmp = Float64(t_0 / n); elseif (Float64(1.0 / n) <= -5e-56) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = t_1; else tmp = Float64(1.0 - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = 1.0 / (n * (x + 0.5)); tmp = 0.0; if ((1.0 / n) <= -20000000.0) tmp = t_0 / n; elseif ((1.0 / n) <= -5e-56) tmp = t_1; elseif ((1.0 / n) <= 5e-142) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 10.0) tmp = t_1; else tmp = 1.0 - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -20000000.0], N[(t$95$0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], t$95$1, N[(1.0 - t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -20000000:\\
\;\;\;\;\frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e7Initial program 100.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%
expm1-log1p-u50.7%
expm1-udef50.7%
associate-/r*50.7%
div-inv50.7%
pow-to-exp50.7%
pow150.7%
pow-div50.7%
Applied egg-rr50.7%
expm1-def50.7%
expm1-log1p100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in n around 0 100.0%
if -2e7 < (/.f64 1 n) < -4.99999999999999997e-56 or 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 11.1%
Taylor expanded in n around inf 35.3%
+-rgt-identity35.3%
+-rgt-identity35.3%
log1p-def35.3%
Simplified35.3%
clear-num35.4%
inv-pow35.4%
Applied egg-rr35.4%
unpow-135.4%
Simplified35.4%
Taylor expanded in x around inf 66.6%
+-commutative66.6%
*-commutative66.6%
distribute-lft-out66.6%
Simplified66.6%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 10 < (/.f64 1 n) Initial program 54.3%
Taylor expanded in x around 0 48.6%
Final simplification83.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -5e-56)
t_1
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0) t_1 (- 1.0 t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-5d-56)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-142) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 10.0d0) then
tmp = t_1
else
tmp = 1.0d0 - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -5e-56: tmp = t_1 elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = t_1 else: tmp = 1.0 - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -5e-56) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = t_1; else tmp = Float64(1.0 - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (t_0 / n) / x; tmp = 0.0; if ((1.0 / n) <= -5e-56) tmp = t_1; elseif ((1.0 / n) <= 5e-142) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 10.0) tmp = t_1; else tmp = 1.0 - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], t$95$1, N[(1.0 - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{t_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999997e-56 or 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 64.7%
Taylor expanded in x around inf 88.3%
mul-1-neg88.3%
log-rec88.3%
mul-1-neg88.3%
distribute-neg-frac88.3%
mul-1-neg88.3%
remove-double-neg88.3%
*-commutative88.3%
Simplified88.3%
expm1-log1p-u58.4%
expm1-udef35.1%
associate-/r*35.1%
div-inv35.1%
pow-to-exp35.2%
pow135.2%
pow-div35.9%
Applied egg-rr35.9%
expm1-def59.0%
expm1-log1p88.9%
sub-neg88.9%
metadata-eval88.9%
Simplified88.9%
unpow-prod-up88.7%
inv-pow88.7%
*-un-lft-identity88.7%
times-frac88.7%
Applied egg-rr88.7%
/-rgt-identity88.7%
associate-/l/88.3%
associate-/r*88.7%
associate-*r/88.7%
associate-*r/88.7%
*-rgt-identity88.7%
Simplified88.7%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 10 < (/.f64 1 n) Initial program 54.3%
Taylor expanded in x around 0 48.6%
Final simplification84.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-56)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-142)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 10.0)
(/ (pow x (+ (/ 1.0 n) -1.0)) n)
(- 1.0 t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = pow(x, ((1.0 / n) + -1.0)) / n;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-56)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-142) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 10.0d0) then
tmp = (x ** ((1.0d0 / n) + (-1.0d0))) / n
else
tmp = 1.0d0 - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-56) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-142) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 10.0) {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-56: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-142: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 10.0: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n else: tmp = 1.0 - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-56) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-142) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); else tmp = Float64(1.0 - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-56) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-142) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 10.0) tmp = (x ^ ((1.0 / n) + -1.0)) / n; else tmp = 1.0 - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-56], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-142], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(1.0 - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\mathbf{else}:\\
\;\;\;\;1 - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999997e-56Initial program 85.7%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
expm1-log1p-u54.6%
expm1-udef44.0%
associate-/r*44.0%
div-inv44.0%
pow-to-exp44.0%
pow144.0%
pow-div44.0%
Applied egg-rr44.0%
expm1-def54.0%
expm1-log1p95.1%
sub-neg95.1%
metadata-eval95.1%
Simplified95.1%
unpow-prod-up95.7%
inv-pow95.7%
*-un-lft-identity95.7%
times-frac95.8%
Applied egg-rr95.8%
/-rgt-identity95.8%
associate-/l/95.7%
associate-/r*95.7%
associate-*r/95.7%
associate-*r/95.8%
*-rgt-identity95.8%
Simplified95.8%
if -4.99999999999999997e-56 < (/.f64 1 n) < 5.0000000000000002e-142Initial program 44.4%
Taylor expanded in n around inf 91.6%
+-rgt-identity91.6%
+-rgt-identity91.6%
log1p-def91.6%
Simplified91.6%
log1p-udef91.6%
diff-log91.8%
Applied egg-rr91.8%
if 5.0000000000000002e-142 < (/.f64 1 n) < 10Initial program 8.7%
Taylor expanded in x around inf 68.3%
mul-1-neg68.3%
log-rec68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
mul-1-neg68.3%
remove-double-neg68.3%
*-commutative68.3%
Simplified68.3%
expm1-log1p-u68.3%
expm1-udef11.6%
associate-/r*11.6%
div-inv11.6%
pow-to-exp11.7%
pow111.7%
pow-div14.3%
Applied egg-rr14.3%
expm1-def72.3%
expm1-log1p72.3%
sub-neg72.3%
metadata-eval72.3%
Simplified72.3%
if 10 < (/.f64 1 n) Initial program 54.3%
Taylor expanded in x around 0 48.6%
Final simplification84.9%
(FPCore (x n)
:precision binary64
(if (<= x 4.5e-171)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.21)
(/ (- x (log x)) n)
(if (<= x 1.65e+212)
(/ (/ 1.0 x) n)
(/ (/ 0.3333333333333333 (pow x 3.0)) n)))))
double code(double x, double n) {
double tmp;
if (x <= 4.5e-171) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.21) {
tmp = (x - log(x)) / n;
} else if (x <= 1.65e+212) {
tmp = (1.0 / x) / n;
} else {
tmp = (0.3333333333333333 / pow(x, 3.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.5d-171) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.21d0) then
tmp = (x - log(x)) / n
else if (x <= 1.65d+212) then
tmp = (1.0d0 / x) / n
else
tmp = (0.3333333333333333d0 / (x ** 3.0d0)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 4.5e-171) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.21) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.65e+212) {
tmp = (1.0 / x) / n;
} else {
tmp = (0.3333333333333333 / Math.pow(x, 3.0)) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.5e-171: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.21: tmp = (x - math.log(x)) / n elif x <= 1.65e+212: tmp = (1.0 / x) / n else: tmp = (0.3333333333333333 / math.pow(x, 3.0)) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 4.5e-171) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.21) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.65e+212) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(Float64(0.3333333333333333 / (x ^ 3.0)) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.5e-171) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.21) tmp = (x - log(x)) / n; elseif (x <= 1.65e+212) tmp = (1.0 / x) / n; else tmp = (0.3333333333333333 / (x ^ 3.0)) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.5e-171], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.21], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.65e+212], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.5 \cdot 10^{-171}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.21:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+212}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\
\end{array}
\end{array}
if x < 4.5000000000000004e-171Initial program 63.3%
Taylor expanded in x around 0 63.3%
if 4.5000000000000004e-171 < x < 0.209999999999999992Initial program 30.4%
Taylor expanded in n around inf 57.3%
+-rgt-identity57.3%
+-rgt-identity57.3%
log1p-def57.3%
Simplified57.3%
Taylor expanded in x around 0 56.9%
neg-mul-156.9%
unsub-neg56.9%
Simplified56.9%
if 0.209999999999999992 < x < 1.65e212Initial program 58.7%
Taylor expanded in n around inf 57.8%
+-rgt-identity57.8%
+-rgt-identity57.8%
log1p-def57.8%
Simplified57.8%
Taylor expanded in x around inf 67.3%
if 1.65e212 < x Initial program 89.4%
Taylor expanded in n around inf 89.5%
+-rgt-identity89.5%
+-rgt-identity89.5%
log1p-def89.5%
Simplified89.5%
Taylor expanded in x around inf 61.5%
associate--l+61.5%
associate-*r/61.5%
metadata-eval61.5%
associate-*r/61.5%
metadata-eval61.5%
Simplified61.5%
Taylor expanded in x around 0 89.5%
Final simplification66.4%
(FPCore (x n) :precision binary64 (if (<= x 4.5e-171) (- 1.0 (pow x (/ 1.0 n))) (if (<= x 0.21) (/ (- x (log x)) n) (/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (x <= 4.5e-171) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.21) {
tmp = (x - log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 4.5d-171) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.21d0) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 4.5e-171) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.21) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.5e-171: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.21: tmp = (x - math.log(x)) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 4.5e-171) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.21) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.5e-171) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.21) tmp = (x - log(x)) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.5e-171], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.21], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.5 \cdot 10^{-171}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.21:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 4.5000000000000004e-171Initial program 63.3%
Taylor expanded in x around 0 63.3%
if 4.5000000000000004e-171 < x < 0.209999999999999992Initial program 30.4%
Taylor expanded in n around inf 57.3%
+-rgt-identity57.3%
+-rgt-identity57.3%
log1p-def57.3%
Simplified57.3%
Taylor expanded in x around 0 56.9%
neg-mul-156.9%
unsub-neg56.9%
Simplified56.9%
if 0.209999999999999992 < x Initial program 67.3%
Taylor expanded in n around inf 66.7%
+-rgt-identity66.7%
+-rgt-identity66.7%
log1p-def66.7%
Simplified66.7%
Taylor expanded in x around inf 65.7%
Final simplification62.5%
(FPCore (x n) :precision binary64 (if (<= x 0.21) (/ (- x (log x)) n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.21) {
tmp = (x - log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.21d0) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.21) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.21: tmp = (x - math.log(x)) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.21) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.21) tmp = (x - log(x)) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.21], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.21:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 0.209999999999999992Initial program 44.0%
Taylor expanded in n around inf 51.2%
+-rgt-identity51.2%
+-rgt-identity51.2%
log1p-def51.2%
Simplified51.2%
Taylor expanded in x around 0 51.0%
neg-mul-151.0%
unsub-neg51.0%
Simplified51.0%
if 0.209999999999999992 < x Initial program 67.3%
Taylor expanded in n around inf 66.7%
+-rgt-identity66.7%
+-rgt-identity66.7%
log1p-def66.7%
Simplified66.7%
Taylor expanded in x around inf 65.7%
Final simplification58.1%
(FPCore (x n) :precision binary64 (if (<= x 0.21) (/ (- (log x)) n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.21) {
tmp = -log(x) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.21d0) then
tmp = -log(x) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.21) {
tmp = -Math.log(x) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.21: tmp = -math.log(x) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.21) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.21) tmp = -log(x) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.21], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.21:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 0.209999999999999992Initial program 44.0%
Taylor expanded in x around 0 42.5%
Taylor expanded in n around inf 50.8%
neg-mul-150.8%
distribute-neg-frac50.8%
Simplified50.8%
if 0.209999999999999992 < x Initial program 67.3%
Taylor expanded in n around inf 66.7%
+-rgt-identity66.7%
+-rgt-identity66.7%
log1p-def66.7%
Simplified66.7%
Taylor expanded in x around inf 65.7%
Final simplification58.0%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 55.3%
Taylor expanded in x around inf 62.7%
mul-1-neg62.7%
log-rec62.7%
mul-1-neg62.7%
distribute-neg-frac62.7%
mul-1-neg62.7%
remove-double-neg62.7%
*-commutative62.7%
Simplified62.7%
Taylor expanded in n around inf 43.5%
*-commutative43.5%
Simplified43.5%
Final simplification43.5%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 55.3%
Taylor expanded in n around inf 58.7%
+-rgt-identity58.7%
+-rgt-identity58.7%
log1p-def58.7%
Simplified58.7%
Taylor expanded in x around inf 44.0%
Final simplification44.0%
herbie shell --seed 2023318
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))