
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n) :precision binary64 (if (<= x 1.0) (- (/ x n) (expm1 (/ (log x) n))) (/ (/ (pow x (pow n -1.0)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x / n) - expm1((log(x) / n));
} else {
tmp = (pow(x, pow(n, -1.0)) / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x / n) - Math.expm1((Math.log(x) / n));
} else {
tmp = (Math.pow(x, Math.pow(n, -1.0)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x / n) - math.expm1((math.log(x) / n)) else: tmp = (math.pow(x, math.pow(n, -1.0)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x / n) - expm1(Float64(log(x) / n))); else tmp = Float64(Float64((x ^ (n ^ -1.0)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x / n), $MachinePrecision] - N[(Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x}{n} - \mathsf{expm1}\left(\frac{\log x}{n}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left({n}^{-1}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 1Initial program 39.9%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
*-rgt-identityN/A
associate-*r/N/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-fracN/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
associate-+l-N/A
lower--.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
Applied rewrites86.5%
if 1 < x Initial program 71.2%
Taylor expanded in x around inf
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f6499.4
Applied rewrites99.4%
Applied rewrites99.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))) (t_1 (- (pow (+ x 1.0) (pow n -1.0)) t_0)))
(if (or (<= t_1 -5e-7) (not (<= t_1 0.0)))
(- 1.0 t_0)
(/ (log (/ (+ 1.0 x) x)) n))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double t_1 = pow((x + 1.0), pow(n, -1.0)) - t_0;
double tmp;
if ((t_1 <= -5e-7) || !(t_1 <= 0.0)) {
tmp = 1.0 - t_0;
} else {
tmp = log(((1.0 + 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) :: t_1
real(8) :: tmp
t_0 = x ** (n ** (-1.0d0))
t_1 = ((x + 1.0d0) ** (n ** (-1.0d0))) - t_0
if ((t_1 <= (-5d-7)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = 1.0d0 - t_0
else
tmp = log(((1.0d0 + x) / x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, Math.pow(n, -1.0));
double t_1 = Math.pow((x + 1.0), Math.pow(n, -1.0)) - t_0;
double tmp;
if ((t_1 <= -5e-7) || !(t_1 <= 0.0)) {
tmp = 1.0 - t_0;
} else {
tmp = Math.log(((1.0 + x) / x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, math.pow(n, -1.0)) t_1 = math.pow((x + 1.0), math.pow(n, -1.0)) - t_0 tmp = 0 if (t_1 <= -5e-7) or not (t_1 <= 0.0): tmp = 1.0 - t_0 else: tmp = math.log(((1.0 + x) / x)) / n return tmp
function code(x, n) t_0 = x ^ (n ^ -1.0) t_1 = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - t_0) tmp = 0.0 if ((t_1 <= -5e-7) || !(t_1 <= 0.0)) tmp = Float64(1.0 - t_0); else tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (n ^ -1.0); t_1 = ((x + 1.0) ^ (n ^ -1.0)) - t_0; tmp = 0.0; if ((t_1 <= -5e-7) || ~((t_1 <= 0.0))) tmp = 1.0 - t_0; else tmp = log(((1.0 + x) / x)) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e-7], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(1.0 - t$95$0), $MachinePrecision], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
t_1 := {\left(x + 1\right)}^{\left({n}^{-1}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-7} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -4.99999999999999977e-7 or 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 74.8%
Taylor expanded in x around 0
Applied rewrites72.1%
if -4.99999999999999977e-7 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 45.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6479.0
Applied rewrites79.0%
Applied rewrites79.7%
Final simplification77.6%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -1.0)
(/ (/ (pow (* x x) (/ 0.5 n)) x) n)
(if (<= (pow n -1.0) 5e-22)
(/ (log (/ (+ 1.0 x) x)) n)
(-
(fma (fma (/ (- (/ 0.5 n) 0.5) n) x (pow n -1.0)) x 1.0)
(pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -1.0) {
tmp = (pow((x * x), (0.5 / n)) / x) / n;
} else if (pow(n, -1.0) <= 5e-22) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = fma(fma((((0.5 / n) - 0.5) / n), x, pow(n, -1.0)), x, 1.0) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -1.0) tmp = Float64(Float64((Float64(x * x) ^ Float64(0.5 / n)) / x) / n); elseif ((n ^ -1.0) <= 5e-22) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(fma(fma(Float64(Float64(Float64(0.5 / n) - 0.5) / n), x, (n ^ -1.0)), x, 1.0) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1.0], N[(N[(N[Power[N[(x * x), $MachinePrecision], N[(0.5 / n), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-22], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.5 / n), $MachinePrecision] - 0.5), $MachinePrecision] / n), $MachinePrecision] * x + N[Power[n, -1.0], $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -1:\\
\;\;\;\;\frac{\frac{{\left(x \cdot x\right)}^{\left(\frac{0.5}{n}\right)}}{x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{\frac{0.5}{n} - 0.5}{n}, x, {n}^{-1}\right), x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1Initial program 98.5%
Taylor expanded in x around inf
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Applied rewrites99.9%
if -1 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999954e-22Initial program 32.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.6
Applied rewrites77.6%
Applied rewrites77.9%
if 4.99999999999999954e-22 < (/.f64 #s(literal 1 binary64) n) Initial program 58.4%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites74.9%
Final simplification83.1%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -1.0)
(/ (/ (pow (* x x) (/ 0.5 n)) x) n)
(if (<= (pow n -1.0) 5e-22)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (pow n -1.0) 5e+185)
(- (+ (/ x n) 1.0) (pow x (pow n -1.0)))
(/ (/ n x) (* n n))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -1.0) {
tmp = (pow((x * x), (0.5 / n)) / x) / n;
} else if (pow(n, -1.0) <= 5e-22) {
tmp = log(((1.0 + x) / x)) / n;
} else if (pow(n, -1.0) <= 5e+185) {
tmp = ((x / n) + 1.0) - pow(x, pow(n, -1.0));
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n ** (-1.0d0)) <= (-1.0d0)) then
tmp = (((x * x) ** (0.5d0 / n)) / x) / n
else if ((n ** (-1.0d0)) <= 5d-22) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((n ** (-1.0d0)) <= 5d+185) then
tmp = ((x / n) + 1.0d0) - (x ** (n ** (-1.0d0)))
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -1.0) {
tmp = (Math.pow((x * x), (0.5 / n)) / x) / n;
} else if (Math.pow(n, -1.0) <= 5e-22) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if (Math.pow(n, -1.0) <= 5e+185) {
tmp = ((x / n) + 1.0) - Math.pow(x, Math.pow(n, -1.0));
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -1.0: tmp = (math.pow((x * x), (0.5 / n)) / x) / n elif math.pow(n, -1.0) <= 5e-22: tmp = math.log(((1.0 + x) / x)) / n elif math.pow(n, -1.0) <= 5e+185: tmp = ((x / n) + 1.0) - math.pow(x, math.pow(n, -1.0)) else: tmp = (n / x) / (n * n) return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -1.0) tmp = Float64(Float64((Float64(x * x) ^ Float64(0.5 / n)) / x) / n); elseif ((n ^ -1.0) <= 5e-22) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif ((n ^ -1.0) <= 5e+185) tmp = Float64(Float64(Float64(x / n) + 1.0) - (x ^ (n ^ -1.0))); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -1.0) tmp = (((x * x) ^ (0.5 / n)) / x) / n; elseif ((n ^ -1.0) <= 5e-22) tmp = log(((1.0 + x) / x)) / n; elseif ((n ^ -1.0) <= 5e+185) tmp = ((x / n) + 1.0) - (x ^ (n ^ -1.0)); else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1.0], N[(N[(N[Power[N[(x * x), $MachinePrecision], N[(0.5 / n), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-22], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e+185], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -1:\\
\;\;\;\;\frac{\frac{{\left(x \cdot x\right)}^{\left(\frac{0.5}{n}\right)}}{x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{+185}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1Initial program 98.5%
Taylor expanded in x around inf
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Applied rewrites99.9%
if -1 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999954e-22Initial program 32.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.6
Applied rewrites77.6%
Applied rewrites77.9%
if 4.99999999999999954e-22 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e185Initial program 81.7%
Taylor expanded in x around 0
+-commutativeN/A
*-rgt-identityN/A
associate-*r/N/A
lower-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6479.8
Applied rewrites79.8%
if 4.9999999999999999e185 < (/.f64 #s(literal 1 binary64) n) Initial program 27.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.3
Applied rewrites6.3%
Applied rewrites78.5%
Taylor expanded in x around inf
Applied rewrites78.5%
Final simplification83.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -1.0)
(/ t_0 (* n x))
(if (<= (pow n -1.0) 5e-22)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (pow n -1.0) 5e+185)
(- (+ (/ x n) 1.0) t_0)
(/ (/ n x) (* n n)))))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double tmp;
if (pow(n, -1.0) <= -1.0) {
tmp = t_0 / (n * x);
} else if (pow(n, -1.0) <= 5e-22) {
tmp = log(((1.0 + x) / x)) / n;
} else if (pow(n, -1.0) <= 5e+185) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (n ** (-1.0d0))
if ((n ** (-1.0d0)) <= (-1.0d0)) then
tmp = t_0 / (n * x)
else if ((n ** (-1.0d0)) <= 5d-22) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((n ** (-1.0d0)) <= 5d+185) then
tmp = ((x / n) + 1.0d0) - t_0
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, Math.pow(n, -1.0));
double tmp;
if (Math.pow(n, -1.0) <= -1.0) {
tmp = t_0 / (n * x);
} else if (Math.pow(n, -1.0) <= 5e-22) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if (Math.pow(n, -1.0) <= 5e+185) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, math.pow(n, -1.0)) tmp = 0 if math.pow(n, -1.0) <= -1.0: tmp = t_0 / (n * x) elif math.pow(n, -1.0) <= 5e-22: tmp = math.log(((1.0 + x) / x)) / n elif math.pow(n, -1.0) <= 5e+185: tmp = ((x / n) + 1.0) - t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -1.0) tmp = Float64(t_0 / Float64(n * x)); elseif ((n ^ -1.0) <= 5e-22) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif ((n ^ -1.0) <= 5e+185) tmp = Float64(Float64(Float64(x / n) + 1.0) - t_0); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (n ^ -1.0); tmp = 0.0; if ((n ^ -1.0) <= -1.0) tmp = t_0 / (n * x); elseif ((n ^ -1.0) <= 5e-22) tmp = log(((1.0 + x) / x)) / n; elseif ((n ^ -1.0) <= 5e+185) tmp = ((x / n) + 1.0) - t_0; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-22], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e+185], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -1:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{+185}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1Initial program 98.5%
Taylor expanded in x around inf
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
if -1 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999954e-22Initial program 32.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.6
Applied rewrites77.6%
Applied rewrites77.9%
if 4.99999999999999954e-22 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e185Initial program 81.7%
Taylor expanded in x around 0
+-commutativeN/A
*-rgt-identityN/A
associate-*r/N/A
lower-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6479.8
Applied rewrites79.8%
if 4.9999999999999999e185 < (/.f64 #s(literal 1 binary64) n) Initial program 27.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.3
Applied rewrites6.3%
Applied rewrites78.5%
Taylor expanded in x around inf
Applied rewrites78.5%
Final simplification83.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -1.0)
(/ t_0 (* n x))
(if (<= (pow n -1.0) 5e-22)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (pow n -1.0) 5e+185)
(- (/ (+ n x) n) t_0)
(/ (/ n x) (* n n)))))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double tmp;
if (pow(n, -1.0) <= -1.0) {
tmp = t_0 / (n * x);
} else if (pow(n, -1.0) <= 5e-22) {
tmp = log(((1.0 + x) / x)) / n;
} else if (pow(n, -1.0) <= 5e+185) {
tmp = ((n + x) / n) - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (n ** (-1.0d0))
if ((n ** (-1.0d0)) <= (-1.0d0)) then
tmp = t_0 / (n * x)
else if ((n ** (-1.0d0)) <= 5d-22) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((n ** (-1.0d0)) <= 5d+185) then
tmp = ((n + x) / n) - t_0
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, Math.pow(n, -1.0));
double tmp;
if (Math.pow(n, -1.0) <= -1.0) {
tmp = t_0 / (n * x);
} else if (Math.pow(n, -1.0) <= 5e-22) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if (Math.pow(n, -1.0) <= 5e+185) {
tmp = ((n + x) / n) - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, math.pow(n, -1.0)) tmp = 0 if math.pow(n, -1.0) <= -1.0: tmp = t_0 / (n * x) elif math.pow(n, -1.0) <= 5e-22: tmp = math.log(((1.0 + x) / x)) / n elif math.pow(n, -1.0) <= 5e+185: tmp = ((n + x) / n) - t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -1.0) tmp = Float64(t_0 / Float64(n * x)); elseif ((n ^ -1.0) <= 5e-22) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif ((n ^ -1.0) <= 5e+185) tmp = Float64(Float64(Float64(n + x) / n) - t_0); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (n ^ -1.0); tmp = 0.0; if ((n ^ -1.0) <= -1.0) tmp = t_0 / (n * x); elseif ((n ^ -1.0) <= 5e-22) tmp = log(((1.0 + x) / x)) / n; elseif ((n ^ -1.0) <= 5e+185) tmp = ((n + x) / n) - t_0; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-22], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e+185], N[(N[(N[(n + x), $MachinePrecision] / n), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -1:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{+185}:\\
\;\;\;\;\frac{n + x}{n} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1Initial program 98.5%
Taylor expanded in x around inf
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
if -1 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999954e-22Initial program 32.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.6
Applied rewrites77.6%
Applied rewrites77.9%
if 4.99999999999999954e-22 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e185Initial program 81.7%
Taylor expanded in x around 0
+-commutativeN/A
*-rgt-identityN/A
associate-*r/N/A
lower-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6479.8
Applied rewrites79.8%
Taylor expanded in n around 0
Applied rewrites79.7%
if 4.9999999999999999e185 < (/.f64 #s(literal 1 binary64) n) Initial program 27.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.3
Applied rewrites6.3%
Applied rewrites78.5%
Taylor expanded in x around inf
Applied rewrites78.5%
Final simplification83.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -1.0)
(/ t_0 (* n x))
(if (<= (pow n -1.0) 5e-22)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (pow n -1.0) 2e+163) (- 1.0 t_0) (/ (/ n x) (* n n)))))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double tmp;
if (pow(n, -1.0) <= -1.0) {
tmp = t_0 / (n * x);
} else if (pow(n, -1.0) <= 5e-22) {
tmp = log(((1.0 + x) / x)) / n;
} else if (pow(n, -1.0) <= 2e+163) {
tmp = 1.0 - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (n ** (-1.0d0))
if ((n ** (-1.0d0)) <= (-1.0d0)) then
tmp = t_0 / (n * x)
else if ((n ** (-1.0d0)) <= 5d-22) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((n ** (-1.0d0)) <= 2d+163) then
tmp = 1.0d0 - t_0
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, Math.pow(n, -1.0));
double tmp;
if (Math.pow(n, -1.0) <= -1.0) {
tmp = t_0 / (n * x);
} else if (Math.pow(n, -1.0) <= 5e-22) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if (Math.pow(n, -1.0) <= 2e+163) {
tmp = 1.0 - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, math.pow(n, -1.0)) tmp = 0 if math.pow(n, -1.0) <= -1.0: tmp = t_0 / (n * x) elif math.pow(n, -1.0) <= 5e-22: tmp = math.log(((1.0 + x) / x)) / n elif math.pow(n, -1.0) <= 2e+163: tmp = 1.0 - t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -1.0) tmp = Float64(t_0 / Float64(n * x)); elseif ((n ^ -1.0) <= 5e-22) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif ((n ^ -1.0) <= 2e+163) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (n ^ -1.0); tmp = 0.0; if ((n ^ -1.0) <= -1.0) tmp = t_0 / (n * x); elseif ((n ^ -1.0) <= 5e-22) tmp = log(((1.0 + x) / x)) / n; elseif ((n ^ -1.0) <= 2e+163) tmp = 1.0 - t_0; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-22], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 2e+163], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -1:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 2 \cdot 10^{+163}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1Initial program 98.5%
Taylor expanded in x around inf
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
if -1 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999954e-22Initial program 32.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.6
Applied rewrites77.6%
Applied rewrites77.9%
if 4.99999999999999954e-22 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e163Initial program 84.5%
Taylor expanded in x around 0
Applied rewrites80.1%
if 1.9999999999999999e163 < (/.f64 #s(literal 1 binary64) n) Initial program 29.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.1
Applied rewrites6.1%
Applied rewrites75.8%
Taylor expanded in x around inf
Applied rewrites75.8%
Final simplification83.6%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -20000000.0)
(/ (log 1.0) n)
(if (<= (pow n -1.0) 4e+129)
(/ (pow (+ 0.5 x) -1.0) n)
(/ (/ n x) (* n n)))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20000000.0) {
tmp = log(1.0) / n;
} else if (pow(n, -1.0) <= 4e+129) {
tmp = pow((0.5 + x), -1.0) / n;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n ** (-1.0d0)) <= (-20000000.0d0)) then
tmp = log(1.0d0) / n
else if ((n ** (-1.0d0)) <= 4d+129) then
tmp = ((0.5d0 + x) ** (-1.0d0)) / n
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -20000000.0) {
tmp = Math.log(1.0) / n;
} else if (Math.pow(n, -1.0) <= 4e+129) {
tmp = Math.pow((0.5 + x), -1.0) / n;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -20000000.0: tmp = math.log(1.0) / n elif math.pow(n, -1.0) <= 4e+129: tmp = math.pow((0.5 + x), -1.0) / n else: tmp = (n / x) / (n * n) return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20000000.0) tmp = Float64(log(1.0) / n); elseif ((n ^ -1.0) <= 4e+129) tmp = Float64((Float64(0.5 + x) ^ -1.0) / n); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -20000000.0) tmp = log(1.0) / n; elseif ((n ^ -1.0) <= 4e+129) tmp = ((0.5 + x) ^ -1.0) / n; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20000000.0], N[(N[Log[1.0], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 4e+129], N[(N[Power[N[(0.5 + x), $MachinePrecision], -1.0], $MachinePrecision] / n), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20000000:\\
\;\;\;\;\frac{\log 1}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 4 \cdot 10^{+129}:\\
\;\;\;\;\frac{{\left(0.5 + x\right)}^{-1}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e7Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6452.3
Applied rewrites52.3%
Applied rewrites53.9%
Taylor expanded in x around inf
Applied rewrites61.5%
if -2e7 < (/.f64 #s(literal 1 binary64) n) < 4e129Initial program 38.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6469.6
Applied rewrites69.6%
Applied rewrites69.9%
Applied rewrites69.6%
Taylor expanded in x around inf
Applied rewrites50.2%
if 4e129 < (/.f64 #s(literal 1 binary64) n) Initial program 34.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f645.8
Applied rewrites5.8%
Applied rewrites61.5%
Taylor expanded in x around inf
Applied rewrites61.6%
Final simplification54.2%
(FPCore (x n) :precision binary64 (if (<= x 3.5e+208) (/ (fma (/ (pow x -1.0) n) (- (/ 0.3333333333333333 x) 0.5) (pow n -1.0)) x) (/ (/ (/ -0.5 x) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 3.5e+208) {
tmp = fma((pow(x, -1.0) / n), ((0.3333333333333333 / x) - 0.5), pow(n, -1.0)) / x;
} else {
tmp = ((-0.5 / x) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 3.5e+208) tmp = Float64(fma(Float64((x ^ -1.0) / n), Float64(Float64(0.3333333333333333 / x) - 0.5), (n ^ -1.0)) / x); else tmp = Float64(Float64(Float64(-0.5 / x) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 3.5e+208], N[(N[(N[(N[Power[x, -1.0], $MachinePrecision] / n), $MachinePrecision] * N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] + N[Power[n, -1.0], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(-0.5 / x), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{+208}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{x}^{-1}}{n}, \frac{0.3333333333333333}{x} - 0.5, {n}^{-1}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{-0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 3.50000000000000016e208Initial program 46.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6452.8
Applied rewrites52.8%
Applied rewrites53.4%
Taylor expanded in x around inf
Applied rewrites39.6%
if 3.50000000000000016e208 < x Initial program 97.5%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in n around inf
Applied rewrites70.9%
Taylor expanded in x around 0
Applied rewrites90.5%
Final simplification46.8%
(FPCore (x n) :precision binary64 (if (<= x 0.62) (- (expm1 (/ (log x) n))) (/ (/ (pow x (pow n -1.0)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.62) {
tmp = -expm1((log(x) / n));
} else {
tmp = (pow(x, pow(n, -1.0)) / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 0.62) {
tmp = -Math.expm1((Math.log(x) / n));
} else {
tmp = (Math.pow(x, Math.pow(n, -1.0)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.62: tmp = -math.expm1((math.log(x) / n)) else: tmp = (math.pow(x, math.pow(n, -1.0)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.62) tmp = Float64(-expm1(Float64(log(x) / n))); else tmp = Float64(Float64((x ^ (n ^ -1.0)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 0.62], (-N[(Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]), N[(N[(N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.62:\\
\;\;\;\;-\mathsf{expm1}\left(\frac{\log x}{n}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left({n}^{-1}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 0.619999999999999996Initial program 39.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6453.9
Applied rewrites53.9%
Applied rewrites53.9%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
neg-sub0N/A
remove-double-negN/A
distribute-frac-negN/A
log-recN/A
mul-1-negN/A
associate-+l-N/A
lower--.f64N/A
mul-1-negN/A
log-recN/A
distribute-frac-negN/A
remove-double-negN/A
lower-expm1.f64N/A
lower-/.f64N/A
lower-log.f6485.8
Applied rewrites85.8%
if 0.619999999999999996 < x Initial program 71.2%
Taylor expanded in x around inf
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f6499.4
Applied rewrites99.4%
Applied rewrites99.5%
Final simplification91.8%
(FPCore (x n) :precision binary64 (if (<= x 0.62) (- (expm1 (/ (log x) n))) (/ (pow x (fma 2.0 (/ 0.5 n) -1.0)) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.62) {
tmp = -expm1((log(x) / n));
} else {
tmp = pow(x, fma(2.0, (0.5 / n), -1.0)) / n;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 0.62) tmp = Float64(-expm1(Float64(log(x) / n))); else tmp = Float64((x ^ fma(2.0, Float64(0.5 / n), -1.0)) / n); end return tmp end
code[x_, n_] := If[LessEqual[x, 0.62], (-N[(Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]), N[(N[Power[x, N[(2.0 * N[(0.5 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.62:\\
\;\;\;\;-\mathsf{expm1}\left(\frac{\log x}{n}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\mathsf{fma}\left(2, \frac{0.5}{n}, -1\right)\right)}}{n}\\
\end{array}
\end{array}
if x < 0.619999999999999996Initial program 39.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6453.9
Applied rewrites53.9%
Applied rewrites53.9%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
neg-sub0N/A
remove-double-negN/A
distribute-frac-negN/A
log-recN/A
mul-1-negN/A
associate-+l-N/A
lower--.f64N/A
mul-1-negN/A
log-recN/A
distribute-frac-negN/A
remove-double-negN/A
lower-expm1.f64N/A
lower-/.f64N/A
lower-log.f6485.8
Applied rewrites85.8%
if 0.619999999999999996 < x Initial program 71.2%
Taylor expanded in x around inf
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f6499.4
Applied rewrites99.4%
Applied rewrites99.4%
Final simplification91.7%
(FPCore (x n)
:precision binary64
(if (<= x 8.8e-76)
(* (- (log x)) (pow n -1.0))
(if (<= x 1.0)
(/ (* (- n) (log x)) (* n n))
(if (or (<= x 540000000000.0) (not (<= x 1e+85)))
(/ (log 1.0) n)
(/ (/ (- 1.0 (/ 0.5 x)) n) x)))))
double code(double x, double n) {
double tmp;
if (x <= 8.8e-76) {
tmp = -log(x) * pow(n, -1.0);
} else if (x <= 1.0) {
tmp = (-n * log(x)) / (n * n);
} else if ((x <= 540000000000.0) || !(x <= 1e+85)) {
tmp = log(1.0) / n;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 8.8d-76) then
tmp = -log(x) * (n ** (-1.0d0))
else if (x <= 1.0d0) then
tmp = (-n * log(x)) / (n * n)
else if ((x <= 540000000000.0d0) .or. (.not. (x <= 1d+85))) then
tmp = log(1.0d0) / n
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 8.8e-76) {
tmp = -Math.log(x) * Math.pow(n, -1.0);
} else if (x <= 1.0) {
tmp = (-n * Math.log(x)) / (n * n);
} else if ((x <= 540000000000.0) || !(x <= 1e+85)) {
tmp = Math.log(1.0) / n;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 8.8e-76: tmp = -math.log(x) * math.pow(n, -1.0) elif x <= 1.0: tmp = (-n * math.log(x)) / (n * n) elif (x <= 540000000000.0) or not (x <= 1e+85): tmp = math.log(1.0) / n else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 8.8e-76) tmp = Float64(Float64(-log(x)) * (n ^ -1.0)); elseif (x <= 1.0) tmp = Float64(Float64(Float64(-n) * log(x)) / Float64(n * n)); elseif ((x <= 540000000000.0) || !(x <= 1e+85)) tmp = Float64(log(1.0) / n); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 8.8e-76) tmp = -log(x) * (n ^ -1.0); elseif (x <= 1.0) tmp = (-n * log(x)) / (n * n); elseif ((x <= 540000000000.0) || ~((x <= 1e+85))) tmp = log(1.0) / n; else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 8.8e-76], N[((-N[Log[x], $MachinePrecision]) * N[Power[n, -1.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[((-n) * N[Log[x], $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 540000000000.0], N[Not[LessEqual[x, 1e+85]], $MachinePrecision]], N[(N[Log[1.0], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.8 \cdot 10^{-76}:\\
\;\;\;\;\left(-\log x\right) \cdot {n}^{-1}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{\left(-n\right) \cdot \log x}{n \cdot n}\\
\mathbf{elif}\;x \leq 540000000000 \lor \neg \left(x \leq 10^{+85}\right):\\
\;\;\;\;\frac{\log 1}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 8.79999999999999997e-76Initial program 39.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6456.7
Applied rewrites56.7%
Taylor expanded in x around 0
Applied rewrites56.7%
Applied rewrites56.7%
if 8.79999999999999997e-76 < x < 1Initial program 43.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6443.2
Applied rewrites43.2%
Applied rewrites68.0%
Taylor expanded in x around 0
Applied rewrites65.5%
if 1 < x < 5.4e11 or 1e85 < x Initial program 83.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6476.9
Applied rewrites76.9%
Applied rewrites77.0%
Taylor expanded in x around inf
Applied rewrites83.3%
if 5.4e11 < x < 1e85Initial program 33.4%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites92.0%
Taylor expanded in n around inf
Applied rewrites73.6%
Final simplification68.4%
(FPCore (x n)
:precision binary64
(if (<= x 2.25e-27)
(/ (- (log x)) n)
(if (<= x 1.0)
(/ (/ n x) (* n n))
(if (or (<= x 540000000000.0) (not (<= x 1e+85)))
(/ (log 1.0) n)
(/ (/ (- 1.0 (/ 0.5 x)) n) x)))))
double code(double x, double n) {
double tmp;
if (x <= 2.25e-27) {
tmp = -log(x) / n;
} else if (x <= 1.0) {
tmp = (n / x) / (n * n);
} else if ((x <= 540000000000.0) || !(x <= 1e+85)) {
tmp = log(1.0) / n;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.25d-27) then
tmp = -log(x) / n
else if (x <= 1.0d0) then
tmp = (n / x) / (n * n)
else if ((x <= 540000000000.0d0) .or. (.not. (x <= 1d+85))) then
tmp = log(1.0d0) / n
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.25e-27) {
tmp = -Math.log(x) / n;
} else if (x <= 1.0) {
tmp = (n / x) / (n * n);
} else if ((x <= 540000000000.0) || !(x <= 1e+85)) {
tmp = Math.log(1.0) / n;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.25e-27: tmp = -math.log(x) / n elif x <= 1.0: tmp = (n / x) / (n * n) elif (x <= 540000000000.0) or not (x <= 1e+85): tmp = math.log(1.0) / n else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 2.25e-27) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.0) tmp = Float64(Float64(n / x) / Float64(n * n)); elseif ((x <= 540000000000.0) || !(x <= 1e+85)) tmp = Float64(log(1.0) / n); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.25e-27) tmp = -log(x) / n; elseif (x <= 1.0) tmp = (n / x) / (n * n); elseif ((x <= 540000000000.0) || ~((x <= 1e+85))) tmp = log(1.0) / n; else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.25e-27], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 540000000000.0], N[Not[LessEqual[x, 1e+85]], $MachinePrecision]], N[(N[Log[1.0], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{-27}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{elif}\;x \leq 540000000000 \lor \neg \left(x \leq 10^{+85}\right):\\
\;\;\;\;\frac{\log 1}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 2.2500000000000001e-27Initial program 38.1%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6456.2
Applied rewrites56.2%
Taylor expanded in x around 0
Applied rewrites56.2%
if 2.2500000000000001e-27 < x < 1Initial program 64.1%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6423.6
Applied rewrites23.6%
Applied rewrites79.6%
Taylor expanded in x around inf
Applied rewrites63.5%
if 1 < x < 5.4e11 or 1e85 < x Initial program 83.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6476.9
Applied rewrites76.9%
Applied rewrites77.0%
Taylor expanded in x around inf
Applied rewrites83.3%
if 5.4e11 < x < 1e85Initial program 33.4%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites92.0%
Taylor expanded in n around inf
Applied rewrites73.6%
Final simplification67.3%
(FPCore (x n) :precision binary64 (if (or (<= n -2.0) (not (<= n 7.5e-133))) (/ (pow (+ 0.5 x) -1.0) n) (/ (/ n x) (* n n))))
double code(double x, double n) {
double tmp;
if ((n <= -2.0) || !(n <= 7.5e-133)) {
tmp = pow((0.5 + x), -1.0) / n;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-2.0d0)) .or. (.not. (n <= 7.5d-133))) then
tmp = ((0.5d0 + x) ** (-1.0d0)) / n
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -2.0) || !(n <= 7.5e-133)) {
tmp = Math.pow((0.5 + x), -1.0) / n;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -2.0) or not (n <= 7.5e-133): tmp = math.pow((0.5 + x), -1.0) / n else: tmp = (n / x) / (n * n) return tmp
function code(x, n) tmp = 0.0 if ((n <= -2.0) || !(n <= 7.5e-133)) tmp = Float64((Float64(0.5 + x) ^ -1.0) / n); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -2.0) || ~((n <= 7.5e-133))) tmp = ((0.5 + x) ^ -1.0) / n; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -2.0], N[Not[LessEqual[n, 7.5e-133]], $MachinePrecision]], N[(N[Power[N[(0.5 + x), $MachinePrecision], -1.0], $MachinePrecision] / n), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2 \lor \neg \left(n \leq 7.5 \cdot 10^{-133}\right):\\
\;\;\;\;\frac{{\left(0.5 + x\right)}^{-1}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if n < -2 or 7.4999999999999999e-133 < n Initial program 38.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6470.4
Applied rewrites70.4%
Applied rewrites70.7%
Applied rewrites70.4%
Taylor expanded in x around inf
Applied rewrites50.8%
if -2 < n < 7.4999999999999999e-133Initial program 80.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6438.5
Applied rewrites38.5%
Applied rewrites50.7%
Taylor expanded in x around inf
Applied rewrites42.5%
Final simplification47.8%
(FPCore (x n) :precision binary64 (if (<= n -2.0) (/ (pow (+ 0.5 x) -1.0) n) (/ (pow n -1.0) x)))
double code(double x, double n) {
double tmp;
if (n <= -2.0) {
tmp = pow((0.5 + x), -1.0) / n;
} else {
tmp = pow(n, -1.0) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-2.0d0)) then
tmp = ((0.5d0 + x) ** (-1.0d0)) / n
else
tmp = (n ** (-1.0d0)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -2.0) {
tmp = Math.pow((0.5 + x), -1.0) / n;
} else {
tmp = Math.pow(n, -1.0) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -2.0: tmp = math.pow((0.5 + x), -1.0) / n else: tmp = math.pow(n, -1.0) / x return tmp
function code(x, n) tmp = 0.0 if (n <= -2.0) tmp = Float64((Float64(0.5 + x) ^ -1.0) / n); else tmp = Float64((n ^ -1.0) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -2.0) tmp = ((0.5 + x) ^ -1.0) / n; else tmp = (n ^ -1.0) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -2.0], N[(N[Power[N[(0.5 + x), $MachinePrecision], -1.0], $MachinePrecision] / n), $MachinePrecision], N[(N[Power[n, -1.0], $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2:\\
\;\;\;\;\frac{{\left(0.5 + x\right)}^{-1}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{n}^{-1}}{x}\\
\end{array}
\end{array}
if n < -2Initial program 32.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.7
Applied rewrites77.7%
Applied rewrites78.1%
Applied rewrites77.6%
Taylor expanded in x around inf
Applied rewrites53.5%
if -2 < n Initial program 63.6%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites33.3%
Taylor expanded in n around inf
Applied rewrites20.7%
Taylor expanded in x around inf
Applied rewrites35.3%
Final simplification41.1%
(FPCore (x n) :precision binary64 (/ (pow n -1.0) x))
double code(double x, double n) {
return pow(n, -1.0) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (n ** (-1.0d0)) / x
end function
public static double code(double x, double n) {
return Math.pow(n, -1.0) / x;
}
def code(x, n): return math.pow(n, -1.0) / x
function code(x, n) return Float64((n ^ -1.0) / x) end
function tmp = code(x, n) tmp = (n ^ -1.0) / x; end
code[x_, n_] := N[(N[Power[n, -1.0], $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{{n}^{-1}}{x}
\end{array}
Initial program 53.6%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites37.8%
Taylor expanded in n around inf
Applied rewrites29.1%
Taylor expanded in x around inf
Applied rewrites39.4%
Final simplification39.4%
(FPCore (x n) :precision binary64 (if (<= x 3.5e+208) (/ (/ (+ (/ (- (/ 0.3333333333333333 x) 0.5) x) 1.0) x) n) (/ (/ (/ -0.5 x) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 3.5e+208) {
tmp = (((((0.3333333333333333 / x) - 0.5) / x) + 1.0) / x) / n;
} else {
tmp = ((-0.5 / x) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.5d+208) then
tmp = (((((0.3333333333333333d0 / x) - 0.5d0) / x) + 1.0d0) / x) / n
else
tmp = (((-0.5d0) / x) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.5e+208) {
tmp = (((((0.3333333333333333 / x) - 0.5) / x) + 1.0) / x) / n;
} else {
tmp = ((-0.5 / x) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.5e+208: tmp = (((((0.3333333333333333 / x) - 0.5) / x) + 1.0) / x) / n else: tmp = ((-0.5 / x) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 3.5e+208) tmp = Float64(Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x) + 1.0) / x) / n); else tmp = Float64(Float64(Float64(-0.5 / x) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.5e+208) tmp = (((((0.3333333333333333 / x) - 0.5) / x) + 1.0) / x) / n; else tmp = ((-0.5 / x) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.5e+208], N[(N[(N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(-0.5 / x), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{+208}:\\
\;\;\;\;\frac{\frac{\frac{\frac{0.3333333333333333}{x} - 0.5}{x} + 1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{-0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 3.50000000000000016e208Initial program 46.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6452.8
Applied rewrites52.8%
Taylor expanded in x around inf
Applied rewrites39.5%
if 3.50000000000000016e208 < x Initial program 97.5%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in n around inf
Applied rewrites70.9%
Taylor expanded in x around 0
Applied rewrites90.5%
herbie shell --seed 2024318
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))