
(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 16 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-14)
(pow (cbrt (/ (pow x (+ (/ 1.0 n) -1.0)) n)) 3.0)
(if (<= (/ 1.0 n) 2e-14)
(/
(+
(log1p x)
(- (/ (* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0))) n) (log x)))
n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-14) {
tmp = pow(cbrt((pow(x, ((1.0 / n) + -1.0)) / n)), 3.0);
} else if ((1.0 / n) <= 2e-14) {
tmp = (log1p(x) + (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) / n) - log(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-14) {
tmp = Math.pow(Math.cbrt((Math.pow(x, ((1.0 / n) + -1.0)) / n)), 3.0);
} else if ((1.0 / n) <= 2e-14) {
tmp = (Math.log1p(x) + (((0.5 * (Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0))) / n) - Math.log(x))) / n;
} else {
tmp = Math.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-14) tmp = cbrt(Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n)) ^ 3.0; elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) / n) - log(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-14], N[Power[N[Power[N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], 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), $MachinePrecision] - N[Log[x], $MachinePrecision]), $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^{-14}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}}\right)}^{3}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(\frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right)}{n} - \log 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) < -9.99999999999999999e-15Initial program 95.6%
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%
add-cube-cbrt98.3%
pow398.3%
associate-/r*98.6%
div-inv98.6%
pow-to-exp98.6%
pow198.6%
pow-div98.4%
Applied egg-rr98.4%
if -9.99999999999999999e-15 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 33.8%
Taylor expanded in n around inf 80.9%
Simplified80.9%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) Initial program 63.7%
Taylor expanded in n around 0 63.7%
log1p-define100.0%
Simplified100.0%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(if (<= x 1700.0)
(*
(-
(log (/ x (+ x 1.0)))
(/
(-
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0)))
(/
(fma
(- (pow (log1p x) 3.0) (pow (log x) 3.0))
-0.16666666666666666
(/
(* -0.041666666666666664 (- (pow (log1p x) 4.0) (pow (log x) 4.0)))
n))
n))
n))
(/ -1.0 n))
(pow (cbrt (/ (pow x (+ (/ 1.0 n) -1.0)) n)) 3.0)))
double code(double x, double n) {
double tmp;
if (x <= 1700.0) {
tmp = (log((x / (x + 1.0))) - (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) - (fma((pow(log1p(x), 3.0) - pow(log(x), 3.0)), -0.16666666666666666, ((-0.041666666666666664 * (pow(log1p(x), 4.0) - pow(log(x), 4.0))) / n)) / n)) / n)) * (-1.0 / n);
} else {
tmp = pow(cbrt((pow(x, ((1.0 / n) + -1.0)) / n)), 3.0);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1700.0) tmp = Float64(Float64(log(Float64(x / Float64(x + 1.0))) - Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) - Float64(fma(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)), -0.16666666666666666, Float64(Float64(-0.041666666666666664 * Float64((log1p(x) ^ 4.0) - (log(x) ^ 4.0))) / n)) / n)) / n)) * Float64(-1.0 / n)); else tmp = cbrt(Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n)) ^ 3.0; end return tmp end
code[x_, n_] := If[LessEqual[x, 1700.0], N[(N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $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[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + N[(N[(-0.041666666666666664 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1700:\\
\;\;\;\;\left(\log \left(\frac{x}{x + 1}\right) - \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) - \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}, -0.16666666666666666, \frac{-0.041666666666666664 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{4} - {\log x}^{4}\right)}{n}\right)}{n}}{n}\right) \cdot \frac{-1}{n}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}}\right)}^{3}\\
\end{array}
\end{array}
if x < 1700Initial program 39.1%
Taylor expanded in n around -inf 75.7%
Simplified75.7%
add-cube-cbrt74.8%
pow374.8%
Applied egg-rr74.8%
rem-cube-cbrt75.7%
div-inv75.7%
Applied egg-rr75.7%
log1p-undefine75.7%
diff-log75.9%
Applied egg-rr75.9%
+-commutative75.9%
Simplified75.9%
if 1700 < x Initial program 72.4%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
add-cube-cbrt97.1%
pow397.1%
associate-/r*98.9%
div-inv98.9%
pow-to-exp98.9%
pow198.9%
pow-div98.7%
Applied egg-rr98.7%
Final simplification86.6%
(FPCore (x n)
:precision binary64
(if (<= x 1700.0)
(/
(-
(+
(log1p x)
(/
(+
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0)))
(/
(+
(/
(* -0.041666666666666664 (- (pow (log x) 4.0) (pow (log1p x) 4.0)))
n)
(* -0.16666666666666666 (- (pow (log x) 3.0) (pow (log1p x) 3.0))))
n))
n))
(log x))
n)
(pow (cbrt (/ (pow x (+ (/ 1.0 n) -1.0)) n)) 3.0)))
double code(double x, double n) {
double tmp;
if (x <= 1700.0) {
tmp = ((log1p(x) + (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) + ((((-0.041666666666666664 * (pow(log(x), 4.0) - pow(log1p(x), 4.0))) / n) + (-0.16666666666666666 * (pow(log(x), 3.0) - pow(log1p(x), 3.0)))) / n)) / n)) - log(x)) / n;
} else {
tmp = pow(cbrt((pow(x, ((1.0 / n) + -1.0)) / n)), 3.0);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 1700.0) {
tmp = ((Math.log1p(x) + (((0.5 * (Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0))) + ((((-0.041666666666666664 * (Math.pow(Math.log(x), 4.0) - Math.pow(Math.log1p(x), 4.0))) / n) + (-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(Math.cbrt((Math.pow(x, ((1.0 / n) + -1.0)) / n)), 3.0);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1700.0) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) + Float64(Float64(Float64(Float64(-0.041666666666666664 * Float64((log(x) ^ 4.0) - (log1p(x) ^ 4.0))) / n) + Float64(-0.16666666666666666 * Float64((log(x) ^ 3.0) - (log1p(x) ^ 3.0)))) / n)) / n)) - log(x)) / n); else tmp = cbrt(Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n)) ^ 3.0; end return tmp end
code[x_, n_] := If[LessEqual[x, 1700.0], 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[(N[(N[(-0.041666666666666664 * N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + 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]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1700:\\
\;\;\;\;\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{\frac{-0.041666666666666664 \cdot \left({\log x}^{4} - {\left(\mathsf{log1p}\left(x\right)\right)}^{4}\right)}{n} + -0.16666666666666666 \cdot \left({\log x}^{3} - {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right)}{n}}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}}\right)}^{3}\\
\end{array}
\end{array}
if x < 1700Initial program 39.1%
Taylor expanded in n around -inf 75.7%
Simplified75.7%
if 1700 < x Initial program 72.4%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
add-cube-cbrt97.1%
pow397.1%
associate-/r*98.9%
div-inv98.9%
pow-to-exp98.9%
pow198.9%
pow-div98.7%
Applied egg-rr98.7%
Final simplification86.5%
(FPCore (x n)
:precision binary64
(if (<= x 1600.0)
(*
(/ -1.0 n)
(-
(- (log x) (log1p x))
(/
(-
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0)))
(/
(fma
(- (pow (log1p x) 3.0) (pow (log x) 3.0))
-0.16666666666666666
(/ (* -0.041666666666666664 (- (pow (log x) 4.0))) n))
n))
n)))
(pow (cbrt (/ (pow x (+ (/ 1.0 n) -1.0)) n)) 3.0)))
double code(double x, double n) {
double tmp;
if (x <= 1600.0) {
tmp = (-1.0 / n) * ((log(x) - log1p(x)) - (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) - (fma((pow(log1p(x), 3.0) - pow(log(x), 3.0)), -0.16666666666666666, ((-0.041666666666666664 * -pow(log(x), 4.0)) / n)) / n)) / n));
} else {
tmp = pow(cbrt((pow(x, ((1.0 / n) + -1.0)) / n)), 3.0);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1600.0) tmp = Float64(Float64(-1.0 / n) * Float64(Float64(log(x) - log1p(x)) - Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) - Float64(fma(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)), -0.16666666666666666, Float64(Float64(-0.041666666666666664 * Float64(-(log(x) ^ 4.0))) / n)) / n)) / n))); else tmp = cbrt(Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n)) ^ 3.0; end return tmp end
code[x_, n_] := If[LessEqual[x, 1600.0], N[(N[(-1.0 / n), $MachinePrecision] * N[(N[(N[Log[x], $MachinePrecision] - N[Log[1 + x], $MachinePrecision]), $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[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + N[(N[(-0.041666666666666664 * (-N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision])), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1600:\\
\;\;\;\;\frac{-1}{n} \cdot \left(\left(\log x - \mathsf{log1p}\left(x\right)\right) - \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) - \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}, -0.16666666666666666, \frac{-0.041666666666666664 \cdot \left(-{\log x}^{4}\right)}{n}\right)}{n}}{n}\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}}\right)}^{3}\\
\end{array}
\end{array}
if x < 1600Initial program 39.1%
Taylor expanded in n around -inf 75.7%
Simplified75.7%
add-cube-cbrt74.8%
pow374.8%
Applied egg-rr74.8%
rem-cube-cbrt75.7%
div-inv75.7%
Applied egg-rr75.7%
Taylor expanded in x around 0 75.7%
neg-mul-175.7%
Simplified75.7%
if 1600 < x Initial program 72.4%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
add-cube-cbrt97.1%
pow397.1%
associate-/r*98.9%
div-inv98.9%
pow-to-exp98.9%
pow198.9%
pow-div98.7%
Applied egg-rr98.7%
Final simplification86.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-45)
(/ (log1p (expm1 t_0)) (* x n))
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = log1p(expm1(t_0)) / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = Math.log1p(Math.expm1(t_0)) / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-45: tmp = math.log1p(math.expm1(t_0)) / (x * n) elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-45) tmp = Float64(log1p(expm1(t_0)) / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-45], N[(N[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], 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] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-45}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(t\_0\right)\right)}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999994e-45Initial program 85.7%
Taylor expanded in x around inf 92.8%
mul-1-neg92.8%
log-rec92.8%
mul-1-neg92.8%
distribute-neg-frac92.8%
mul-1-neg92.8%
remove-double-neg92.8%
*-commutative92.8%
Simplified92.8%
div-inv92.8%
pow-to-exp92.8%
log1p-expm1-u92.9%
Applied egg-rr92.9%
if -3.99999999999999994e-45 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 35.3%
Taylor expanded in n around inf 82.6%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.6%
diff-log82.8%
Applied egg-rr82.8%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) Initial program 63.7%
Taylor expanded in n around 0 63.7%
log1p-define100.0%
Simplified100.0%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-45)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-45: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-45) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-45], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], 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] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-45}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999994e-45Initial program 85.7%
Taylor expanded in x around inf 92.8%
mul-1-neg92.8%
log-rec92.8%
mul-1-neg92.8%
distribute-neg-frac92.8%
mul-1-neg92.8%
remove-double-neg92.8%
*-commutative92.8%
Simplified92.8%
Taylor expanded in x around 0 92.8%
*-rgt-identity92.8%
associate-*r/92.8%
exp-to-pow92.8%
*-commutative92.8%
Simplified92.8%
if -3.99999999999999994e-45 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 35.3%
Taylor expanded in n around inf 82.6%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.6%
diff-log82.8%
Applied egg-rr82.8%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) Initial program 63.7%
Taylor expanded in n around 0 63.7%
log1p-define100.0%
Simplified100.0%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-45)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(- (+ 1.0 (* x (/ (+ 1.0 (+ (* x -0.5) (* 0.5 (/ x n)))) n))) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-4d-45)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 2d-14) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = (1.0d0 + (x * ((1.0d0 + ((x * (-0.5d0)) + (0.5d0 * (x / n)))) / n))) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-45: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n else: tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-45) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 + Float64(Float64(x * -0.5) + Float64(0.5 * Float64(x / n)))) / n))) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -4e-45) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 2e-14) tmp = log(((x + 1.0) / x)) / n; else tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-45], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 + N[(N[(x * -0.5), $MachinePrecision] + N[(0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-45}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \frac{1 + \left(x \cdot -0.5 + 0.5 \cdot \frac{x}{n}\right)}{n}\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999994e-45Initial program 85.7%
Taylor expanded in x around inf 92.8%
mul-1-neg92.8%
log-rec92.8%
mul-1-neg92.8%
distribute-neg-frac92.8%
mul-1-neg92.8%
remove-double-neg92.8%
*-commutative92.8%
Simplified92.8%
Taylor expanded in x around 0 92.8%
*-rgt-identity92.8%
associate-*r/92.8%
exp-to-pow92.8%
*-commutative92.8%
Simplified92.8%
if -3.99999999999999994e-45 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 35.3%
Taylor expanded in n around inf 82.6%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.6%
diff-log82.8%
Applied egg-rr82.8%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) Initial program 63.7%
Taylor expanded in x around 0 75.9%
Taylor expanded in n around inf 80.0%
Final simplification85.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-45)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 4e+227) (- (+ 1.0 (/ x n)) t_0) (/ 1.0 (* x n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 4e+227) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-4d-45)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 2d-14) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 4d+227) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 4e+227) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-45: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 4e+227: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (x * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-45) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 4e+227) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -4e-45) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 2e-14) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 4e+227) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-45], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+227], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-45}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+227}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999994e-45Initial program 85.7%
Taylor expanded in x around inf 92.8%
mul-1-neg92.8%
log-rec92.8%
mul-1-neg92.8%
distribute-neg-frac92.8%
mul-1-neg92.8%
remove-double-neg92.8%
*-commutative92.8%
Simplified92.8%
Taylor expanded in x around 0 92.8%
*-rgt-identity92.8%
associate-*r/92.8%
exp-to-pow92.8%
*-commutative92.8%
Simplified92.8%
if -3.99999999999999994e-45 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 35.3%
Taylor expanded in n around inf 82.6%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.6%
diff-log82.8%
Applied egg-rr82.8%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 4.0000000000000004e227Initial program 79.6%
Taylor expanded in x around 0 69.6%
if 4.0000000000000004e227 < (/.f64 #s(literal 1 binary64) n) Initial program 3.1%
Taylor expanded in n around inf 10.8%
log1p-define10.8%
Simplified10.8%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification85.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-45)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 1e+219) (- 1.0 t_0) (/ 1.0 (* x n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+219) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-4d-45)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 2d-14) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 1d+219) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-45) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+219) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-45: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+219: tmp = 1.0 - t_0 else: tmp = 1.0 / (x * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-45) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+219) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -4e-45) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 2e-14) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 1e+219) tmp = 1.0 - t_0; else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-45], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+219], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-45}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+219}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999994e-45Initial program 85.7%
Taylor expanded in x around inf 92.8%
mul-1-neg92.8%
log-rec92.8%
mul-1-neg92.8%
distribute-neg-frac92.8%
mul-1-neg92.8%
remove-double-neg92.8%
*-commutative92.8%
Simplified92.8%
Taylor expanded in x around 0 92.8%
*-rgt-identity92.8%
associate-*r/92.8%
exp-to-pow92.8%
*-commutative92.8%
Simplified92.8%
if -3.99999999999999994e-45 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 35.3%
Taylor expanded in n around inf 82.6%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.6%
diff-log82.8%
Applied egg-rr82.8%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999965e218Initial program 82.9%
Taylor expanded in x around 0 71.5%
if 9.99999999999999965e218 < (/.f64 #s(literal 1 binary64) n) Initial program 17.0%
Taylor expanded in n around inf 9.2%
log1p-define9.2%
Simplified9.2%
Taylor expanded in x around inf 86.2%
*-commutative86.2%
Simplified86.2%
Final simplification85.5%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) 2e-14) (/ (log (/ (+ x 1.0) x)) n) (if (<= (/ 1.0 n) 1e+219) (- 1.0 (pow x (/ 1.0 n))) (/ 1.0 (* x n)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+219) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= 2d-14) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 1d+219) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = 1.0d0 / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+219) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+219: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = 1.0 / (x * n) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+219) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(1.0 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= 2e-14) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 1e+219) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+219], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+219}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 53.8%
Taylor expanded in n around inf 70.9%
log1p-define70.9%
Simplified70.9%
log1p-undefine70.9%
diff-log70.6%
Applied egg-rr70.6%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999965e218Initial program 82.9%
Taylor expanded in x around 0 71.5%
if 9.99999999999999965e218 < (/.f64 #s(literal 1 binary64) n) Initial program 17.0%
Taylor expanded in n around inf 9.2%
log1p-define9.2%
Simplified9.2%
Taylor expanded in x around inf 86.2%
*-commutative86.2%
Simplified86.2%
Final simplification71.1%
(FPCore (x n)
:precision binary64
(if (<= x 0.88)
(/ (- x (log x)) n)
(if (<= x 4.3e+67)
(/
(/
(+ 1.0 (/ (- (/ (- 0.3333333333333333 (* 0.25 (/ 1.0 x))) x) 0.5) x))
x)
n)
0.0)))
double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else if (x <= 4.3e+67) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.88d0) then
tmp = (x - log(x)) / n
else if (x <= 4.3d+67) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - (0.25d0 * (1.0d0 / x))) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 4.3e+67) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.88: tmp = (x - math.log(x)) / n elif x <= 4.3e+67: tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 4.3e+67) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 * Float64(1.0 / x))) / x) - 0.5) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.88) tmp = (x - log(x)) / n; elseif (x <= 4.3e+67) tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 4.3e+67], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(0.25 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{+67}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.880000000000000004Initial program 39.5%
Taylor expanded in n around inf 60.1%
log1p-define60.1%
Simplified60.1%
Taylor expanded in x around 0 59.7%
if 0.880000000000000004 < x < 4.3000000000000001e67Initial program 39.4%
Taylor expanded in n around inf 33.9%
log1p-define33.9%
Simplified33.9%
Taylor expanded in x around -inf 67.1%
if 4.3000000000000001e67 < x Initial program 81.9%
Taylor expanded in x around 0 49.4%
Taylor expanded in n around inf 81.9%
metadata-eval81.9%
Applied egg-rr81.9%
Final simplification68.5%
(FPCore (x n)
:precision binary64
(if (<= x 0.72)
(/ (log x) (- n))
(if (<= x 4.2e+67)
(/
(/
(+ 1.0 (/ (- (/ (- 0.3333333333333333 (* 0.25 (/ 1.0 x))) x) 0.5) x))
x)
n)
0.0)))
double code(double x, double n) {
double tmp;
if (x <= 0.72) {
tmp = log(x) / -n;
} else if (x <= 4.2e+67) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.72d0) then
tmp = log(x) / -n
else if (x <= 4.2d+67) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - (0.25d0 * (1.0d0 / x))) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.72) {
tmp = Math.log(x) / -n;
} else if (x <= 4.2e+67) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.72: tmp = math.log(x) / -n elif x <= 4.2e+67: tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.72) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 4.2e+67) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 * Float64(1.0 / x))) / x) - 0.5) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.72) tmp = log(x) / -n; elseif (x <= 4.2e+67) tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.72], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 4.2e+67], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(0.25 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.72:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+67}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.71999999999999997Initial program 39.0%
Taylor expanded in n around inf 60.5%
log1p-define60.5%
Simplified60.5%
Taylor expanded in x around 0 59.4%
neg-mul-159.4%
Simplified59.4%
if 0.71999999999999997 < x < 4.2000000000000003e67Initial program 41.3%
Taylor expanded in n around inf 33.0%
log1p-define33.0%
Simplified33.0%
Taylor expanded in x around -inf 65.0%
if 4.2000000000000003e67 < x Initial program 81.9%
Taylor expanded in x around 0 49.4%
Taylor expanded in n around inf 81.9%
metadata-eval81.9%
Applied egg-rr81.9%
Final simplification68.2%
(FPCore (x n) :precision binary64 (if (<= x 3.5e+67) (/ (- (/ 1.0 n) (/ (- (/ 0.5 n) (/ 0.3333333333333333 (* x n))) x)) x) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 3.5e+67) {
tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.5d+67) then
tmp = ((1.0d0 / n) - (((0.5d0 / n) - (0.3333333333333333d0 / (x * n))) / x)) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.5e+67) {
tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.5e+67: tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 3.5e+67) tmp = Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(0.5 / n) - Float64(0.3333333333333333 / Float64(x * n))) / x)) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.5e+67) tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (x * n))) / x)) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.5e+67], 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], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{+67}:\\
\;\;\;\;\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 3.5e67Initial program 39.4%
Taylor expanded in n around inf 55.3%
log1p-define55.3%
Simplified55.3%
Taylor expanded in x around -inf 34.4%
mul-1-neg34.4%
mul-1-neg34.4%
associate-*r/34.4%
metadata-eval34.4%
*-commutative34.4%
associate-*r/34.4%
metadata-eval34.4%
Simplified34.4%
if 3.5e67 < x Initial program 81.9%
Taylor expanded in x around 0 49.4%
Taylor expanded in n around inf 81.9%
metadata-eval81.9%
Applied egg-rr81.9%
Final simplification51.5%
(FPCore (x n) :precision binary64 (if (or (<= n -5.6e-10) (not (<= n -5.5e-271))) (/ 1.0 (* x n)) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -5.6e-10) || !(n <= -5.5e-271)) {
tmp = 1.0 / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-5.6d-10)) .or. (.not. (n <= (-5.5d-271)))) then
tmp = 1.0d0 / (x * n)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -5.6e-10) || !(n <= -5.5e-271)) {
tmp = 1.0 / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -5.6e-10) or not (n <= -5.5e-271): tmp = 1.0 / (x * n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -5.6e-10) || !(n <= -5.5e-271)) tmp = Float64(1.0 / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -5.6e-10) || ~((n <= -5.5e-271))) tmp = 1.0 / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -5.6e-10], N[Not[LessEqual[n, -5.5e-271]], $MachinePrecision]], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.6 \cdot 10^{-10} \lor \neg \left(n \leq -5.5 \cdot 10^{-271}\right):\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -5.60000000000000031e-10 or -5.4999999999999996e-271 < n Initial program 41.1%
Taylor expanded in n around inf 67.9%
log1p-define67.9%
Simplified67.9%
Taylor expanded in x around inf 47.2%
*-commutative47.2%
Simplified47.2%
if -5.60000000000000031e-10 < n < -5.4999999999999996e-271Initial program 100.0%
Taylor expanded in x around 0 44.2%
Taylor expanded in n around inf 58.3%
metadata-eval58.3%
Applied egg-rr58.3%
Final simplification49.8%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -1000000000000.0) 0.0 (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1000000000000.0) {
tmp = 0.0;
} else {
tmp = (1.0 / n) / x;
}
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) <= (-1000000000000.0d0)) then
tmp = 0.0d0
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1000000000000.0) {
tmp = 0.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1000000000000.0: tmp = 0.0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1000000000000.0) tmp = 0.0; else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -1000000000000.0) tmp = 0.0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1000000000000.0], 0.0, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1000000000000:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e12Initial program 100.0%
Taylor expanded in x around 0 45.2%
Taylor expanded in n around inf 57.2%
metadata-eval57.2%
Applied egg-rr57.2%
if -1e12 < (/.f64 #s(literal 1 binary64) n) Initial program 38.0%
Taylor expanded in n around inf 69.2%
log1p-define69.2%
Simplified69.2%
flip--69.2%
unpow269.2%
unpow269.2%
Applied egg-rr69.2%
Taylor expanded in x around inf 47.0%
associate-/r*48.2%
Simplified48.2%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 54.7%
Taylor expanded in x around 0 38.9%
Taylor expanded in n around inf 36.1%
metadata-eval36.1%
Applied egg-rr36.1%
herbie shell --seed 2024165
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))