
(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 13 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-22)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-69)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 200000.0)
(/ (exp (/ (log x) n)) (* n x))
(- (exp (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-22) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-69) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = exp((log(x) / n)) / (n * x);
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-22)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-69) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 200000.0d0) then
tmp = exp((log(x) / n)) / (n * x)
else
tmp = exp((x / n)) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-22) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-69) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-22: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-69: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 200000.0: tmp = math.exp((math.log(x) / n)) / (n * x) else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-22) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 200000.0) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-22) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-69) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 200000.0) tmp = exp((log(x) / n)) / (n * x); else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-22], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.99999999999999954e-22Initial program 95.5%
Taylor expanded in x around inf 97.4%
associate-/r*97.8%
mul-1-neg97.8%
log-rec97.8%
mul-1-neg97.8%
distribute-neg-frac97.8%
mul-1-neg97.8%
remove-double-neg97.8%
*-rgt-identity97.8%
associate-/l*97.8%
exp-to-pow97.8%
Simplified97.8%
if -4.99999999999999954e-22 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e-69Initial program 26.7%
Taylor expanded in n around inf 82.5%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.5%
diff-log82.7%
Applied egg-rr82.7%
+-commutative82.7%
Simplified82.7%
if 1.9999999999999999e-69 < (/.f64 #s(literal 1 binary64) n) < 2e5Initial program 10.0%
Taylor expanded in x around inf 68.4%
mul-1-neg68.4%
log-rec68.4%
mul-1-neg68.4%
distribute-neg-frac68.4%
mul-1-neg68.4%
remove-double-neg68.4%
*-commutative68.4%
Simplified68.4%
if 2e5 < (/.f64 #s(literal 1 binary64) n) Initial program 45.2%
Taylor expanded in n around 0 45.2%
log1p-define100.0%
*-rgt-identity100.0%
associate-*l/100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(if (<= x 1e-35)
(* x (- (/ 1.0 n) (/ (log x) (* n x))))
(if (<= x 3.7e-16)
(log1p (expm1 (/ x n)))
(if (<= x 92.0)
(/ (log (/ (+ 1.0 x) x)) n)
(/ (/ (pow x (/ 1.0 n)) n) x)))))
double code(double x, double n) {
double tmp;
if (x <= 1e-35) {
tmp = x * ((1.0 / n) - (log(x) / (n * x)));
} else if (x <= 3.7e-16) {
tmp = log1p(expm1((x / n)));
} else if (x <= 92.0) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 1e-35) {
tmp = x * ((1.0 / n) - (Math.log(x) / (n * x)));
} else if (x <= 3.7e-16) {
tmp = Math.log1p(Math.expm1((x / n)));
} else if (x <= 92.0) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1e-35: tmp = x * ((1.0 / n) - (math.log(x) / (n * x))) elif x <= 3.7e-16: tmp = math.log1p(math.expm1((x / n))) elif x <= 92.0: tmp = math.log(((1.0 + x) / x)) / n else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 1e-35) tmp = Float64(x * Float64(Float64(1.0 / n) - Float64(log(x) / Float64(n * x)))); elseif (x <= 3.7e-16) tmp = log1p(expm1(Float64(x / n))); elseif (x <= 92.0) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 1e-35], N[(x * N[(N[(1.0 / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.7e-16], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 92.0], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-35}:\\
\;\;\;\;x \cdot \left(\frac{1}{n} - \frac{\log x}{n \cdot x}\right)\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\mathbf{elif}\;x \leq 92:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 1.00000000000000001e-35Initial program 38.4%
Taylor expanded in n around inf 58.3%
log1p-define58.3%
Simplified58.3%
Taylor expanded in x around 0 58.3%
Taylor expanded in x around inf 74.3%
log-rec74.3%
*-commutative74.3%
Simplified74.3%
if 1.00000000000000001e-35 < x < 3.7e-16Initial program 68.2%
Taylor expanded in n around inf 16.5%
log1p-define16.5%
Simplified16.5%
Taylor expanded in x around inf 7.5%
*-commutative7.5%
Simplified7.5%
log1p-expm1-u89.9%
associate-/r*89.9%
rem-exp-log89.9%
neg-log89.9%
add-sqr-sqrt89.9%
sqrt-unprod89.9%
sqr-neg89.9%
sqrt-prod0.0%
add-sqr-sqrt89.9%
add-exp-log89.9%
Applied egg-rr89.9%
if 3.7e-16 < x < 92Initial program 17.8%
Taylor expanded in n around inf 89.1%
log1p-define89.1%
Simplified89.1%
log1p-undefine89.1%
diff-log89.3%
Applied egg-rr89.3%
+-commutative89.3%
Simplified89.3%
if 92 < x Initial program 65.9%
Taylor expanded in x around inf 97.8%
associate-/r*98.8%
mul-1-neg98.8%
log-rec98.8%
mul-1-neg98.8%
distribute-neg-frac98.8%
mul-1-neg98.8%
remove-double-neg98.8%
*-rgt-identity98.8%
associate-/l*98.8%
exp-to-pow98.8%
Simplified98.8%
Final simplification86.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -5e-22)
t_1
(if (<= (/ 1.0 n) 2e-69)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 200000.0)
t_1
(if (<= (/ 1.0 n) 1e+182)
(- (+ 1.0 (/ x n)) t_0)
(/
(+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x))
x)))))))
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-22) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-69) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+182) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-5d-22)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-69) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 200000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+182) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -5e-22) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-69) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+182) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
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-22: tmp = t_1 elif (1.0 / n) <= 2e-69: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 200000.0: tmp = t_1 elif (1.0 / n) <= 1e+182: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x 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-22) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 200000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+182) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x); 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-22) tmp = t_1; elseif ((1.0 / n) <= 2e-69) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 200000.0) tmp = t_1; elseif ((1.0 / n) <= 1e+182) tmp = (1.0 + (x / n)) - t_0; else tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-22], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+182], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $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^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+182}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.99999999999999954e-22 or 1.9999999999999999e-69 < (/.f64 #s(literal 1 binary64) n) < 2e5Initial program 80.8%
Taylor expanded in x around inf 92.4%
associate-/r*92.8%
mul-1-neg92.8%
log-rec92.8%
mul-1-neg92.8%
distribute-neg-frac92.8%
mul-1-neg92.8%
remove-double-neg92.8%
*-rgt-identity92.8%
associate-/l*92.8%
exp-to-pow92.7%
Simplified92.7%
if -4.99999999999999954e-22 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e-69Initial program 26.7%
Taylor expanded in n around inf 82.5%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.5%
diff-log82.7%
Applied egg-rr82.7%
+-commutative82.7%
Simplified82.7%
if 2e5 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e182Initial program 60.1%
Taylor expanded in x around 0 61.0%
if 1.0000000000000001e182 < (/.f64 #s(literal 1 binary64) n) Initial program 24.2%
Taylor expanded in n around inf 6.7%
log1p-define6.7%
Simplified6.7%
clear-num6.7%
associate-/r/6.7%
Applied egg-rr6.7%
Taylor expanded in x around inf 1.2%
Simplified61.9%
Final simplification84.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -5e-22)
t_1
(if (<= (/ 1.0 n) 2e-69)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 200000.0)
t_1
(if (<= (/ 1.0 n) 1e+170)
(- 1.0 t_0)
(/
(+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x))
x)))))))
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-22) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-69) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+170) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-5d-22)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-69) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 200000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+170) then
tmp = 1.0d0 - t_0
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -5e-22) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-69) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 200000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+170) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
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-22: tmp = t_1 elif (1.0 / n) <= 2e-69: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 200000.0: tmp = t_1 elif (1.0 / n) <= 1e+170: tmp = 1.0 - t_0 else: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x 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-22) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 200000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+170) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x); 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-22) tmp = t_1; elseif ((1.0 / n) <= 2e-69) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 200000.0) tmp = t_1; elseif ((1.0 / n) <= 1e+170) tmp = 1.0 - t_0; else tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-22], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 200000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+170], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $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^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 200000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+170}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.99999999999999954e-22 or 1.9999999999999999e-69 < (/.f64 #s(literal 1 binary64) n) < 2e5Initial program 80.8%
Taylor expanded in x around inf 92.4%
associate-/r*92.8%
mul-1-neg92.8%
log-rec92.8%
mul-1-neg92.8%
distribute-neg-frac92.8%
mul-1-neg92.8%
remove-double-neg92.8%
*-rgt-identity92.8%
associate-/l*92.8%
exp-to-pow92.7%
Simplified92.7%
if -4.99999999999999954e-22 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e-69Initial program 26.7%
Taylor expanded in n around inf 82.5%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.5%
diff-log82.7%
Applied egg-rr82.7%
+-commutative82.7%
Simplified82.7%
if 2e5 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000003e170Initial program 61.6%
Taylor expanded in x around 0 61.6%
*-rgt-identity61.6%
associate-*l/61.6%
associate-/l*61.6%
exp-to-pow61.6%
Simplified61.6%
if 1.00000000000000003e170 < (/.f64 #s(literal 1 binary64) n) Initial program 28.8%
Taylor expanded in n around inf 6.4%
log1p-define6.4%
Simplified6.4%
clear-num6.4%
associate-/r/6.4%
Applied egg-rr6.4%
Taylor expanded in x around inf 9.4%
Simplified60.1%
Final simplification84.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 1e-35)
(* x (- (/ 1.0 n) (/ (log x) (* n x))))
(if (<= x 3.5e-16)
(- (+ 1.0 (/ x n)) t_0)
(if (<= x 145.0) (/ (log (/ (+ 1.0 x) x)) n) (/ (/ t_0 n) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 1e-35) {
tmp = x * ((1.0 / n) - (log(x) / (n * x)));
} else if (x <= 3.5e-16) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 145.0) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 1d-35) then
tmp = x * ((1.0d0 / n) - (log(x) / (n * x)))
else if (x <= 3.5d-16) then
tmp = (1.0d0 + (x / n)) - t_0
else if (x <= 145.0d0) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = (t_0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1e-35) {
tmp = x * ((1.0 / n) - (Math.log(x) / (n * x)));
} else if (x <= 3.5e-16) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 145.0) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 1e-35: tmp = x * ((1.0 / n) - (math.log(x) / (n * x))) elif x <= 3.5e-16: tmp = (1.0 + (x / n)) - t_0 elif x <= 145.0: tmp = math.log(((1.0 + x) / x)) / n else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1e-35) tmp = Float64(x * Float64(Float64(1.0 / n) - Float64(log(x) / Float64(n * x)))); elseif (x <= 3.5e-16) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif (x <= 145.0) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 1e-35) tmp = x * ((1.0 / n) - (log(x) / (n * x))); elseif (x <= 3.5e-16) tmp = (1.0 + (x / n)) - t_0; elseif (x <= 145.0) tmp = log(((1.0 + x) / x)) / n; else tmp = (t_0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1e-35], N[(x * N[(N[(1.0 / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.5e-16], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 145.0], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 10^{-35}:\\
\;\;\;\;x \cdot \left(\frac{1}{n} - \frac{\log x}{n \cdot x}\right)\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-16}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{elif}\;x \leq 145:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.00000000000000001e-35Initial program 38.4%
Taylor expanded in n around inf 58.3%
log1p-define58.3%
Simplified58.3%
Taylor expanded in x around 0 58.3%
Taylor expanded in x around inf 74.3%
log-rec74.3%
*-commutative74.3%
Simplified74.3%
if 1.00000000000000001e-35 < x < 3.50000000000000017e-16Initial program 68.2%
Taylor expanded in x around 0 68.5%
if 3.50000000000000017e-16 < x < 145Initial program 17.8%
Taylor expanded in n around inf 89.1%
log1p-define89.1%
Simplified89.1%
log1p-undefine89.1%
diff-log89.3%
Applied egg-rr89.3%
+-commutative89.3%
Simplified89.3%
if 145 < x Initial program 65.9%
Taylor expanded in x around inf 97.8%
associate-/r*98.8%
mul-1-neg98.8%
log-rec98.8%
mul-1-neg98.8%
distribute-neg-frac98.8%
mul-1-neg98.8%
remove-double-neg98.8%
*-rgt-identity98.8%
associate-/l*98.8%
exp-to-pow98.8%
Simplified98.8%
Final simplification85.2%
(FPCore (x n)
:precision binary64
(if (<= x 3e-163)
(/ (log x) (- n))
(if (<= x 3e-119)
(/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x)
(if (<= x 0.88)
(/ (- x (log x)) n)
(/
(/
(+ 1.0 (/ (- (/ (+ 0.3333333333333333 (* 0.25 (/ -1.0 x))) x) 0.5) x))
x)
n)))))
double code(double x, double n) {
double tmp;
if (x <= 3e-163) {
tmp = log(x) / -n;
} else if (x <= 3e-119) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
} else if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3d-163) then
tmp = log(x) / -n
else if (x <= 3d-119) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
else if (x <= 0.88d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 + (0.25d0 * ((-1.0d0) / x))) / x) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3e-163) {
tmp = Math.log(x) / -n;
} else if (x <= 3e-119) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
} else if (x <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3e-163: tmp = math.log(x) / -n elif x <= 3e-119: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x elif x <= 0.88: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 3e-163) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 3e-119) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x); elseif (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(0.25 * Float64(-1.0 / x))) / x) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3e-163) tmp = log(x) / -n; elseif (x <= 3e-119) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; elseif (x <= 0.88) tmp = (x - log(x)) / n; else tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3e-163], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 3e-119], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 + N[(0.25 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3 \cdot 10^{-163}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + 0.25 \cdot \frac{-1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 3.0000000000000002e-163Initial program 36.4%
Taylor expanded in n around inf 63.8%
log1p-define63.8%
Simplified63.8%
Taylor expanded in x around 0 63.8%
neg-mul-163.8%
Simplified63.8%
if 3.0000000000000002e-163 < x < 3.0000000000000002e-119Initial program 67.9%
Taylor expanded in n around inf 30.7%
log1p-define30.7%
Simplified30.7%
clear-num30.7%
associate-/r/30.6%
Applied egg-rr30.6%
Taylor expanded in x around inf 34.4%
Simplified61.1%
if 3.0000000000000002e-119 < x < 0.880000000000000004Initial program 34.6%
Taylor expanded in n around inf 57.0%
log1p-define57.0%
Simplified57.0%
Taylor expanded in x around 0 55.7%
if 0.880000000000000004 < x Initial program 65.9%
Taylor expanded in n around inf 66.3%
log1p-define66.3%
Simplified66.3%
Taylor expanded in x around -inf 60.8%
Final simplification60.5%
(FPCore (x n)
:precision binary64
(if (<= x 1.8e-170)
(/ (log x) (- n))
(if (<= x 5.7e-117)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.9)
(/ (- x (log x)) n)
(/
(/
(+ 1.0 (/ (- (/ (+ 0.3333333333333333 (* 0.25 (/ -1.0 x))) x) 0.5) x))
x)
n)))))
double code(double x, double n) {
double tmp;
if (x <= 1.8e-170) {
tmp = log(x) / -n;
} else if (x <= 5.7e-117) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.8d-170) then
tmp = log(x) / -n
else if (x <= 5.7d-117) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 + (0.25d0 * ((-1.0d0) / x))) / x) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.8e-170) {
tmp = Math.log(x) / -n;
} else if (x <= 5.7e-117) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.8e-170: tmp = math.log(x) / -n elif x <= 5.7e-117: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.9: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.8e-170) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 5.7e-117) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(0.25 * Float64(-1.0 / x))) / x) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.8e-170) tmp = log(x) / -n; elseif (x <= 5.7e-117) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.9) tmp = (x - log(x)) / n; else tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.8e-170], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 5.7e-117], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 + N[(0.25 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{-170}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{-117}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + 0.25 \cdot \frac{-1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 1.8000000000000002e-170Initial program 34.4%
Taylor expanded in n around inf 65.4%
log1p-define65.4%
Simplified65.4%
Taylor expanded in x around 0 65.4%
neg-mul-165.4%
Simplified65.4%
if 1.8000000000000002e-170 < x < 5.6999999999999999e-117Initial program 64.8%
Taylor expanded in x around 0 64.8%
*-rgt-identity64.8%
associate-*l/64.8%
associate-/l*64.8%
exp-to-pow64.8%
Simplified64.8%
if 5.6999999999999999e-117 < x < 0.900000000000000022Initial program 34.7%
Taylor expanded in n around inf 57.9%
log1p-define57.9%
Simplified57.9%
Taylor expanded in x around 0 56.6%
if 0.900000000000000022 < x Initial program 65.9%
Taylor expanded in n around inf 66.3%
log1p-define66.3%
Simplified66.3%
Taylor expanded in x around -inf 60.8%
Final simplification61.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.4e-163)
t_0
(if (<= x 6.5e-119)
(/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x)
(if (<= x 0.7)
t_0
(/
(/
(+
1.0
(/ (- (/ (+ 0.3333333333333333 (* 0.25 (/ -1.0 x))) x) 0.5) x))
x)
n))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.4e-163) {
tmp = t_0;
} else if (x <= 6.5e-119) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
} else if (x <= 0.7) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 1.4d-163) then
tmp = t_0
else if (x <= 6.5d-119) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
else if (x <= 0.7d0) then
tmp = t_0
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 + (0.25d0 * ((-1.0d0) / x))) / x) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 1.4e-163) {
tmp = t_0;
} else if (x <= 6.5e-119) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
} else if (x <= 0.7) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.4e-163: tmp = t_0 elif x <= 6.5e-119: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x elif x <= 0.7: tmp = t_0 else: tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.4e-163) tmp = t_0; elseif (x <= 6.5e-119) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x); elseif (x <= 0.7) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(0.25 * Float64(-1.0 / x))) / x) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.4e-163) tmp = t_0; elseif (x <= 6.5e-119) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; elseif (x <= 0.7) tmp = t_0; else tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.4e-163], t$95$0, If[LessEqual[x, 6.5e-119], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.7], t$95$0, N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 + N[(0.25 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.4 \cdot 10^{-163}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.7:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + 0.25 \cdot \frac{-1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 1.4e-163 or 6.5e-119 < x < 0.69999999999999996Initial program 35.6%
Taylor expanded in n around inf 60.7%
log1p-define60.7%
Simplified60.7%
Taylor expanded in x around 0 59.2%
neg-mul-159.2%
Simplified59.2%
if 1.4e-163 < x < 6.5e-119Initial program 67.9%
Taylor expanded in n around inf 30.7%
log1p-define30.7%
Simplified30.7%
clear-num30.7%
associate-/r/30.6%
Applied egg-rr30.6%
Taylor expanded in x around inf 34.4%
Simplified61.1%
if 0.69999999999999996 < x Initial program 65.9%
Taylor expanded in n around inf 66.3%
log1p-define66.3%
Simplified66.3%
Taylor expanded in x around -inf 60.8%
Final simplification60.0%
(FPCore (x n) :precision binary64 (if (or (<= n -9.6e-231) (not (<= n 2.5e+67))) (/ (log (/ (+ 1.0 x) x)) n) (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x)))
double code(double x, double n) {
double tmp;
if ((n <= -9.6e-231) || !(n <= 2.5e+67)) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-9.6d-231)) .or. (.not. (n <= 2.5d+67))) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -9.6e-231) || !(n <= 2.5e+67)) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -9.6e-231) or not (n <= 2.5e+67): tmp = math.log(((1.0 + x) / x)) / n else: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if ((n <= -9.6e-231) || !(n <= 2.5e+67)) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -9.6e-231) || ~((n <= 2.5e+67))) tmp = log(((1.0 + x) / x)) / n; else tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -9.6e-231], N[Not[LessEqual[n, 2.5e+67]], $MachinePrecision]], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.6 \cdot 10^{-231} \lor \neg \left(n \leq 2.5 \cdot 10^{+67}\right):\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if n < -9.59999999999999967e-231 or 2.49999999999999988e67 < n Initial program 50.0%
Taylor expanded in n around inf 73.6%
log1p-define73.6%
Simplified73.6%
log1p-undefine73.6%
diff-log73.2%
Applied egg-rr73.2%
+-commutative73.2%
Simplified73.2%
if -9.59999999999999967e-231 < n < 2.49999999999999988e67Initial program 52.6%
Taylor expanded in n around inf 23.2%
log1p-define23.2%
Simplified23.2%
clear-num23.2%
associate-/r/23.2%
Applied egg-rr23.2%
Taylor expanded in x around inf 27.6%
Simplified53.7%
Final simplification68.5%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}
\end{array}
Initial program 50.6%
Taylor expanded in n around inf 61.4%
log1p-define61.4%
Simplified61.4%
clear-num61.3%
associate-/r/61.4%
Applied egg-rr61.4%
Taylor expanded in x around inf 35.3%
Simplified44.0%
Final simplification44.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 50.6%
Taylor expanded in n around inf 61.4%
log1p-define61.4%
Simplified61.4%
Taylor expanded in x around inf 36.9%
*-commutative36.9%
Simplified36.9%
Final simplification36.9%
(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 50.6%
Taylor expanded in n around inf 61.4%
log1p-define61.4%
Simplified61.4%
Taylor expanded in x around inf 36.9%
*-commutative36.9%
Simplified36.9%
Taylor expanded in x around 0 36.9%
associate-/r*37.4%
Simplified37.4%
Final simplification37.4%
(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 50.6%
Taylor expanded in n around inf 61.4%
log1p-define61.4%
Simplified61.4%
Taylor expanded in x around inf 36.9%
*-commutative36.9%
Simplified36.9%
*-un-lft-identity36.9%
associate-/r*37.3%
rem-exp-log36.3%
neg-log36.3%
add-sqr-sqrt11.4%
sqrt-unprod12.8%
sqr-neg12.8%
sqrt-prod1.4%
add-sqr-sqrt4.6%
add-exp-log4.6%
Applied egg-rr4.6%
*-lft-identity4.6%
Simplified4.6%
Final simplification4.6%
herbie shell --seed 2024084
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))