
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (cbrt (cbrt x))))
(if (<= (/ 1.0 n) -1.0)
(-
(pow (+ 1.0 x) (/ 1.0 n))
(* (pow (* t_0 (* t_0 t_0)) (/ 1.0 n)) (pow (cbrt (* x x)) (/ 1.0 n))))
(if (<= (/ 1.0 n) 500.0)
(+
(+
(/ (- (log1p x) (log x)) n)
(/
(* -0.16666666666666666 (- (pow (log x) 3.0) (pow (log1p x) 3.0)))
(pow n 3.0)))
(-
(fma
0.5
(/ (pow (log1p x) 2.0) (* n n))
(* 0.041666666666666664 (/ (pow (log1p x) 4.0) (pow n 4.0))))
(fma
0.5
(/ (pow (log x) 2.0) (* n n))
(* 0.041666666666666664 (/ (pow (log x) 4.0) (pow n 4.0))))))
(- (exp (/ x n)) (pow x (/ 1.0 n)))))))
double code(double x, double n) {
double t_0 = cbrt(cbrt(x));
double tmp;
if ((1.0 / n) <= -1.0) {
tmp = pow((1.0 + x), (1.0 / n)) - (pow((t_0 * (t_0 * t_0)), (1.0 / n)) * pow(cbrt((x * x)), (1.0 / n)));
} else if ((1.0 / n) <= 500.0) {
tmp = (((log1p(x) - log(x)) / n) + ((-0.16666666666666666 * (pow(log(x), 3.0) - pow(log1p(x), 3.0))) / pow(n, 3.0))) + (fma(0.5, (pow(log1p(x), 2.0) / (n * n)), (0.041666666666666664 * (pow(log1p(x), 4.0) / pow(n, 4.0)))) - fma(0.5, (pow(log(x), 2.0) / (n * n)), (0.041666666666666664 * (pow(log(x), 4.0) / pow(n, 4.0)))));
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) t_0 = cbrt(cbrt(x)) tmp = 0.0 if (Float64(1.0 / n) <= -1.0) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - Float64((Float64(t_0 * Float64(t_0 * t_0)) ^ Float64(1.0 / n)) * (cbrt(Float64(x * x)) ^ Float64(1.0 / n)))); elseif (Float64(1.0 / n) <= 500.0) tmp = Float64(Float64(Float64(Float64(log1p(x) - log(x)) / n) + Float64(Float64(-0.16666666666666666 * Float64((log(x) ^ 3.0) - (log1p(x) ^ 3.0))) / (n ^ 3.0))) + Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), Float64(0.041666666666666664 * Float64((log1p(x) ^ 4.0) / (n ^ 4.0)))) - fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), Float64(0.041666666666666664 * Float64((log(x) ^ 4.0) / (n ^ 4.0)))))); else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[N[Power[x, 1/3], $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.0], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] * N[Power[N[Power[N[(x * x), $MachinePrecision], 1/3], $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 500.0], N[(N[(N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $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[Power[n, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
t_0 := \sqrt[3]{\sqrt[3]{x}}\\
\mathbf{if}\;\frac{1}{n} \leq -1:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {\left(t_0 \cdot \left(t_0 \cdot t_0\right)\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x \cdot x}\right)}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 500:\\
\;\;\;\;\left(\frac{\mathsf{log1p}\left(x\right) - \log x}{n} + \frac{-0.16666666666666666 \cdot \left({\log x}^{3} - {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right)}{{n}^{3}}\right) + \left(\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, 0.041666666666666664 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{{n}^{4}}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, 0.041666666666666664 \cdot \frac{{\log x}^{4}}{{n}^{4}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1Initial program 99.9%
add-cube-cbrt99.9%
unpow-prod-down99.9%
cbrt-unprod99.9%
inv-pow99.9%
inv-pow99.9%
Applied egg-rr99.9%
*-commutative99.9%
unpow-199.9%
unpow-199.9%
Simplified99.9%
add-cube-cbrt99.9%
Applied egg-rr99.9%
if -1 < (/.f64 1 n) < 500Initial program 36.4%
Taylor expanded in n around -inf 74.9%
Simplified74.9%
if 500 < (/.f64 1 n) Initial program 44.8%
Taylor expanded in n around 0 44.8%
log1p-def97.6%
*-rgt-identity97.6%
associate-*r/97.6%
unpow-197.6%
exp-to-pow97.6%
/-rgt-identity97.6%
metadata-eval97.6%
associate-/l*97.6%
*-commutative97.6%
*-commutative97.6%
associate-/l*97.6%
metadata-eval97.6%
/-rgt-identity97.6%
unpow-197.6%
Simplified97.6%
Taylor expanded in x around 0 97.6%
Final simplification86.0%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-43)
(/ (pow x (/ 1.0 n)) (* n x))
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ 1.0 x) x)) n)
(exp (log (- (exp (/ (log1p x) n)) (pow x (pow n -1.0))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-43) {
tmp = pow(x, (1.0 / n)) / (n * x);
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp(log((exp((log1p(x) / n)) - pow(x, pow(n, -1.0)))));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-43) {
tmp = Math.pow(x, (1.0 / n)) / (n * x);
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp(Math.log((Math.exp((Math.log1p(x) / n)) - Math.pow(x, Math.pow(n, -1.0)))));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5e-43: tmp = math.pow(x, (1.0 / n)) / (n * x) elif (1.0 / n) <= 2e-18: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp(math.log((math.exp((math.log1p(x) / n)) - math.pow(x, math.pow(n, -1.0))))) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-43) tmp = Float64((x ^ Float64(1.0 / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = exp(log(Float64(exp(Float64(log1p(x) / n)) - (x ^ (n ^ -1.0))))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-43], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Exp[N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-43}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left({n}^{-1}\right)}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-43Initial program 91.8%
Taylor expanded in x around inf 94.9%
exp-prod94.9%
log-rec94.9%
distribute-frac-neg94.9%
exp-prod94.9%
neg-mul-194.9%
remove-double-neg94.9%
*-rgt-identity94.9%
associate-*r/94.9%
unpow-194.9%
exp-to-pow94.9%
unpow-194.9%
*-commutative94.9%
Simplified94.9%
if -5.00000000000000019e-43 < (/.f64 1 n) < 2.0000000000000001e-18Initial program 35.8%
add-cube-cbrt35.8%
unpow-prod-down35.8%
cbrt-unprod11.1%
inv-pow11.1%
inv-pow11.1%
Applied egg-rr11.1%
*-commutative11.1%
unpow-111.1%
unpow-111.1%
Simplified11.1%
Taylor expanded in n around inf 29.1%
sum-log27.9%
diff-log24.3%
+-commutative24.3%
pow-pow48.1%
pow-prod-up77.0%
metadata-eval77.0%
metadata-eval77.0%
pow177.0%
Applied egg-rr77.0%
if 2.0000000000000001e-18 < (/.f64 1 n) Initial program 45.6%
add-exp-log45.6%
pow-to-exp45.6%
un-div-inv45.6%
+-commutative45.6%
log1p-udef92.7%
inv-pow92.7%
Applied egg-rr92.7%
Final simplification86.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-43)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-43) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-43) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-43: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-18: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-43) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-43], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-43}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-43Initial program 91.8%
Taylor expanded in x around inf 94.9%
exp-prod94.9%
log-rec94.9%
distribute-frac-neg94.9%
exp-prod94.9%
neg-mul-194.9%
remove-double-neg94.9%
*-rgt-identity94.9%
associate-*r/94.9%
unpow-194.9%
exp-to-pow94.9%
unpow-194.9%
*-commutative94.9%
Simplified94.9%
if -5.00000000000000019e-43 < (/.f64 1 n) < 2.0000000000000001e-18Initial program 35.8%
add-cube-cbrt35.8%
unpow-prod-down35.8%
cbrt-unprod11.1%
inv-pow11.1%
inv-pow11.1%
Applied egg-rr11.1%
*-commutative11.1%
unpow-111.1%
unpow-111.1%
Simplified11.1%
Taylor expanded in n around inf 29.1%
sum-log27.9%
diff-log24.3%
+-commutative24.3%
pow-pow48.1%
pow-prod-up77.0%
metadata-eval77.0%
metadata-eval77.0%
pow177.0%
Applied egg-rr77.0%
if 2.0000000000000001e-18 < (/.f64 1 n) Initial program 45.6%
Taylor expanded in n around 0 45.6%
log1p-def92.7%
*-rgt-identity92.7%
associate-*r/92.7%
unpow-192.7%
exp-to-pow92.7%
/-rgt-identity92.7%
metadata-eval92.7%
associate-/l*92.7%
*-commutative92.7%
*-commutative92.7%
associate-/l*92.7%
metadata-eval92.7%
/-rgt-identity92.7%
unpow-192.7%
Simplified92.7%
Final simplification86.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-43)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-43) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((x / 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) <= (-5d-43)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-9) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = exp((x / 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) <= -5e-43) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-43: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((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) <= -5e-43) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(x / 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) <= -5e-43) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-9) tmp = log(((1.0 + x) / x)) / n; else tmp = exp((x / 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], -5e-43], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / 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 -5 \cdot 10^{-43}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-43Initial program 91.8%
Taylor expanded in x around inf 94.9%
exp-prod94.9%
log-rec94.9%
distribute-frac-neg94.9%
exp-prod94.9%
neg-mul-194.9%
remove-double-neg94.9%
*-rgt-identity94.9%
associate-*r/94.9%
unpow-194.9%
exp-to-pow94.9%
unpow-194.9%
*-commutative94.9%
Simplified94.9%
if -5.00000000000000019e-43 < (/.f64 1 n) < 5.0000000000000001e-9Initial program 35.6%
add-cube-cbrt35.6%
unpow-prod-down35.6%
cbrt-unprod11.0%
inv-pow11.0%
inv-pow11.0%
Applied egg-rr11.0%
*-commutative11.0%
unpow-111.0%
unpow-111.0%
Simplified11.0%
Taylor expanded in n around inf 28.9%
sum-log27.7%
diff-log24.1%
+-commutative24.1%
pow-pow47.7%
pow-prod-up76.4%
metadata-eval76.4%
metadata-eval76.4%
pow176.4%
Applied egg-rr76.4%
if 5.0000000000000001e-9 < (/.f64 1 n) Initial program 46.5%
Taylor expanded in n around 0 46.5%
log1p-def94.6%
*-rgt-identity94.6%
associate-*r/94.6%
unpow-194.6%
exp-to-pow94.6%
/-rgt-identity94.6%
metadata-eval94.6%
associate-/l*94.6%
*-commutative94.6%
*-commutative94.6%
associate-/l*94.6%
metadata-eval94.6%
/-rgt-identity94.6%
unpow-194.6%
Simplified94.6%
Taylor expanded in x around 0 94.6%
Final simplification86.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -5e-9)
t_0
(if (<= (/ 1.0 n) 5e-220)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (- x (log x)) n)
(if (<= (/ 1.0 n) 5e+161)
t_0
(* x (* x (- (/ 0.5 (* n n)) (/ 0.5 n))))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-9) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-220) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = (x - log(x)) / n;
} else if ((1.0 / n) <= 5e+161) {
tmp = t_0;
} else {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n)));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-5d-9)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d-220) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 2d-18) then
tmp = (x - log(x)) / n
else if ((1.0d0 / n) <= 5d+161) then
tmp = t_0
else
tmp = x * (x * ((0.5d0 / (n * n)) - (0.5d0 / n)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-9) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-220) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = (x - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e+161) {
tmp = t_0;
} else {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n)));
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-9: tmp = t_0 elif (1.0 / n) <= 5e-220: tmp = (1.0 / n) / x elif (1.0 / n) <= 2e-18: tmp = (x - math.log(x)) / n elif (1.0 / n) <= 5e+161: tmp = t_0 else: tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n))) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -5e-9) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-220) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(Float64(x - log(x)) / n); elseif (Float64(1.0 / n) <= 5e+161) tmp = t_0; else tmp = Float64(x * Float64(x * Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)))); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -5e-9) tmp = t_0; elseif ((1.0 / n) <= 5e-220) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 2e-18) tmp = (x - log(x)) / n; elseif ((1.0 / n) <= 5e+161) tmp = t_0; else tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n))); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-9], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-220], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+161], t$95$0, N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-220}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+161}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.0000000000000001e-9 or 2.0000000000000001e-18 < (/.f64 1 n) < 4.9999999999999997e161Initial program 93.4%
Taylor expanded in x around 0 57.9%
*-rgt-identity57.9%
associate-*r/57.9%
unpow-157.9%
exp-to-pow57.9%
unpow-157.9%
Simplified57.9%
if -5.0000000000000001e-9 < (/.f64 1 n) < 5.0000000000000002e-220Initial program 44.1%
Taylor expanded in x around inf 63.7%
exp-prod63.7%
log-rec63.7%
distribute-frac-neg63.7%
exp-prod63.7%
neg-mul-163.7%
remove-double-neg63.7%
*-rgt-identity63.7%
associate-*r/63.7%
unpow-163.7%
exp-to-pow63.7%
unpow-163.7%
*-commutative63.7%
Simplified63.7%
Taylor expanded in n around inf 63.7%
associate-/r*66.5%
Simplified66.5%
if 5.0000000000000002e-220 < (/.f64 1 n) < 2.0000000000000001e-18Initial program 16.4%
Taylor expanded in x around 0 4.0%
fma-def4.0%
unpow24.0%
associate-*r/4.0%
metadata-eval4.0%
unpow24.0%
associate-*r/4.0%
metadata-eval4.0%
Simplified4.0%
Taylor expanded in n around inf 56.5%
*-commutative56.5%
unpow256.5%
Simplified56.5%
Taylor expanded in x around 0 57.0%
if 4.9999999999999997e161 < (/.f64 1 n) Initial program 12.0%
Taylor expanded in x around 0 66.7%
fma-def66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in x around inf 66.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*l*90.8%
Simplified90.8%
Final simplification63.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-43)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+161)
(- (+ 1.0 (/ x n)) t_0)
(* x (* x (- (/ 0.5 (* n n)) (/ 0.5 n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-43) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+161) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / 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) <= (-5d-43)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-9) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d+161) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = x * (x * ((0.5d0 / (n * n)) - (0.5d0 / 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) <= -5e-43) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+161) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-43: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+161: tmp = (1.0 + (x / n)) - t_0 else: tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-43) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+161) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(x * Float64(x * Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-43) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-9) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e+161) tmp = (1.0 + (x / n)) - t_0; else tmp = x * (x * ((0.5 / (n * n)) - (0.5 / 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], -5e-43], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+161], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-43}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+161}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-43Initial program 91.8%
Taylor expanded in x around inf 94.9%
exp-prod94.9%
log-rec94.9%
distribute-frac-neg94.9%
exp-prod94.9%
neg-mul-194.9%
remove-double-neg94.9%
*-rgt-identity94.9%
associate-*r/94.9%
unpow-194.9%
exp-to-pow94.9%
unpow-194.9%
*-commutative94.9%
Simplified94.9%
if -5.00000000000000019e-43 < (/.f64 1 n) < 5.0000000000000001e-9Initial program 35.6%
add-cube-cbrt35.6%
unpow-prod-down35.6%
cbrt-unprod11.0%
inv-pow11.0%
inv-pow11.0%
Applied egg-rr11.0%
*-commutative11.0%
unpow-111.0%
unpow-111.0%
Simplified11.0%
Taylor expanded in n around inf 28.9%
sum-log27.7%
diff-log24.1%
+-commutative24.1%
pow-pow47.7%
pow-prod-up76.4%
metadata-eval76.4%
metadata-eval76.4%
pow176.4%
Applied egg-rr76.4%
if 5.0000000000000001e-9 < (/.f64 1 n) < 4.9999999999999997e161Initial program 76.7%
Taylor expanded in x around 0 70.5%
*-rgt-identity70.5%
associate-*r/70.5%
unpow-170.5%
exp-to-pow70.5%
unpow-170.5%
Simplified70.5%
if 4.9999999999999997e161 < (/.f64 1 n) Initial program 12.0%
Taylor expanded in x around 0 66.7%
fma-def66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in x around inf 66.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*l*90.8%
Simplified90.8%
Final simplification83.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-43)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+161)
(- 1.0 t_0)
(* x (* x (- (/ 0.5 (* n n)) (/ 0.5 n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-43) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+161) {
tmp = 1.0 - t_0;
} else {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / 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) <= (-5d-43)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-9) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d+161) then
tmp = 1.0d0 - t_0
else
tmp = x * (x * ((0.5d0 / (n * n)) - (0.5d0 / 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) <= -5e-43) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+161) {
tmp = 1.0 - t_0;
} else {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-43: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+161: tmp = 1.0 - t_0 else: tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-43) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+161) tmp = Float64(1.0 - t_0); else tmp = Float64(x * Float64(x * Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-43) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-9) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e+161) tmp = 1.0 - t_0; else tmp = x * (x * ((0.5 / (n * n)) - (0.5 / 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], -5e-43], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+161], N[(1.0 - t$95$0), $MachinePrecision], N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-43}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+161}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-43Initial program 91.8%
Taylor expanded in x around inf 94.9%
exp-prod94.9%
log-rec94.9%
distribute-frac-neg94.9%
exp-prod94.9%
neg-mul-194.9%
remove-double-neg94.9%
*-rgt-identity94.9%
associate-*r/94.9%
unpow-194.9%
exp-to-pow94.9%
unpow-194.9%
*-commutative94.9%
Simplified94.9%
if -5.00000000000000019e-43 < (/.f64 1 n) < 5.0000000000000001e-9Initial program 35.6%
add-cube-cbrt35.6%
unpow-prod-down35.6%
cbrt-unprod11.0%
inv-pow11.0%
inv-pow11.0%
Applied egg-rr11.0%
*-commutative11.0%
unpow-111.0%
unpow-111.0%
Simplified11.0%
Taylor expanded in n around inf 28.9%
sum-log27.7%
diff-log24.1%
+-commutative24.1%
pow-pow47.7%
pow-prod-up76.4%
metadata-eval76.4%
metadata-eval76.4%
pow176.4%
Applied egg-rr76.4%
if 5.0000000000000001e-9 < (/.f64 1 n) < 4.9999999999999997e161Initial program 76.7%
Taylor expanded in x around 0 68.6%
*-rgt-identity68.6%
associate-*r/68.6%
unpow-168.6%
exp-to-pow68.6%
unpow-168.6%
Simplified68.6%
if 4.9999999999999997e161 < (/.f64 1 n) Initial program 12.0%
Taylor expanded in x around 0 66.7%
fma-def66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in x around inf 66.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*l*90.8%
Simplified90.8%
Final simplification83.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ (+ 1.0 x) x)) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= n -2.2e-192)
t_0
(if (<= n 3e-309)
t_1
(if (<= n 1e-167)
(* x (* x (- (/ 0.5 (* n n)) (/ 0.5 n))))
(if (<= n 215000000.0) t_1 t_0))))))
double code(double x, double n) {
double t_0 = log(((1.0 + x) / x)) / n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (n <= -2.2e-192) {
tmp = t_0;
} else if (n <= 3e-309) {
tmp = t_1;
} else if (n <= 1e-167) {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n)));
} else if (n <= 215000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log(((1.0d0 + x) / x)) / n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (n <= (-2.2d-192)) then
tmp = t_0
else if (n <= 3d-309) then
tmp = t_1
else if (n <= 1d-167) then
tmp = x * (x * ((0.5d0 / (n * n)) - (0.5d0 / n)))
else if (n <= 215000000.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(((1.0 + x) / x)) / n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (n <= -2.2e-192) {
tmp = t_0;
} else if (n <= 3e-309) {
tmp = t_1;
} else if (n <= 1e-167) {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n)));
} else if (n <= 215000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.log(((1.0 + x) / x)) / n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if n <= -2.2e-192: tmp = t_0 elif n <= 3e-309: tmp = t_1 elif n <= 1e-167: tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n))) elif n <= 215000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (n <= -2.2e-192) tmp = t_0; elseif (n <= 3e-309) tmp = t_1; elseif (n <= 1e-167) tmp = Float64(x * Float64(x * Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)))); elseif (n <= 215000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = log(((1.0 + x) / x)) / n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (n <= -2.2e-192) tmp = t_0; elseif (n <= 3e-309) tmp = t_1; elseif (n <= 1e-167) tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n))); elseif (n <= 215000000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -2.2e-192], t$95$0, If[LessEqual[n, 3e-309], t$95$1, If[LessEqual[n, 1e-167], N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 215000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;n \leq -2.2 \cdot 10^{-192}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 3 \cdot 10^{-309}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;n \leq 10^{-167}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\
\mathbf{elif}\;n \leq 215000000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -2.20000000000000006e-192 or 2.15e8 < n Initial program 50.0%
add-cube-cbrt50.0%
unpow-prod-down50.0%
cbrt-unprod30.9%
inv-pow30.9%
inv-pow30.9%
Applied egg-rr30.9%
*-commutative30.9%
unpow-130.9%
unpow-130.9%
Simplified30.9%
Taylor expanded in n around inf 32.6%
sum-log31.8%
diff-log25.3%
+-commutative25.3%
pow-pow36.7%
pow-prod-up69.9%
metadata-eval69.9%
metadata-eval69.9%
pow169.9%
Applied egg-rr69.9%
if -2.20000000000000006e-192 < n < 3.000000000000001e-309 or 1e-167 < n < 2.15e8Initial program 91.0%
Taylor expanded in x around 0 66.0%
*-rgt-identity66.0%
associate-*r/66.0%
unpow-166.0%
exp-to-pow66.0%
unpow-166.0%
Simplified66.0%
if 3.000000000000001e-309 < n < 1e-167Initial program 12.0%
Taylor expanded in x around 0 66.7%
fma-def66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in x around inf 66.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*r/66.7%
metadata-eval66.7%
unpow266.7%
associate-*l*90.8%
Simplified90.8%
Final simplification70.7%
(FPCore (x n)
:precision binary64
(if (<= x 4.8e-264)
(/ (- (log x)) n)
(if (<= x 7.5e-247)
(/ 1.0 (* n x))
(if (<= x 1.0) (/ (- x (log x)) n) (/ (/ 1.0 n) x)))))
double code(double x, double n) {
double tmp;
if (x <= 4.8e-264) {
tmp = -log(x) / n;
} else if (x <= 7.5e-247) {
tmp = 1.0 / (n * x);
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} 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 (x <= 4.8d-264) then
tmp = -log(x) / n
else if (x <= 7.5d-247) then
tmp = 1.0d0 / (n * x)
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 4.8e-264) {
tmp = -Math.log(x) / n;
} else if (x <= 7.5e-247) {
tmp = 1.0 / (n * x);
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.8e-264: tmp = -math.log(x) / n elif x <= 7.5e-247: tmp = 1.0 / (n * x) elif x <= 1.0: tmp = (x - math.log(x)) / n else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 4.8e-264) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 7.5e-247) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.8e-264) tmp = -log(x) / n; elseif (x <= 7.5e-247) tmp = 1.0 / (n * x); elseif (x <= 1.0) tmp = (x - log(x)) / n; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.8e-264], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 7.5e-247], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-264}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-247}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if x < 4.7999999999999997e-264Initial program 48.5%
Taylor expanded in x around 0 48.5%
*-rgt-identity48.5%
associate-*r/48.5%
unpow-148.5%
exp-to-pow48.5%
unpow-148.5%
Simplified48.5%
Taylor expanded in n around inf 54.3%
associate-*r/54.3%
mul-1-neg54.3%
Simplified54.3%
if 4.7999999999999997e-264 < x < 7.5e-247Initial program 100.0%
Taylor expanded in x around inf 87.5%
exp-prod87.5%
log-rec87.5%
distribute-frac-neg87.5%
exp-prod87.5%
neg-mul-187.5%
remove-double-neg87.5%
*-rgt-identity87.5%
associate-*r/87.5%
unpow-187.5%
exp-to-pow87.5%
unpow-187.5%
*-commutative87.5%
Simplified87.5%
Taylor expanded in n around inf 76.6%
*-commutative76.6%
Simplified76.6%
if 7.5e-247 < x < 1Initial program 43.6%
Taylor expanded in x around 0 35.9%
fma-def35.9%
unpow235.9%
associate-*r/35.9%
metadata-eval35.9%
unpow235.9%
associate-*r/35.9%
metadata-eval35.9%
Simplified35.9%
Taylor expanded in n around inf 45.7%
*-commutative45.7%
unpow245.7%
Simplified45.7%
Taylor expanded in x around 0 45.5%
if 1 < x Initial program 68.0%
Taylor expanded in x around inf 96.8%
exp-prod96.8%
log-rec96.8%
distribute-frac-neg96.8%
exp-prod96.8%
neg-mul-196.8%
remove-double-neg96.8%
*-rgt-identity96.8%
associate-*r/96.8%
unpow-196.8%
exp-to-pow96.8%
unpow-196.8%
*-commutative96.8%
Simplified96.8%
Taylor expanded in n around inf 64.6%
associate-/r*66.7%
Simplified66.7%
Final simplification56.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 5e-264)
t_0
(if (<= x 8.2e-247)
(/ 1.0 (* n x))
(if (<= x 0.52) t_0 (/ (/ 1.0 n) x))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 5e-264) {
tmp = t_0;
} else if (x <= 8.2e-247) {
tmp = 1.0 / (n * x);
} else if (x <= 0.52) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = -log(x) / n
if (x <= 5d-264) then
tmp = t_0
else if (x <= 8.2d-247) then
tmp = 1.0d0 / (n * x)
else if (x <= 0.52d0) then
tmp = t_0
else
tmp = (1.0d0 / n) / x
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 <= 5e-264) {
tmp = t_0;
} else if (x <= 8.2e-247) {
tmp = 1.0 / (n * x);
} else if (x <= 0.52) {
tmp = t_0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 5e-264: tmp = t_0 elif x <= 8.2e-247: tmp = 1.0 / (n * x) elif x <= 0.52: tmp = t_0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 5e-264) tmp = t_0; elseif (x <= 8.2e-247) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 0.52) tmp = t_0; else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (x <= 5e-264) tmp = t_0; elseif (x <= 8.2e-247) tmp = 1.0 / (n * x); elseif (x <= 0.52) tmp = t_0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 5e-264], t$95$0, If[LessEqual[x, 8.2e-247], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.52], t$95$0, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 5 \cdot 10^{-264}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-247}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 0.52:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if x < 5.0000000000000001e-264 or 8.1999999999999997e-247 < x < 0.52000000000000002Initial program 44.4%
Taylor expanded in x around 0 42.9%
*-rgt-identity42.9%
associate-*r/42.9%
unpow-142.9%
exp-to-pow43.0%
unpow-143.0%
Simplified43.0%
Taylor expanded in n around inf 46.4%
associate-*r/46.4%
mul-1-neg46.4%
Simplified46.4%
if 5.0000000000000001e-264 < x < 8.1999999999999997e-247Initial program 100.0%
Taylor expanded in x around inf 87.5%
exp-prod87.5%
log-rec87.5%
distribute-frac-neg87.5%
exp-prod87.5%
neg-mul-187.5%
remove-double-neg87.5%
*-rgt-identity87.5%
associate-*r/87.5%
unpow-187.5%
exp-to-pow87.5%
unpow-187.5%
*-commutative87.5%
Simplified87.5%
Taylor expanded in n around inf 76.6%
*-commutative76.6%
Simplified76.6%
if 0.52000000000000002 < x Initial program 68.0%
Taylor expanded in x around inf 96.8%
exp-prod96.8%
log-rec96.8%
distribute-frac-neg96.8%
exp-prod96.8%
neg-mul-196.8%
remove-double-neg96.8%
*-rgt-identity96.8%
associate-*r/96.8%
unpow-196.8%
exp-to-pow96.8%
unpow-196.8%
*-commutative96.8%
Simplified96.8%
Taylor expanded in n around inf 64.6%
associate-/r*66.7%
Simplified66.7%
Final simplification56.6%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) 5e-7) (/ (/ 1.0 n) x) (* x (* x (- (/ 0.5 (* n n)) (/ 0.5 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 5e-7) {
tmp = (1.0 / n) / x;
} else {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / 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) <= 5d-7) then
tmp = (1.0d0 / n) / x
else
tmp = x * (x * ((0.5d0 / (n * n)) - (0.5d0 / n)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 5e-7) {
tmp = (1.0 / n) / x;
} else {
tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n)));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 5e-7: tmp = (1.0 / n) / x else: tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n))) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 5e-7) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(x * Float64(x * Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= 5e-7) tmp = (1.0 / n) / x; else tmp = x * (x * ((0.5 / (n * n)) - (0.5 / n))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-7], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < 4.99999999999999977e-7Initial program 59.4%
Taylor expanded in x around inf 72.1%
exp-prod72.1%
log-rec72.1%
distribute-frac-neg72.1%
exp-prod72.1%
neg-mul-172.1%
remove-double-neg72.1%
*-rgt-identity72.1%
associate-*r/72.1%
unpow-172.1%
exp-to-pow72.1%
unpow-172.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in n around inf 49.6%
associate-/r*50.7%
Simplified50.7%
if 4.99999999999999977e-7 < (/.f64 1 n) Initial program 43.7%
Taylor expanded in x around 0 66.1%
fma-def66.1%
unpow266.1%
associate-*r/66.1%
metadata-eval66.1%
unpow266.1%
associate-*r/66.1%
metadata-eval66.1%
Simplified66.1%
Taylor expanded in x around inf 40.1%
associate-*r/40.1%
metadata-eval40.1%
unpow240.1%
associate-*r/40.1%
metadata-eval40.1%
unpow240.1%
associate-*l*52.3%
Simplified52.3%
Final simplification51.0%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 61.3%
exp-prod61.3%
log-rec61.3%
distribute-frac-neg61.3%
exp-prod61.3%
neg-mul-161.3%
remove-double-neg61.3%
*-rgt-identity61.3%
associate-*r/61.3%
unpow-161.3%
exp-to-pow61.3%
unpow-161.3%
*-commutative61.3%
Simplified61.3%
Taylor expanded in n around inf 46.7%
*-commutative46.7%
Simplified46.7%
Final simplification46.7%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 61.3%
exp-prod61.3%
log-rec61.3%
distribute-frac-neg61.3%
exp-prod61.3%
neg-mul-161.3%
remove-double-neg61.3%
*-rgt-identity61.3%
associate-*r/61.3%
unpow-161.3%
exp-to-pow61.3%
unpow-161.3%
*-commutative61.3%
Simplified61.3%
Taylor expanded in n around inf 46.7%
associate-/r*47.6%
Simplified47.6%
Final simplification47.6%
(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 56.8%
Taylor expanded in x around 0 22.5%
fma-def22.5%
unpow222.5%
associate-*r/22.5%
metadata-eval22.5%
unpow222.5%
associate-*r/22.5%
metadata-eval22.5%
Simplified22.5%
Taylor expanded in n around inf 25.3%
*-commutative25.3%
unpow225.3%
Simplified25.3%
Taylor expanded in x around 0 25.9%
Taylor expanded in x around inf 4.4%
Final simplification4.4%
herbie shell --seed 2023271
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))