
(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 19 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 (<= (/ 1.0 n) -5e-18)
(/ (cbrt (pow x (/ 3.0 n))) (* n x))
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(* 2.0 (log (sqrt (exp (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = cbrt(pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = 2.0 * log(sqrt(exp((exp((log1p(x) / n)) - pow(x, (1.0 / n))))));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = 2.0 * Math.log(Math.sqrt(Math.exp((Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n))))));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(2.0 * log(sqrt(exp(Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))))))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(2.0 * N[Log[N[Sqrt[N[Exp[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \log \left(\sqrt{e^{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
div-inv98.3%
pow-to-exp98.4%
add-cbrt-cube98.4%
pow1/398.3%
pow398.3%
pow-pow98.4%
Applied egg-rr98.4%
unpow1/398.4%
associate-*l/98.4%
metadata-eval98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 50.4%
add-log-exp50.3%
add-sqr-sqrt50.3%
log-prod50.5%
pow-to-exp50.5%
un-div-inv50.5%
+-commutative50.5%
log1p-define90.8%
Applied egg-rr96.0%
count-296.0%
Simplified96.0%
Final simplification98.6%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-18)
(/ (cbrt (pow x (/ 3.0 n))) (* n x))
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(pow
(pow (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))) 3.0)
0.3333333333333333))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = cbrt(pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = pow(pow((exp((log1p(x) / n)) - pow(x, (1.0 / n))), 3.0), 0.3333333333333333);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.pow(Math.pow((Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n))), 3.0), 0.3333333333333333);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = (Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))) ^ 3.0) ^ 0.3333333333333333; end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;{\left({\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\right)}^{3}\right)}^{0.3333333333333333}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
div-inv98.3%
pow-to-exp98.4%
add-cbrt-cube98.4%
pow1/398.3%
pow398.3%
pow-pow98.4%
Applied egg-rr98.4%
unpow1/398.4%
associate-*l/98.4%
metadata-eval98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 50.4%
add-cbrt-cube50.4%
pow1/350.4%
pow350.4%
pow-to-exp50.4%
un-div-inv50.4%
+-commutative50.4%
log1p-define95.8%
Applied egg-rr95.8%
Final simplification98.6%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-18)
(/ (cbrt (pow x (/ 3.0 n))) (* n x))
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(exp (log (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = cbrt(pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = exp(log((exp((log1p(x) / n)) - pow(x, (1.0 / n)))));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.exp(Math.log((Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n)))));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = exp(log(Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Exp[N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
div-inv98.3%
pow-to-exp98.4%
add-cbrt-cube98.4%
pow1/398.3%
pow398.3%
pow-pow98.4%
Applied egg-rr98.4%
unpow1/398.4%
associate-*l/98.4%
metadata-eval98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 50.4%
add-exp-log50.4%
pow-to-exp50.4%
un-div-inv50.4%
+-commutative50.4%
log1p-define95.8%
Applied egg-rr95.8%
Final simplification98.6%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-18)
(/ (cbrt (pow x (/ 3.0 n))) (* n x))
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = cbrt(pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
div-inv98.3%
pow-to-exp98.4%
add-cbrt-cube98.4%
pow1/398.3%
pow398.3%
pow-pow98.4%
Applied egg-rr98.4%
unpow1/398.4%
associate-*l/98.4%
metadata-eval98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 50.4%
Taylor expanded in n around 0 50.4%
log1p-define95.8%
*-rgt-identity95.8%
associate-/l*95.8%
exp-to-pow95.8%
Simplified95.8%
Final simplification98.6%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-18)
(/ (cbrt (pow x (/ 3.0 n))) (* n x))
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n)))))))
(pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = cbrt(pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - Math.pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / 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(0.5 * Float64(-1.0 / n))))))) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / 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[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
div-inv98.3%
pow-to-exp98.4%
add-cbrt-cube98.4%
pow1/398.3%
pow398.3%
pow-pow98.4%
Applied egg-rr98.4%
unpow1/398.4%
associate-*l/98.4%
metadata-eval98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 50.4%
Taylor expanded in x around 0 79.1%
Final simplification96.7%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-18)
(/ (cbrt (pow x (/ 3.0 n))) (* n x))
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 1e+188)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(- (/ x n) (/ (log1p (+ x -1.0)) n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = cbrt(pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else {
tmp = (x / n) - (log1p((x + -1.0)) / n);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = (x / n) - (Math.log1p((x + -1.0)) / n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 1e+188) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(x / n) - Float64(log1p(Float64(x + -1.0)) / n)); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(x / n), $MachinePrecision] - N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{n} - \frac{\mathsf{log1p}\left(x + -1\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
div-inv98.3%
pow-to-exp98.4%
add-cbrt-cube98.4%
pow1/398.3%
pow398.3%
pow-pow98.4%
Applied egg-rr98.4%
unpow1/398.4%
associate-*l/98.4%
metadata-eval98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 78.0%
Taylor expanded in x around 0 80.9%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 11.2%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
Taylor expanded in x around 0 16.0%
+-commutative16.0%
mul-1-neg16.0%
unsub-neg16.0%
Simplified16.0%
log1p-expm1-u91.9%
expm1-undefine91.9%
add-exp-log91.9%
Applied egg-rr91.9%
Final simplification97.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-18)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 1e+188)
(- (+ 1.0 (/ x n)) t_0)
(- (/ x n) (/ (log1p (+ x -1.0)) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (x / n) - (log1p((x + -1.0)) / 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) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (x / n) - (Math.log1p((x + -1.0)) / n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-18: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-9: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 1e+188: tmp = (1.0 + (x / n)) - t_0 else: tmp = (x / n) - (math.log1p((x + -1.0)) / n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 1e+188) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(x / n) - Float64(log1p(Float64(x + -1.0)) / 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], -5e-18], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(x / n), $MachinePrecision] - N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{n} - \frac{\mathsf{log1p}\left(x + -1\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 98.4%
associate-/r*98.4%
*-lft-identity98.4%
associate-*l/98.4%
*-commutative98.4%
exp-to-pow98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 78.0%
Taylor expanded in x around 0 80.9%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 11.2%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
Taylor expanded in x around 0 16.0%
+-commutative16.0%
mul-1-neg16.0%
unsub-neg16.0%
Simplified16.0%
log1p-expm1-u91.9%
expm1-undefine91.9%
add-exp-log91.9%
Applied egg-rr91.9%
Final simplification97.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-18)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 1e+188)
(- 1.0 t_0)
(- (/ x n) (/ (log1p (+ x -1.0)) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = 1.0 - t_0;
} else {
tmp = (x / n) - (log1p((x + -1.0)) / 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) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = 1.0 - t_0;
} else {
tmp = (x / n) - (Math.log1p((x + -1.0)) / n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-18: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-9: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 1e+188: tmp = 1.0 - t_0 else: tmp = (x / n) - (math.log1p((x + -1.0)) / n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 1e+188) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(x / n) - Float64(log1p(Float64(x + -1.0)) / 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], -5e-18], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(x / n), $MachinePrecision] - N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{n} - \frac{\mathsf{log1p}\left(x + -1\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 98.4%
associate-/r*98.4%
*-lft-identity98.4%
associate-*l/98.4%
*-commutative98.4%
exp-to-pow98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 78.0%
Taylor expanded in x around 0 76.8%
*-rgt-identity76.8%
associate-/l*76.8%
exp-to-pow76.8%
Simplified76.8%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 11.2%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
Taylor expanded in x around 0 16.0%
+-commutative16.0%
mul-1-neg16.0%
unsub-neg16.0%
Simplified16.0%
log1p-expm1-u91.9%
expm1-undefine91.9%
add-exp-log91.9%
Applied egg-rr91.9%
Final simplification97.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-18)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 1e+188)
(- 1.0 t_0)
(/ (/ (+ 1.0 (/ (+ (/ 0.3333333333333333 x) -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) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / 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) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 + (((0.3333333333333333 / x) + -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) <= -5e-18: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-9: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 1e+188: tmp = 1.0 - t_0 else: tmp = ((1.0 + (((0.3333333333333333 / x) + -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) <= -5e-18) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 1e+188) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) + -0.5) / x)) / 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], -5e-18], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $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 -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 93.8%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
log-rec98.4%
mul-1-neg98.4%
distribute-neg-frac98.4%
mul-1-neg98.4%
remove-double-neg98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 98.4%
associate-/r*98.4%
*-lft-identity98.4%
associate-*l/98.4%
*-commutative98.4%
exp-to-pow98.4%
Simplified98.4%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.7%
Taylor expanded in n around inf 79.3%
log1p-define79.3%
Simplified79.3%
log1p-undefine79.3%
diff-log79.6%
Applied egg-rr79.6%
log-div79.3%
log1p-undefine79.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
log1p-undefine79.3%
log-div79.6%
add-exp-log79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*l/77.4%
distribute-lft-in77.4%
*-rgt-identity77.4%
lft-mult-inverse79.6%
associate--l+99.1%
metadata-eval99.1%
Simplified99.1%
if 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 78.0%
Taylor expanded in x around 0 76.8%
*-rgt-identity76.8%
associate-/l*76.8%
exp-to-pow76.8%
Simplified76.8%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 11.2%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
log1p-undefine16.0%
diff-log16.0%
Applied egg-rr16.0%
Taylor expanded in x around inf 84.8%
associate--l+84.8%
unpow284.8%
associate-/r*84.8%
metadata-eval84.8%
associate-*r/84.8%
associate-*r/84.8%
metadata-eval84.8%
div-sub84.8%
sub-neg84.8%
associate-*r/84.8%
metadata-eval84.8%
metadata-eval84.8%
Simplified84.8%
Final simplification96.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -0.02)
t_0
(if (<= (/ 1.0 n) 2e-9)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 1e+188)
t_0
(/ (/ (+ 1.0 (/ (+ (/ 0.3333333333333333 x) -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) <= -0.02) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-9) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = t_0;
} else {
tmp = ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / x) / n;
}
return tmp;
}
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) <= -0.02) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = t_0;
} else {
tmp = ((1.0 + (((0.3333333333333333 / x) + -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) <= -0.02: tmp = t_0 elif (1.0 / n) <= 2e-9: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 1e+188: tmp = t_0 else: tmp = ((1.0 + (((0.3333333333333333 / x) + -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) <= -0.02) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 1e+188) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) + -0.5) / x)) / x) / n); end return 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], -0.02], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], t$95$0, N[(N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $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 -0.02:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.0200000000000000004 or 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 93.8%
Taylor expanded in x around 0 61.6%
*-rgt-identity61.6%
associate-/l*61.6%
exp-to-pow61.6%
Simplified61.6%
if -0.0200000000000000004 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 31.2%
Taylor expanded in n around inf 78.0%
log1p-define78.0%
Simplified78.0%
log1p-undefine78.0%
diff-log78.3%
Applied egg-rr78.3%
log-div78.0%
log1p-undefine78.0%
log1p-expm1-u78.0%
expm1-undefine78.0%
log1p-undefine78.0%
log-div78.3%
add-exp-log78.3%
Applied egg-rr78.3%
*-lft-identity78.3%
associate-*l/76.1%
distribute-lft-in76.1%
*-rgt-identity76.1%
lft-mult-inverse78.3%
associate--l+98.5%
metadata-eval98.5%
Simplified98.5%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 11.2%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
log1p-undefine16.0%
diff-log16.0%
Applied egg-rr16.0%
Taylor expanded in x around inf 84.8%
associate--l+84.8%
unpow284.8%
associate-/r*84.8%
metadata-eval84.8%
associate-*r/84.8%
associate-*r/84.8%
metadata-eval84.8%
div-sub84.8%
sub-neg84.8%
associate-*r/84.8%
metadata-eval84.8%
metadata-eval84.8%
Simplified84.8%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -1e+198)
t_0
(if (<= (/ 1.0 n) 2e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+188)
t_0
(/ (/ (+ 1.0 (/ (+ (/ 0.3333333333333333 x) -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) <= -1e+198) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = t_0;
} else {
tmp = ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-1d+198)) then
tmp = t_0
else if ((1.0d0 / n) <= 2d-9) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d+188) then
tmp = t_0
else
tmp = ((1.0d0 + (((0.3333333333333333d0 / x) + (-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) <= -1e+198) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = t_0;
} else {
tmp = ((1.0 + (((0.3333333333333333 / x) + -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) <= -1e+198: tmp = t_0 elif (1.0 / n) <= 2e-9: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+188: tmp = t_0 else: tmp = ((1.0 + (((0.3333333333333333 / x) + -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) <= -1e+198) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+188) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) + -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) <= -1e+198) tmp = t_0; elseif ((1.0 / n) <= 2e-9) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e+188) tmp = t_0; else tmp = ((1.0 + (((0.3333333333333333 / x) + -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], -1e+198], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], t$95$0, N[(N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $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 -1 \cdot 10^{+198}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.00000000000000002e198 or 2.00000000000000012e-9 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 91.1%
Taylor expanded in x around 0 74.5%
*-rgt-identity74.5%
associate-/l*74.5%
exp-to-pow74.5%
Simplified74.5%
if -1.00000000000000002e198 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000012e-9Initial program 42.3%
Taylor expanded in n around inf 74.1%
log1p-define74.1%
Simplified74.1%
log1p-undefine74.1%
diff-log74.4%
Applied egg-rr74.4%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 11.2%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
log1p-undefine16.0%
diff-log16.0%
Applied egg-rr16.0%
Taylor expanded in x around inf 84.8%
associate--l+84.8%
unpow284.8%
associate-/r*84.8%
metadata-eval84.8%
associate-*r/84.8%
associate-*r/84.8%
metadata-eval84.8%
div-sub84.8%
sub-neg84.8%
associate-*r/84.8%
metadata-eval84.8%
metadata-eval84.8%
Simplified84.8%
(FPCore (x n)
:precision binary64
(if (<= x 0.9)
(/ (- x (log x)) n)
(if (<= x 3.3e+152)
(/
(/
(+ 1.0 (/ (- (/ (- 0.3333333333333333 (* (/ 1.0 x) 0.25)) x) 0.5) x))
x)
n)
(/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else if (x <= 3.3e+152) {
tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else if (x <= 3.3d+152) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - ((1.0d0 / x) * 0.25d0)) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 3.3e+152) {
tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.9: tmp = (x - math.log(x)) / n elif x <= 3.3e+152: tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 3.3e+152) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(Float64(1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.9) tmp = (x - log(x)) / n; elseif (x <= 3.3e+152) tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3.3e+152], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(N[(1.0 / x), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+152}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - \frac{1}{x} \cdot 0.25}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 0.900000000000000022Initial program 37.3%
Taylor expanded in n around inf 60.5%
log1p-define60.5%
Simplified60.5%
Taylor expanded in x around 0 59.5%
if 0.900000000000000022 < x < 3.3000000000000001e152Initial program 36.6%
Taylor expanded in n around inf 45.1%
log1p-define45.1%
Simplified45.1%
Taylor expanded in x around -inf 76.6%
if 3.3000000000000001e152 < x Initial program 92.8%
Taylor expanded in n around inf 92.8%
log1p-define92.8%
Simplified92.8%
log1p-undefine92.8%
diff-log92.8%
Applied egg-rr92.8%
Taylor expanded in x around inf 92.8%
Final simplification70.7%
(FPCore (x n)
:precision binary64
(if (<= x 0.7)
(- (/ (log x) n))
(if (<= x 2.6e+153)
(/
(/
(+ 1.0 (/ (- (/ (- 0.3333333333333333 (* (/ 1.0 x) 0.25)) x) 0.5) x))
x)
n)
(/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = -(log(x) / n);
} else if (x <= 2.6e+153) {
tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.7d0) then
tmp = -(log(x) / n)
else if (x <= 2.6d+153) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - ((1.0d0 / x) * 0.25d0)) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = -(Math.log(x) / n);
} else if (x <= 2.6e+153) {
tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.7: tmp = -(math.log(x) / n) elif x <= 2.6e+153: tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.7) tmp = Float64(-Float64(log(x) / n)); elseif (x <= 2.6e+153) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(Float64(1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.7) tmp = -(log(x) / n); elseif (x <= 2.6e+153) tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.7], (-N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), If[LessEqual[x, 2.6e+153], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(N[(1.0 / x), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;-\frac{\log x}{n}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - \frac{1}{x} \cdot 0.25}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial program 37.6%
Taylor expanded in x around 0 37.4%
*-rgt-identity37.4%
associate-/l*37.4%
exp-to-pow37.4%
Simplified37.4%
Taylor expanded in n around inf 58.7%
associate-*r/58.7%
neg-mul-158.7%
Simplified58.7%
if 0.69999999999999996 < x < 2.5999999999999999e153Initial program 36.0%
Taylor expanded in n around inf 45.9%
log1p-define45.9%
Simplified45.9%
Taylor expanded in x around -inf 75.7%
if 2.5999999999999999e153 < x Initial program 92.8%
Taylor expanded in n around inf 92.8%
log1p-define92.8%
Simplified92.8%
log1p-undefine92.8%
diff-log92.8%
Applied egg-rr92.8%
Taylor expanded in x around inf 92.8%
Final simplification70.1%
(FPCore (x n) :precision binary64 (if (<= x 2.5e+153) (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x) (/ 0.0 n)))
double code(double x, double n) {
double tmp;
if (x <= 2.5e+153) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.5d+153) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.5e+153) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.5e+153: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 2.5e+153) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.5e+153) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.5e+153], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.50000000000000009e153Initial program 37.1%
Taylor expanded in n around inf 55.7%
log1p-define55.7%
Simplified55.7%
log1p-undefine55.7%
diff-log55.9%
Applied egg-rr55.9%
Taylor expanded in x around inf 30.6%
Simplified44.0%
if 2.50000000000000009e153 < x Initial program 92.8%
Taylor expanded in n around inf 92.8%
log1p-define92.8%
Simplified92.8%
log1p-undefine92.8%
diff-log92.8%
Applied egg-rr92.8%
Taylor expanded in x around inf 92.8%
Final simplification54.3%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}
\end{array}
Initial program 48.8%
Taylor expanded in n around inf 63.5%
log1p-define63.5%
Simplified63.5%
log1p-undefine63.5%
diff-log63.7%
Applied egg-rr63.7%
Taylor expanded in x around inf 39.5%
Simplified50.1%
Final simplification50.1%
(FPCore (x n) :precision binary64 (/ (/ (+ 1.0 (/ (+ (/ 0.3333333333333333 x) -0.5) x)) x) n))
double code(double x, double n) {
return ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 + (((0.3333333333333333d0 / x) + (-0.5d0)) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / x) / n;
}
def code(x, n): return ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) + -0.5) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + -0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 + \frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x}}{n}
\end{array}
Initial program 48.8%
Taylor expanded in n around inf 63.5%
log1p-define63.5%
Simplified63.5%
log1p-undefine63.5%
diff-log63.7%
Applied egg-rr63.7%
Taylor expanded in x around inf 50.1%
associate--l+50.1%
unpow250.1%
associate-/r*50.1%
metadata-eval50.1%
associate-*r/50.1%
associate-*r/50.1%
metadata-eval50.1%
div-sub50.1%
sub-neg50.1%
associate-*r/50.1%
metadata-eval50.1%
metadata-eval50.1%
Simplified50.1%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 48.8%
Taylor expanded in n around inf 63.5%
log1p-define63.5%
Simplified63.5%
Taylor expanded in x around inf 46.1%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 48.8%
Taylor expanded in x around inf 58.2%
mul-1-neg58.2%
log-rec58.2%
mul-1-neg58.2%
distribute-neg-frac58.2%
mul-1-neg58.2%
remove-double-neg58.2%
*-commutative58.2%
Simplified58.2%
Taylor expanded in n around inf 45.9%
*-commutative45.9%
Simplified45.9%
Final simplification45.9%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 48.8%
Taylor expanded in n around inf 63.5%
log1p-define63.5%
Simplified63.5%
Taylor expanded in x around 0 34.2%
+-commutative34.2%
mul-1-neg34.2%
unsub-neg34.2%
Simplified34.2%
Taylor expanded in x around inf 5.1%
herbie shell --seed 2024132
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))