
(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 20 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) -1e-173)
(/ (pow x (- -1.0 (/ -1.0 n))) n)
(if (<= (/ 1.0 n) 5e-15)
(/ (log (/ (+ x 1.0) x)) n)
(pow (cbrt (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))) 3.0))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-15) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = pow(cbrt((exp((log1p(x) / n)) - pow(x, (1.0 / n)))), 3.0);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-15) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.pow(Math.cbrt((Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n)))), 3.0);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-173) tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); elseif (Float64(1.0 / n) <= 5e-15) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = cbrt(Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n)))) ^ 3.0; end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-15], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / 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], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-173}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{3}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-173Initial program 72.1%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
log-rec85.8%
mul-1-neg85.8%
distribute-neg-frac85.8%
mul-1-neg85.8%
remove-double-neg85.8%
*-commutative85.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
*-lft-identity86.7%
sub-neg86.7%
metadata-eval86.7%
Simplified86.7%
if -1e-173 < (/.f64 1 n) < 4.99999999999999999e-15Initial program 39.5%
Taylor expanded in n around inf 86.2%
log1p-define86.2%
Simplified86.2%
log1p-undefine86.2%
diff-log86.4%
Applied egg-rr86.4%
+-commutative86.4%
Simplified86.4%
if 4.99999999999999999e-15 < (/.f64 1 n) Initial program 48.3%
add-cube-cbrt48.3%
pow348.3%
pow-to-exp48.3%
un-div-inv48.3%
+-commutative48.3%
log1p-define96.3%
Applied egg-rr96.3%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(if (<= x 0.052)
(/
(-
(+
(log1p x)
(/
(-
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0)))
(/
(* 0.16666666666666666 (- (pow (log x) 3.0) (pow (log1p x) 3.0)))
n))
n))
(log x))
n)
(/ (pow x (- -1.0 (/ -1.0 n))) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.052) {
tmp = ((log1p(x) + (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) - ((0.16666666666666666 * (pow(log(x), 3.0) - pow(log1p(x), 3.0))) / n)) / n)) - log(x)) / n;
} else {
tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 0.052) {
tmp = ((Math.log1p(x) + (((0.5 * (Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0))) - ((0.16666666666666666 * (Math.pow(Math.log(x), 3.0) - Math.pow(Math.log1p(x), 3.0))) / n)) / n)) - Math.log(x)) / n;
} else {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.052: tmp = ((math.log1p(x) + (((0.5 * (math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0))) - ((0.16666666666666666 * (math.pow(math.log(x), 3.0) - math.pow(math.log1p(x), 3.0))) / n)) / n)) - math.log(x)) / n else: tmp = math.pow(x, (-1.0 - (-1.0 / n))) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.052) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) - Float64(Float64(0.16666666666666666 * Float64((log(x) ^ 3.0) - (log1p(x) ^ 3.0))) / n)) / n)) - log(x)) / n); else tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); end return tmp end
code[x_, n_] := If[LessEqual[x, 0.052], 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[(N[(0.16666666666666666 * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.052:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) - \frac{0.16666666666666666 \cdot \left({\log x}^{3} - {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right)}{n}}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\end{array}
\end{array}
if x < 0.0519999999999999976Initial program 45.2%
Taylor expanded in n around -inf 76.7%
Simplified76.7%
if 0.0519999999999999976 < x Initial program 70.5%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
log-rec96.6%
mul-1-neg96.6%
distribute-neg-frac96.6%
mul-1-neg96.6%
remove-double-neg96.6%
*-commutative96.6%
Simplified96.6%
*-un-lft-identity96.6%
associate-/r*98.6%
div-inv98.6%
pow-to-exp98.6%
pow198.6%
pow-div98.4%
Applied egg-rr98.4%
*-lft-identity98.4%
sub-neg98.4%
metadata-eval98.4%
Simplified98.4%
Final simplification87.0%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-173)
(/ (pow x (- -1.0 (/ -1.0 n))) n)
(if (<= (/ 1.0 n) 5e-15)
(/ (log (/ (+ x 1.0) x)) n)
(cbrt (pow (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))) 3.0)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-15) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = cbrt(pow((exp((log1p(x) / n)) - pow(x, (1.0 / n))), 3.0));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-15) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.cbrt(Math.pow((Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n))), 3.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-173) tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); elseif (Float64(1.0 / n) <= 5e-15) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = cbrt((Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))) ^ 3.0)); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-15], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / 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], 1/3], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-173}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\right)}^{3}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-173Initial program 72.1%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
log-rec85.8%
mul-1-neg85.8%
distribute-neg-frac85.8%
mul-1-neg85.8%
remove-double-neg85.8%
*-commutative85.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
*-lft-identity86.7%
sub-neg86.7%
metadata-eval86.7%
Simplified86.7%
if -1e-173 < (/.f64 1 n) < 4.99999999999999999e-15Initial program 39.5%
Taylor expanded in n around inf 86.2%
log1p-define86.2%
Simplified86.2%
log1p-undefine86.2%
diff-log86.4%
Applied egg-rr86.4%
+-commutative86.4%
Simplified86.4%
if 4.99999999999999999e-15 < (/.f64 1 n) Initial program 48.3%
add-cbrt-cube48.3%
pow348.3%
pow-to-exp48.3%
un-div-inv48.3%
+-commutative48.3%
log1p-define96.3%
Applied egg-rr96.3%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(if (<= x 0.025)
(/
(-
(/
(+
(* -0.16666666666666666 (/ (pow (log x) 3.0) n))
(* (pow (log x) 2.0) -0.5))
n)
(log x))
n)
(/ (pow x (- -1.0 (/ -1.0 n))) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.025) {
tmp = ((((-0.16666666666666666 * (pow(log(x), 3.0) / n)) + (pow(log(x), 2.0) * -0.5)) / n) - log(x)) / n;
} else {
tmp = pow(x, (-1.0 - (-1.0 / n))) / 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.025d0) then
tmp = (((((-0.16666666666666666d0) * ((log(x) ** 3.0d0) / n)) + ((log(x) ** 2.0d0) * (-0.5d0))) / n) - log(x)) / n
else
tmp = (x ** ((-1.0d0) - ((-1.0d0) / n))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.025) {
tmp = ((((-0.16666666666666666 * (Math.pow(Math.log(x), 3.0) / n)) + (Math.pow(Math.log(x), 2.0) * -0.5)) / n) - Math.log(x)) / n;
} else {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.025: tmp = ((((-0.16666666666666666 * (math.pow(math.log(x), 3.0) / n)) + (math.pow(math.log(x), 2.0) * -0.5)) / n) - math.log(x)) / n else: tmp = math.pow(x, (-1.0 - (-1.0 / n))) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.025) tmp = Float64(Float64(Float64(Float64(Float64(-0.16666666666666666 * Float64((log(x) ^ 3.0) / n)) + Float64((log(x) ^ 2.0) * -0.5)) / n) - log(x)) / n); else tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.025) tmp = ((((-0.16666666666666666 * ((log(x) ^ 3.0) / n)) + ((log(x) ^ 2.0) * -0.5)) / n) - log(x)) / n; else tmp = (x ^ (-1.0 - (-1.0 / n))) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.025], N[(N[(N[(N[(N[(-0.16666666666666666 * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.025:\\
\;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\end{array}
\end{array}
if x < 0.025000000000000001Initial program 45.2%
Taylor expanded in x around 0 44.4%
Taylor expanded in n around -inf 75.5%
mul-1-neg75.5%
Simplified75.5%
if 0.025000000000000001 < x Initial program 70.5%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
log-rec96.6%
mul-1-neg96.6%
distribute-neg-frac96.6%
mul-1-neg96.6%
remove-double-neg96.6%
*-commutative96.6%
Simplified96.6%
*-un-lft-identity96.6%
associate-/r*98.6%
div-inv98.6%
pow-to-exp98.6%
pow198.6%
pow-div98.4%
Applied egg-rr98.4%
*-lft-identity98.4%
sub-neg98.4%
metadata-eval98.4%
Simplified98.4%
Final simplification86.3%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-173)
(/ (pow x (- -1.0 (/ -1.0 n))) n)
(if (<= (/ 1.0 n) 5e-15)
(/ (log (/ (+ x 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) <= -1e-173) {
tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-15) {
tmp = log(((x + 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) <= -1e-173) {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-15) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1e-173: tmp = math.pow(x, (-1.0 - (-1.0 / n))) / n elif (1.0 / n) <= 5e-15: tmp = math.log(((x + 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) <= -1e-173) tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); elseif (Float64(1.0 / n) <= 5e-15) tmp = Float64(log(Float64(Float64(x + 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], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-15], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / 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 -1 \cdot 10^{-173}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{x + 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 1 n) < -1e-173Initial program 72.1%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
log-rec85.8%
mul-1-neg85.8%
distribute-neg-frac85.8%
mul-1-neg85.8%
remove-double-neg85.8%
*-commutative85.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
*-lft-identity86.7%
sub-neg86.7%
metadata-eval86.7%
Simplified86.7%
if -1e-173 < (/.f64 1 n) < 4.99999999999999999e-15Initial program 39.5%
Taylor expanded in n around inf 86.2%
log1p-define86.2%
Simplified86.2%
log1p-undefine86.2%
diff-log86.4%
Applied egg-rr86.4%
+-commutative86.4%
Simplified86.4%
if 4.99999999999999999e-15 < (/.f64 1 n) Initial program 48.3%
Taylor expanded in n around 0 48.3%
log1p-define96.3%
Simplified96.3%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-173)
(/ (pow x (- -1.0 (/ -1.0 n))) n)
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+130)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(log1p (expm1 (/ 1.0 (* x n))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+130) {
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 tmp;
if ((1.0 / n) <= -1e-173) {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+130) {
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): tmp = 0 if (1.0 / n) <= -1e-173: tmp = math.pow(x, (-1.0 - (-1.0 / n))) / n elif (1.0 / n) <= 5e-13: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+130: 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) tmp = 0.0 if (Float64(1.0 / n) <= -1e-173) tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+130) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = log1p(expm1(Float64(1.0 / Float64(x * n)))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+130], 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[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-173}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+130}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-173Initial program 72.1%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
log-rec85.8%
mul-1-neg85.8%
distribute-neg-frac85.8%
mul-1-neg85.8%
remove-double-neg85.8%
*-commutative85.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
*-lft-identity86.7%
sub-neg86.7%
metadata-eval86.7%
Simplified86.7%
if -1e-173 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 39.2%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.5%
Applied egg-rr85.5%
+-commutative85.5%
Simplified85.5%
if 4.9999999999999999e-13 < (/.f64 1 n) < 2.0000000000000001e130Initial program 75.1%
Taylor expanded in x around 0 75.2%
if 2.0000000000000001e130 < (/.f64 1 n) Initial program 22.5%
Taylor expanded in x around inf 0.8%
mul-1-neg0.8%
log-rec0.8%
mul-1-neg0.8%
distribute-neg-frac0.8%
mul-1-neg0.8%
remove-double-neg0.8%
*-commutative0.8%
Simplified0.8%
Taylor expanded in n around inf 50.1%
*-commutative50.1%
Simplified50.1%
log1p-expm1-u87.1%
Applied egg-rr87.1%
Final simplification85.5%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-173)
(/ (pow x (- -1.0 (/ -1.0 n))) n)
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ x n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-1d-173)) then
tmp = (x ** ((-1.0d0) - ((-1.0d0) / n))) / n
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = exp((x / n)) - (x ** (1.0d0 / n))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1e-173: tmp = math.pow(x, (-1.0 - (-1.0 / n))) / n elif (1.0 / n) <= 5e-13: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-173) tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -1e-173) tmp = (x ^ (-1.0 - (-1.0 / n))) / n; elseif ((1.0 / n) <= 5e-13) tmp = log(((x + 1.0) / x)) / n; else tmp = exp((x / n)) - (x ^ (1.0 / n)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / 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 -1 \cdot 10^{-173}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-173Initial program 72.1%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
log-rec85.8%
mul-1-neg85.8%
distribute-neg-frac85.8%
mul-1-neg85.8%
remove-double-neg85.8%
*-commutative85.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
*-lft-identity86.7%
sub-neg86.7%
metadata-eval86.7%
Simplified86.7%
if -1e-173 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 39.2%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.5%
Applied egg-rr85.5%
+-commutative85.5%
Simplified85.5%
if 4.9999999999999999e-13 < (/.f64 1 n) Initial program 49.6%
Taylor expanded in n around 0 49.6%
log1p-define99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- x (log x)) n)))
(if (<= (/ 1.0 n) -5.0)
(/ 0.2 (* n (pow x 5.0)))
(if (<= (/ 1.0 n) -1e-179)
(/
(/
(+
1.0
(/
(- (+ (/ 0.3333333333333333 x) (/ (/ (+ (/ 0.2 x) -0.25) x) x)) 0.5)
x))
x)
n)
(if (<= (/ 1.0 n) -1e-221)
t_0
(if (<= (/ 1.0 n) 5e-208)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e-15)
t_0
(if (<= (/ 1.0 n) 2e+130)
(- 1.0 (pow x (/ 1.0 n)))
(/
(+
1.0
(/
(-
(/ (- 0.3333333333333333 (/ (+ 0.25 (/ -0.2 x)) x)) x)
0.5)
x))
(* x n))))))))))
double code(double x, double n) {
double t_0 = (x - log(x)) / n;
double tmp;
if ((1.0 / n) <= -5.0) {
tmp = 0.2 / (n * pow(x, 5.0));
} else if ((1.0 / n) <= -1e-179) {
tmp = ((1.0 + ((((0.3333333333333333 / x) + ((((0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n;
} else if ((1.0 / n) <= -1e-221) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-208) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-15) {
tmp = t_0;
} else if ((1.0 / n) <= 2e+130) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (x - log(x)) / n
if ((1.0d0 / n) <= (-5.0d0)) then
tmp = 0.2d0 / (n * (x ** 5.0d0))
else if ((1.0d0 / n) <= (-1d-179)) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 / x) + ((((0.2d0 / x) + (-0.25d0)) / x) / x)) - 0.5d0) / x)) / x) / n
else if ((1.0d0 / n) <= (-1d-221)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d-208) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 5d-15) then
tmp = t_0
else if ((1.0d0 / n) <= 2d+130) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = (1.0d0 + ((((0.3333333333333333d0 - ((0.25d0 + ((-0.2d0) / x)) / x)) / x) - 0.5d0) / x)) / (x * n)
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 ((1.0 / n) <= -5.0) {
tmp = 0.2 / (n * Math.pow(x, 5.0));
} else if ((1.0 / n) <= -1e-179) {
tmp = ((1.0 + ((((0.3333333333333333 / x) + ((((0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n;
} else if ((1.0 / n) <= -1e-221) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-208) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-15) {
tmp = t_0;
} else if ((1.0 / n) <= 2e+130) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n);
}
return tmp;
}
def code(x, n): t_0 = (x - math.log(x)) / n tmp = 0 if (1.0 / n) <= -5.0: tmp = 0.2 / (n * math.pow(x, 5.0)) elif (1.0 / n) <= -1e-179: tmp = ((1.0 + ((((0.3333333333333333 / x) + ((((0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n elif (1.0 / n) <= -1e-221: tmp = t_0 elif (1.0 / n) <= 5e-208: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e-15: tmp = t_0 elif (1.0 / n) <= 2e+130: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n) return tmp
function code(x, n) t_0 = Float64(Float64(x - log(x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5.0) tmp = Float64(0.2 / Float64(n * (x ^ 5.0))); elseif (Float64(1.0 / n) <= -1e-179) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 / x) + Float64(Float64(Float64(Float64(0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n); elseif (Float64(1.0 / n) <= -1e-221) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-208) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e-15) tmp = t_0; elseif (Float64(1.0 / n) <= 2e+130) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(Float64(0.25 + Float64(-0.2 / x)) / x)) / x) - 0.5) / x)) / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = (x - log(x)) / n; tmp = 0.0; if ((1.0 / n) <= -5.0) tmp = 0.2 / (n * (x ^ 5.0)); elseif ((1.0 / n) <= -1e-179) tmp = ((1.0 + ((((0.3333333333333333 / x) + ((((0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n; elseif ((1.0 / n) <= -1e-221) tmp = t_0; elseif ((1.0 / n) <= 5e-208) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 5e-15) tmp = t_0; elseif ((1.0 / n) <= 2e+130) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n); 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[(1.0 / n), $MachinePrecision], -5.0], N[(0.2 / N[(n * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-179], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + N[(N[(N[(N[(0.2 / x), $MachinePrecision] + -0.25), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-221], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-208], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-15], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+130], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(N[(0.25 + N[(-0.2 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5:\\
\;\;\;\;\frac{0.2}{n \cdot {x}^{5}}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-179}:\\
\;\;\;\;\frac{\frac{1 + \frac{\left(\frac{0.3333333333333333}{x} + \frac{\frac{\frac{0.2}{x} + -0.25}{x}}{x}\right) - 0.5}{x}}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-221}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-208}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+130}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333 - \frac{0.25 + \frac{-0.2}{x}}{x}}{x} - 0.5}{x}}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5Initial program 100.0%
Taylor expanded in n around inf 50.7%
log1p-define50.7%
Simplified50.7%
Taylor expanded in x around -inf 42.0%
Taylor expanded in x around 0 79.5%
*-commutative79.5%
Simplified79.5%
if -5 < (/.f64 1 n) < -1e-179Initial program 23.9%
Taylor expanded in n around inf 53.6%
log1p-define53.6%
Simplified53.6%
Taylor expanded in x around -inf 60.4%
div-sub60.4%
mul-1-neg60.4%
sub-neg60.4%
un-div-inv60.4%
metadata-eval60.4%
Applied egg-rr60.4%
if -1e-179 < (/.f64 1 n) < -1.00000000000000002e-221 or 4.99999999999999963e-208 < (/.f64 1 n) < 4.99999999999999999e-15Initial program 20.0%
Taylor expanded in n around inf 79.6%
log1p-define79.6%
Simplified79.6%
Taylor expanded in x around 0 63.3%
if -1.00000000000000002e-221 < (/.f64 1 n) < 4.99999999999999963e-208Initial program 59.3%
Taylor expanded in n around inf 92.5%
log1p-define92.5%
Simplified92.5%
Taylor expanded in x around inf 65.9%
if 4.99999999999999999e-15 < (/.f64 1 n) < 2.0000000000000001e130Initial program 71.0%
Taylor expanded in x around 0 70.8%
if 2.0000000000000001e130 < (/.f64 1 n) Initial program 22.5%
Taylor expanded in n around inf 6.1%
log1p-define6.1%
Simplified6.1%
Taylor expanded in x around -inf 80.9%
Taylor expanded in n around 0 80.9%
Simplified80.9%
Final simplification70.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (- (/ (log x) n))))
(if (<= x 4.5e-302)
t_0
(if (<= x 4.5e-209)
t_1
(if (<= x 8.5e-164)
t_0
(if (<= x 1.65e-107)
t_1
(if (<= x 2.6e-68)
(/
(+
(/ 1.0 n)
(/
(-
(/
(+
(/ (- (/ 0.2 (* x n)) (/ 0.25 n)) x)
(/ 0.3333333333333333 n))
x)
(/ 0.5 n))
x))
x)
(if (<= x 0.86)
(/ (- x (log x)) n)
(/
(/
(+
1.0
(/
(-
(/
(+
0.3333333333333333
(/
(-
(/ (+ 0.2 (* 0.16666666666666666 (/ -1.0 x))) x)
0.25)
x))
x)
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(x) / n);
double tmp;
if (x <= 4.5e-302) {
tmp = t_0;
} else if (x <= 4.5e-209) {
tmp = t_1;
} else if (x <= 8.5e-164) {
tmp = t_0;
} else if (x <= 1.65e-107) {
tmp = t_1;
} else if (x <= 2.6e-68) {
tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x;
} else if (x <= 0.86) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = -(log(x) / n)
if (x <= 4.5d-302) then
tmp = t_0
else if (x <= 4.5d-209) then
tmp = t_1
else if (x <= 8.5d-164) then
tmp = t_0
else if (x <= 1.65d-107) then
tmp = t_1
else if (x <= 2.6d-68) then
tmp = ((1.0d0 / n) + (((((((0.2d0 / (x * n)) - (0.25d0 / n)) / x) + (0.3333333333333333d0 / n)) / x) - (0.5d0 / n)) / x)) / x
else if (x <= 0.86d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 + ((((0.2d0 + (0.16666666666666666d0 * ((-1.0d0) / x))) / x) - 0.25d0) / x)) / 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 t_1 = -(Math.log(x) / n);
double tmp;
if (x <= 4.5e-302) {
tmp = t_0;
} else if (x <= 4.5e-209) {
tmp = t_1;
} else if (x <= 8.5e-164) {
tmp = t_0;
} else if (x <= 1.65e-107) {
tmp = t_1;
} else if (x <= 2.6e-68) {
tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x;
} else if (x <= 0.86) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 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(x) / n) tmp = 0 if x <= 4.5e-302: tmp = t_0 elif x <= 4.5e-209: tmp = t_1 elif x <= 8.5e-164: tmp = t_0 elif x <= 1.65e-107: tmp = t_1 elif x <= 2.6e-68: tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x elif x <= 0.86: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(-Float64(log(x) / n)) tmp = 0.0 if (x <= 4.5e-302) tmp = t_0; elseif (x <= 4.5e-209) tmp = t_1; elseif (x <= 8.5e-164) tmp = t_0; elseif (x <= 1.65e-107) tmp = t_1; elseif (x <= 2.6e-68) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.2 / Float64(x * n)) - Float64(0.25 / n)) / x) + Float64(0.3333333333333333 / n)) / x) - Float64(0.5 / n)) / x)) / x); elseif (x <= 0.86) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(Float64(Float64(Float64(0.2 + Float64(0.16666666666666666 * Float64(-1.0 / x))) / x) - 0.25) / x)) / x) - 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(x) / n); tmp = 0.0; if (x <= 4.5e-302) tmp = t_0; elseif (x <= 4.5e-209) tmp = t_1; elseif (x <= 8.5e-164) tmp = t_0; elseif (x <= 1.65e-107) tmp = t_1; elseif (x <= 2.6e-68) tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x; elseif (x <= 0.86) tmp = (x - log(x)) / n; else tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / 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]}, Block[{t$95$1 = (-N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision])}, If[LessEqual[x, 4.5e-302], t$95$0, If[LessEqual[x, 4.5e-209], t$95$1, If[LessEqual[x, 8.5e-164], t$95$0, If[LessEqual[x, 1.65e-107], t$95$1, If[LessEqual[x, 2.6e-68], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(N[(N[(0.2 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.25 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.86], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 + N[(N[(N[(N[(0.2 + N[(0.16666666666666666 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.25), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / 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)}\\
t_1 := -\frac{\log x}{n}\\
\mathbf{if}\;x \leq 4.5 \cdot 10^{-302}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-209}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-107}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.86:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 4.50000000000000009e-302 or 4.4999999999999998e-209 < x < 8.50000000000000035e-164Initial program 76.2%
Taylor expanded in x around 0 76.2%
if 4.50000000000000009e-302 < x < 4.4999999999999998e-209 or 8.50000000000000035e-164 < x < 1.65000000000000002e-107Initial program 38.9%
Taylor expanded in x around 0 38.9%
Taylor expanded in n around inf 64.0%
neg-mul-164.0%
distribute-neg-frac264.0%
Simplified64.0%
if 1.65000000000000002e-107 < x < 2.5999999999999998e-68Initial program 38.4%
Taylor expanded in n around inf 33.2%
log1p-define33.2%
Simplified33.2%
Taylor expanded in x around -inf 65.7%
Simplified65.7%
if 2.5999999999999998e-68 < x < 0.859999999999999987Initial program 40.7%
Taylor expanded in n around inf 44.0%
log1p-define44.0%
Simplified44.0%
Taylor expanded in x around 0 42.2%
if 0.859999999999999987 < x Initial program 70.0%
Taylor expanded in n around inf 69.9%
log1p-define69.9%
Simplified69.9%
Taylor expanded in x around -inf 64.7%
Final simplification63.3%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-173)
(/ (pow x (- -1.0 (/ -1.0 n))) n)
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+130)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(/
(+
1.0
(/ (- (/ (- 0.3333333333333333 (/ (+ 0.25 (/ -0.2 x)) x)) x) 0.5) x))
(* x n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+130) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-1d-173)) then
tmp = (x ** ((-1.0d0) - ((-1.0d0) / n))) / n
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+130) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else
tmp = (1.0d0 + ((((0.3333333333333333d0 - ((0.25d0 + ((-0.2d0) / x)) / x)) / x) - 0.5d0) / x)) / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+130) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1e-173: tmp = math.pow(x, (-1.0 - (-1.0 / n))) / n elif (1.0 / n) <= 5e-13: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+130: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) else: tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-173) tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+130) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(Float64(0.25 + Float64(-0.2 / x)) / x)) / x) - 0.5) / x)) / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -1e-173) tmp = (x ^ (-1.0 - (-1.0 / n))) / n; elseif ((1.0 / n) <= 5e-13) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+130) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); else tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+130], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(N[(0.25 + N[(-0.2 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-173}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+130}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333 - \frac{0.25 + \frac{-0.2}{x}}{x}}{x} - 0.5}{x}}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-173Initial program 72.1%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
log-rec85.8%
mul-1-neg85.8%
distribute-neg-frac85.8%
mul-1-neg85.8%
remove-double-neg85.8%
*-commutative85.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
*-lft-identity86.7%
sub-neg86.7%
metadata-eval86.7%
Simplified86.7%
if -1e-173 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 39.2%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.5%
Applied egg-rr85.5%
+-commutative85.5%
Simplified85.5%
if 4.9999999999999999e-13 < (/.f64 1 n) < 2.0000000000000001e130Initial program 75.1%
Taylor expanded in x around 0 75.2%
if 2.0000000000000001e130 < (/.f64 1 n) Initial program 22.5%
Taylor expanded in n around inf 6.1%
log1p-define6.1%
Simplified6.1%
Taylor expanded in x around -inf 80.9%
Taylor expanded in n around 0 80.9%
Simplified80.9%
Final simplification85.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (/ (log x) n))))
(if (<= x 9e-180)
t_0
(if (<= x 2.8e-164)
(/ (- (/ 1.0 n) (/ (- (/ 0.5 n) (/ 0.3333333333333333 (* x n))) x)) x)
(if (<= x 1.2e-109)
t_0
(if (<= x 1e-69)
(/
(+
(/ 1.0 n)
(/
(-
(/
(+
(/ (- (/ 0.2 (* x n)) (/ 0.25 n)) x)
(/ 0.3333333333333333 n))
x)
(/ 0.5 n))
x))
x)
(if (<= x 0.86)
(/ (- x (log x)) n)
(/
(/
(+
1.0
(/
(-
(/
(+
0.3333333333333333
(/
(- (/ (+ 0.2 (* 0.16666666666666666 (/ -1.0 x))) x) 0.25)
x))
x)
0.5)
x))
x)
n))))))))
double code(double x, double n) {
double t_0 = -(log(x) / n);
double tmp;
if (x <= 9e-180) {
tmp = t_0;
} else if (x <= 2.8e-164) {
tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x;
} else if (x <= 1.2e-109) {
tmp = t_0;
} else if (x <= 1e-69) {
tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x;
} else if (x <= 0.86) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = -(log(x) / n)
if (x <= 9d-180) then
tmp = t_0
else if (x <= 2.8d-164) then
tmp = ((1.0d0 / n) - (((0.5d0 / n) - (0.3333333333333333d0 / (x * n))) / x)) / x
else if (x <= 1.2d-109) then
tmp = t_0
else if (x <= 1d-69) then
tmp = ((1.0d0 / n) + (((((((0.2d0 / (x * n)) - (0.25d0 / n)) / x) + (0.3333333333333333d0 / n)) / x) - (0.5d0 / n)) / x)) / x
else if (x <= 0.86d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 + ((((0.2d0 + (0.16666666666666666d0 * ((-1.0d0) / x))) / x) - 0.25d0) / x)) / x) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -(Math.log(x) / n);
double tmp;
if (x <= 9e-180) {
tmp = t_0;
} else if (x <= 2.8e-164) {
tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x;
} else if (x <= 1.2e-109) {
tmp = t_0;
} else if (x <= 1e-69) {
tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x;
} else if (x <= 0.86) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = -(math.log(x) / n) tmp = 0 if x <= 9e-180: tmp = t_0 elif x <= 2.8e-164: tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x elif x <= 1.2e-109: tmp = t_0 elif x <= 1e-69: tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x elif x <= 0.86: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(-Float64(log(x) / n)) tmp = 0.0 if (x <= 9e-180) tmp = t_0; elseif (x <= 2.8e-164) tmp = Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(0.5 / n) - Float64(0.3333333333333333 / Float64(x * n))) / x)) / x); elseif (x <= 1.2e-109) tmp = t_0; elseif (x <= 1e-69) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.2 / Float64(x * n)) - Float64(0.25 / n)) / x) + Float64(0.3333333333333333 / n)) / x) - Float64(0.5 / n)) / x)) / x); elseif (x <= 0.86) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(Float64(Float64(Float64(0.2 + Float64(0.16666666666666666 * Float64(-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -(log(x) / n); tmp = 0.0; if (x <= 9e-180) tmp = t_0; elseif (x <= 2.8e-164) tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x; elseif (x <= 1.2e-109) tmp = t_0; elseif (x <= 1e-69) tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x; elseif (x <= 0.86) tmp = (x - log(x)) / n; else tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = (-N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision])}, If[LessEqual[x, 9e-180], t$95$0, If[LessEqual[x, 2.8e-164], N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(0.5 / n), $MachinePrecision] - N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 1.2e-109], t$95$0, If[LessEqual[x, 1e-69], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(N[(N[(0.2 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.25 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.86], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 + N[(N[(N[(N[(0.2 + N[(0.16666666666666666 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.25), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{\log x}{n}\\
\mathbf{if}\;x \leq 9 \cdot 10^{-180}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-164}:\\
\;\;\;\;\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-109}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 10^{-69}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.86:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 9.00000000000000019e-180 or 2.8000000000000001e-164 < x < 1.19999999999999994e-109Initial program 47.0%
Taylor expanded in x around 0 47.0%
Taylor expanded in n around inf 56.7%
neg-mul-156.7%
distribute-neg-frac256.7%
Simplified56.7%
if 9.00000000000000019e-180 < x < 2.8000000000000001e-164Initial program 67.8%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
Taylor expanded in x around -inf 78.4%
mul-1-neg78.4%
mul-1-neg78.4%
associate-*r/78.4%
metadata-eval78.4%
*-commutative78.4%
associate-*r/78.4%
metadata-eval78.4%
Simplified78.4%
if 1.19999999999999994e-109 < x < 9.9999999999999996e-70Initial program 38.4%
Taylor expanded in n around inf 33.2%
log1p-define33.2%
Simplified33.2%
Taylor expanded in x around -inf 65.7%
Simplified65.7%
if 9.9999999999999996e-70 < x < 0.859999999999999987Initial program 40.7%
Taylor expanded in n around inf 44.0%
log1p-define44.0%
Simplified44.0%
Taylor expanded in x around 0 42.2%
if 0.859999999999999987 < x Initial program 70.0%
Taylor expanded in n around inf 69.9%
log1p-define69.9%
Simplified69.9%
Taylor expanded in x around -inf 64.7%
Final simplification60.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (/ (log x) n))))
(if (<= x 1.4e-180)
t_0
(if (<= x 1e-162)
(/ (- (/ 1.0 n) (/ (- (/ 0.5 n) (/ 0.3333333333333333 (* x n))) x)) x)
(if (<= x 9.5e-109)
t_0
(if (<= x 2.4e-68)
(/
(+
(/ 1.0 n)
(/
(-
(/
(+
(/ (- (/ 0.2 (* x n)) (/ 0.25 n)) x)
(/ 0.3333333333333333 n))
x)
(/ 0.5 n))
x))
x)
(if (<= x 0.75)
t_0
(/
(/
(+
1.0
(/
(-
(/
(+
0.3333333333333333
(/
(- (/ (+ 0.2 (* 0.16666666666666666 (/ -1.0 x))) x) 0.25)
x))
x)
0.5)
x))
x)
n))))))))
double code(double x, double n) {
double t_0 = -(log(x) / n);
double tmp;
if (x <= 1.4e-180) {
tmp = t_0;
} else if (x <= 1e-162) {
tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x;
} else if (x <= 9.5e-109) {
tmp = t_0;
} else if (x <= 2.4e-68) {
tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x;
} else if (x <= 0.75) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = -(log(x) / n)
if (x <= 1.4d-180) then
tmp = t_0
else if (x <= 1d-162) then
tmp = ((1.0d0 / n) - (((0.5d0 / n) - (0.3333333333333333d0 / (x * n))) / x)) / x
else if (x <= 9.5d-109) then
tmp = t_0
else if (x <= 2.4d-68) then
tmp = ((1.0d0 / n) + (((((((0.2d0 / (x * n)) - (0.25d0 / n)) / x) + (0.3333333333333333d0 / n)) / x) - (0.5d0 / n)) / x)) / x
else if (x <= 0.75d0) then
tmp = t_0
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 + ((((0.2d0 + (0.16666666666666666d0 * ((-1.0d0) / x))) / x) - 0.25d0) / x)) / x) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -(Math.log(x) / n);
double tmp;
if (x <= 1.4e-180) {
tmp = t_0;
} else if (x <= 1e-162) {
tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x;
} else if (x <= 9.5e-109) {
tmp = t_0;
} else if (x <= 2.4e-68) {
tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x;
} else if (x <= 0.75) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = -(math.log(x) / n) tmp = 0 if x <= 1.4e-180: tmp = t_0 elif x <= 1e-162: tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x elif x <= 9.5e-109: tmp = t_0 elif x <= 2.4e-68: tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x elif x <= 0.75: tmp = t_0 else: tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(-Float64(log(x) / n)) tmp = 0.0 if (x <= 1.4e-180) tmp = t_0; elseif (x <= 1e-162) tmp = Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(0.5 / n) - Float64(0.3333333333333333 / Float64(x * n))) / x)) / x); elseif (x <= 9.5e-109) tmp = t_0; elseif (x <= 2.4e-68) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.2 / Float64(x * n)) - Float64(0.25 / n)) / x) + Float64(0.3333333333333333 / n)) / x) - Float64(0.5 / n)) / x)) / x); elseif (x <= 0.75) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(Float64(Float64(Float64(0.2 + Float64(0.16666666666666666 * Float64(-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -(log(x) / n); tmp = 0.0; if (x <= 1.4e-180) tmp = t_0; elseif (x <= 1e-162) tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x; elseif (x <= 9.5e-109) tmp = t_0; elseif (x <= 2.4e-68) tmp = ((1.0 / n) + (((((((0.2 / (x * n)) - (0.25 / n)) / x) + (0.3333333333333333 / n)) / x) - (0.5 / n)) / x)) / x; elseif (x <= 0.75) tmp = t_0; else tmp = ((1.0 + ((((0.3333333333333333 + ((((0.2 + (0.16666666666666666 * (-1.0 / x))) / x) - 0.25) / x)) / x) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = (-N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision])}, If[LessEqual[x, 1.4e-180], t$95$0, If[LessEqual[x, 1e-162], N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(0.5 / n), $MachinePrecision] - N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 9.5e-109], t$95$0, If[LessEqual[x, 2.4e-68], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(N[(N[(0.2 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.25 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.75], t$95$0, N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 + N[(N[(N[(N[(0.2 + N[(0.16666666666666666 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.25), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{\log x}{n}\\
\mathbf{if}\;x \leq 1.4 \cdot 10^{-180}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 10^{-162}:\\
\;\;\;\;\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-109}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.75:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 1.39999999999999999e-180 or 9.99999999999999954e-163 < x < 9.49999999999999933e-109 or 2.39999999999999991e-68 < x < 0.75Initial program 45.4%
Taylor expanded in x around 0 44.4%
Taylor expanded in n around inf 52.4%
neg-mul-152.4%
distribute-neg-frac252.4%
Simplified52.4%
if 1.39999999999999999e-180 < x < 9.99999999999999954e-163Initial program 67.8%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
Taylor expanded in x around -inf 78.4%
mul-1-neg78.4%
mul-1-neg78.4%
associate-*r/78.4%
metadata-eval78.4%
*-commutative78.4%
associate-*r/78.4%
metadata-eval78.4%
Simplified78.4%
if 9.49999999999999933e-109 < x < 2.39999999999999991e-68Initial program 38.4%
Taylor expanded in n around inf 33.2%
log1p-define33.2%
Simplified33.2%
Taylor expanded in x around -inf 65.7%
Simplified65.7%
if 0.75 < x Initial program 70.0%
Taylor expanded in n around inf 69.9%
log1p-define69.9%
Simplified69.9%
Taylor expanded in x around -inf 64.7%
Final simplification59.9%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -10000.0)
(/ 0.2 (* n (pow x 5.0)))
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+130)
(- 1.0 (pow x (/ 1.0 n)))
(/
(+
1.0
(/ (- (/ (- 0.3333333333333333 (/ (+ 0.25 (/ -0.2 x)) x)) x) 0.5) x))
(* x n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -10000.0) {
tmp = 0.2 / (n * pow(x, 5.0));
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+130) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-10000.0d0)) then
tmp = 0.2d0 / (n * (x ** 5.0d0))
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+130) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = (1.0d0 + ((((0.3333333333333333d0 - ((0.25d0 + ((-0.2d0) / x)) / x)) / x) - 0.5d0) / x)) / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -10000.0) {
tmp = 0.2 / (n * Math.pow(x, 5.0));
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+130) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -10000.0: tmp = 0.2 / (n * math.pow(x, 5.0)) elif (1.0 / n) <= 5e-13: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+130: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -10000.0) tmp = Float64(0.2 / Float64(n * (x ^ 5.0))); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+130) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(Float64(0.25 + Float64(-0.2 / x)) / x)) / x) - 0.5) / x)) / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -10000.0) tmp = 0.2 / (n * (x ^ 5.0)); elseif ((1.0 / n) <= 5e-13) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+130) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -10000.0], N[(0.2 / N[(n * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+130], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(N[(0.25 + N[(-0.2 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10000:\\
\;\;\;\;\frac{0.2}{n \cdot {x}^{5}}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+130}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333 - \frac{0.25 + \frac{-0.2}{x}}{x}}{x} - 0.5}{x}}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e4Initial program 100.0%
Taylor expanded in n around inf 49.4%
log1p-define49.4%
Simplified49.4%
Taylor expanded in x around -inf 42.9%
Taylor expanded in x around 0 79.0%
*-commutative79.0%
Simplified79.0%
if -1e4 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 34.6%
Taylor expanded in n around inf 74.6%
log1p-define74.5%
Simplified74.5%
log1p-undefine74.6%
diff-log74.9%
Applied egg-rr74.9%
+-commutative74.9%
Simplified74.9%
if 4.9999999999999999e-13 < (/.f64 1 n) < 2.0000000000000001e130Initial program 75.1%
Taylor expanded in x around 0 75.1%
if 2.0000000000000001e130 < (/.f64 1 n) Initial program 22.5%
Taylor expanded in n around inf 6.1%
log1p-define6.1%
Simplified6.1%
Taylor expanded in x around -inf 80.9%
Taylor expanded in n around 0 80.9%
Simplified80.9%
Final simplification76.5%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-173)
(/ (pow x (- -1.0 (/ -1.0 n))) n)
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+130)
(- 1.0 (pow x (/ 1.0 n)))
(/
(+
1.0
(/ (- (/ (- 0.3333333333333333 (/ (+ 0.25 (/ -0.2 x)) x)) x) 0.5) x))
(* x n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+130) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-1d-173)) then
tmp = (x ** ((-1.0d0) - ((-1.0d0) / n))) / n
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+130) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = (1.0d0 + ((((0.3333333333333333d0 - ((0.25d0 + ((-0.2d0) / x)) / x)) / x) - 0.5d0) / x)) / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-173) {
tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+130) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1e-173: tmp = math.pow(x, (-1.0 - (-1.0 / n))) / n elif (1.0 / n) <= 5e-13: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+130: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-173) tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+130) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(Float64(0.25 + Float64(-0.2 / x)) / x)) / x) - 0.5) / x)) / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -1e-173) tmp = (x ^ (-1.0 - (-1.0 / n))) / n; elseif ((1.0 / n) <= 5e-13) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+130) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = (1.0 + ((((0.3333333333333333 - ((0.25 + (-0.2 / x)) / x)) / x) - 0.5) / x)) / (x * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+130], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(N[(0.25 + N[(-0.2 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-173}:\\
\;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+130}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333 - \frac{0.25 + \frac{-0.2}{x}}{x}}{x} - 0.5}{x}}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-173Initial program 72.1%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
log-rec85.8%
mul-1-neg85.8%
distribute-neg-frac85.8%
mul-1-neg85.8%
remove-double-neg85.8%
*-commutative85.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
*-lft-identity86.7%
sub-neg86.7%
metadata-eval86.7%
Simplified86.7%
if -1e-173 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 39.2%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.5%
Applied egg-rr85.5%
+-commutative85.5%
Simplified85.5%
if 4.9999999999999999e-13 < (/.f64 1 n) < 2.0000000000000001e130Initial program 75.1%
Taylor expanded in x around 0 75.1%
if 2.0000000000000001e130 < (/.f64 1 n) Initial program 22.5%
Taylor expanded in n around inf 6.1%
log1p-define6.1%
Simplified6.1%
Taylor expanded in x around -inf 80.9%
Taylor expanded in n around 0 80.9%
Simplified80.9%
Final simplification85.2%
(FPCore (x n)
:precision binary64
(/
(/
(+
1.0
(/ (- (+ (/ 0.3333333333333333 x) (/ (/ (+ (/ 0.2 x) -0.25) x) x)) 0.5) x))
x)
n))
double code(double x, double n) {
return ((1.0 + ((((0.3333333333333333 / x) + ((((0.2 / x) + -0.25) / x) / 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.2d0 / x) + (-0.25d0)) / x) / x)) - 0.5d0) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 + ((((0.3333333333333333 / x) + ((((0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n;
}
def code(x, n): return ((1.0 + ((((0.3333333333333333 / x) + ((((0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 / x) + Float64(Float64(Float64(Float64(0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 + ((((0.3333333333333333 / x) + ((((0.2 / x) + -0.25) / x) / x)) - 0.5) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + N[(N[(N[(N[(0.2 / x), $MachinePrecision] + -0.25), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 + \frac{\left(\frac{0.3333333333333333}{x} + \frac{\frac{\frac{0.2}{x} + -0.25}{x}}{x}\right) - 0.5}{x}}{x}}{n}
\end{array}
Initial program 57.1%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around -inf 49.2%
div-sub49.2%
mul-1-neg49.2%
sub-neg49.2%
un-div-inv49.2%
metadata-eval49.2%
Applied egg-rr49.2%
Final simplification49.2%
(FPCore (x n) :precision binary64 (/ (- (/ 1.0 n) (/ (- (/ 0.5 n) (/ 0.3333333333333333 (* x n))) x)) x))
double code(double x, double n) {
return ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) - (((0.5d0 / n) - (0.3333333333333333d0 / (x * n))) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x;
}
def code(x, n): return ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(0.5 / n) - Float64(0.3333333333333333 / Float64(x * n))) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(0.5 / n), $MachinePrecision] - N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x}
\end{array}
Initial program 57.1%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around -inf 48.9%
mul-1-neg48.9%
mul-1-neg48.9%
associate-*r/48.9%
metadata-eval48.9%
*-commutative48.9%
associate-*r/48.9%
metadata-eval48.9%
Simplified48.9%
Final simplification48.9%
(FPCore (x n) :precision binary64 (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))
double code(double x, double n) {
return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
def code(x, n): return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Initial program 57.1%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around -inf 49.2%
Taylor expanded in x around inf 48.9%
Final simplification48.9%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 57.1%
Taylor expanded in x around inf 62.8%
mul-1-neg62.8%
log-rec62.8%
mul-1-neg62.8%
distribute-neg-frac62.8%
mul-1-neg62.8%
remove-double-neg62.8%
*-commutative62.8%
Simplified62.8%
Taylor expanded in n around inf 41.1%
*-commutative41.1%
Simplified41.1%
Final simplification41.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 57.1%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around inf 42.1%
Final simplification42.1%
(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 57.1%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around 0 27.4%
Taylor expanded in x around inf 4.3%
Final simplification4.3%
herbie shell --seed 2024055
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))