
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) n)))
(if (<= x 2.65e-173)
(- (- 1.0 (cosh t_0)) (sinh t_0))
(if (<= x 7.7)
(/
(+
(- (log x))
(+
(/
(fma
0.16666666666666666
(/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)
(* (- (pow (log1p x) 2.0) (pow (log x) 2.0)) 0.5))
n)
(log1p x)))
n)
(pow (* (pow x (/ -1.0 n)) (* x n)) -1.0)))))
double code(double x, double n) {
double t_0 = log(x) / n;
double tmp;
if (x <= 2.65e-173) {
tmp = (1.0 - cosh(t_0)) - sinh(t_0);
} else if (x <= 7.7) {
tmp = (-log(x) + ((fma(0.16666666666666666, ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n), ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) * 0.5)) / n) + log1p(x))) / n;
} else {
tmp = pow((pow(x, (-1.0 / n)) * (x * n)), -1.0);
}
return tmp;
}
function code(x, n) t_0 = Float64(log(x) / n) tmp = 0.0 if (x <= 2.65e-173) tmp = Float64(Float64(1.0 - cosh(t_0)) - sinh(t_0)); elseif (x <= 7.7) tmp = Float64(Float64(Float64(-log(x)) + Float64(Float64(fma(0.16666666666666666, Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n), Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) * 0.5)) / n) + log1p(x))) / n); else tmp = Float64((x ^ Float64(-1.0 / n)) * Float64(x * n)) ^ -1.0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 2.65e-173], N[(N[(1.0 - N[Cosh[t$95$0], $MachinePrecision]), $MachinePrecision] - N[Sinh[t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.7], N[(N[((-N[Log[x], $MachinePrecision]) + N[(N[(N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[Log[1 + x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[Power[N[(N[Power[x, N[(-1.0 / n), $MachinePrecision]], $MachinePrecision] * N[(x * n), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;x \leq 2.65 \cdot 10^{-173}:\\
\;\;\;\;\left(1 - \cosh t\_0\right) - \sinh t\_0\\
\mathbf{elif}\;x \leq 7.7:\\
\;\;\;\;\frac{\left(-\log x\right) + \left(\frac{\mathsf{fma}\left(0.16666666666666666, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}, \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) \cdot 0.5\right)}{n} + \mathsf{log1p}\left(x\right)\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;{\left({x}^{\left(\frac{-1}{n}\right)} \cdot \left(x \cdot n\right)\right)}^{-1}\\
\end{array}
\end{array}
if x < 2.64999999999999982e-173Initial program 46.0%
Taylor expanded in x around 0
Applied rewrites46.0%
lift--.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-log.f64N/A
div-invN/A
lift-/.f64N/A
sinh-+-cosh-revN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lower-cosh.f64N/A
lower-sinh.f6485.5
Applied rewrites85.5%
if 2.64999999999999982e-173 < x < 7.70000000000000018Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites89.4%
if 7.70000000000000018 < x Initial program 71.8%
Taylor expanded in x around inf
lower-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
distribute-neg-fracN/A
mul-1-negN/A
remove-double-negN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6496.1
Applied rewrites96.1%
Applied rewrites96.1%
Applied rewrites96.2%
Final simplification91.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 0.5 n))))
(if (<= (pow n -1.0) -1e-7)
(- (pow (+ x 1.0) (pow n -1.0)) (pow x (pow n -1.0)))
(if (<= (pow n -1.0) 5e-8)
(/ (- (log1p x) (log x)) n)
(fma t_0 (- t_0) (exp (/ (log1p x) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (0.5 / n));
double tmp;
if (pow(n, -1.0) <= -1e-7) {
tmp = pow((x + 1.0), pow(n, -1.0)) - pow(x, pow(n, -1.0));
} else if (pow(n, -1.0) <= 5e-8) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = fma(t_0, -t_0, exp((log1p(x) / n)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(0.5 / n) tmp = 0.0 if ((n ^ -1.0) <= -1e-7) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - (x ^ (n ^ -1.0))); elseif ((n ^ -1.0) <= 5e-8) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = fma(t_0, Float64(-t_0), exp(Float64(log1p(x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(0.5 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1e-7], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-8], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 * (-t$95$0) + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{0.5}{n}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -1 \cdot 10^{-7}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - {x}^{\left({n}^{-1}\right)}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, -t\_0, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999995e-8Initial program 99.8%
if -9.9999999999999995e-8 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e-8Initial program 28.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6479.5
Applied rewrites79.5%
if 4.9999999999999998e-8 < (/.f64 #s(literal 1 binary64) n) Initial program 33.5%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-pow.f64N/A
sqr-powN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.3%
Final simplification88.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -1e-7)
(- (pow (+ x 1.0) (pow n -1.0)) t_0)
(if (<= (pow n -1.0) 1e-12)
(/ (- (log1p x) (log x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double tmp;
if (pow(n, -1.0) <= -1e-7) {
tmp = pow((x + 1.0), pow(n, -1.0)) - t_0;
} else if (pow(n, -1.0) <= 1e-12) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, Math.pow(n, -1.0));
double tmp;
if (Math.pow(n, -1.0) <= -1e-7) {
tmp = Math.pow((x + 1.0), Math.pow(n, -1.0)) - t_0;
} else if (Math.pow(n, -1.0) <= 1e-12) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, math.pow(n, -1.0)) tmp = 0 if math.pow(n, -1.0) <= -1e-7: tmp = math.pow((x + 1.0), math.pow(n, -1.0)) - t_0 elif math.pow(n, -1.0) <= 1e-12: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -1e-7) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - t_0); elseif ((n ^ -1.0) <= 1e-12) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1e-7], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 1e-12], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -1 \cdot 10^{-7}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - t\_0\\
\mathbf{elif}\;{n}^{-1} \leq 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999995e-8Initial program 99.8%
if -9.9999999999999995e-8 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 29.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6480.5
Applied rewrites80.5%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 31.9%
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.5
Applied rewrites93.5%
Final simplification88.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) n)))
(if (<= x 2.65e-173)
(- (- 1.0 (cosh t_0)) (sinh t_0))
(if (<= x 0.205)
(/
(-
(fma 0.5 (/ (pow (log x) 2.0) n) (log x))
(* (/ -0.16666666666666666 n) (/ (pow (log x) 3.0) n)))
(- n))
(pow (* (pow x (/ -1.0 n)) (* x n)) -1.0)))))
double code(double x, double n) {
double t_0 = log(x) / n;
double tmp;
if (x <= 2.65e-173) {
tmp = (1.0 - cosh(t_0)) - sinh(t_0);
} else if (x <= 0.205) {
tmp = (fma(0.5, (pow(log(x), 2.0) / n), log(x)) - ((-0.16666666666666666 / n) * (pow(log(x), 3.0) / n))) / -n;
} else {
tmp = pow((pow(x, (-1.0 / n)) * (x * n)), -1.0);
}
return tmp;
}
function code(x, n) t_0 = Float64(log(x) / n) tmp = 0.0 if (x <= 2.65e-173) tmp = Float64(Float64(1.0 - cosh(t_0)) - sinh(t_0)); elseif (x <= 0.205) tmp = Float64(Float64(fma(0.5, Float64((log(x) ^ 2.0) / n), log(x)) - Float64(Float64(-0.16666666666666666 / n) * Float64((log(x) ^ 3.0) / n))) / Float64(-n)); else tmp = Float64((x ^ Float64(-1.0 / n)) * Float64(x * n)) ^ -1.0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 2.65e-173], N[(N[(1.0 - N[Cosh[t$95$0], $MachinePrecision]), $MachinePrecision] - N[Sinh[t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.205], 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), $MachinePrecision] * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision], N[Power[N[(N[Power[x, N[(-1.0 / n), $MachinePrecision]], $MachinePrecision] * N[(x * n), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;x \leq 2.65 \cdot 10^{-173}:\\
\;\;\;\;\left(1 - \cosh t\_0\right) - \sinh t\_0\\
\mathbf{elif}\;x \leq 0.205:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n}, \log x\right) - \frac{-0.16666666666666666}{n} \cdot \frac{{\log x}^{3}}{n}}{-n}\\
\mathbf{else}:\\
\;\;\;\;{\left({x}^{\left(\frac{-1}{n}\right)} \cdot \left(x \cdot n\right)\right)}^{-1}\\
\end{array}
\end{array}
if x < 2.64999999999999982e-173Initial program 46.0%
Taylor expanded in x around 0
Applied rewrites46.0%
lift--.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-log.f64N/A
div-invN/A
lift-/.f64N/A
sinh-+-cosh-revN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lower-cosh.f64N/A
lower-sinh.f6485.5
Applied rewrites85.5%
if 2.64999999999999982e-173 < x < 0.204999999999999988Initial program 30.8%
Taylor expanded in n around -inf
Applied rewrites89.4%
Taylor expanded in x around 0
Applied rewrites85.0%
if 0.204999999999999988 < x Initial program 71.8%
Taylor expanded in x around inf
lower-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
distribute-neg-fracN/A
mul-1-negN/A
remove-double-negN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6496.1
Applied rewrites96.1%
Applied rewrites96.1%
Applied rewrites96.2%
Final simplification89.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -1e-7)
(- (pow (+ x 1.0) (pow n -1.0)) t_0)
(if (<= (pow n -1.0) 5e-8)
(/ (- (log1p x) (log x)) n)
(- (fma (* (/ x (* n n)) 0.5) x 1.0) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double tmp;
if (pow(n, -1.0) <= -1e-7) {
tmp = pow((x + 1.0), pow(n, -1.0)) - t_0;
} else if (pow(n, -1.0) <= 5e-8) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = fma(((x / (n * n)) * 0.5), x, 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -1e-7) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - t_0); elseif ((n ^ -1.0) <= 5e-8) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(fma(Float64(Float64(x / Float64(n * n)) * 0.5), x, 1.0) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1e-7], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-8], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(x / N[(n * n), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -1 \cdot 10^{-7}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - t\_0\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{n \cdot n} \cdot 0.5, x, 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999995e-8Initial program 99.8%
if -9.9999999999999995e-8 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e-8Initial program 28.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6479.5
Applied rewrites79.5%
if 4.9999999999999998e-8 < (/.f64 #s(literal 1 binary64) n) Initial program 33.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites74.4%
Taylor expanded in n around 0
Applied rewrites74.4%
Final simplification85.3%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -10.0)
(pow (* (pow x (/ -1.0 n)) (* x n)) -1.0)
(if (<= (pow n -1.0) 5e-8)
(/ (- (log1p x) (log x)) n)
(- (fma (* (/ x (* n n)) 0.5) x 1.0) (pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -10.0) {
tmp = pow((pow(x, (-1.0 / n)) * (x * n)), -1.0);
} else if (pow(n, -1.0) <= 5e-8) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = fma(((x / (n * n)) * 0.5), x, 1.0) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -10.0) tmp = Float64((x ^ Float64(-1.0 / n)) * Float64(x * n)) ^ -1.0; elseif ((n ^ -1.0) <= 5e-8) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(fma(Float64(Float64(x / Float64(n * n)) * 0.5), x, 1.0) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -10.0], N[Power[N[(N[Power[x, N[(-1.0 / n), $MachinePrecision]], $MachinePrecision] * N[(x * n), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-8], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(x / N[(n * n), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -10:\\
\;\;\;\;{\left({x}^{\left(\frac{-1}{n}\right)} \cdot \left(x \cdot n\right)\right)}^{-1}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{n \cdot n} \cdot 0.5, x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10Initial program 100.0%
Taylor expanded in x around inf
lower-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
distribute-neg-fracN/A
mul-1-negN/A
remove-double-negN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
if -10 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e-8Initial program 29.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6479.2
Applied rewrites79.2%
if 4.9999999999999998e-8 < (/.f64 #s(literal 1 binary64) n) Initial program 33.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites74.4%
Taylor expanded in n around 0
Applied rewrites74.4%
Final simplification85.1%
(FPCore (x n)
:precision binary64
(let* ((t_0
(/
(fma (fma (fma -0.3333333333333333 x 0.5) x -1.0) x (log x))
(- n))))
(if (<= x 2.05e-194)
t_0
(if (<= x 3.8e-129)
(/ (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)) (* n x))
(if (<= x 0.00044) t_0 (pow (* (pow x (/ -1.0 n)) (* x n)) -1.0))))))
double code(double x, double n) {
double t_0 = fma(fma(fma(-0.3333333333333333, x, 0.5), x, -1.0), x, log(x)) / -n;
double tmp;
if (x <= 2.05e-194) {
tmp = t_0;
} else if (x <= 3.8e-129) {
tmp = (((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / (n * x);
} else if (x <= 0.00044) {
tmp = t_0;
} else {
tmp = pow((pow(x, (-1.0 / n)) * (x * n)), -1.0);
}
return tmp;
}
function code(x, n) t_0 = Float64(fma(fma(fma(-0.3333333333333333, x, 0.5), x, -1.0), x, log(x)) / Float64(-n)) tmp = 0.0 if (x <= 2.05e-194) tmp = t_0; elseif (x <= 3.8e-129) tmp = Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) / Float64(n * x)); elseif (x <= 0.00044) tmp = t_0; else tmp = Float64((x ^ Float64(-1.0 / n)) * Float64(x * n)) ^ -1.0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + N[Log[x], $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 2.05e-194], t$95$0, If[LessEqual[x, 3.8e-129], N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.00044], t$95$0, N[Power[N[(N[Power[x, N[(-1.0 / n), $MachinePrecision]], $MachinePrecision] * N[(x * n), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, -1\right), x, \log x\right)}{-n}\\
\mathbf{if}\;x \leq 2.05 \cdot 10^{-194}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-129}:\\
\;\;\;\;\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}}{n \cdot x}\\
\mathbf{elif}\;x \leq 0.00044:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left({x}^{\left(\frac{-1}{n}\right)} \cdot \left(x \cdot n\right)\right)}^{-1}\\
\end{array}
\end{array}
if x < 2.0500000000000001e-194 or 3.79999999999999985e-129 < x < 4.40000000000000016e-4Initial program 33.6%
Taylor expanded in n around -inf
Applied rewrites85.8%
Taylor expanded in x around 0
Applied rewrites67.1%
Taylor expanded in n around -inf
Applied rewrites59.6%
if 2.0500000000000001e-194 < x < 3.79999999999999985e-129Initial program 59.3%
Taylor expanded in x around inf
Applied rewrites35.5%
Taylor expanded in n around inf
Applied rewrites74.6%
if 4.40000000000000016e-4 < x Initial program 70.8%
Taylor expanded in x around inf
lower-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
distribute-neg-fracN/A
mul-1-negN/A
remove-double-negN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6494.7
Applied rewrites94.7%
Applied rewrites94.7%
Applied rewrites94.7%
Final simplification76.1%
(FPCore (x n) :precision binary64 (if (<= x 1.35e-169) (- (+ (/ x n) 1.0) (pow x (pow n -1.0))) (/ (/ (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 1.35e-169) {
tmp = ((x / n) + 1.0) - pow(x, pow(n, -1.0));
} else {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.35d-169) then
tmp = ((x / n) + 1.0d0) - (x ** (n ** (-1.0d0)))
else
tmp = ((((0.3333333333333333d0 / (x * x)) + 1.0d0) - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.35e-169) {
tmp = ((x / n) + 1.0) - Math.pow(x, Math.pow(n, -1.0));
} else {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.35e-169: tmp = ((x / n) + 1.0) - math.pow(x, math.pow(n, -1.0)) else: tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 1.35e-169) tmp = Float64(Float64(Float64(x / n) + 1.0) - (x ^ (n ^ -1.0))); else tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.35e-169) tmp = ((x / n) + 1.0) - (x ^ (n ^ -1.0)); else tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.35e-169], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{-169}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 1.3500000000000001e-169Initial program 45.8%
Taylor expanded in x around 0
*-rgt-identityN/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6445.8
Applied rewrites45.8%
if 1.3500000000000001e-169 < x Initial program 54.1%
Taylor expanded in x around inf
Applied rewrites50.0%
Taylor expanded in n around inf
Applied rewrites52.2%
Final simplification50.5%
(FPCore (x n) :precision binary64 (if (<= x 1.35e-169) (- 1.0 (pow x (pow n -1.0))) (/ (/ (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 1.35e-169) {
tmp = 1.0 - pow(x, pow(n, -1.0));
} else {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.35d-169) then
tmp = 1.0d0 - (x ** (n ** (-1.0d0)))
else
tmp = ((((0.3333333333333333d0 / (x * x)) + 1.0d0) - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.35e-169) {
tmp = 1.0 - Math.pow(x, Math.pow(n, -1.0));
} else {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.35e-169: tmp = 1.0 - math.pow(x, math.pow(n, -1.0)) else: tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 1.35e-169) tmp = Float64(1.0 - (x ^ (n ^ -1.0))); else tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.35e-169) tmp = 1.0 - (x ^ (n ^ -1.0)); else tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.35e-169], N[(1.0 - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{-169}:\\
\;\;\;\;1 - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 1.3500000000000001e-169Initial program 45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
if 1.3500000000000001e-169 < x Initial program 54.1%
Taylor expanded in x around inf
Applied rewrites50.0%
Taylor expanded in n around inf
Applied rewrites52.2%
Final simplification50.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)))
(t_1
(/
(fma (fma (fma -0.3333333333333333 x 0.5) x -1.0) x (log x))
(- n))))
(if (<= x 2.05e-194)
t_1
(if (<= x 3.8e-129)
(/ t_0 (* n x))
(if (<= x 1.0) t_1 (/ (/ t_0 n) x))))))
double code(double x, double n) {
double t_0 = ((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x);
double t_1 = fma(fma(fma(-0.3333333333333333, x, 0.5), x, -1.0), x, log(x)) / -n;
double tmp;
if (x <= 2.05e-194) {
tmp = t_1;
} else if (x <= 3.8e-129) {
tmp = t_0 / (n * x);
} else if (x <= 1.0) {
tmp = t_1;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
function code(x, n) t_0 = Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) t_1 = Float64(fma(fma(fma(-0.3333333333333333, x, 0.5), x, -1.0), x, log(x)) / Float64(-n)) tmp = 0.0 if (x <= 2.05e-194) tmp = t_1; elseif (x <= 3.8e-129) tmp = Float64(t_0 / Float64(n * x)); elseif (x <= 1.0) tmp = t_1; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + N[Log[x], $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 2.05e-194], t$95$1, If[LessEqual[x, 3.8e-129], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], t$95$1, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}\\
t_1 := \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, -1\right), x, \log x\right)}{-n}\\
\mathbf{if}\;x \leq 2.05 \cdot 10^{-194}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-129}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 2.0500000000000001e-194 or 3.79999999999999985e-129 < x < 1Initial program 33.6%
Taylor expanded in n around -inf
Applied rewrites86.1%
Taylor expanded in x around 0
Applied rewrites66.5%
Taylor expanded in n around -inf
Applied rewrites59.2%
if 2.0500000000000001e-194 < x < 3.79999999999999985e-129Initial program 59.3%
Taylor expanded in x around inf
Applied rewrites35.5%
Taylor expanded in n around inf
Applied rewrites74.6%
if 1 < x Initial program 71.8%
Taylor expanded in x around inf
Applied rewrites75.6%
Taylor expanded in n around inf
Applied rewrites62.0%
Final simplification61.8%
(FPCore (x n) :precision binary64 (/ (pow x -1.0) n))
double code(double x, double n) {
return 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)) / n
end function
public static double code(double x, double n) {
return Math.pow(x, -1.0) / n;
}
def code(x, n): return math.pow(x, -1.0) / n
function code(x, n) return Float64((x ^ -1.0) / n) end
function tmp = code(x, n) tmp = (x ^ -1.0) / n; end
code[x_, n_] := N[(N[Power[x, -1.0], $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{{x}^{-1}}{n}
\end{array}
Initial program 51.9%
Taylor expanded in x around inf
lower-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
distribute-neg-fracN/A
mul-1-negN/A
remove-double-negN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6457.7
Applied rewrites57.7%
Taylor expanded in n around inf
Applied rewrites39.7%
Taylor expanded in n around inf
Applied rewrites39.9%
Final simplification39.9%
(FPCore (x n) :precision binary64 (pow (* x n) -1.0))
double code(double x, double n) {
return pow((x * n), -1.0);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (x * n) ** (-1.0d0)
end function
public static double code(double x, double n) {
return Math.pow((x * n), -1.0);
}
def code(x, n): return math.pow((x * n), -1.0)
function code(x, n) return Float64(x * n) ^ -1.0 end
function tmp = code(x, n) tmp = (x * n) ^ -1.0; end
code[x_, n_] := N[Power[N[(x * n), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(x \cdot n\right)}^{-1}
\end{array}
Initial program 51.9%
Taylor expanded in x around inf
lower-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
distribute-neg-fracN/A
mul-1-negN/A
remove-double-negN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6457.7
Applied rewrites57.7%
Taylor expanded in n around inf
Applied rewrites39.9%
Applied rewrites38.9%
Final simplification38.9%
(FPCore (x n) :precision binary64 (/ (/ (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)) n) x))
double code(double x, double n) {
return ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((((0.3333333333333333d0 / (x * x)) + 1.0d0) - (0.5d0 / x)) / n) / x
end function
public static double code(double x, double n) {
return ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
}
def code(x, n): return ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x
function code(x, n) return Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) / n) / x) end
function tmp = code(x, n) tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x; end
code[x_, n_] := N[(N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}}{n}}{x}
\end{array}
Initial program 51.9%
Taylor expanded in x around inf
Applied rewrites41.0%
Taylor expanded in n around inf
Applied rewrites47.0%
(FPCore (x n) :precision binary64 (/ (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)) (* n x)))
double code(double x, double n) {
return (((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (((0.3333333333333333d0 / (x * x)) + 1.0d0) - (0.5d0 / x)) / (n * x)
end function
public static double code(double x, double n) {
return (((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / (n * x);
}
def code(x, n): return (((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / (n * x)
function code(x, n) return Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) / Float64(n * x)) end
function tmp = code(x, n) tmp = (((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / (n * x); end
code[x_, n_] := N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}}{n \cdot x}
\end{array}
Initial program 51.9%
Taylor expanded in x around inf
Applied rewrites41.0%
Taylor expanded in n around inf
Applied rewrites46.0%
herbie shell --seed 2024305
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))