
(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 21 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (sqrt t_0)))
(if (<= (/ 1.0 n) -5e-6)
(- (pow (+ 1.0 x) (/ 1.0 n)) (expm1 (log1p t_0)))
(if (<= (/ 1.0 n) 2e-9)
(/
(-
(+
(log1p x)
(/
(+
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0)))
(*
0.16666666666666666
(/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)))
n))
(log x))
n)
(fma t_1 (- t_1) (exp (/ (log1p x) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = sqrt(t_0);
double tmp;
if ((1.0 / n) <= -5e-6) {
tmp = pow((1.0 + x), (1.0 / n)) - expm1(log1p(t_0));
} else if ((1.0 / n) <= 2e-9) {
tmp = ((log1p(x) + (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) + (0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n))) / n)) - log(x)) / n;
} else {
tmp = fma(t_1, -t_1, exp((log1p(x) / n)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = sqrt(t_0) tmp = 0.0 if (Float64(1.0 / n) <= -5e-6) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - expm1(log1p(t_0))); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) + Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n)) - log(x)) / n); else tmp = fma(t_1, Float64(-t_1), exp(Float64(log1p(x) / n))); 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[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-6], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$1 * (-t$95$1) + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-6}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -t\_1, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000041e-6Initial program 99.8%
expm1-log1p-u99.8%
expm1-undefine99.8%
Applied egg-rr99.8%
expm1-define99.8%
Simplified99.8%
if -5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 7.4%
Taylor expanded in n around -inf 91.4%
Simplified91.4%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 45.8%
sub-neg45.8%
+-commutative45.8%
sqr-pow45.8%
distribute-rgt-neg-in45.8%
fma-define45.8%
sqrt-pow145.8%
sqrt-pow145.8%
pow-to-exp45.8%
un-div-inv45.8%
+-commutative45.8%
log1p-define99.8%
Applied egg-rr99.8%
Final simplification96.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ 1.0 x) (/ 1.0 n)) t_0)))
(if (<= t_1 -5e-6)
(- 1.0 (exp (* (/ 1.0 n) (log x))))
(if (<= t_1 0.0)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((1.0 + x), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-6) {
tmp = 1.0 - exp(((1.0 / n) * log(x)));
} else if (t_1 <= 0.0) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((1.0 + x), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-6) {
tmp = 1.0 - Math.exp(((1.0 / n) * Math.log(x)));
} else if (t_1 <= 0.0) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((1.0 + x), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -5e-6: tmp = 1.0 - math.exp(((1.0 / n) * math.log(x))) elif t_1 <= 0.0: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -5e-6) tmp = Float64(1.0 - exp(Float64(Float64(1.0 / n) * log(x)))); elseif (t_1 <= 0.0) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-6], N[(1.0 - N[Exp[N[(N[(1.0 / n), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-6}:\\
\;\;\;\;1 - e^{\frac{1}{n} \cdot \log x}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\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))) < -5.00000000000000041e-6Initial program 99.1%
Taylor expanded in x around 0 99.1%
*-rgt-identity99.1%
associate-*l/99.1%
associate-/l*99.1%
exp-to-pow99.1%
Simplified99.1%
expm1-log1p-u99.1%
expm1-undefine99.0%
Applied egg-rr99.0%
expm1-define99.1%
Simplified99.1%
expm1-log1p-u99.1%
pow-to-exp99.1%
Applied egg-rr99.1%
if -5.00000000000000041e-6 < (-.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 29.0%
Taylor expanded in n around inf 93.1%
log1p-define92.5%
Simplified92.5%
log1p-undefine93.1%
diff-log93.2%
Applied egg-rr93.2%
+-commutative93.2%
Simplified93.2%
if 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 46.4%
Taylor expanded in n around 0 46.4%
log1p-define98.8%
*-rgt-identity98.8%
associate-*l/98.8%
associate-/l*98.8%
exp-to-pow98.8%
Simplified98.8%
Final simplification95.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (sqrt t_0)))
(if (<= (/ 1.0 n) -1e-8)
(- (pow (+ 1.0 x) (/ 1.0 n)) (expm1 (log1p t_0)))
(if (<= (/ 1.0 n) 2e-9)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(fma t_1 (- t_1) (exp (/ (log1p x) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = sqrt(t_0);
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = pow((1.0 + x), (1.0 / n)) - expm1(log1p(t_0));
} else if ((1.0 / n) <= 2e-9) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else {
tmp = fma(t_1, -t_1, exp((log1p(x) / n)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = sqrt(t_0) tmp = 0.0 if (Float64(1.0 / n) <= -1e-8) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - expm1(log1p(t_0))); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); else tmp = fma(t_1, Float64(-t_1), exp(Float64(log1p(x) / n))); 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[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$1 * (-t$95$1) + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -t\_1, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e-8Initial program 99.5%
expm1-log1p-u99.5%
expm1-undefine99.5%
Applied egg-rr99.5%
expm1-define99.5%
Simplified99.5%
if -1e-8 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 6.8%
Taylor expanded in n around inf 91.3%
associate--l+91.3%
log1p-define91.3%
+-commutative91.3%
associate--r+91.3%
distribute-lft-out--91.3%
div-sub91.3%
log1p-define91.3%
Simplified91.3%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 45.8%
sub-neg45.8%
+-commutative45.8%
sqr-pow45.8%
distribute-rgt-neg-in45.8%
fma-define45.8%
sqrt-pow145.8%
sqrt-pow145.8%
pow-to-exp45.8%
un-div-inv45.8%
+-commutative45.8%
log1p-define99.8%
Applied egg-rr99.8%
Final simplification95.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ 1.0 x) (/ 1.0 n)) t_0)))
(if (<= t_1 -5e-6)
(- 1.0 (exp (* (/ 1.0 n) (log x))))
(if (<= t_1 0.0)
(/ (log (/ (+ 1.0 x) x)) n)
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (- (* 0.5 (/ 1.0 (pow n 2.0))) (* (/ 1.0 n) 0.5))))))
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((1.0 + x), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-6) {
tmp = 1.0 - exp(((1.0 / n) * log(x)));
} else if (t_1 <= 0.0) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) - ((1.0 / n) * 0.5)))))) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = ((1.0d0 + x) ** (1.0d0 / n)) - t_0
if (t_1 <= (-5d-6)) then
tmp = 1.0d0 - exp(((1.0d0 / n) * log(x)))
else if (t_1 <= 0.0d0) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = (1.0d0 + (x * ((1.0d0 / n) + (x * ((0.5d0 * (1.0d0 / (n ** 2.0d0))) - ((1.0d0 / n) * 0.5d0)))))) - 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((1.0 + x), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-6) {
tmp = 1.0 - Math.exp(((1.0 / n) * Math.log(x)));
} else if (t_1 <= 0.0) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) - ((1.0 / n) * 0.5)))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((1.0 + x), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -5e-6: tmp = 1.0 - math.exp(((1.0 / n) * math.log(x))) elif t_1 <= 0.0: tmp = math.log(((1.0 + x) / x)) / n else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / math.pow(n, 2.0))) - ((1.0 / n) * 0.5)))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -5e-6) tmp = Float64(1.0 - exp(Float64(Float64(1.0 / n) * log(x)))); elseif (t_1 <= 0.0) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) - Float64(Float64(1.0 / n) * 0.5)))))) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = ((1.0 + x) ^ (1.0 / n)) - t_0; tmp = 0.0; if (t_1 <= -5e-6) tmp = 1.0 - exp(((1.0 / n) * log(x))); elseif (t_1 <= 0.0) tmp = log(((1.0 + x) / x)) / n; else tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / (n ^ 2.0))) - ((1.0 / n) * 0.5)))))) - 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[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-6], N[(1.0 - N[Exp[N[(N[(1.0 / n), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / n), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-6}:\\
\;\;\;\;1 - e^{\frac{1}{n} \cdot \log x}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} - \frac{1}{n} \cdot 0.5\right)\right)\right) - t\_0\\
\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))) < -5.00000000000000041e-6Initial program 99.1%
Taylor expanded in x around 0 99.1%
*-rgt-identity99.1%
associate-*l/99.1%
associate-/l*99.1%
exp-to-pow99.1%
Simplified99.1%
expm1-log1p-u99.1%
expm1-undefine99.0%
Applied egg-rr99.0%
expm1-define99.1%
Simplified99.1%
expm1-log1p-u99.1%
pow-to-exp99.1%
Applied egg-rr99.1%
if -5.00000000000000041e-6 < (-.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 29.0%
Taylor expanded in n around inf 93.1%
log1p-define92.5%
Simplified92.5%
log1p-undefine93.1%
diff-log93.2%
Applied egg-rr93.2%
+-commutative93.2%
Simplified93.2%
if 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 46.4%
Taylor expanded in x around 0 71.7%
Final simplification88.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-8)
(- (pow (+ 1.0 x) (/ 1.0 n)) (expm1 (log1p t_0)))
(if (<= (/ 1.0 n) 2e-9)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(cbrt (pow (- (exp (/ (log1p x) n)) t_0) 3.0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = pow((1.0 + x), (1.0 / n)) - expm1(log1p(t_0));
} else if ((1.0 / n) <= 2e-9) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else {
tmp = cbrt(pow((exp((log1p(x) / n)) - t_0), 3.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - Math.expm1(Math.log1p(t_0));
} else if ((1.0 / n) <= 2e-9) {
tmp = (Math.log1p(x) + ((0.5 * ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n)) - Math.log(x))) / n;
} else {
tmp = Math.cbrt(Math.pow((Math.exp((Math.log1p(x) / n)) - t_0), 3.0));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-8) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - expm1(log1p(t_0))); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); else tmp = cbrt((Float64(exp(Float64(log1p(x) / n)) - t_0) ^ 3.0)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\right)}^{3}}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e-8Initial program 99.5%
expm1-log1p-u99.5%
expm1-undefine99.5%
Applied egg-rr99.5%
expm1-define99.5%
Simplified99.5%
if -1e-8 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 6.8%
Taylor expanded in n around inf 91.3%
associate--l+91.3%
log1p-define91.3%
+-commutative91.3%
associate--r+91.3%
distribute-lft-out--91.3%
div-sub91.3%
log1p-define91.3%
Simplified91.3%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 45.8%
add-cbrt-cube45.8%
pow345.8%
pow-to-exp45.8%
un-div-inv45.8%
+-commutative45.8%
log1p-define99.8%
Applied egg-rr99.8%
Final simplification95.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-8)
(- (pow (+ 1.0 x) (/ 1.0 n)) (expm1 (log1p t_0)))
(if (<= (/ 1.0 n) 2e-21)
(/ (log (/ (+ 1.0 x) x)) n)
(cbrt (pow (- (exp (/ (log1p x) n)) t_0) 3.0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = pow((1.0 + x), (1.0 / n)) - expm1(log1p(t_0));
} else if ((1.0 / n) <= 2e-21) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = cbrt(pow((exp((log1p(x) / n)) - t_0), 3.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - Math.expm1(Math.log1p(t_0));
} else if ((1.0 / n) <= 2e-21) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.cbrt(Math.pow((Math.exp((Math.log1p(x) / n)) - t_0), 3.0));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-8) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - expm1(log1p(t_0))); elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = cbrt((Float64(exp(Float64(log1p(x) / n)) - t_0) ^ 3.0)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\right)}^{3}}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e-8Initial program 99.5%
expm1-log1p-u99.5%
expm1-undefine99.5%
Applied egg-rr99.5%
expm1-define99.5%
Simplified99.5%
if -1e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 5.7%
Taylor expanded in n around inf 90.9%
log1p-define90.9%
Simplified90.9%
log1p-undefine90.9%
diff-log91.0%
Applied egg-rr91.0%
+-commutative91.0%
Simplified91.0%
if 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) Initial program 46.4%
add-cbrt-cube46.4%
pow346.4%
pow-to-exp46.4%
un-div-inv46.4%
+-commutative46.4%
log1p-define98.8%
Applied egg-rr98.8%
Final simplification95.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-8)
(- (pow (+ 1.0 x) (/ 1.0 n)) (expm1 (log1p t_0)))
(if (<= (/ 1.0 n) 2e-21)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = pow((1.0 + x), (1.0 / n)) - expm1(log1p(t_0));
} else if ((1.0 / n) <= 2e-21) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - Math.expm1(Math.log1p(t_0));
} else if ((1.0 / n) <= 2e-21) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-8: tmp = math.pow((1.0 + x), (1.0 / n)) - math.expm1(math.log1p(t_0)) elif (1.0 / n) <= 2e-21: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-8) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - expm1(log1p(t_0))); elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e-8Initial program 99.5%
expm1-log1p-u99.5%
expm1-undefine99.5%
Applied egg-rr99.5%
expm1-define99.5%
Simplified99.5%
if -1e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 5.7%
Taylor expanded in n around inf 90.9%
log1p-define90.9%
Simplified90.9%
log1p-undefine90.9%
diff-log91.0%
Applied egg-rr91.0%
+-commutative91.0%
Simplified91.0%
if 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) Initial program 46.4%
Taylor expanded in n around 0 46.4%
log1p-define98.8%
*-rgt-identity98.8%
associate-*l/98.8%
associate-/l*98.8%
exp-to-pow98.8%
Simplified98.8%
Final simplification95.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (pow (+ 1.0 x) (/ 1.0 n)) (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -1e-8)
t_0
(if (<= (/ 1.0 n) 2e-21)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+167) t_0 (log1p (expm1 (/ (/ 1.0 x) n))))))))
double code(double x, double n) {
double t_0 = pow((1.0 + x), (1.0 / n)) - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-21) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = t_0;
} else {
tmp = log1p(expm1(((1.0 / x) / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow((1.0 + x), (1.0 / n)) - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-21) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = t_0;
} else {
tmp = Math.log1p(Math.expm1(((1.0 / x) / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow((1.0 + x), (1.0 / n)) - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-8: tmp = t_0 elif (1.0 / n) <= 2e-21: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+167: tmp = t_0 else: tmp = math.log1p(math.expm1(((1.0 / x) / n))) return tmp
function code(x, n) t_0 = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -1e-8) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+167) tmp = t_0; else tmp = log1p(expm1(Float64(Float64(1.0 / x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+167], t$95$0, N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+167}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e-8 or 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) < 1e167Initial program 90.6%
if -1e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 5.7%
Taylor expanded in n around inf 90.9%
log1p-define90.9%
Simplified90.9%
log1p-undefine90.9%
diff-log91.0%
Applied egg-rr91.0%
+-commutative91.0%
Simplified91.0%
if 1e167 < (/.f64 #s(literal 1 binary64) n) Initial program 17.4%
Taylor expanded in x around inf 0.5%
mul-1-neg0.5%
log-rec0.5%
mul-1-neg0.5%
distribute-neg-frac0.5%
mul-1-neg0.5%
remove-double-neg0.5%
*-commutative0.5%
Simplified0.5%
Taylor expanded in n around inf 64.5%
log1p-expm1-u86.6%
associate-/r*86.6%
Applied egg-rr86.6%
Final simplification90.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1000.0)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-21)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+167)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ (/ 1.0 x) n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1000.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-21) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1(((1.0 / x) / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1000.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-21) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1(((1.0 / x) / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1000.0: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-21: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+167: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1(((1.0 / x) / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1000.0) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+167) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(Float64(1.0 / x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1000.0], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+167], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1000:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+167}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e3Initial program 100.0%
Taylor expanded in x around inf 100.0%
associate-/r*100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if -1e3 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 7.9%
Taylor expanded in n around inf 89.3%
log1p-define89.3%
Simplified89.3%
log1p-undefine89.3%
diff-log89.4%
Applied egg-rr89.4%
+-commutative89.4%
Simplified89.4%
if 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) < 1e167Initial program 70.5%
Taylor expanded in x around 0 66.9%
if 1e167 < (/.f64 #s(literal 1 binary64) n) Initial program 17.4%
Taylor expanded in x around inf 0.5%
mul-1-neg0.5%
log-rec0.5%
mul-1-neg0.5%
distribute-neg-frac0.5%
mul-1-neg0.5%
remove-double-neg0.5%
*-commutative0.5%
Simplified0.5%
Taylor expanded in n around inf 64.5%
log1p-expm1-u86.6%
associate-/r*86.6%
Applied egg-rr86.6%
Final simplification89.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (+ 1.0 x) x)))
(if (<= (/ 1.0 n) -1e-11)
(log (pow t_0 (/ 1.0 n)))
(if (<= (/ 1.0 n) 2e-21)
(/ (log t_0) n)
(if (<= (/ 1.0 n) 1e+167)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(log1p (expm1 (/ (/ 1.0 x) n))))))))
double code(double x, double n) {
double t_0 = (1.0 + x) / x;
double tmp;
if ((1.0 / n) <= -1e-11) {
tmp = log(pow(t_0, (1.0 / n)));
} else if ((1.0 / n) <= 2e-21) {
tmp = log(t_0) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else {
tmp = log1p(expm1(((1.0 / x) / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (1.0 + x) / x;
double tmp;
if ((1.0 / n) <= -1e-11) {
tmp = Math.log(Math.pow(t_0, (1.0 / n)));
} else if ((1.0 / n) <= 2e-21) {
tmp = Math.log(t_0) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = Math.log1p(Math.expm1(((1.0 / x) / n)));
}
return tmp;
}
def code(x, n): t_0 = (1.0 + x) / x tmp = 0 if (1.0 / n) <= -1e-11: tmp = math.log(math.pow(t_0, (1.0 / n))) elif (1.0 / n) <= 2e-21: tmp = math.log(t_0) / n elif (1.0 / n) <= 1e+167: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) else: tmp = math.log1p(math.expm1(((1.0 / x) / n))) return tmp
function code(x, n) t_0 = Float64(Float64(1.0 + x) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1e-11) tmp = log((t_0 ^ Float64(1.0 / n))); elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(log(t_0) / n); elseif (Float64(1.0 / n) <= 1e+167) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = log1p(expm1(Float64(Float64(1.0 / x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-11], N[Log[N[Power[t$95$0, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[Log[t$95$0], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+167], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 + x}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-11}:\\
\;\;\;\;\log \left({t\_0}^{\left(\frac{1}{n}\right)}\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\log t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+167}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999939e-12Initial program 99.1%
Taylor expanded in n around inf 52.5%
log1p-define51.3%
Simplified51.3%
add-log-exp95.7%
div-inv95.7%
exp-prod95.7%
exp-diff95.7%
add-exp-log51.4%
log1p-undefine51.4%
rem-exp-log96.9%
Applied egg-rr96.9%
+-commutative96.9%
Simplified96.9%
if -9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 5.3%
Taylor expanded in n around inf 91.2%
log1p-define91.2%
Simplified91.2%
log1p-undefine91.2%
diff-log91.3%
Applied egg-rr91.3%
+-commutative91.3%
Simplified91.3%
if 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) < 1e167Initial program 70.5%
Taylor expanded in x around 0 66.9%
if 1e167 < (/.f64 #s(literal 1 binary64) n) Initial program 17.4%
Taylor expanded in x around inf 0.5%
mul-1-neg0.5%
log-rec0.5%
mul-1-neg0.5%
distribute-neg-frac0.5%
mul-1-neg0.5%
remove-double-neg0.5%
*-commutative0.5%
Simplified0.5%
Taylor expanded in n around inf 64.5%
log1p-expm1-u86.6%
associate-/r*86.6%
Applied egg-rr86.6%
Final simplification89.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -5e+202)
t_0
(if (<= (/ 1.0 n) -2e+67)
0.0
(if (<= (/ 1.0 n) -1e-8)
t_0
(if (<= (/ 1.0 n) 2e-21)
(/ (- x (log x)) n)
(if (<= (/ 1.0 n) 1e+167)
t_0
(/
(/ (+ 1.0 (/ (- (* (/ 1.0 x) 0.3333333333333333) 0.5) x)) x)
n))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e+202) {
tmp = t_0;
} else if ((1.0 / n) <= -2e+67) {
tmp = 0.0;
} else if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-21) {
tmp = (x - log(x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-5d+202)) then
tmp = t_0
else if ((1.0d0 / n) <= (-2d+67)) then
tmp = 0.0d0
else if ((1.0d0 / n) <= (-1d-8)) then
tmp = t_0
else if ((1.0d0 / n) <= 2d-21) then
tmp = (x - log(x)) / n
else if ((1.0d0 / n) <= 1d+167) then
tmp = t_0
else
tmp = ((1.0d0 + ((((1.0d0 / x) * 0.3333333333333333d0) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e+202) {
tmp = t_0;
} else if ((1.0 / n) <= -2e+67) {
tmp = 0.0;
} else if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-21) {
tmp = (x - Math.log(x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e+202: tmp = t_0 elif (1.0 / n) <= -2e+67: tmp = 0.0 elif (1.0 / n) <= -1e-8: tmp = t_0 elif (1.0 / n) <= 2e-21: tmp = (x - math.log(x)) / n elif (1.0 / n) <= 1e+167: tmp = t_0 else: tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -5e+202) tmp = t_0; elseif (Float64(1.0 / n) <= -2e+67) tmp = 0.0; elseif (Float64(1.0 / n) <= -1e-8) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(Float64(x - log(x)) / n); elseif (Float64(1.0 / n) <= 1e+167) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -5e+202) tmp = t_0; elseif ((1.0 / n) <= -2e+67) tmp = 0.0; elseif ((1.0 / n) <= -1e-8) tmp = t_0; elseif ((1.0 / n) <= 2e-21) tmp = (x - log(x)) / n; elseif ((1.0 / n) <= 1e+167) tmp = t_0; else tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+202], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+67], 0.0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+167], t$95$0, N[(N[(N[(1.0 + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+202}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+67}:\\
\;\;\;\;0\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+167}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{1}{x} \cdot 0.3333333333333333 - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999999e202 or -1.99999999999999997e67 < (/.f64 #s(literal 1 binary64) n) < -1e-8 or 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) < 1e167Initial program 87.1%
Taylor expanded in x around 0 65.7%
*-rgt-identity65.7%
associate-*l/65.7%
associate-/l*65.8%
exp-to-pow65.8%
Simplified65.8%
if -4.9999999999999999e202 < (/.f64 #s(literal 1 binary64) n) < -1.99999999999999997e67Initial program 100.0%
Taylor expanded in x around 0 34.4%
*-rgt-identity34.4%
associate-*l/34.4%
associate-/l*34.4%
exp-to-pow34.4%
Simplified34.4%
expm1-log1p-u100.0%
expm1-undefine100.0%
Applied egg-rr34.4%
expm1-define100.0%
Simplified34.4%
Taylor expanded in n around inf 68.2%
if -1e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 5.7%
Taylor expanded in n around inf 90.9%
log1p-define90.9%
Simplified90.9%
Taylor expanded in x around 0 89.8%
if 1e167 < (/.f64 #s(literal 1 binary64) n) Initial program 17.4%
Taylor expanded in n around inf 6.7%
log1p-define6.7%
Simplified6.7%
Taylor expanded in x around -inf 80.3%
Final simplification78.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -2e+207)
t_0
(if (<= (/ 1.0 n) -5e+38)
t_1
(if (<= (/ 1.0 n) -1e-8)
t_0
(if (<= (/ 1.0 n) 2e-21)
t_1
(if (<= (/ 1.0 n) 1e+167)
t_0
(/
(/ (+ 1.0 (/ (- (* (/ 1.0 x) 0.3333333333333333) 0.5) x)) x)
n))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -2e+207) {
tmp = t_0;
} else if ((1.0 / n) <= -5e+38) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-21) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+167) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-2d+207)) then
tmp = t_0
else if ((1.0d0 / n) <= (-5d+38)) then
tmp = t_1
else if ((1.0d0 / n) <= (-1d-8)) then
tmp = t_0
else if ((1.0d0 / n) <= 2d-21) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+167) then
tmp = t_0
else
tmp = ((1.0d0 + ((((1.0d0 / x) * 0.3333333333333333d0) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -2e+207) {
tmp = t_0;
} else if ((1.0 / n) <= -5e+38) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-21) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+167) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -2e+207: tmp = t_0 elif (1.0 / n) <= -5e+38: tmp = t_1 elif (1.0 / n) <= -1e-8: tmp = t_0 elif (1.0 / n) <= 2e-21: tmp = t_1 elif (1.0 / n) <= 1e+167: tmp = t_0 else: tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e+207) tmp = t_0; elseif (Float64(1.0 / n) <= -5e+38) tmp = t_1; elseif (Float64(1.0 / n) <= -1e-8) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-21) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+167) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -2e+207) tmp = t_0; elseif ((1.0 / n) <= -5e+38) tmp = t_1; elseif ((1.0 / n) <= -1e-8) tmp = t_0; elseif ((1.0 / n) <= 2e-21) tmp = t_1; elseif ((1.0 / n) <= 1e+167) tmp = t_0; else tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+207], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+38], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+167], t$95$0, N[(N[(N[(1.0 + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+207}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+167}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{1}{x} \cdot 0.3333333333333333 - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e207 or -4.9999999999999997e38 < (/.f64 #s(literal 1 binary64) n) < -1e-8 or 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) < 1e167Initial program 86.1%
Taylor expanded in x around 0 66.9%
*-rgt-identity66.9%
associate-*l/66.9%
associate-/l*66.9%
exp-to-pow66.9%
Simplified66.9%
if -2.0000000000000001e207 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999997e38 or -1e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 29.0%
Taylor expanded in n around inf 84.9%
log1p-define84.2%
Simplified84.2%
log1p-undefine84.9%
diff-log84.9%
Applied egg-rr84.9%
+-commutative84.9%
Simplified84.9%
if 1e167 < (/.f64 #s(literal 1 binary64) n) Initial program 17.4%
Taylor expanded in n around inf 6.7%
log1p-define6.7%
Simplified6.7%
Taylor expanded in x around -inf 80.3%
Final simplification79.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1000.0)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-21)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+167)
(- (+ 1.0 (/ x n)) t_0)
(/
(/ (+ 1.0 (/ (- (* (/ 1.0 x) 0.3333333333333333) 0.5) x)) x)
n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1000.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-21) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-1000.0d0)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-21) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d+167) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = ((1.0d0 + ((((1.0d0 / x) * 0.3333333333333333d0) - 0.5d0) / x)) / 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 tmp;
if ((1.0 / n) <= -1000.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-21) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1000.0: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-21: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+167: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1000.0) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+167) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1000.0) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-21) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e+167) tmp = (1.0 + (x / n)) - t_0; else tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1000.0], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+167], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1000:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+167}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{1}{x} \cdot 0.3333333333333333 - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e3Initial program 100.0%
Taylor expanded in x around inf 100.0%
associate-/r*100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if -1e3 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 7.9%
Taylor expanded in n around inf 89.3%
log1p-define89.3%
Simplified89.3%
log1p-undefine89.3%
diff-log89.4%
Applied egg-rr89.4%
+-commutative89.4%
Simplified89.4%
if 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) < 1e167Initial program 70.5%
Taylor expanded in x around 0 66.9%
if 1e167 < (/.f64 #s(literal 1 binary64) n) Initial program 17.4%
Taylor expanded in n around inf 6.7%
log1p-define6.7%
Simplified6.7%
Taylor expanded in x around -inf 80.3%
Final simplification88.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1000.0)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-21)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+167)
(- 1.0 t_0)
(/
(/ (+ 1.0 (/ (- (* (/ 1.0 x) 0.3333333333333333) 0.5) x)) x)
n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1000.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-21) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-1000.0d0)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-21) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d+167) then
tmp = 1.0d0 - t_0
else
tmp = ((1.0d0 + ((((1.0d0 / x) * 0.3333333333333333d0) - 0.5d0) / x)) / 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 tmp;
if ((1.0 / n) <= -1000.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-21) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+167) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1000.0: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-21: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+167: tmp = 1.0 - t_0 else: tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1000.0) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-21) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+167) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1000.0) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-21) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e+167) tmp = 1.0 - t_0; else tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1000.0], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+167], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1000:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+167}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{1}{x} \cdot 0.3333333333333333 - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e3Initial program 100.0%
Taylor expanded in x around inf 100.0%
associate-/r*100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if -1e3 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999982e-21Initial program 7.9%
Taylor expanded in n around inf 89.3%
log1p-define89.3%
Simplified89.3%
log1p-undefine89.3%
diff-log89.4%
Applied egg-rr89.4%
+-commutative89.4%
Simplified89.4%
if 1.99999999999999982e-21 < (/.f64 #s(literal 1 binary64) n) < 1e167Initial program 70.5%
Taylor expanded in x around 0 64.2%
*-rgt-identity64.2%
associate-*l/64.2%
associate-/l*64.2%
exp-to-pow64.2%
Simplified64.2%
if 1e167 < (/.f64 #s(literal 1 binary64) n) Initial program 17.4%
Taylor expanded in n around inf 6.7%
log1p-define6.7%
Simplified6.7%
Taylor expanded in x around -inf 80.3%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- x (log x)) n)))
(if (<= n -5.6e-14)
t_0
(if (<= n -3.4e-196)
0.0
(if (<= n 1.75e-107)
(/ (/ (+ 1.0 (/ (- (* (/ 1.0 x) 0.3333333333333333) 0.5) x)) x) n)
t_0)))))
double code(double x, double n) {
double t_0 = (x - log(x)) / n;
double tmp;
if (n <= -5.6e-14) {
tmp = t_0;
} else if (n <= -3.4e-196) {
tmp = 0.0;
} else if (n <= 1.75e-107) {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (x - log(x)) / n
if (n <= (-5.6d-14)) then
tmp = t_0
else if (n <= (-3.4d-196)) then
tmp = 0.0d0
else if (n <= 1.75d-107) then
tmp = ((1.0d0 + ((((1.0d0 / x) * 0.3333333333333333d0) - 0.5d0) / x)) / x) / n
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (x - Math.log(x)) / n;
double tmp;
if (n <= -5.6e-14) {
tmp = t_0;
} else if (n <= -3.4e-196) {
tmp = 0.0;
} else if (n <= 1.75e-107) {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = (x - math.log(x)) / n tmp = 0 if n <= -5.6e-14: tmp = t_0 elif n <= -3.4e-196: tmp = 0.0 elif n <= 1.75e-107: tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(Float64(x - log(x)) / n) tmp = 0.0 if (n <= -5.6e-14) tmp = t_0; elseif (n <= -3.4e-196) tmp = 0.0; elseif (n <= 1.75e-107) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = (x - log(x)) / n; tmp = 0.0; if (n <= -5.6e-14) tmp = t_0; elseif (n <= -3.4e-196) tmp = 0.0; elseif (n <= 1.75e-107) tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -5.6e-14], t$95$0, If[LessEqual[n, -3.4e-196], 0.0, If[LessEqual[n, 1.75e-107], N[(N[(N[(1.0 + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;n \leq -5.6 \cdot 10^{-14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -3.4 \cdot 10^{-196}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 1.75 \cdot 10^{-107}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{1}{x} \cdot 0.3333333333333333 - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -5.6000000000000001e-14 or 1.74999999999999993e-107 < n Initial program 19.9%
Taylor expanded in n around inf 77.1%
log1p-define77.1%
Simplified77.1%
Taylor expanded in x around 0 76.2%
if -5.6000000000000001e-14 < n < -3.4e-196Initial program 100.0%
Taylor expanded in x around 0 39.5%
*-rgt-identity39.5%
associate-*l/39.5%
associate-/l*39.5%
exp-to-pow39.5%
Simplified39.5%
expm1-log1p-u100.0%
expm1-undefine100.0%
Applied egg-rr39.5%
expm1-define100.0%
Simplified39.5%
Taylor expanded in n around inf 63.1%
if -3.4e-196 < n < 1.74999999999999993e-107Initial program 60.7%
Taylor expanded in n around inf 22.4%
log1p-define22.4%
Simplified22.4%
Taylor expanded in x around -inf 64.1%
Final simplification70.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= n -5.6e-14)
t_0
(if (<= n -3.4e-196)
0.0
(if (<= n 1.8e-107)
(/ (/ (+ 1.0 (/ (- (* (/ 1.0 x) 0.3333333333333333) 0.5) x)) x) n)
t_0)))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (n <= -5.6e-14) {
tmp = t_0;
} else if (n <= -3.4e-196) {
tmp = 0.0;
} else if (n <= 1.8e-107) {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = -log(x) / n
if (n <= (-5.6d-14)) then
tmp = t_0
else if (n <= (-3.4d-196)) then
tmp = 0.0d0
else if (n <= 1.8d-107) then
tmp = ((1.0d0 + ((((1.0d0 / x) * 0.3333333333333333d0) - 0.5d0) / x)) / x) / n
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double tmp;
if (n <= -5.6e-14) {
tmp = t_0;
} else if (n <= -3.4e-196) {
tmp = 0.0;
} else if (n <= 1.8e-107) {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if n <= -5.6e-14: tmp = t_0 elif n <= -3.4e-196: tmp = 0.0 elif n <= 1.8e-107: tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (n <= -5.6e-14) tmp = t_0; elseif (n <= -3.4e-196) tmp = 0.0; elseif (n <= 1.8e-107) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (n <= -5.6e-14) tmp = t_0; elseif (n <= -3.4e-196) tmp = 0.0; elseif (n <= 1.8e-107) tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[n, -5.6e-14], t$95$0, If[LessEqual[n, -3.4e-196], 0.0, If[LessEqual[n, 1.8e-107], N[(N[(N[(1.0 + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;n \leq -5.6 \cdot 10^{-14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -3.4 \cdot 10^{-196}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 1.8 \cdot 10^{-107}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{1}{x} \cdot 0.3333333333333333 - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -5.6000000000000001e-14 or 1.79999999999999988e-107 < n Initial program 19.9%
Taylor expanded in x around 0 19.0%
*-rgt-identity19.0%
associate-*l/19.0%
associate-/l*19.1%
exp-to-pow19.1%
Simplified19.1%
Taylor expanded in n around inf 75.3%
associate-*r/75.3%
neg-mul-175.3%
Simplified75.3%
if -5.6000000000000001e-14 < n < -3.4e-196Initial program 100.0%
Taylor expanded in x around 0 39.5%
*-rgt-identity39.5%
associate-*l/39.5%
associate-/l*39.5%
exp-to-pow39.5%
Simplified39.5%
expm1-log1p-u100.0%
expm1-undefine100.0%
Applied egg-rr39.5%
expm1-define100.0%
Simplified39.5%
Taylor expanded in n around inf 63.1%
if -3.4e-196 < n < 1.79999999999999988e-107Initial program 60.7%
Taylor expanded in n around inf 22.4%
log1p-define22.4%
Simplified22.4%
Taylor expanded in x around -inf 64.1%
Final simplification70.0%
(FPCore (x n)
:precision binary64
(if (<= x 1.9e+18)
(/
(+
(/ 1.0 n)
(/ (+ (* 0.3333333333333333 (/ 1.0 (* n x))) (* 0.5 (/ -1.0 n))) x))
x)
0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.9e+18) {
tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.9d+18) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 * (1.0d0 / (n * x))) + (0.5d0 * ((-1.0d0) / n))) / x)) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.9e+18) {
tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.9e+18: tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.9e+18) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 * Float64(1.0 / Float64(n * x))) + Float64(0.5 * Float64(-1.0 / n))) / x)) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.9e+18) tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.9e+18], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9 \cdot 10^{+18}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} + 0.5 \cdot \frac{-1}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.9e18Initial program 36.7%
Taylor expanded in n around inf 53.2%
log1p-define53.2%
Simplified53.2%
Taylor expanded in x around -inf 33.7%
if 1.9e18 < x Initial program 83.0%
Taylor expanded in x around 0 3.3%
*-rgt-identity3.3%
associate-*l/3.3%
associate-/l*3.3%
exp-to-pow3.3%
Simplified3.3%
expm1-log1p-u83.0%
expm1-undefine83.0%
Applied egg-rr3.3%
expm1-define83.0%
Simplified3.3%
Taylor expanded in n around inf 83.0%
Final simplification42.4%
(FPCore (x n) :precision binary64 (if (<= x 2.15e+18) (/ (/ (+ 1.0 (/ (- (* (/ 1.0 x) 0.3333333333333333) 0.5) x)) x) n) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 2.15e+18) {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.15d+18) then
tmp = ((1.0d0 + ((((1.0d0 / x) * 0.3333333333333333d0) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.15e+18) {
tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.15e+18: tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 2.15e+18) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.15e+18) tmp = ((1.0 + ((((1.0 / x) * 0.3333333333333333) - 0.5) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.15e+18], N[(N[(N[(1.0 + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.15 \cdot 10^{+18}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{1}{x} \cdot 0.3333333333333333 - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.15e18Initial program 36.7%
Taylor expanded in n around inf 53.2%
log1p-define53.2%
Simplified53.2%
Taylor expanded in x around -inf 33.6%
if 2.15e18 < x Initial program 83.0%
Taylor expanded in x around 0 3.3%
*-rgt-identity3.3%
associate-*l/3.3%
associate-/l*3.3%
exp-to-pow3.3%
Simplified3.3%
expm1-log1p-u83.0%
expm1-undefine83.0%
Applied egg-rr3.3%
expm1-define83.0%
Simplified3.3%
Taylor expanded in n around inf 83.0%
Final simplification42.3%
(FPCore (x n) :precision binary64 (if (<= x 2.7e+18) (/ 1.0 (* n x)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 2.7e+18) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.7d+18) then
tmp = 1.0d0 / (n * x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.7e+18) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.7e+18: tmp = 1.0 / (n * x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 2.7e+18) tmp = Float64(1.0 / Float64(n * x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.7e+18) tmp = 1.0 / (n * x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.7e+18], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.7 \cdot 10^{+18}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.7e18Initial program 36.7%
Taylor expanded in x around inf 22.7%
mul-1-neg22.7%
log-rec22.7%
mul-1-neg22.7%
distribute-neg-frac22.7%
mul-1-neg22.7%
remove-double-neg22.7%
*-commutative22.7%
Simplified22.7%
Taylor expanded in n around inf 23.1%
if 2.7e18 < x Initial program 83.0%
Taylor expanded in x around 0 3.3%
*-rgt-identity3.3%
associate-*l/3.3%
associate-/l*3.3%
exp-to-pow3.3%
Simplified3.3%
expm1-log1p-u83.0%
expm1-undefine83.0%
Applied egg-rr3.3%
expm1-define83.0%
Simplified3.3%
Taylor expanded in n around inf 83.0%
Final simplification33.6%
(FPCore (x n) :precision binary64 (if (<= x 1.8e+18) (/ x n) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.8e+18) {
tmp = x / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.8d+18) then
tmp = x / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.8e+18) {
tmp = x / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.8e+18: tmp = x / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.8e+18) tmp = Float64(x / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.8e+18) tmp = x / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.8e+18], N[(x / n), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{+18}:\\
\;\;\;\;\frac{x}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.8e18Initial program 36.7%
Taylor expanded in n around inf 53.2%
log1p-define53.2%
Simplified53.2%
Taylor expanded in x around 0 52.5%
neg-mul-152.5%
+-commutative52.5%
unsub-neg52.5%
Simplified52.5%
Taylor expanded in x around inf 5.7%
if 1.8e18 < x Initial program 83.0%
Taylor expanded in x around 0 3.3%
*-rgt-identity3.3%
associate-*l/3.3%
associate-/l*3.3%
exp-to-pow3.3%
Simplified3.3%
expm1-log1p-u83.0%
expm1-undefine83.0%
Applied egg-rr3.3%
expm1-define83.0%
Simplified3.3%
Taylor expanded in n around inf 83.0%
Final simplification19.3%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 44.9%
Taylor expanded in x around 0 29.6%
*-rgt-identity29.6%
associate-*l/29.6%
associate-/l*29.6%
exp-to-pow29.6%
Simplified29.6%
expm1-log1p-u44.8%
expm1-undefine44.7%
Applied egg-rr29.5%
expm1-define44.8%
Simplified29.6%
Taylor expanded in n around inf 17.5%
Final simplification17.5%
herbie shell --seed 2024083
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))