
(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 22 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-70)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-42)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e-25) (/ 1.0 (* 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-70) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-42) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e-25) {
tmp = 1.0 / (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-70)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 2d-42) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 5d-25) then
tmp = 1.0d0 / (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-70) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-42) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e-25) {
tmp = 1.0 / (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-70: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-42: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e-25: tmp = 1.0 / (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-70) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-42) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e-25) tmp = Float64(1.0 / Float64(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-70) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 2e-42) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 5e-25) tmp = 1.0 / (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-70], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-42], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], N[(1.0 / N[(x * n), $MachinePrecision]), $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^{-70}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-70Initial program 83.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
if -4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000008e-42Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites84.2%
Applied rewrites64.4%
Taylor expanded in n around inf
Applied rewrites84.4%
Applied rewrites84.4%
if 2.00000000000000008e-42 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 5.8%
Taylor expanded in n around -inf
Applied rewrites5.8%
Applied rewrites1.5%
Taylor expanded in n around inf
Applied rewrites5.8%
Taylor expanded in x around inf
Applied rewrites99.7%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 45.4%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6493.4
Applied rewrites93.4%
Taylor expanded in x around 0
lower-/.f6493.4
Applied rewrites93.4%
(FPCore (x n)
:precision binary64
(if (<= x 40.0)
(/
(+
(/
(fma
0.5
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
(/ (* 0.16666666666666666 (- (pow (log1p x) 3.0) (pow (log x) 3.0))) n))
n)
(- (log1p x) (log x)))
n)
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 40.0) {
tmp = ((fma(0.5, (pow(log1p(x), 2.0) - pow(log(x), 2.0)), ((0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0))) / n)) / n) + (log1p(x) - log(x))) / n;
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 40.0) tmp = Float64(Float64(Float64(fma(0.5, Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), Float64(Float64(0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / n)) / n) + Float64(log1p(x) - log(x))) / n); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 40.0], N[(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] + N[(N[(0.16666666666666666 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 40:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(0.5, {\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n}\right)}{n} + \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 40Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
if 40 < x Initial program 63.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(if (<= x 40.0)
(-
(/
(+
(log1p x)
(/
(fma
0.5
(* (log (* x (+ x 1.0))) (log (/ (+ x 1.0) x)))
(*
(- (pow (log1p x) 3.0) (pow (log x) 3.0))
(/ 0.16666666666666666 n)))
n))
n)
(/ (log x) n))
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 40.0) {
tmp = ((log1p(x) + (fma(0.5, (log((x * (x + 1.0))) * log(((x + 1.0) / x))), ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) * (0.16666666666666666 / n))) / n)) / n) - (log(x) / n);
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 40.0) tmp = Float64(Float64(Float64(log1p(x) + Float64(fma(0.5, Float64(log(Float64(x * Float64(x + 1.0))) * log(Float64(Float64(x + 1.0) / x))), Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) * Float64(0.16666666666666666 / n))) / n)) / n) - Float64(log(x) / n)); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 40.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[Log[N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 40:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(0.5, \log \left(x \cdot \left(x + 1\right)\right) \cdot \log \left(\frac{x + 1}{x}\right), \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right) \cdot \frac{0.16666666666666666}{n}\right)}{n}}{n} - \frac{\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 40Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
Applied rewrites81.5%
if 40 < x Initial program 63.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(if (<= x 40.0)
(/
1.0
(/
n
(-
(/
(fma
(- (pow (log1p x) 3.0) (pow (log x) 3.0))
(/ 0.16666666666666666 n)
(* (log (fma x x x)) (* 0.5 (log (/ (+ x 1.0) x)))))
n)
(log (/ x (+ x 1.0))))))
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 40.0) {
tmp = 1.0 / (n / ((fma((pow(log1p(x), 3.0) - pow(log(x), 3.0)), (0.16666666666666666 / n), (log(fma(x, x, x)) * (0.5 * log(((x + 1.0) / x))))) / n) - log((x / (x + 1.0)))));
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 40.0) tmp = Float64(1.0 / Float64(n / Float64(Float64(fma(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)), Float64(0.16666666666666666 / n), Float64(log(fma(x, x, x)) * Float64(0.5 * log(Float64(Float64(x + 1.0) / x))))) / n) - log(Float64(x / Float64(x + 1.0)))))); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 40.0], N[(1.0 / N[(n / N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 / n), $MachinePrecision] + N[(N[Log[N[(x * x + x), $MachinePrecision]], $MachinePrecision] * N[(0.5 * N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 40:\\
\;\;\;\;\frac{1}{\frac{n}{\frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}, \frac{0.16666666666666666}{n}, \log \left(\mathsf{fma}\left(x, x, x\right)\right) \cdot \left(0.5 \cdot \log \left(\frac{x + 1}{x}\right)\right)\right)}{n} - \log \left(\frac{x}{x + 1}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 40Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
Applied rewrites81.4%
Applied rewrites81.5%
if 40 < x Initial program 63.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(if (<= x 40.0)
(*
(/ 1.0 n)
(-
(/
(fma
0.5
(* (log (* x (+ x 1.0))) (log (/ (+ x 1.0) x)))
(* (- (pow (log1p x) 3.0) (pow (log x) 3.0)) (/ 0.16666666666666666 n)))
n)
(log (/ x (+ x 1.0)))))
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 40.0) {
tmp = (1.0 / n) * ((fma(0.5, (log((x * (x + 1.0))) * log(((x + 1.0) / x))), ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) * (0.16666666666666666 / n))) / n) - log((x / (x + 1.0))));
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 40.0) tmp = Float64(Float64(1.0 / n) * Float64(Float64(fma(0.5, Float64(log(Float64(x * Float64(x + 1.0))) * log(Float64(Float64(x + 1.0) / x))), Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) * Float64(0.16666666666666666 / n))) / n) - log(Float64(x / Float64(x + 1.0))))); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 40.0], N[(N[(1.0 / n), $MachinePrecision] * N[(N[(N[(0.5 * N[(N[Log[N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 40:\\
\;\;\;\;\frac{1}{n} \cdot \left(\frac{\mathsf{fma}\left(0.5, \log \left(x \cdot \left(x + 1\right)\right) \cdot \log \left(\frac{x + 1}{x}\right), \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right) \cdot \frac{0.16666666666666666}{n}\right)}{n} - \log \left(\frac{x}{x + 1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 40Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
Applied rewrites81.4%
if 40 < x Initial program 63.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(if (<= x 40.0)
(*
(/ 1.0 n)
(-
(/
(fma
0.5
(* (log (* x (+ x 1.0))) (log (/ (+ x 1.0) x)))
(* (/ 0.16666666666666666 n) (- (pow (log x) 3.0))))
n)
(log (/ x (+ x 1.0)))))
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 40.0) {
tmp = (1.0 / n) * ((fma(0.5, (log((x * (x + 1.0))) * log(((x + 1.0) / x))), ((0.16666666666666666 / n) * -pow(log(x), 3.0))) / n) - log((x / (x + 1.0))));
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 40.0) tmp = Float64(Float64(1.0 / n) * Float64(Float64(fma(0.5, Float64(log(Float64(x * Float64(x + 1.0))) * log(Float64(Float64(x + 1.0) / x))), Float64(Float64(0.16666666666666666 / n) * Float64(-(log(x) ^ 3.0)))) / n) - log(Float64(x / Float64(x + 1.0))))); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 40.0], N[(N[(1.0 / n), $MachinePrecision] * N[(N[(N[(0.5 * N[(N[Log[N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(0.16666666666666666 / n), $MachinePrecision] * (-N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 40:\\
\;\;\;\;\frac{1}{n} \cdot \left(\frac{\mathsf{fma}\left(0.5, \log \left(x \cdot \left(x + 1\right)\right) \cdot \log \left(\frac{x + 1}{x}\right), \frac{0.16666666666666666}{n} \cdot \left(-{\log x}^{3}\right)\right)}{n} - \log \left(\frac{x}{x + 1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 40Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
Applied rewrites81.4%
Taylor expanded in x around 0
Applied rewrites81.4%
if 40 < x Initial program 63.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 (- INFINITY))
(- 1.0 t_0)
(if (<= t_1 0.05)
(/ (log (/ (+ x 1.0) x)) n)
(- (fma x (fma x (+ (/ 0.5 (* n n)) (/ -0.5 n)) (/ 1.0 n)) 1.0) 1.0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.05) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = fma(x, fma(x, ((0.5 / (n * n)) + (-0.5 / n)), (1.0 / n)), 1.0) - 1.0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(1.0 - t_0); elseif (t_1 <= 0.05) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(fma(x, fma(x, Float64(Float64(0.5 / Float64(n * n)) + Float64(-0.5 / n)), Float64(1.0 / n)), 1.0) - 1.0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.05], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 0.05:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} + \frac{-0.5}{n}, \frac{1}{n}\right), 1\right) - 1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -inf.0Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
if -inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.050000000000000003Initial program 39.5%
Taylor expanded in n around -inf
Applied rewrites79.3%
Applied rewrites57.3%
Taylor expanded in n around inf
Applied rewrites78.7%
Applied rewrites78.7%
if 0.050000000000000003 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 42.9%
Taylor expanded in x around 0
Applied rewrites39.8%
Taylor expanded in n around inf
Applied rewrites2.3%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
sub-negN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6446.3
Applied rewrites46.3%
(FPCore (x n)
:precision binary64
(if (<= x 0.32)
(+
(/
(-
(fma
-0.5
(/ (pow (log x) 2.0) n)
(/ (* (pow (log x) 3.0) -0.16666666666666666) (* n n)))
(log x))
n)
(/ x n))
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 0.32) {
tmp = ((fma(-0.5, (pow(log(x), 2.0) / n), ((pow(log(x), 3.0) * -0.16666666666666666) / (n * n))) - log(x)) / n) + (x / n);
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 0.32) tmp = Float64(Float64(Float64(fma(-0.5, Float64((log(x) ^ 2.0) / n), Float64(Float64((log(x) ^ 3.0) * -0.16666666666666666) / Float64(n * n))) - log(x)) / n) + Float64(x / n)); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 0.32], N[(N[(N[(N[(-0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] + N[(N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(x / n), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.32:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.5, \frac{{\log x}^{2}}{n}, \frac{{\log x}^{3} \cdot -0.16666666666666666}{n \cdot n}\right) - \log x}{n} + \frac{x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 0.320000000000000007Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
Taylor expanded in x around 0
Applied rewrites80.0%
if 0.320000000000000007 < x Initial program 63.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification87.0%
(FPCore (x n)
:precision binary64
(if (<= x 1.25e-6)
(/
(-
(log x)
(fma
-0.5
(/ (pow (log x) 2.0) n)
(/ (* (pow (log x) 3.0) -0.16666666666666666) (* n n))))
(- n))
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 1.25e-6) {
tmp = (log(x) - fma(-0.5, (pow(log(x), 2.0) / n), ((pow(log(x), 3.0) * -0.16666666666666666) / (n * n)))) / -n;
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1.25e-6) tmp = Float64(Float64(log(x) - fma(-0.5, Float64((log(x) ^ 2.0) / n), Float64(Float64((log(x) ^ 3.0) * -0.16666666666666666) / Float64(n * n)))) / Float64(-n)); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 1.25e-6], N[(N[(N[Log[x], $MachinePrecision] - N[(-0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] + N[(N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.25 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log x - \mathsf{fma}\left(-0.5, \frac{{\log x}^{2}}{n}, \frac{{\log x}^{3} \cdot -0.16666666666666666}{n \cdot n}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 1.2500000000000001e-6Initial program 35.6%
Taylor expanded in n around -inf
Applied rewrites81.9%
Taylor expanded in x around 0
Applied rewrites81.1%
if 1.2500000000000001e-6 < x Initial program 62.8%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6494.0
Applied rewrites94.0%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-70)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-42)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e-25)
(/ 1.0 (* x n))
(-
(fma
x
(/
(-
(/
(fma 0.16666666666666666 (/ (* x x) n) (* x (fma x -0.5 0.5)))
n)
(fma x (fma x -0.3333333333333333 0.5) -1.0))
n)
1.0)
t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-70) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-42) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e-25) {
tmp = 1.0 / (x * n);
} else {
tmp = fma(x, (((fma(0.16666666666666666, ((x * x) / n), (x * fma(x, -0.5, 0.5))) / n) - fma(x, fma(x, -0.3333333333333333, 0.5), -1.0)) / n), 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-70) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-42) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e-25) tmp = Float64(1.0 / Float64(x * n)); else tmp = Float64(fma(x, Float64(Float64(Float64(fma(0.16666666666666666, Float64(Float64(x * x) / n), Float64(x * fma(x, -0.5, 0.5))) / n) - fma(x, fma(x, -0.3333333333333333, 0.5), -1.0)) / n), 1.0) - 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-70], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-42], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(N[(N[(0.16666666666666666 * N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision] + N[(x * N[(x * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(x * N[(x * -0.3333333333333333 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + 1.0), $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^{-70}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{\frac{\mathsf{fma}\left(0.16666666666666666, \frac{x \cdot x}{n}, x \cdot \mathsf{fma}\left(x, -0.5, 0.5\right)\right)}{n} - \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.3333333333333333, 0.5\right), -1\right)}{n}, 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-70Initial program 83.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
if -4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000008e-42Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites84.2%
Applied rewrites64.4%
Taylor expanded in n around inf
Applied rewrites84.4%
Applied rewrites84.4%
if 2.00000000000000008e-42 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 5.8%
Taylor expanded in n around -inf
Applied rewrites5.8%
Applied rewrites1.5%
Taylor expanded in n around inf
Applied rewrites5.8%
Taylor expanded in x around inf
Applied rewrites99.7%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 45.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites25.7%
Taylor expanded in n around -inf
Applied rewrites67.9%
Final simplification85.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-70)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-42)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e-25)
(/ 1.0 (* x n))
(-
(fma x (fma x (+ (/ 0.5 (* n n)) (/ -0.5 n)) (/ 1.0 n)) 1.0)
t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-70) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-42) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e-25) {
tmp = 1.0 / (x * n);
} else {
tmp = fma(x, fma(x, ((0.5 / (n * n)) + (-0.5 / n)), (1.0 / n)), 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-70) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-42) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e-25) tmp = Float64(1.0 / Float64(x * n)); else tmp = Float64(fma(x, fma(x, Float64(Float64(0.5 / Float64(n * n)) + Float64(-0.5 / n)), Float64(1.0 / n)), 1.0) - 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-70], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-42], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] + 1.0), $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^{-70}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} + \frac{-0.5}{n}, \frac{1}{n}\right), 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-70Initial program 83.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
if -4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000008e-42Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites84.2%
Applied rewrites64.4%
Taylor expanded in n around inf
Applied rewrites84.4%
Applied rewrites84.4%
if 2.00000000000000008e-42 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 5.8%
Taylor expanded in n around -inf
Applied rewrites5.8%
Applied rewrites1.5%
Taylor expanded in n around inf
Applied rewrites5.8%
Taylor expanded in x around inf
Applied rewrites99.7%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 45.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
sub-negN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6466.6
Applied rewrites66.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-70)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-42)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e-25)
(/ 1.0 (* x n))
(- (fma x (/ (+ 1.0 (fma x -0.5 (* 0.5 (/ x n)))) n) 1.0) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-70) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-42) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e-25) {
tmp = 1.0 / (x * n);
} else {
tmp = fma(x, ((1.0 + fma(x, -0.5, (0.5 * (x / n)))) / n), 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-70) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-42) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e-25) tmp = Float64(1.0 / Float64(x * n)); else tmp = Float64(fma(x, Float64(Float64(1.0 + fma(x, -0.5, Float64(0.5 * Float64(x / n)))) / n), 1.0) - 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-70], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-42], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(1.0 + N[(x * -0.5 + N[(0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + 1.0), $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^{-70}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{1 + \mathsf{fma}\left(x, -0.5, 0.5 \cdot \frac{x}{n}\right)}{n}, 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-70Initial program 83.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
if -4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000008e-42Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites84.2%
Applied rewrites64.4%
Taylor expanded in n around inf
Applied rewrites84.4%
Applied rewrites84.4%
if 2.00000000000000008e-42 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 5.8%
Taylor expanded in n around -inf
Applied rewrites5.8%
Applied rewrites1.5%
Taylor expanded in n around inf
Applied rewrites5.8%
Taylor expanded in x around inf
Applied rewrites99.7%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 45.4%
Taylor expanded in x around 0
Applied rewrites42.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6466.6
Applied rewrites66.6%
Taylor expanded in n around inf
Applied rewrites62.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-70)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-42)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e-25)
(/ 1.0 (* x n))
(- (fma x (/ (fma x (fma n -0.5 0.5) n) (* n n)) 1.0) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-70) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-42) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e-25) {
tmp = 1.0 / (x * n);
} else {
tmp = fma(x, (fma(x, fma(n, -0.5, 0.5), n) / (n * n)), 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-70) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-42) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e-25) tmp = Float64(1.0 / Float64(x * n)); else tmp = Float64(fma(x, Float64(fma(x, fma(n, -0.5, 0.5), n) / Float64(n * n)), 1.0) - 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-70], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-42], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(x * N[(n * -0.5 + 0.5), $MachinePrecision] + n), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + 1.0), $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^{-70}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(n, -0.5, 0.5\right), n\right)}{n \cdot n}, 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-70Initial program 83.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
if -4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000008e-42Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites84.2%
Applied rewrites64.4%
Taylor expanded in n around inf
Applied rewrites84.4%
Applied rewrites84.4%
if 2.00000000000000008e-42 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 5.8%
Taylor expanded in n around -inf
Applied rewrites5.8%
Applied rewrites1.5%
Taylor expanded in n around inf
Applied rewrites5.8%
Taylor expanded in x around inf
Applied rewrites99.7%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) Initial program 45.4%
Taylor expanded in x around 0
Applied rewrites42.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6466.6
Applied rewrites66.6%
Taylor expanded in n around 0
Applied rewrites59.0%
Taylor expanded in x around 0
Applied rewrites59.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-70)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-42)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e-25)
(/ 1.0 (* x n))
(if (<= (/ 1.0 n) 5e+151)
(- (+ 1.0 (/ x n)) t_0)
(-
(fma x (fma x (+ (/ 0.5 (* n n)) (/ -0.5 n)) (/ 1.0 n)) 1.0)
1.0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-70) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-42) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e-25) {
tmp = 1.0 / (x * n);
} else if ((1.0 / n) <= 5e+151) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = fma(x, fma(x, ((0.5 / (n * n)) + (-0.5 / n)), (1.0 / n)), 1.0) - 1.0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-70) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-42) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e-25) tmp = Float64(1.0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 5e+151) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(fma(x, fma(x, Float64(Float64(0.5 / Float64(n * n)) + Float64(-0.5 / n)), Float64(1.0 / n)), 1.0) - 1.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-70], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-42], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+151], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - 1.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^{-70}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+151}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} + \frac{-0.5}{n}, \frac{1}{n}\right), 1\right) - 1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-70Initial program 83.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
if -4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000008e-42Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites84.2%
Applied rewrites64.4%
Taylor expanded in n around inf
Applied rewrites84.4%
Applied rewrites84.4%
if 2.00000000000000008e-42 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 5.8%
Taylor expanded in n around -inf
Applied rewrites5.8%
Applied rewrites1.5%
Taylor expanded in n around inf
Applied rewrites5.8%
Taylor expanded in x around inf
Applied rewrites99.7%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000002e151Initial program 67.8%
Taylor expanded in x around 0
*-rgt-identityN/A
associate-*r/N/A
lower-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6464.5
Applied rewrites64.5%
if 5.0000000000000002e151 < (/.f64 #s(literal 1 binary64) n) Initial program 27.3%
Taylor expanded in x around 0
Applied rewrites27.3%
Taylor expanded in n around inf
Applied rewrites2.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
sub-negN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-70)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-42)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e-25)
(/ 1.0 (* x n))
(if (<= (/ 1.0 n) 5e+151)
(- 1.0 t_0)
(-
(fma x (fma x (+ (/ 0.5 (* n n)) (/ -0.5 n)) (/ 1.0 n)) 1.0)
1.0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-70) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-42) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e-25) {
tmp = 1.0 / (x * n);
} else if ((1.0 / n) <= 5e+151) {
tmp = 1.0 - t_0;
} else {
tmp = fma(x, fma(x, ((0.5 / (n * n)) + (-0.5 / n)), (1.0 / n)), 1.0) - 1.0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-70) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-42) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e-25) tmp = Float64(1.0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 5e+151) tmp = Float64(1.0 - t_0); else tmp = Float64(fma(x, fma(x, Float64(Float64(0.5 / Float64(n * n)) + Float64(-0.5 / n)), Float64(1.0 / n)), 1.0) - 1.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-70], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-42], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+151], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - 1.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^{-70}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+151}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} + \frac{-0.5}{n}, \frac{1}{n}\right), 1\right) - 1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-70Initial program 83.1%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
lower-pow.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
if -4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000008e-42Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites84.2%
Applied rewrites64.4%
Taylor expanded in n around inf
Applied rewrites84.4%
Applied rewrites84.4%
if 2.00000000000000008e-42 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999962e-25Initial program 5.8%
Taylor expanded in n around -inf
Applied rewrites5.8%
Applied rewrites1.5%
Taylor expanded in n around inf
Applied rewrites5.8%
Taylor expanded in x around inf
Applied rewrites99.7%
if 4.99999999999999962e-25 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000002e151Initial program 67.8%
Taylor expanded in x around 0
Applied rewrites62.1%
if 5.0000000000000002e151 < (/.f64 #s(literal 1 binary64) n) Initial program 27.3%
Taylor expanded in x around 0
Applied rewrites27.3%
Taylor expanded in n around inf
Applied rewrites2.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
sub-negN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
(FPCore (x n)
:precision binary64
(if (<= x 0.88)
(- (/ x n) (/ (log x) n))
(if (<= x 1.02e+170)
(/
(/ (+ -1.0 (/ (- 0.5 (/ (- 0.3333333333333333 (/ 0.25 x)) x)) x)) x)
(- n))
(- 1.0 1.0))))
double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (x / n) - (log(x) / n);
} else if (x <= 1.02e+170) {
tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n;
} else {
tmp = 1.0 - 1.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 / n) - (log(x) / n)
else if (x <= 1.02d+170) then
tmp = (((-1.0d0) + ((0.5d0 - ((0.3333333333333333d0 - (0.25d0 / x)) / x)) / x)) / x) / -n
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (x / n) - (Math.log(x) / n);
} else if (x <= 1.02e+170) {
tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.88: tmp = (x / n) - (math.log(x) / n) elif x <= 1.02e+170: tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.88) tmp = Float64(Float64(x / n) - Float64(log(x) / n)); elseif (x <= 1.02e+170) tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 - Float64(0.25 / x)) / x)) / x)) / x) / Float64(-n)); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.88) tmp = (x / n) - (log(x) / n); elseif (x <= 1.02e+170) tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.88], N[(N[(x / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.02e+170], N[(N[(N[(-1.0 + N[(N[(0.5 - N[(N[(0.3333333333333333 - N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / (-n)), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.88:\\
\;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+170}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25}{x}}{x}}{x}}{x}}{-n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 0.880000000000000004Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
Applied rewrites81.4%
Taylor expanded in n around inf
Applied rewrites57.7%
Taylor expanded in x around 0
Applied rewrites56.8%
if 0.880000000000000004 < x < 1.02000000000000002e170Initial program 46.5%
Taylor expanded in n around -inf
Applied rewrites48.1%
Applied rewrites44.8%
Taylor expanded in n around inf
Applied rewrites48.8%
Taylor expanded in x around -inf
Applied rewrites76.7%
if 1.02000000000000002e170 < x Initial program 83.4%
Taylor expanded in x around 0
Applied rewrites55.1%
Taylor expanded in n around inf
Applied rewrites83.4%
Final simplification66.4%
(FPCore (x n)
:precision binary64
(if (<= x 0.88)
(/ (- (log x) x) (- n))
(if (<= x 1.02e+170)
(/
(/ (+ -1.0 (/ (- 0.5 (/ (- 0.3333333333333333 (/ 0.25 x)) x)) x)) x)
(- n))
(- 1.0 1.0))))
double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (log(x) - x) / -n;
} else if (x <= 1.02e+170) {
tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n;
} else {
tmp = 1.0 - 1.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 = (log(x) - x) / -n
else if (x <= 1.02d+170) then
tmp = (((-1.0d0) + ((0.5d0 - ((0.3333333333333333d0 - (0.25d0 / x)) / x)) / x)) / x) / -n
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (Math.log(x) - x) / -n;
} else if (x <= 1.02e+170) {
tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.88: tmp = (math.log(x) - x) / -n elif x <= 1.02e+170: tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.88) tmp = Float64(Float64(log(x) - x) / Float64(-n)); elseif (x <= 1.02e+170) tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 - Float64(0.25 / x)) / x)) / x)) / x) / Float64(-n)); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.88) tmp = (log(x) - x) / -n; elseif (x <= 1.02e+170) tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.88], N[(N[(N[Log[x], $MachinePrecision] - x), $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.02e+170], N[(N[(N[(-1.0 + N[(N[(0.5 - N[(N[(0.3333333333333333 - N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / (-n)), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.88:\\
\;\;\;\;\frac{\log x - x}{-n}\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+170}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25}{x}}{x}}{x}}{x}}{-n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 0.880000000000000004Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
Applied rewrites81.4%
Taylor expanded in n around inf
Applied rewrites57.7%
Taylor expanded in x around 0
Applied rewrites56.8%
if 0.880000000000000004 < x < 1.02000000000000002e170Initial program 46.5%
Taylor expanded in n around -inf
Applied rewrites48.1%
Applied rewrites44.8%
Taylor expanded in n around inf
Applied rewrites48.8%
Taylor expanded in x around -inf
Applied rewrites76.7%
if 1.02000000000000002e170 < x Initial program 83.4%
Taylor expanded in x around 0
Applied rewrites55.1%
Taylor expanded in n around inf
Applied rewrites83.4%
Final simplification66.4%
(FPCore (x n)
:precision binary64
(if (<= x 0.7)
(/ (log x) (- n))
(if (<= x 1.02e+170)
(/
(/ (+ -1.0 (/ (- 0.5 (/ (- 0.3333333333333333 (/ 0.25 x)) x)) x)) x)
(- n))
(- 1.0 1.0))))
double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = log(x) / -n;
} else if (x <= 1.02e+170) {
tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n;
} else {
tmp = 1.0 - 1.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.7d0) then
tmp = log(x) / -n
else if (x <= 1.02d+170) then
tmp = (((-1.0d0) + ((0.5d0 - ((0.3333333333333333d0 - (0.25d0 / x)) / x)) / x)) / x) / -n
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = Math.log(x) / -n;
} else if (x <= 1.02e+170) {
tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.7: tmp = math.log(x) / -n elif x <= 1.02e+170: tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.7) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.02e+170) tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 - Float64(0.25 / x)) / x)) / x)) / x) / Float64(-n)); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.7) tmp = log(x) / -n; elseif (x <= 1.02e+170) tmp = ((-1.0 + ((0.5 - ((0.3333333333333333 - (0.25 / x)) / x)) / x)) / x) / -n; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.7], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.02e+170], N[(N[(N[(-1.0 + N[(N[(0.5 - N[(N[(0.3333333333333333 - N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / (-n)), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+170}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25}{x}}{x}}{x}}{x}}{-n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial program 36.7%
Taylor expanded in n around -inf
Applied rewrites81.5%
Applied rewrites81.4%
Taylor expanded in n around inf
Applied rewrites57.7%
Taylor expanded in x around 0
Applied rewrites56.4%
if 0.69999999999999996 < x < 1.02000000000000002e170Initial program 46.5%
Taylor expanded in n around -inf
Applied rewrites48.1%
Applied rewrites44.8%
Taylor expanded in n around inf
Applied rewrites48.8%
Taylor expanded in x around -inf
Applied rewrites76.7%
if 1.02000000000000002e170 < x Initial program 83.4%
Taylor expanded in x around 0
Applied rewrites55.1%
Taylor expanded in n around inf
Applied rewrites83.4%
Final simplification66.2%
(FPCore (x n) :precision binary64 (if (<= x 1.02e+170) (/ (/ (+ -1.0 (/ (- 0.5 (/ 0.3333333333333333 x)) x)) x) (- n)) (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if (x <= 1.02e+170) {
tmp = ((-1.0 + ((0.5 - (0.3333333333333333 / x)) / x)) / x) / -n;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.02d+170) then
tmp = (((-1.0d0) + ((0.5d0 - (0.3333333333333333d0 / x)) / x)) / x) / -n
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.02e+170) {
tmp = ((-1.0 + ((0.5 - (0.3333333333333333 / x)) / x)) / x) / -n;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.02e+170: tmp = ((-1.0 + ((0.5 - (0.3333333333333333 / x)) / x)) / x) / -n else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.02e+170) tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 - Float64(0.3333333333333333 / x)) / x)) / x) / Float64(-n)); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.02e+170) tmp = ((-1.0 + ((0.5 - (0.3333333333333333 / x)) / x)) / x) / -n; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.02e+170], N[(N[(N[(-1.0 + N[(N[(0.5 - N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / (-n)), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{+170}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 - \frac{0.3333333333333333}{x}}{x}}{x}}{-n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 1.02000000000000002e170Initial program 39.5%
Taylor expanded in n around -inf
Applied rewrites72.0%
Applied rewrites71.1%
Taylor expanded in n around inf
Applied rewrites55.2%
Taylor expanded in x around -inf
Applied rewrites42.4%
if 1.02000000000000002e170 < x Initial program 83.4%
Taylor expanded in x around 0
Applied rewrites55.1%
Taylor expanded in n around inf
Applied rewrites83.4%
Final simplification50.1%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -10.0) (- 1.0 1.0) (/ (/ -1.0 x) (- n))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -10.0) {
tmp = 1.0 - 1.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) :: tmp
if ((1.0d0 / n) <= (-10.0d0)) then
tmp = 1.0d0 - 1.0d0
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) <= -10.0) {
tmp = 1.0 - 1.0;
} else {
tmp = (-1.0 / x) / -n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -10.0: tmp = 1.0 - 1.0 else: tmp = (-1.0 / x) / -n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -10.0) tmp = Float64(1.0 - 1.0); else tmp = Float64(Float64(-1.0 / x) / Float64(-n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -10.0) tmp = 1.0 - 1.0; else tmp = (-1.0 / x) / -n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -10.0], N[(1.0 - 1.0), $MachinePrecision], N[(N[(-1.0 / x), $MachinePrecision] / (-n)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10:\\
\;\;\;\;1 - 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{x}}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites55.5%
Taylor expanded in n around inf
Applied rewrites46.7%
if -10 < (/.f64 #s(literal 1 binary64) n) Initial program 31.3%
Taylor expanded in n around -inf
Applied rewrites72.4%
Applied rewrites58.0%
Taylor expanded in n around inf
Applied rewrites65.1%
Taylor expanded in x around inf
Applied rewrites46.1%
Final simplification46.3%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -10.0) (- 1.0 1.0) (/ 1.0 (* x n))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -10.0) {
tmp = 1.0 - 1.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) :: tmp
if ((1.0d0 / n) <= (-10.0d0)) then
tmp = 1.0d0 - 1.0d0
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) <= -10.0) {
tmp = 1.0 - 1.0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -10.0: tmp = 1.0 - 1.0 else: tmp = 1.0 / (x * n) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -10.0) tmp = Float64(1.0 - 1.0); 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) <= -10.0) tmp = 1.0 - 1.0; else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -10.0], N[(1.0 - 1.0), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10:\\
\;\;\;\;1 - 1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites55.5%
Taylor expanded in n around inf
Applied rewrites46.7%
if -10 < (/.f64 #s(literal 1 binary64) n) Initial program 31.3%
Taylor expanded in n around -inf
Applied rewrites72.4%
Applied rewrites58.0%
Taylor expanded in n around inf
Applied rewrites65.1%
Taylor expanded in x around inf
Applied rewrites45.6%
(FPCore (x n) :precision binary64 (- 1.0 1.0))
double code(double x, double n) {
return 1.0 - 1.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 - 1.0d0
end function
public static double code(double x, double n) {
return 1.0 - 1.0;
}
def code(x, n): return 1.0 - 1.0
function code(x, n) return Float64(1.0 - 1.0) end
function tmp = code(x, n) tmp = 1.0 - 1.0; end
code[x_, n_] := N[(1.0 - 1.0), $MachinePrecision]
\begin{array}{l}
\\
1 - 1
\end{array}
Initial program 47.7%
Taylor expanded in x around 0
Applied rewrites36.7%
Taylor expanded in n around inf
Applied rewrites28.6%
herbie shell --seed 2024227
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))