
(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 15 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 (/ (log x) n))
(t_1 (* -0.16666666666666666 (pow t_0 3.0)))
(t_2 (pow x (/ 1.0 n)))
(t_3 (cbrt t_2)))
(if (<= x 8.2e-153)
(- (+ (* -0.5 (pow (+ (log (* t_3 t_3)) (log t_3)) 2.0)) t_1) t_0)
(if (<= x 4.7e-125)
(- (exp (/ x n)) t_2)
(if (<= x 1.0)
(- (+ t_1 (* -0.5 (pow t_0 2.0))) t_0)
(/ t_2 (* x n)))))))
double code(double x, double n) {
double t_0 = log(x) / n;
double t_1 = -0.16666666666666666 * pow(t_0, 3.0);
double t_2 = pow(x, (1.0 / n));
double t_3 = cbrt(t_2);
double tmp;
if (x <= 8.2e-153) {
tmp = ((-0.5 * pow((log((t_3 * t_3)) + log(t_3)), 2.0)) + t_1) - t_0;
} else if (x <= 4.7e-125) {
tmp = exp((x / n)) - t_2;
} else if (x <= 1.0) {
tmp = (t_1 + (-0.5 * pow(t_0, 2.0))) - t_0;
} else {
tmp = t_2 / (x * n);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log(x) / n;
double t_1 = -0.16666666666666666 * Math.pow(t_0, 3.0);
double t_2 = Math.pow(x, (1.0 / n));
double t_3 = Math.cbrt(t_2);
double tmp;
if (x <= 8.2e-153) {
tmp = ((-0.5 * Math.pow((Math.log((t_3 * t_3)) + Math.log(t_3)), 2.0)) + t_1) - t_0;
} else if (x <= 4.7e-125) {
tmp = Math.exp((x / n)) - t_2;
} else if (x <= 1.0) {
tmp = (t_1 + (-0.5 * Math.pow(t_0, 2.0))) - t_0;
} else {
tmp = t_2 / (x * n);
}
return tmp;
}
function code(x, n) t_0 = Float64(log(x) / n) t_1 = Float64(-0.16666666666666666 * (t_0 ^ 3.0)) t_2 = x ^ Float64(1.0 / n) t_3 = cbrt(t_2) tmp = 0.0 if (x <= 8.2e-153) tmp = Float64(Float64(Float64(-0.5 * (Float64(log(Float64(t_3 * t_3)) + log(t_3)) ^ 2.0)) + t_1) - t_0); elseif (x <= 4.7e-125) tmp = Float64(exp(Float64(x / n)) - t_2); elseif (x <= 1.0) tmp = Float64(Float64(t_1 + Float64(-0.5 * (t_0 ^ 2.0))) - t_0); else tmp = Float64(t_2 / Float64(x * n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[t$95$2, 1/3], $MachinePrecision]}, If[LessEqual[x, 8.2e-153], N[(N[(N[(-0.5 * N[Power[N[(N[Log[N[(t$95$3 * t$95$3), $MachinePrecision]], $MachinePrecision] + N[Log[t$95$3], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 4.7e-125], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$2), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(t$95$1 + N[(-0.5 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(t$95$2 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
t_1 := -0.16666666666666666 \cdot {t_0}^{3}\\
t_2 := {x}^{\left(\frac{1}{n}\right)}\\
t_3 := \sqrt[3]{t_2}\\
\mathbf{if}\;x \leq 8.2 \cdot 10^{-153}:\\
\;\;\;\;\left(-0.5 \cdot {\left(\log \left(t_3 \cdot t_3\right) + \log t_3\right)}^{2} + t_1\right) - t_0\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-125}:\\
\;\;\;\;e^{\frac{x}{n}} - t_2\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\left(t_1 + -0.5 \cdot {t_0}^{2}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2}{x \cdot n}\\
\end{array}
\end{array}
if x < 8.2e-153Initial program 39.8%
Taylor expanded in x around 0 39.8%
Taylor expanded in n around inf 76.0%
neg-mul-176.0%
+-commutative76.0%
unsub-neg76.0%
Simplified76.0%
fma-udef76.0%
Applied egg-rr76.0%
add-log-exp82.5%
div-inv82.5%
pow-to-exp82.5%
add-cube-cbrt82.5%
log-prod82.5%
Applied egg-rr82.5%
if 8.2e-153 < x < 4.7e-125Initial program 76.5%
Taylor expanded in n around 0 76.5%
log1p-def91.0%
Simplified91.0%
Taylor expanded in x around 0 91.0%
if 4.7e-125 < x < 1Initial program 23.5%
Taylor expanded in x around 0 23.5%
Taylor expanded in n around inf 65.9%
neg-mul-165.9%
+-commutative65.9%
unsub-neg65.9%
Simplified65.9%
fma-udef65.9%
Applied egg-rr65.9%
if 1 < x Initial program 61.1%
Taylor expanded in x around inf 97.8%
log-rec97.8%
mul-1-neg97.8%
associate-*r/97.8%
neg-mul-197.8%
mul-1-neg97.8%
remove-double-neg97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 97.8%
*-rgt-identity97.8%
associate-*r/97.8%
exp-to-pow97.8%
*-commutative97.8%
Simplified97.8%
Final simplification85.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) n))
(t_1 (pow t_0 2.0))
(t_2 (* -0.16666666666666666 (pow t_0 3.0)))
(t_3 (pow x (/ 1.0 n))))
(if (<= x 8.2e-153)
(-
(fma
-0.041666666666666664
(/ (pow (log x) 4.0) (pow n 4.0))
(fma -0.5 t_1 t_2))
t_0)
(if (<= x 4.3e-125)
(- (exp (/ x n)) t_3)
(if (<= x 0.94) (- (+ t_2 (* -0.5 t_1)) t_0) (/ t_3 (* x n)))))))
double code(double x, double n) {
double t_0 = log(x) / n;
double t_1 = pow(t_0, 2.0);
double t_2 = -0.16666666666666666 * pow(t_0, 3.0);
double t_3 = pow(x, (1.0 / n));
double tmp;
if (x <= 8.2e-153) {
tmp = fma(-0.041666666666666664, (pow(log(x), 4.0) / pow(n, 4.0)), fma(-0.5, t_1, t_2)) - t_0;
} else if (x <= 4.3e-125) {
tmp = exp((x / n)) - t_3;
} else if (x <= 0.94) {
tmp = (t_2 + (-0.5 * t_1)) - t_0;
} else {
tmp = t_3 / (x * n);
}
return tmp;
}
function code(x, n) t_0 = Float64(log(x) / n) t_1 = t_0 ^ 2.0 t_2 = Float64(-0.16666666666666666 * (t_0 ^ 3.0)) t_3 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 8.2e-153) tmp = Float64(fma(-0.041666666666666664, Float64((log(x) ^ 4.0) / (n ^ 4.0)), fma(-0.5, t_1, t_2)) - t_0); elseif (x <= 4.3e-125) tmp = Float64(exp(Float64(x / n)) - t_3); elseif (x <= 0.94) tmp = Float64(Float64(t_2 + Float64(-0.5 * t_1)) - t_0); else tmp = Float64(t_3 / Float64(x * n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(-0.16666666666666666 * N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 8.2e-153], N[(N[(-0.041666666666666664 * N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * t$95$1 + t$95$2), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 4.3e-125], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$3), $MachinePrecision], If[LessEqual[x, 0.94], N[(N[(t$95$2 + N[(-0.5 * t$95$1), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(t$95$3 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
t_1 := {t_0}^{2}\\
t_2 := -0.16666666666666666 \cdot {t_0}^{3}\\
t_3 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 8.2 \cdot 10^{-153}:\\
\;\;\;\;\mathsf{fma}\left(-0.041666666666666664, \frac{{\log x}^{4}}{{n}^{4}}, \mathsf{fma}\left(-0.5, t_1, t_2\right)\right) - t_0\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{-125}:\\
\;\;\;\;e^{\frac{x}{n}} - t_3\\
\mathbf{elif}\;x \leq 0.94:\\
\;\;\;\;\left(t_2 + -0.5 \cdot t_1\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t_3}{x \cdot n}\\
\end{array}
\end{array}
if x < 8.2e-153Initial program 39.8%
Taylor expanded in x around 0 39.8%
Taylor expanded in n around inf 78.5%
neg-mul-178.5%
+-commutative78.5%
unsub-neg78.5%
Simplified78.5%
if 8.2e-153 < x < 4.3000000000000002e-125Initial program 76.5%
Taylor expanded in n around 0 76.5%
log1p-def91.0%
Simplified91.0%
Taylor expanded in x around 0 91.0%
if 4.3000000000000002e-125 < x < 0.93999999999999995Initial program 23.5%
Taylor expanded in x around 0 23.5%
Taylor expanded in n around inf 65.9%
neg-mul-165.9%
+-commutative65.9%
unsub-neg65.9%
Simplified65.9%
fma-udef65.9%
Applied egg-rr65.9%
if 0.93999999999999995 < x Initial program 61.1%
Taylor expanded in x around inf 97.8%
log-rec97.8%
mul-1-neg97.8%
associate-*r/97.8%
neg-mul-197.8%
mul-1-neg97.8%
remove-double-neg97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 97.8%
*-rgt-identity97.8%
associate-*r/97.8%
exp-to-pow97.8%
*-commutative97.8%
Simplified97.8%
Final simplification84.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -5e-8)
(log (* (exp (- (pow x (pow n -1.0)))) (exp (exp (/ (log1p x) n)))))
(if (<= t_1 1e-8) (/ (log (/ (+ x 1.0) x)) n) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-8) {
tmp = log((exp(-pow(x, pow(n, -1.0))) * exp(exp((log1p(x) / n)))));
} else if (t_1 <= 1e-8) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-8) {
tmp = Math.log((Math.exp(-Math.pow(x, Math.pow(n, -1.0))) * Math.exp(Math.exp((Math.log1p(x) / n)))));
} else if (t_1 <= 1e-8) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -5e-8: tmp = math.log((math.exp(-math.pow(x, math.pow(n, -1.0))) * math.exp(math.exp((math.log1p(x) / n))))) elif t_1 <= 1e-8: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -5e-8) tmp = log(Float64(exp(Float64(-(x ^ (n ^ -1.0)))) * exp(exp(Float64(log1p(x) / n))))); elseif (t_1 <= 1e-8) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-8], N[Log[N[(N[Exp[(-N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision])], $MachinePrecision] * N[Exp[N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 1e-8], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-8}:\\
\;\;\;\;\log \left(e^{-{x}^{\left({n}^{-1}\right)}} \cdot e^{e^{\frac{\mathsf{log1p}\left(x\right)}{n}}}\right)\\
\mathbf{elif}\;t_1 \leq 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -4.9999999999999998e-8Initial program 97.5%
sub-neg97.5%
+-commutative97.5%
add-log-exp97.5%
add-log-exp97.5%
sum-log97.7%
inv-pow97.7%
pow-to-exp97.7%
un-div-inv97.7%
+-commutative97.7%
log1p-udef97.7%
Applied egg-rr97.7%
if -4.9999999999999998e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 1e-8Initial program 39.2%
Taylor expanded in n around inf 76.0%
+-rgt-identity76.0%
+-rgt-identity76.0%
log1p-def76.0%
Simplified76.0%
log1p-udef76.0%
diff-log76.1%
+-commutative76.1%
Applied egg-rr76.1%
if 1e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 39.3%
Taylor expanded in n around 0 39.3%
log1p-def99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
Final simplification82.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -5e-8)
(- 1.0 t_0)
(if (<= t_1 1e-8) (/ (log (/ (+ x 1.0) x)) n) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-8) {
tmp = 1.0 - t_0;
} else if (t_1 <= 1e-8) {
tmp = log(((x + 1.0) / x)) / n;
} 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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = ((x + 1.0d0) ** (1.0d0 / n)) - t_0
if (t_1 <= (-5d-8)) then
tmp = 1.0d0 - t_0
else if (t_1 <= 1d-8) then
tmp = log(((x + 1.0d0) / x)) / n
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 t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-8) {
tmp = 1.0 - t_0;
} else if (t_1 <= 1e-8) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -5e-8: tmp = 1.0 - t_0 elif t_1 <= 1e-8: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -5e-8) tmp = Float64(1.0 - t_0); elseif (t_1 <= 1e-8) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); 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); t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0; tmp = 0.0; if (t_1 <= -5e-8) tmp = 1.0 - t_0; elseif (t_1 <= 1e-8) tmp = log(((x + 1.0) / x)) / n; 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]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-8], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 1e-8], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-8}:\\
\;\;\;\;1 - t_0\\
\mathbf{elif}\;t_1 \leq 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -4.9999999999999998e-8Initial program 97.5%
Taylor expanded in x around 0 97.5%
if -4.9999999999999998e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 1e-8Initial program 39.2%
Taylor expanded in n around inf 76.0%
+-rgt-identity76.0%
+-rgt-identity76.0%
log1p-def76.0%
Simplified76.0%
log1p-udef76.0%
diff-log76.1%
+-commutative76.1%
Applied egg-rr76.1%
if 1e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 39.3%
Taylor expanded in n around 0 39.3%
log1p-def99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
Final simplification82.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 n) x)) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-18)
(/ t_1 (* x n))
(if (<= (/ 1.0 n) 1e-254)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-190)
t_0
(if (<= (/ 1.0 n) 2e-8)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+141)
(- (+ 1.0 (/ x n)) t_1)
(cbrt (* t_0 (/ t_0 (* x n)))))))))))
double code(double x, double n) {
double t_0 = (1.0 / n) / x;
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-18) {
tmp = t_1 / (x * n);
} else if ((1.0 / n) <= 1e-254) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-190) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-8) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+141) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = cbrt((t_0 * (t_0 / (x * n))));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (1.0 / n) / x;
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-18) {
tmp = t_1 / (x * n);
} else if ((1.0 / n) <= 1e-254) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-190) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-8) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+141) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = Math.cbrt((t_0 * (t_0 / (x * n))));
}
return tmp;
}
function code(x, n) t_0 = Float64(Float64(1.0 / n) / x) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-18) tmp = Float64(t_1 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-254) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-190) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-8) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+141) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); else tmp = cbrt(Float64(t_0 * Float64(t_0 / Float64(x * n)))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-18], N[(t$95$1 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-254], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-190], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+141], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[Power[N[(t$95$0 * N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{n}}{x}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-18}:\\
\;\;\;\;\frac{t_1}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-254}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-190}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+141}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{t_0 \cdot \frac{t_0}{x \cdot n}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.0000000000000003e-18Initial program 94.6%
Taylor expanded in x around inf 94.4%
log-rec94.4%
mul-1-neg94.4%
associate-*r/94.4%
neg-mul-194.4%
mul-1-neg94.4%
remove-double-neg94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in x around 0 94.4%
*-rgt-identity94.4%
associate-*r/94.4%
exp-to-pow94.4%
*-commutative94.4%
Simplified94.4%
if -4.0000000000000003e-18 < (/.f64 1 n) < 9.9999999999999991e-255Initial program 32.8%
Taylor expanded in n around inf 81.4%
+-rgt-identity81.4%
+-rgt-identity81.4%
log1p-def81.4%
Simplified81.4%
if 9.9999999999999991e-255 < (/.f64 1 n) < 5.00000000000000034e-190Initial program 41.3%
Taylor expanded in n around inf 52.3%
associate--l+52.3%
fma-def52.3%
log1p-def52.3%
unpow252.3%
associate--r+52.3%
+-rgt-identity52.3%
div-sub52.3%
+-rgt-identity52.3%
log1p-def52.3%
unpow252.3%
Simplified52.3%
Taylor expanded in x around inf 88.5%
mul-1-neg88.5%
unsub-neg88.5%
log-rec88.5%
distribute-frac-neg88.5%
unpow288.5%
Simplified88.5%
Taylor expanded in n around inf 88.5%
if 5.00000000000000034e-190 < (/.f64 1 n) < 2e-8Initial program 16.2%
Taylor expanded in n around inf 68.9%
+-rgt-identity68.9%
+-rgt-identity68.9%
log1p-def68.9%
Simplified68.9%
log1p-udef68.9%
diff-log69.2%
+-commutative69.2%
Applied egg-rr69.2%
if 2e-8 < (/.f64 1 n) < 2.00000000000000003e141Initial program 71.1%
Taylor expanded in x around 0 72.7%
if 2.00000000000000003e141 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 0.0%
associate--l+0.0%
fma-def0.0%
log1p-def0.0%
unpow20.0%
associate--r+0.0%
+-rgt-identity0.0%
div-sub0.0%
+-rgt-identity0.0%
log1p-def0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in x around inf 0.1%
mul-1-neg0.1%
unsub-neg0.1%
log-rec0.1%
distribute-frac-neg0.1%
unpow20.1%
Simplified0.1%
Taylor expanded in n around inf 63.5%
add-cbrt-cube83.2%
associate-/l/83.2%
associate-/l/83.2%
associate-/l/83.2%
Applied egg-rr83.2%
associate-*l*83.2%
associate-/l/83.2%
associate-*l/83.2%
*-lft-identity83.2%
associate-/l/83.2%
Simplified83.2%
Final simplification82.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 n) x))
(t_1 (pow x (/ 1.0 n)))
(t_2 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -4e-18)
(/ t_1 (* x n))
(if (<= (/ 1.0 n) 1e-254)
t_2
(if (<= (/ 1.0 n) 5e-190)
t_0
(if (<= (/ 1.0 n) 2e-8)
t_2
(if (<= (/ 1.0 n) 2e+141)
(- (+ 1.0 (/ x n)) t_1)
(cbrt (* t_0 (/ t_0 (* x n)))))))))))
double code(double x, double n) {
double t_0 = (1.0 / n) / x;
double t_1 = pow(x, (1.0 / n));
double t_2 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -4e-18) {
tmp = t_1 / (x * n);
} else if ((1.0 / n) <= 1e-254) {
tmp = t_2;
} else if ((1.0 / n) <= 5e-190) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-8) {
tmp = t_2;
} else if ((1.0 / n) <= 2e+141) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = cbrt((t_0 * (t_0 / (x * n))));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (1.0 / n) / x;
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -4e-18) {
tmp = t_1 / (x * n);
} else if ((1.0 / n) <= 1e-254) {
tmp = t_2;
} else if ((1.0 / n) <= 5e-190) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-8) {
tmp = t_2;
} else if ((1.0 / n) <= 2e+141) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = Math.cbrt((t_0 * (t_0 / (x * n))));
}
return tmp;
}
function code(x, n) t_0 = Float64(Float64(1.0 / n) / x) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-18) tmp = Float64(t_1 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-254) tmp = t_2; elseif (Float64(1.0 / n) <= 5e-190) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-8) tmp = t_2; elseif (Float64(1.0 / n) <= 2e+141) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); else tmp = cbrt(Float64(t_0 * Float64(t_0 / Float64(x * n)))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-18], N[(t$95$1 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-254], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-190], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+141], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[Power[N[(t$95$0 * N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{n}}{x}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-18}:\\
\;\;\;\;\frac{t_1}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-254}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-190}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+141}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{t_0 \cdot \frac{t_0}{x \cdot n}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.0000000000000003e-18Initial program 94.6%
Taylor expanded in x around inf 94.4%
log-rec94.4%
mul-1-neg94.4%
associate-*r/94.4%
neg-mul-194.4%
mul-1-neg94.4%
remove-double-neg94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in x around 0 94.4%
*-rgt-identity94.4%
associate-*r/94.4%
exp-to-pow94.4%
*-commutative94.4%
Simplified94.4%
if -4.0000000000000003e-18 < (/.f64 1 n) < 9.9999999999999991e-255 or 5.00000000000000034e-190 < (/.f64 1 n) < 2e-8Initial program 26.3%
Taylor expanded in n around inf 76.5%
+-rgt-identity76.5%
+-rgt-identity76.5%
log1p-def76.5%
Simplified76.5%
log1p-udef76.5%
diff-log76.6%
+-commutative76.6%
Applied egg-rr76.6%
if 9.9999999999999991e-255 < (/.f64 1 n) < 5.00000000000000034e-190Initial program 41.3%
Taylor expanded in n around inf 52.3%
associate--l+52.3%
fma-def52.3%
log1p-def52.3%
unpow252.3%
associate--r+52.3%
+-rgt-identity52.3%
div-sub52.3%
+-rgt-identity52.3%
log1p-def52.3%
unpow252.3%
Simplified52.3%
Taylor expanded in x around inf 88.5%
mul-1-neg88.5%
unsub-neg88.5%
log-rec88.5%
distribute-frac-neg88.5%
unpow288.5%
Simplified88.5%
Taylor expanded in n around inf 88.5%
if 2e-8 < (/.f64 1 n) < 2.00000000000000003e141Initial program 71.1%
Taylor expanded in x around 0 72.7%
if 2.00000000000000003e141 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 0.0%
associate--l+0.0%
fma-def0.0%
log1p-def0.0%
unpow20.0%
associate--r+0.0%
+-rgt-identity0.0%
div-sub0.0%
+-rgt-identity0.0%
log1p-def0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in x around inf 0.1%
mul-1-neg0.1%
unsub-neg0.1%
log-rec0.1%
distribute-frac-neg0.1%
unpow20.1%
Simplified0.1%
Taylor expanded in n around inf 63.5%
add-cbrt-cube83.2%
associate-/l/83.2%
associate-/l/83.2%
associate-/l/83.2%
Applied egg-rr83.2%
associate-*l*83.2%
associate-/l/83.2%
associate-*l/83.2%
*-lft-identity83.2%
associate-/l/83.2%
Simplified83.2%
Final simplification82.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -4e-18)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 1e-254)
t_1
(if (<= (/ 1.0 n) 5e-190)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 2e-8)
t_1
(if (<= (/ 1.0 n) 2e+141)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* x n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -4e-18) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-254) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-190) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-8) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+141) {
tmp = (1.0 + (x / n)) - t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(((x + 1.0d0) / x)) / n
if ((1.0d0 / n) <= (-4d-18)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 1d-254) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-190) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 2d-8) then
tmp = t_1
else if ((1.0d0 / n) <= 2d+141) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -4e-18) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-254) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-190) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-8) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+141) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -4e-18: tmp = t_0 / (x * n) elif (1.0 / n) <= 1e-254: tmp = t_1 elif (1.0 / n) <= 5e-190: tmp = (1.0 / n) / x elif (1.0 / n) <= 2e-8: tmp = t_1 elif (1.0 / n) <= 2e+141: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (x * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-18) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-254) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-190) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 2e-8) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+141) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(((x + 1.0) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -4e-18) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 1e-254) tmp = t_1; elseif ((1.0 / n) <= 5e-190) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 2e-8) tmp = t_1; elseif ((1.0 / n) <= 2e+141) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-18], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-254], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-190], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+141], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-18}:\\
\;\;\;\;\frac{t_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-254}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-190}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+141}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.0000000000000003e-18Initial program 94.6%
Taylor expanded in x around inf 94.4%
log-rec94.4%
mul-1-neg94.4%
associate-*r/94.4%
neg-mul-194.4%
mul-1-neg94.4%
remove-double-neg94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in x around 0 94.4%
*-rgt-identity94.4%
associate-*r/94.4%
exp-to-pow94.4%
*-commutative94.4%
Simplified94.4%
if -4.0000000000000003e-18 < (/.f64 1 n) < 9.9999999999999991e-255 or 5.00000000000000034e-190 < (/.f64 1 n) < 2e-8Initial program 26.3%
Taylor expanded in n around inf 76.5%
+-rgt-identity76.5%
+-rgt-identity76.5%
log1p-def76.5%
Simplified76.5%
log1p-udef76.5%
diff-log76.6%
+-commutative76.6%
Applied egg-rr76.6%
if 9.9999999999999991e-255 < (/.f64 1 n) < 5.00000000000000034e-190Initial program 41.3%
Taylor expanded in n around inf 52.3%
associate--l+52.3%
fma-def52.3%
log1p-def52.3%
unpow252.3%
associate--r+52.3%
+-rgt-identity52.3%
div-sub52.3%
+-rgt-identity52.3%
log1p-def52.3%
unpow252.3%
Simplified52.3%
Taylor expanded in x around inf 88.5%
mul-1-neg88.5%
unsub-neg88.5%
log-rec88.5%
distribute-frac-neg88.5%
unpow288.5%
Simplified88.5%
Taylor expanded in n around inf 88.5%
if 2e-8 < (/.f64 1 n) < 2.00000000000000003e141Initial program 71.1%
Taylor expanded in x around 0 72.7%
if 2.00000000000000003e141 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 7.1%
+-rgt-identity7.1%
+-rgt-identity7.1%
log1p-def7.1%
Simplified7.1%
Taylor expanded in x around inf 63.5%
*-commutative63.5%
Simplified63.5%
Final simplification80.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -4e-18)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 1e-254)
t_1
(if (<= (/ 1.0 n) 5e-190)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 2e-8)
t_1
(if (<= (/ 1.0 n) 2e+141) (- 1.0 t_0) (/ 1.0 (* x n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -4e-18) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-254) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-190) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-8) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+141) {
tmp = 1.0 - t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(((x + 1.0d0) / x)) / n
if ((1.0d0 / n) <= (-4d-18)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 1d-254) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-190) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 2d-8) then
tmp = t_1
else if ((1.0d0 / n) <= 2d+141) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -4e-18) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-254) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-190) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-8) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+141) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -4e-18: tmp = t_0 / (x * n) elif (1.0 / n) <= 1e-254: tmp = t_1 elif (1.0 / n) <= 5e-190: tmp = (1.0 / n) / x elif (1.0 / n) <= 2e-8: tmp = t_1 elif (1.0 / n) <= 2e+141: tmp = 1.0 - t_0 else: tmp = 1.0 / (x * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-18) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-254) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-190) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 2e-8) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+141) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(((x + 1.0) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -4e-18) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 1e-254) tmp = t_1; elseif ((1.0 / n) <= 5e-190) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 2e-8) tmp = t_1; elseif ((1.0 / n) <= 2e+141) tmp = 1.0 - t_0; else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-18], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-254], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-190], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+141], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-18}:\\
\;\;\;\;\frac{t_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-254}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-190}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+141}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.0000000000000003e-18Initial program 94.6%
Taylor expanded in x around inf 94.4%
log-rec94.4%
mul-1-neg94.4%
associate-*r/94.4%
neg-mul-194.4%
mul-1-neg94.4%
remove-double-neg94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in x around 0 94.4%
*-rgt-identity94.4%
associate-*r/94.4%
exp-to-pow94.4%
*-commutative94.4%
Simplified94.4%
if -4.0000000000000003e-18 < (/.f64 1 n) < 9.9999999999999991e-255 or 5.00000000000000034e-190 < (/.f64 1 n) < 2e-8Initial program 26.3%
Taylor expanded in n around inf 76.5%
+-rgt-identity76.5%
+-rgt-identity76.5%
log1p-def76.5%
Simplified76.5%
log1p-udef76.5%
diff-log76.6%
+-commutative76.6%
Applied egg-rr76.6%
if 9.9999999999999991e-255 < (/.f64 1 n) < 5.00000000000000034e-190Initial program 41.3%
Taylor expanded in n around inf 52.3%
associate--l+52.3%
fma-def52.3%
log1p-def52.3%
unpow252.3%
associate--r+52.3%
+-rgt-identity52.3%
div-sub52.3%
+-rgt-identity52.3%
log1p-def52.3%
unpow252.3%
Simplified52.3%
Taylor expanded in x around inf 88.5%
mul-1-neg88.5%
unsub-neg88.5%
log-rec88.5%
distribute-frac-neg88.5%
unpow288.5%
Simplified88.5%
Taylor expanded in n around inf 88.5%
if 2e-8 < (/.f64 1 n) < 2.00000000000000003e141Initial program 71.1%
Taylor expanded in x around 0 70.9%
if 2.00000000000000003e141 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 7.1%
+-rgt-identity7.1%
+-rgt-identity7.1%
log1p-def7.1%
Simplified7.1%
Taylor expanded in x around inf 63.5%
*-commutative63.5%
Simplified63.5%
Final simplification80.6%
(FPCore (x n)
:precision binary64
(if (<= x 3.8e-164)
(/ (- (log x)) n)
(if (<= x 4.1e-131)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 780.0)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= x 3e+176) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n) (/ 0.0 n))))))
double code(double x, double n) {
double tmp;
if (x <= 3.8e-164) {
tmp = -log(x) / n;
} else if (x <= 4.1e-131) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 780.0) {
tmp = log(((x + 1.0) / x)) / n;
} else if (x <= 3e+176) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.8d-164) then
tmp = -log(x) / n
else if (x <= 4.1d-131) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 780.0d0) then
tmp = log(((x + 1.0d0) / x)) / n
else if (x <= 3d+176) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.8e-164) {
tmp = -Math.log(x) / n;
} else if (x <= 4.1e-131) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 780.0) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if (x <= 3e+176) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.8e-164: tmp = -math.log(x) / n elif x <= 4.1e-131: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 780.0: tmp = math.log(((x + 1.0) / x)) / n elif x <= 3e+176: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 3.8e-164) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 4.1e-131) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 780.0) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (x <= 3e+176) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.8e-164) tmp = -log(x) / n; elseif (x <= 4.1e-131) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 780.0) tmp = log(((x + 1.0) / x)) / n; elseif (x <= 3e+176) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.8e-164], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 4.1e-131], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 780.0], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3e+176], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.8 \cdot 10^{-164}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{-131}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 780:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+176}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 3.79999999999999989e-164Initial program 36.9%
Taylor expanded in n around inf 61.7%
+-rgt-identity61.7%
+-rgt-identity61.7%
log1p-def61.7%
Simplified61.7%
Taylor expanded in x around 0 61.7%
neg-mul-161.7%
Simplified61.7%
if 3.79999999999999989e-164 < x < 4.1000000000000002e-131Initial program 79.8%
Taylor expanded in x around 0 79.8%
if 4.1000000000000002e-131 < x < 780Initial program 23.4%
Taylor expanded in n around inf 56.9%
+-rgt-identity56.9%
+-rgt-identity56.9%
log1p-def56.9%
Simplified56.9%
log1p-udef56.9%
diff-log56.9%
+-commutative56.9%
Applied egg-rr56.9%
if 780 < x < 3e176Initial program 45.6%
Taylor expanded in n around inf 44.8%
+-rgt-identity44.8%
+-rgt-identity44.8%
log1p-def44.8%
Simplified44.8%
Taylor expanded in x around inf 72.4%
associate-*r/72.4%
metadata-eval72.4%
unpow272.4%
Simplified72.4%
if 3e176 < x Initial program 83.6%
Taylor expanded in n around inf 83.6%
+-rgt-identity83.6%
+-rgt-identity83.6%
log1p-def83.6%
Simplified83.6%
log1p-udef83.6%
diff-log83.6%
+-commutative83.6%
Applied egg-rr83.6%
Taylor expanded in x around inf 83.6%
Final simplification68.5%
(FPCore (x n)
:precision binary64
(if (<= x 6.6e-164)
(/ (- (log x)) n)
(if (<= x 9e-131)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (<= x 3e+176) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n) (/ 0.0 n))))))
double code(double x, double n) {
double tmp;
if (x <= 6.6e-164) {
tmp = -log(x) / n;
} else if (x <= 9e-131) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 3e+176) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 6.6d-164) then
tmp = -log(x) / n
else if (x <= 9d-131) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 3d+176) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 6.6e-164) {
tmp = -Math.log(x) / n;
} else if (x <= 9e-131) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 3e+176) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 6.6e-164: tmp = -math.log(x) / n elif x <= 9e-131: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 3e+176: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 6.6e-164) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 9e-131) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 3e+176) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6.6e-164) tmp = -log(x) / n; elseif (x <= 9e-131) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 3e+176) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 6.6e-164], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 9e-131], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3e+176], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.6 \cdot 10^{-164}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-131}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+176}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 6.6e-164Initial program 36.9%
Taylor expanded in n around inf 61.7%
+-rgt-identity61.7%
+-rgt-identity61.7%
log1p-def61.7%
Simplified61.7%
Taylor expanded in x around 0 61.7%
neg-mul-161.7%
Simplified61.7%
if 6.6e-164 < x < 9.0000000000000004e-131Initial program 79.8%
Taylor expanded in x around 0 79.8%
if 9.0000000000000004e-131 < x < 1Initial program 23.4%
Taylor expanded in n around inf 56.9%
+-rgt-identity56.9%
+-rgt-identity56.9%
log1p-def56.9%
Simplified56.9%
Taylor expanded in x around 0 54.1%
neg-mul-154.1%
unsub-neg54.1%
Simplified54.1%
if 1 < x < 3e176Initial program 45.6%
Taylor expanded in n around inf 44.8%
+-rgt-identity44.8%
+-rgt-identity44.8%
log1p-def44.8%
Simplified44.8%
Taylor expanded in x around inf 72.4%
associate-*r/72.4%
metadata-eval72.4%
unpow272.4%
Simplified72.4%
if 3e176 < x Initial program 83.6%
Taylor expanded in n around inf 83.6%
+-rgt-identity83.6%
+-rgt-identity83.6%
log1p-def83.6%
Simplified83.6%
log1p-udef83.6%
diff-log83.6%
+-commutative83.6%
Applied egg-rr83.6%
Taylor expanded in x around inf 83.6%
Final simplification67.8%
(FPCore (x n) :precision binary64 (if (<= x 0.94) (/ (- x (log x)) n) (if (<= x 1.55e+176) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.94) {
tmp = (x - log(x)) / n;
} else if (x <= 1.55e+176) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.94d0) then
tmp = (x - log(x)) / n
else if (x <= 1.55d+176) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.94) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.55e+176) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.94: tmp = (x - math.log(x)) / n elif x <= 1.55e+176: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.94) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.55e+176) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.94) tmp = (x - log(x)) / n; elseif (x <= 1.55e+176) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.94], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.55e+176], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.94:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+176}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 0.93999999999999995Initial program 36.8%
Taylor expanded in n around inf 54.5%
+-rgt-identity54.5%
+-rgt-identity54.5%
log1p-def54.5%
Simplified54.5%
Taylor expanded in x around 0 53.2%
neg-mul-153.2%
unsub-neg53.2%
Simplified53.2%
if 0.93999999999999995 < x < 1.55e176Initial program 45.6%
Taylor expanded in n around inf 44.8%
+-rgt-identity44.8%
+-rgt-identity44.8%
log1p-def44.8%
Simplified44.8%
Taylor expanded in x around inf 72.4%
associate-*r/72.4%
metadata-eval72.4%
unpow272.4%
Simplified72.4%
if 1.55e176 < x Initial program 83.6%
Taylor expanded in n around inf 83.6%
+-rgt-identity83.6%
+-rgt-identity83.6%
log1p-def83.6%
Simplified83.6%
log1p-udef83.6%
diff-log83.6%
+-commutative83.6%
Applied egg-rr83.6%
Taylor expanded in x around inf 83.6%
Final simplification63.4%
(FPCore (x n) :precision binary64 (if (<= x 0.7) (/ (- (log x)) n) (if (<= x 2.4e+176) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = -log(x) / n;
} else if (x <= 2.4e+176) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.7d0) then
tmp = -log(x) / n
else if (x <= 2.4d+176) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = -Math.log(x) / n;
} else if (x <= 2.4e+176) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.7: tmp = -math.log(x) / n elif x <= 2.4e+176: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.7) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.4e+176) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.7) tmp = -log(x) / n; elseif (x <= 2.4e+176) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.7], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.4e+176], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+176}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial program 36.8%
Taylor expanded in n around inf 54.5%
+-rgt-identity54.5%
+-rgt-identity54.5%
log1p-def54.5%
Simplified54.5%
Taylor expanded in x around 0 51.9%
neg-mul-151.9%
Simplified51.9%
if 0.69999999999999996 < x < 2.4000000000000001e176Initial program 45.6%
Taylor expanded in n around inf 44.8%
+-rgt-identity44.8%
+-rgt-identity44.8%
log1p-def44.8%
Simplified44.8%
Taylor expanded in x around inf 72.4%
associate-*r/72.4%
metadata-eval72.4%
unpow272.4%
Simplified72.4%
if 2.4000000000000001e176 < x Initial program 83.6%
Taylor expanded in n around inf 83.6%
+-rgt-identity83.6%
+-rgt-identity83.6%
log1p-def83.6%
Simplified83.6%
log1p-udef83.6%
diff-log83.6%
+-commutative83.6%
Applied egg-rr83.6%
Taylor expanded in x around inf 83.6%
Final simplification62.7%
(FPCore (x n) :precision binary64 (if (<= n -3.55) (/ (/ 1.0 n) x) (if (<= n -9e-216) (/ 0.0 n) (/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (n <= -3.55) {
tmp = (1.0 / n) / x;
} else if (n <= -9e-216) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-3.55d0)) then
tmp = (1.0d0 / n) / x
else if (n <= (-9d-216)) then
tmp = 0.0d0 / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -3.55) {
tmp = (1.0 / n) / x;
} else if (n <= -9e-216) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -3.55: tmp = (1.0 / n) / x elif n <= -9e-216: tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (n <= -3.55) tmp = Float64(Float64(1.0 / n) / x); elseif (n <= -9e-216) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -3.55) tmp = (1.0 / n) / x; elseif (n <= -9e-216) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -3.55], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[n, -9e-216], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.55:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;n \leq -9 \cdot 10^{-216}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if n < -3.5499999999999998Initial program 34.0%
Taylor expanded in n around inf 75.2%
associate--l+68.2%
fma-def68.2%
log1p-def68.2%
unpow268.2%
associate--r+75.2%
+-rgt-identity75.2%
div-sub75.2%
+-rgt-identity75.2%
log1p-def75.2%
unpow275.2%
Simplified75.2%
Taylor expanded in x around inf 53.1%
mul-1-neg53.1%
unsub-neg53.1%
log-rec53.1%
distribute-frac-neg53.1%
unpow253.1%
Simplified53.1%
Taylor expanded in n around inf 52.7%
if -3.5499999999999998 < n < -8.9999999999999997e-216Initial program 100.0%
Taylor expanded in n around inf 54.5%
+-rgt-identity54.5%
+-rgt-identity54.5%
log1p-def54.5%
Simplified54.5%
log1p-udef54.5%
diff-log54.5%
+-commutative54.5%
Applied egg-rr54.5%
Taylor expanded in x around inf 56.0%
if -8.9999999999999997e-216 < n Initial program 40.0%
Taylor expanded in n around inf 49.5%
+-rgt-identity49.5%
+-rgt-identity49.5%
log1p-def49.5%
Simplified49.5%
Taylor expanded in x around inf 49.4%
Final simplification51.3%
(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(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 47.2%
Taylor expanded in n around inf 57.1%
+-rgt-identity57.1%
+-rgt-identity57.1%
log1p-def57.1%
Simplified57.1%
Taylor expanded in x around inf 44.1%
*-commutative44.1%
Simplified44.1%
Final simplification44.1%
(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 47.2%
Taylor expanded in n around inf 51.9%
associate--l+49.2%
fma-def49.2%
log1p-def49.2%
unpow249.2%
associate--r+51.9%
+-rgt-identity51.9%
div-sub51.9%
+-rgt-identity51.9%
log1p-def51.9%
unpow251.9%
Simplified51.9%
Taylor expanded in x around inf 42.6%
mul-1-neg42.6%
unsub-neg42.6%
log-rec42.6%
distribute-frac-neg42.6%
unpow242.6%
Simplified42.6%
Taylor expanded in n around inf 44.9%
Final simplification44.9%
herbie shell --seed 2023201
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))