
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(if (<= x 1650000.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 <= 1650000.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 <= 1650000.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, 1650000.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 1650000:\\
\;\;\;\;\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 < 1.65e6Initial program 45.7%
Taylor expanded in n around -inf
Applied rewrites77.2%
if 1.65e6 < x Initial program 64.5%
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-*.f6498.9
Applied rewrites98.9%
Final simplification87.0%
(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 -2e-5)
(- 1.0 t_0)
(if (<= t_1 0.9101169306103679)
(/ (log (/ x (+ x 1.0))) (- n))
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))))))
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 <= -2e-5) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.9101169306103679) {
tmp = log((x / (x + 1.0))) / -n;
} else {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = ((x + 1.0d0) ** (1.0d0 / n)) - t_0
if (t_1 <= (-2d-5)) then
tmp = 1.0d0 - t_0
else if (t_1 <= 0.9101169306103679d0) then
tmp = log((x / (x + 1.0d0))) / -n
else
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -2e-5) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.9101169306103679) {
tmp = Math.log((x / (x + 1.0))) / -n;
} else {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -2e-5: tmp = 1.0 - t_0 elif t_1 <= 0.9101169306103679: tmp = math.log((x / (x + 1.0))) / -n else: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) 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 <= -2e-5) tmp = Float64(1.0 - t_0); elseif (t_1 <= 0.9101169306103679) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); else tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0; tmp = 0.0; if (t_1 <= -2e-5) tmp = 1.0 - t_0; elseif (t_1 <= 0.9101169306103679) tmp = log((x / (x + 1.0))) / -n; else tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, 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, -2e-5], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.9101169306103679], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $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 -2 \cdot 10^{-5}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 0.9101169306103679:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\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))) < -2.00000000000000016e-5Initial program 98.8%
Taylor expanded in x around 0
Applied rewrites98.8%
if -2.00000000000000016e-5 < (-.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.910116930610367914Initial program 45.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6474.8
Applied rewrites74.8%
Applied rewrites75.0%
if 0.910116930610367914 < (-.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 44.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.0
Applied rewrites6.0%
Taylor expanded in x around inf
Applied rewrites0.1%
Taylor expanded in n around 0
Applied rewrites0.1%
Taylor expanded in x around inf
Applied rewrites42.9%
Final simplification73.5%
(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 -2e-5)
(- 1.0 t_0)
(if (<= t_1 0.9101169306103679)
(/ (log (/ (+ x 1.0) x)) n)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))))))
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 <= -2e-5) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.9101169306103679) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = ((x + 1.0d0) ** (1.0d0 / n)) - t_0
if (t_1 <= (-2d-5)) then
tmp = 1.0d0 - t_0
else if (t_1 <= 0.9101169306103679d0) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -2e-5) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.9101169306103679) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -2e-5: tmp = 1.0 - t_0 elif t_1 <= 0.9101169306103679: tmp = math.log(((x + 1.0) / x)) / n else: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) 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 <= -2e-5) tmp = Float64(1.0 - t_0); elseif (t_1 <= 0.9101169306103679) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0; tmp = 0.0; if (t_1 <= -2e-5) tmp = 1.0 - t_0; elseif (t_1 <= 0.9101169306103679) tmp = log(((x + 1.0) / x)) / n; else tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, 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, -2e-5], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.9101169306103679], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $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 -2 \cdot 10^{-5}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 0.9101169306103679:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\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))) < -2.00000000000000016e-5Initial program 98.8%
Taylor expanded in x around 0
Applied rewrites98.8%
if -2.00000000000000016e-5 < (-.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.910116930610367914Initial program 45.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6474.8
Applied rewrites74.8%
Applied rewrites75.0%
if 0.910116930610367914 < (-.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 44.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.0
Applied rewrites6.0%
Taylor expanded in x around inf
Applied rewrites0.1%
Taylor expanded in n around 0
Applied rewrites0.1%
Taylor expanded in x around inf
Applied rewrites42.9%
Final simplification73.5%
(FPCore (x n)
:precision binary64
(if (<= x 1.0)
(/
(-
(- (log x) 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.0) {
tmp = ((log(x) - 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.0) tmp = Float64(Float64(Float64(log(x) - 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.0], N[(N[(N[(N[Log[x], $MachinePrecision] - 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:\\
\;\;\;\;\frac{\left(\log x - x\right) - \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 < 1Initial program 46.3%
Taylor expanded in n around -inf
Applied rewrites77.1%
Taylor expanded in x around 0
Applied rewrites76.5%
if 1 < x Initial program 63.5%
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-*.f6497.8
Applied rewrites97.8%
Final simplification86.3%
(FPCore (x n)
:precision binary64
(if (<= x 0.97)
(/
(+
(fma 0.5 (/ (pow (log x) 2.0) n) (log x))
(/ (* 0.16666666666666666 (pow (log x) 3.0)) (* n n)))
(- n))
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 0.97) {
tmp = (fma(0.5, (pow(log(x), 2.0) / n), log(x)) + ((0.16666666666666666 * pow(log(x), 3.0)) / (n * n))) / -n;
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 0.97) tmp = Float64(Float64(fma(0.5, Float64((log(x) ^ 2.0) / n), log(x)) + Float64(Float64(0.16666666666666666 * (log(x) ^ 3.0)) / 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, 0.97], N[(N[(N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] + N[Log[x], $MachinePrecision]), $MachinePrecision] + N[(N[(0.16666666666666666 * N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / N[(n * n), $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 0.97:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n}, \log x\right) + \frac{0.16666666666666666 \cdot {\log x}^{3}}{n \cdot n}}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 0.96999999999999997Initial program 46.3%
Taylor expanded in n around -inf
Applied rewrites77.1%
Taylor expanded in x around 0
Applied rewrites76.2%
if 0.96999999999999997 < x Initial program 63.5%
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-*.f6497.8
Applied rewrites97.8%
Final simplification86.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-29)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 1e-97)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 2e-34)
(/ 1.0 (* x (fma 0.5 (/ n 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) <= -4e-29) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-97) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 2e-34) {
tmp = 1.0 / (x * fma(0.5, (n / x), n));
} else {
tmp = 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) <= -4e-29) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-97) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2e-34) tmp = Float64(1.0 / Float64(x * fma(0.5, Float64(n / x), n))); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-29], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-97], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-34], N[(1.0 / N[(x * N[(0.5 * N[(n / x), $MachinePrecision] + n), $MachinePrecision]), $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 -4 \cdot 10^{-29}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-97}:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-34}:\\
\;\;\;\;\frac{1}{x \cdot \mathsf{fma}\left(0.5, \frac{n}{x}, n\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999977e-29Initial program 88.6%
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-*.f6491.4
Applied rewrites91.4%
if -3.99999999999999977e-29 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000004e-97Initial program 39.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.3
Applied rewrites77.3%
Applied rewrites77.5%
if 1.00000000000000004e-97 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999986e-34Initial program 4.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6430.2
Applied rewrites30.2%
Applied rewrites30.2%
Taylor expanded in x around inf
Applied rewrites75.2%
if 1.99999999999999986e-34 < (/.f64 #s(literal 1 binary64) n) Initial program 45.0%
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.f6497.8
Applied rewrites97.8%
Taylor expanded in x around 0
lower-/.f6497.8
Applied rewrites97.8%
Final simplification85.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-29)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 1e-97)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 4e-21)
(/ 1.0 (* x (fma 0.5 (/ n x) n)))
(-
(fma
x
(fma
x
(/
(fma x 0.16666666666666666 (* n (fma x -0.5 0.5)))
(* n (* n 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) <= -4e-29) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-97) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 4e-21) {
tmp = 1.0 / (x * fma(0.5, (n / x), n));
} else {
tmp = fma(x, fma(x, (fma(x, 0.16666666666666666, (n * fma(x, -0.5, 0.5))) / (n * (n * 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) <= -4e-29) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-97) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-21) tmp = Float64(1.0 / Float64(x * fma(0.5, Float64(n / x), n))); else tmp = Float64(fma(x, fma(x, Float64(fma(x, 0.16666666666666666, Float64(n * fma(x, -0.5, 0.5))) / Float64(n * Float64(n * 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], -4e-29], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-97], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-21], N[(1.0 / N[(x * N[(0.5 * N[(n / x), $MachinePrecision] + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(x * N[(N[(x * 0.16666666666666666 + N[(n * N[(x * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * N[(n * n), $MachinePrecision]), $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 -4 \cdot 10^{-29}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-97}:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-21}:\\
\;\;\;\;\frac{1}{x \cdot \mathsf{fma}\left(0.5, \frac{n}{x}, n\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{\mathsf{fma}\left(x, 0.16666666666666666, n \cdot \mathsf{fma}\left(x, -0.5, 0.5\right)\right)}{n \cdot \left(n \cdot n\right)}, \frac{1}{n}\right), 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999977e-29Initial program 88.6%
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-*.f6491.4
Applied rewrites91.4%
if -3.99999999999999977e-29 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000004e-97Initial program 39.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.3
Applied rewrites77.3%
Applied rewrites77.5%
if 1.00000000000000004e-97 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999963e-21Initial program 4.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6435.9
Applied rewrites35.9%
Applied rewrites35.9%
Taylor expanded in x around inf
Applied rewrites69.2%
if 3.99999999999999963e-21 < (/.f64 #s(literal 1 binary64) n) Initial program 46.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites35.1%
Taylor expanded in n around 0
Applied rewrites72.9%
Final simplification80.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-29)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 1e-97)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 4e-21)
(/ 1.0 (* x (fma 0.5 (/ n x) n)))
(-
(fma
x
(fma x (* 0.16666666666666666 (/ x (* n (* n 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) <= -4e-29) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-97) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 4e-21) {
tmp = 1.0 / (x * fma(0.5, (n / x), n));
} else {
tmp = fma(x, fma(x, (0.16666666666666666 * (x / (n * (n * 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) <= -4e-29) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-97) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-21) tmp = Float64(1.0 / Float64(x * fma(0.5, Float64(n / x), n))); else tmp = Float64(fma(x, fma(x, Float64(0.16666666666666666 * Float64(x / Float64(n * Float64(n * 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], -4e-29], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-97], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-21], N[(1.0 / N[(x * N[(0.5 * N[(n / x), $MachinePrecision] + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(x * N[(0.16666666666666666 * N[(x / N[(n * N[(n * n), $MachinePrecision]), $MachinePrecision]), $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 -4 \cdot 10^{-29}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-97}:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-21}:\\
\;\;\;\;\frac{1}{x \cdot \mathsf{fma}\left(0.5, \frac{n}{x}, n\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.16666666666666666 \cdot \frac{x}{n \cdot \left(n \cdot n\right)}, \frac{1}{n}\right), 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999977e-29Initial program 88.6%
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-*.f6491.4
Applied rewrites91.4%
if -3.99999999999999977e-29 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000004e-97Initial program 39.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.3
Applied rewrites77.3%
Applied rewrites77.5%
if 1.00000000000000004e-97 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999963e-21Initial program 4.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6435.9
Applied rewrites35.9%
Applied rewrites35.9%
Taylor expanded in x around inf
Applied rewrites69.2%
if 3.99999999999999963e-21 < (/.f64 #s(literal 1 binary64) n) Initial program 46.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites35.1%
Taylor expanded in n around 0
Applied rewrites72.0%
Final simplification80.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-29)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 1e-97)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 4e-21)
(/ 1.0 (* x (fma 0.5 (/ n x) n)))
(if (<= (/ 1.0 n) 4e+171)
(- (+ (/ x n) 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) <= -4e-29) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-97) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 4e-21) {
tmp = 1.0 / (x * fma(0.5, (n / x), n));
} else if ((1.0 / n) <= 4e+171) {
tmp = ((x / n) + 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) <= -4e-29) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-97) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-21) tmp = Float64(1.0 / Float64(x * fma(0.5, Float64(n / x), n))); elseif (Float64(1.0 / n) <= 4e+171) tmp = Float64(Float64(Float64(x / n) + 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], -4e-29], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-97], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-21], N[(1.0 / N[(x * N[(0.5 * N[(n / x), $MachinePrecision] + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+171], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $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 -4 \cdot 10^{-29}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-97}:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-21}:\\
\;\;\;\;\frac{1}{x \cdot \mathsf{fma}\left(0.5, \frac{n}{x}, n\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+171}:\\
\;\;\;\;\left(\frac{x}{n} + 1\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) < -3.99999999999999977e-29Initial program 88.6%
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-*.f6491.4
Applied rewrites91.4%
if -3.99999999999999977e-29 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000004e-97Initial program 39.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.3
Applied rewrites77.3%
Applied rewrites77.5%
if 1.00000000000000004e-97 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999963e-21Initial program 4.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6435.9
Applied rewrites35.9%
Applied rewrites35.9%
Taylor expanded in x around inf
Applied rewrites69.2%
if 3.99999999999999963e-21 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999982e171Initial program 63.3%
Taylor expanded in x around 0
*-rgt-identityN/A
associate-*r/N/A
lower-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6461.1
Applied rewrites61.1%
if 3.99999999999999982e171 < (/.f64 #s(literal 1 binary64) n) Initial program 29.5%
Taylor expanded in x around 0
Applied rewrites25.1%
Taylor expanded in n around inf
Applied rewrites2.0%
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-/.f6473.6
Applied rewrites73.6%
Final simplification79.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-29)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 1e-97)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 2e-34)
(/ 1.0 (* x (fma 0.5 (/ n x) n)))
(if (<= (/ 1.0 n) 4e+171)
(- 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) <= -4e-29) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 1e-97) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 2e-34) {
tmp = 1.0 / (x * fma(0.5, (n / x), n));
} else if ((1.0 / n) <= 4e+171) {
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) <= -4e-29) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 1e-97) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2e-34) tmp = Float64(1.0 / Float64(x * fma(0.5, Float64(n / x), n))); elseif (Float64(1.0 / n) <= 4e+171) 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], -4e-29], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-97], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-34], N[(1.0 / N[(x * N[(0.5 * N[(n / x), $MachinePrecision] + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+171], 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 -4 \cdot 10^{-29}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-97}:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-34}:\\
\;\;\;\;\frac{1}{x \cdot \mathsf{fma}\left(0.5, \frac{n}{x}, n\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+171}:\\
\;\;\;\;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) < -3.99999999999999977e-29Initial program 88.6%
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-*.f6491.4
Applied rewrites91.4%
if -3.99999999999999977e-29 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000004e-97Initial program 39.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.3
Applied rewrites77.3%
Applied rewrites77.5%
if 1.00000000000000004e-97 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999986e-34Initial program 4.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6430.2
Applied rewrites30.2%
Applied rewrites30.2%
Taylor expanded in x around inf
Applied rewrites75.2%
if 1.99999999999999986e-34 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999982e171Initial program 60.6%
Taylor expanded in x around 0
Applied rewrites56.2%
if 3.99999999999999982e171 < (/.f64 #s(literal 1 binary64) n) Initial program 29.5%
Taylor expanded in x around 0
Applied rewrites25.1%
Taylor expanded in n around inf
Applied rewrites2.0%
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-/.f6473.6
Applied rewrites73.6%
Final simplification79.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 1.85e-187)
t_0
(if (<= x 1.9e-148)
(/ (- (log x)) n)
(if (<= x 4.2e-82)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 0.0145)
t_0
(if (<= x 4.6e+128)
(/
1.0
(*
x
(+
(-
n
(/
(fma n 0.041666666666666664 (* n -0.08333333333333333))
(* x (* x x))))
(/ (fma n 0.5 (/ (* n -0.08333333333333333) x)) x))))
(- 1.0 1.0))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 1.85e-187) {
tmp = t_0;
} else if (x <= 1.9e-148) {
tmp = -log(x) / n;
} else if (x <= 4.2e-82) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 0.0145) {
tmp = t_0;
} else if (x <= 4.6e+128) {
tmp = 1.0 / (x * ((n - (fma(n, 0.041666666666666664, (n * -0.08333333333333333)) / (x * (x * x)))) + (fma(n, 0.5, ((n * -0.08333333333333333) / x)) / x)));
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 1.85e-187) tmp = t_0; elseif (x <= 1.9e-148) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 4.2e-82) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 0.0145) tmp = t_0; elseif (x <= 4.6e+128) tmp = Float64(1.0 / Float64(x * Float64(Float64(n - Float64(fma(n, 0.041666666666666664, Float64(n * -0.08333333333333333)) / Float64(x * Float64(x * x)))) + Float64(fma(n, 0.5, Float64(Float64(n * -0.08333333333333333) / x)) / x)))); else tmp = Float64(1.0 - 1.0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.85e-187], t$95$0, If[LessEqual[x, 1.9e-148], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 4.2e-82], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0145], t$95$0, If[LessEqual[x, 4.6e+128], N[(1.0 / N[(x * N[(N[(n - N[(N[(n * 0.041666666666666664 + N[(n * -0.08333333333333333), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(n * 0.5 + N[(N[(n * -0.08333333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.85 \cdot 10^{-187}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-148}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-82}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 0.0145:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(n - \frac{\mathsf{fma}\left(n, 0.041666666666666664, n \cdot -0.08333333333333333\right)}{x \cdot \left(x \cdot x\right)}\right) + \frac{\mathsf{fma}\left(n, 0.5, \frac{n \cdot -0.08333333333333333}{x}\right)}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 1.85000000000000005e-187 or 4.2000000000000001e-82 < x < 0.0145000000000000007Initial program 52.4%
Taylor expanded in x around 0
Applied rewrites50.4%
if 1.85000000000000005e-187 < x < 1.90000000000000007e-148Initial program 24.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6465.6
Applied rewrites65.6%
Taylor expanded in x around 0
Applied rewrites65.6%
if 1.90000000000000007e-148 < x < 4.2000000000000001e-82Initial program 40.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6429.5
Applied rewrites29.5%
Taylor expanded in x around inf
Applied rewrites0.3%
Taylor expanded in n around 0
Applied rewrites0.3%
Taylor expanded in x around inf
Applied rewrites66.3%
if 0.0145000000000000007 < x < 4.59999999999999996e128Initial program 32.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6436.3
Applied rewrites36.3%
Applied rewrites37.0%
Taylor expanded in x around inf
Applied rewrites80.1%
if 4.59999999999999996e128 < x Initial program 86.5%
Taylor expanded in x around 0
Applied rewrites58.9%
Taylor expanded in n around inf
Applied rewrites86.5%
Final simplification68.4%
(FPCore (x n)
:precision binary64
(if (<= x 1.9e-148)
(/ (- (log x)) n)
(if (<= x 3.2e-71)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 0.5)
(/ (- x (log x)) n)
(if (<= x 4.6e+128)
(/
1.0
(*
x
(+
(-
n
(/
(fma n 0.041666666666666664 (* n -0.08333333333333333))
(* x (* x x))))
(/ (fma n 0.5 (/ (* n -0.08333333333333333) x)) x))))
(- 1.0 1.0))))))
double code(double x, double n) {
double tmp;
if (x <= 1.9e-148) {
tmp = -log(x) / n;
} else if (x <= 3.2e-71) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 0.5) {
tmp = (x - log(x)) / n;
} else if (x <= 4.6e+128) {
tmp = 1.0 / (x * ((n - (fma(n, 0.041666666666666664, (n * -0.08333333333333333)) / (x * (x * x)))) + (fma(n, 0.5, ((n * -0.08333333333333333) / x)) / x)));
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1.9e-148) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 3.2e-71) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 0.5) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 4.6e+128) tmp = Float64(1.0 / Float64(x * Float64(Float64(n - Float64(fma(n, 0.041666666666666664, Float64(n * -0.08333333333333333)) / Float64(x * Float64(x * x)))) + Float64(fma(n, 0.5, Float64(Float64(n * -0.08333333333333333) / x)) / x)))); else tmp = Float64(1.0 - 1.0); end return tmp end
code[x_, n_] := If[LessEqual[x, 1.9e-148], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 3.2e-71], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 4.6e+128], N[(1.0 / N[(x * N[(N[(n - N[(N[(n * 0.041666666666666664 + N[(n * -0.08333333333333333), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(n * 0.5 + N[(N[(n * -0.08333333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9 \cdot 10^{-148}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-71}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(n - \frac{\mathsf{fma}\left(n, 0.041666666666666664, n \cdot -0.08333333333333333\right)}{x \cdot \left(x \cdot x\right)}\right) + \frac{\mathsf{fma}\left(n, 0.5, \frac{n \cdot -0.08333333333333333}{x}\right)}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 1.90000000000000007e-148Initial program 46.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6448.6
Applied rewrites48.6%
Taylor expanded in x around 0
Applied rewrites48.6%
if 1.90000000000000007e-148 < x < 3.1999999999999999e-71Initial program 45.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6427.4
Applied rewrites27.4%
Taylor expanded in x around inf
Applied rewrites0.3%
Taylor expanded in n around 0
Applied rewrites0.3%
Taylor expanded in x around inf
Applied rewrites65.2%
if 3.1999999999999999e-71 < x < 0.5Initial program 45.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6444.4
Applied rewrites44.4%
Taylor expanded in x around 0
Applied rewrites41.8%
if 0.5 < x < 4.59999999999999996e128Initial program 33.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6435.1
Applied rewrites35.1%
Applied rewrites35.8%
Taylor expanded in x around inf
Applied rewrites81.4%
if 4.59999999999999996e128 < x Initial program 86.5%
Taylor expanded in x around 0
Applied rewrites58.9%
Taylor expanded in n around inf
Applied rewrites86.5%
Final simplification65.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 1.9e-148)
t_0
(if (<= x 3.2e-71)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 2.7e-16)
t_0
(if (<= x 4.6e+128)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x)
(- 1.0 1.0)))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 1.9e-148) {
tmp = t_0;
} else if (x <= 3.2e-71) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 2.7e-16) {
tmp = t_0;
} else if (x <= 4.6e+128) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} 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) :: t_0
real(8) :: tmp
t_0 = -log(x) / n
if (x <= 1.9d-148) then
tmp = t_0
else if (x <= 3.2d-71) then
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
else if (x <= 2.7d-16) then
tmp = t_0
else if (x <= 4.6d+128) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double tmp;
if (x <= 1.9e-148) {
tmp = t_0;
} else if (x <= 3.2e-71) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 2.7e-16) {
tmp = t_0;
} else if (x <= 4.6e+128) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 1.9e-148: tmp = t_0 elif x <= 3.2e-71: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) elif x <= 2.7e-16: tmp = t_0 elif x <= 4.6e+128: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 1.9e-148) tmp = t_0; elseif (x <= 3.2e-71) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 2.7e-16) tmp = t_0; elseif (x <= 4.6e+128) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (x <= 1.9e-148) tmp = t_0; elseif (x <= 3.2e-71) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); elseif (x <= 2.7e-16) tmp = t_0; elseif (x <= 4.6e+128) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 1.9e-148], t$95$0, If[LessEqual[x, 3.2e-71], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.7e-16], t$95$0, If[LessEqual[x, 4.6e+128], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 1.9 \cdot 10^{-148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-71}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 1.90000000000000007e-148 or 3.1999999999999999e-71 < x < 2.69999999999999999e-16Initial program 44.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6448.4
Applied rewrites48.4%
Taylor expanded in x around 0
Applied rewrites48.4%
if 1.90000000000000007e-148 < x < 3.1999999999999999e-71Initial program 45.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6427.4
Applied rewrites27.4%
Taylor expanded in x around inf
Applied rewrites0.3%
Taylor expanded in n around 0
Applied rewrites0.3%
Taylor expanded in x around inf
Applied rewrites65.2%
if 2.69999999999999999e-16 < x < 4.59999999999999996e128Initial program 38.1%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6434.7
Applied rewrites34.7%
Taylor expanded in x around inf
Applied rewrites71.7%
Taylor expanded in x around -inf
Applied rewrites73.8%
if 4.59999999999999996e128 < x Initial program 86.5%
Taylor expanded in x around 0
Applied rewrites58.9%
Taylor expanded in n around inf
Applied rewrites86.5%
Final simplification65.8%
(FPCore (x n) :precision binary64 (if (<= x 4.6e+128) (/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x)) x) (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if (x <= 4.6e+128) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} 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 <= 4.6d+128) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 4.6e+128) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.6e+128: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 4.6e+128) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.6e+128) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.6e+128], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 4.59999999999999996e128Initial program 42.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6441.4
Applied rewrites41.4%
Taylor expanded in x around inf
Applied rewrites22.2%
Taylor expanded in x around -inf
Applied rewrites47.6%
if 4.59999999999999996e128 < x Initial program 86.5%
Taylor expanded in x around 0
Applied rewrites58.9%
Taylor expanded in n around inf
Applied rewrites86.5%
Final simplification57.8%
(FPCore (x n) :precision binary64 (if (<= x 4.6e+128) (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n)) (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if (x <= 4.6e+128) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (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 <= 4.6d+128) then
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (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 <= 4.6e+128) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.6e+128: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 4.6e+128) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.6e+128) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.6e+128], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 4.59999999999999996e128Initial program 42.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6441.4
Applied rewrites41.4%
Taylor expanded in x around inf
Applied rewrites22.2%
Taylor expanded in n around 0
Applied rewrites22.2%
Taylor expanded in x around inf
Applied rewrites47.6%
if 4.59999999999999996e128 < x Initial program 86.5%
Taylor expanded in x around 0
Applied rewrites58.9%
Taylor expanded in n around inf
Applied rewrites86.5%
Final simplification57.8%
(FPCore (x n) :precision binary64 (if (<= n -0.0075) (/ 1.0 (* x (fma 0.5 (/ n x) n))) (if (<= n -1.4e-171) (- 1.0 1.0) (/ (/ 1.0 n) x))))
double code(double x, double n) {
double tmp;
if (n <= -0.0075) {
tmp = 1.0 / (x * fma(0.5, (n / x), n));
} else if (n <= -1.4e-171) {
tmp = 1.0 - 1.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (n <= -0.0075) tmp = Float64(1.0 / Float64(x * fma(0.5, Float64(n / x), n))); elseif (n <= -1.4e-171) tmp = Float64(1.0 - 1.0); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[n, -0.0075], N[(1.0 / N[(x * N[(0.5 * N[(n / x), $MachinePrecision] + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -1.4e-171], N[(1.0 - 1.0), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.0075:\\
\;\;\;\;\frac{1}{x \cdot \mathsf{fma}\left(0.5, \frac{n}{x}, n\right)}\\
\mathbf{elif}\;n \leq -1.4 \cdot 10^{-171}:\\
\;\;\;\;1 - 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if n < -0.0074999999999999997Initial program 37.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6469.1
Applied rewrites69.1%
Applied rewrites69.2%
Taylor expanded in x around inf
Applied rewrites59.9%
if -0.0074999999999999997 < n < -1.40000000000000011e-171Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites47.4%
Taylor expanded in n around inf
Applied rewrites55.0%
if -1.40000000000000011e-171 < n Initial program 53.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6441.3
Applied rewrites41.3%
Taylor expanded in x around inf
Applied rewrites29.0%
Taylor expanded in x around inf
Applied rewrites52.4%
(FPCore (x n) :precision binary64 (if (<= x 4.6e+128) (/ (/ 1.0 n) x) (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if (x <= 4.6e+128) {
tmp = (1.0 / n) / x;
} 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 <= 4.6d+128) then
tmp = (1.0d0 / n) / x
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 4.6e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.6e+128: tmp = (1.0 / n) / x else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 4.6e+128) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.6e+128) tmp = (1.0 / n) / x; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.6e+128], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 4.59999999999999996e128Initial program 42.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6441.4
Applied rewrites41.4%
Taylor expanded in x around inf
Applied rewrites22.2%
Taylor expanded in x around inf
Applied rewrites41.8%
if 4.59999999999999996e128 < x Initial program 86.5%
Taylor expanded in x around 0
Applied rewrites58.9%
Taylor expanded in n around inf
Applied rewrites86.5%
(FPCore (x n) :precision binary64 (if (<= x 4.6e+128) (/ 1.0 (* x n)) (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if (x <= 4.6e+128) {
tmp = 1.0 / (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 <= 4.6d+128) then
tmp = 1.0d0 / (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 <= 4.6e+128) {
tmp = 1.0 / (x * n);
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.6e+128: tmp = 1.0 / (x * n) else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 4.6e+128) tmp = Float64(1.0 / Float64(x * n)); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.6e+128) tmp = 1.0 / (x * n); else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.6e+128], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 4.59999999999999996e128Initial program 42.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6441.4
Applied rewrites41.4%
Taylor expanded in x around inf
Applied rewrites41.8%
if 4.59999999999999996e128 < x Initial program 86.5%
Taylor expanded in x around 0
Applied rewrites58.9%
Taylor expanded in n around inf
Applied rewrites86.5%
(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 54.2%
Taylor expanded in x around 0
Applied rewrites42.8%
Taylor expanded in n around inf
Applied rewrites31.0%
herbie shell --seed 2024219
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))