
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -5e-6)
(- (pow (+ x 1.0) (pow n -1.0)) (pow (sqrt t_0) 2.0))
(if (<= (pow n -1.0) 1e-12)
(-
(/
(+
(log1p x)
(/
(fma
0.5
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
(/
(fma
(/ (- (pow (log1p x) 4.0) (pow (log x) 4.0)) n)
-0.041666666666666664
(*
-0.16666666666666666
(- (pow (log1p x) 3.0) (pow (log x) 3.0))))
(- n)))
n))
n)
(/ (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) <= -5e-6) {
tmp = pow((x + 1.0), pow(n, -1.0)) - pow(sqrt(t_0), 2.0);
} else if (pow(n, -1.0) <= 1e-12) {
tmp = ((log1p(x) + (fma(0.5, (pow(log1p(x), 2.0) - pow(log(x), 2.0)), (fma(((pow(log1p(x), 4.0) - pow(log(x), 4.0)) / n), -0.041666666666666664, (-0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0)))) / -n)) / n)) / n) - (log(x) / n);
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -5e-6) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - (sqrt(t_0) ^ 2.0)); elseif ((n ^ -1.0) <= 1e-12) tmp = Float64(Float64(Float64(log1p(x) + Float64(fma(0.5, Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), Float64(fma(Float64(Float64((log1p(x) ^ 4.0) - (log(x) ^ 4.0)) / n), -0.041666666666666664, Float64(-0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)))) / Float64(-n))) / n)) / n) - Float64(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], -5e-6], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - N[Power[N[Sqrt[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 1e-12], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + 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[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * -0.041666666666666664 + 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]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $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 -5 \cdot 10^{-6}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - {\left(\sqrt{t\_0}\right)}^{2}\\
\mathbf{elif}\;{n}^{-1} \leq 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(0.5, {\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, \frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4} - {\log x}^{4}}{n}, -0.041666666666666664, -0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)\right)}{-n}\right)}{n}}{n} - \frac{\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) < -5.00000000000000041e-6Initial program 99.8%
lift-pow.f64N/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
pow-to-expN/A
associate-*r/N/A
exp-sqrt-revN/A
pow-to-expN/A
lift-pow.f64N/A
lower-sqrt.f6499.8
lift-/.f64N/A
inv-powN/A
lower-pow.f6499.8
Applied rewrites99.8%
if -5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 33.6%
Taylor expanded in n around -inf
Applied rewrites82.5%
Applied rewrites82.5%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6499.7
Applied rewrites99.7%
Final simplification90.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -5e-6)
(- (pow (+ x 1.0) (pow n -1.0)) (pow (sqrt t_0) 2.0))
(if (<= (pow n -1.0) 1e-12)
(/
(-
(+
(log1p x)
(/
(fma
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
0.5
(/
(fma
-0.041666666666666664
(/ (- (pow (log1p x) 4.0) (pow (log x) 4.0)) n)
(*
(- (pow (log1p x) 3.0) (pow (log x) 3.0))
-0.16666666666666666))
(- n)))
n))
(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) <= -5e-6) {
tmp = pow((x + 1.0), pow(n, -1.0)) - pow(sqrt(t_0), 2.0);
} else if (pow(n, -1.0) <= 1e-12) {
tmp = ((log1p(x) + (fma((pow(log1p(x), 2.0) - pow(log(x), 2.0)), 0.5, (fma(-0.041666666666666664, ((pow(log1p(x), 4.0) - pow(log(x), 4.0)) / n), ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) * -0.16666666666666666)) / -n)) / n)) - log(x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -5e-6) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - (sqrt(t_0) ^ 2.0)); elseif ((n ^ -1.0) <= 1e-12) tmp = Float64(Float64(Float64(log1p(x) + Float64(fma(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), 0.5, Float64(fma(-0.041666666666666664, Float64(Float64((log1p(x) ^ 4.0) - (log(x) ^ 4.0)) / n), Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) * -0.16666666666666666)) / Float64(-n))) / n)) - 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], -5e-6], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - N[Power[N[Sqrt[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 1e-12], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(-0.041666666666666664 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $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 -5 \cdot 10^{-6}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - {\left(\sqrt{t\_0}\right)}^{2}\\
\mathbf{elif}\;{n}^{-1} \leq 10^{-12}:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, \frac{\mathsf{fma}\left(-0.041666666666666664, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4} - {\log x}^{4}}{n}, \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right) \cdot -0.16666666666666666\right)}{-n}\right)}{n}\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) < -5.00000000000000041e-6Initial program 99.8%
lift-pow.f64N/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
pow-to-expN/A
associate-*r/N/A
exp-sqrt-revN/A
pow-to-expN/A
lift-pow.f64N/A
lower-sqrt.f6499.8
lift-/.f64N/A
inv-powN/A
lower-pow.f6499.8
Applied rewrites99.8%
if -5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 33.6%
Taylor expanded in n around -inf
Applied rewrites82.5%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6499.7
Applied rewrites99.7%
Final simplification90.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log1p x) n)) (t_1 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -5e-6)
(- (pow (+ x 1.0) (pow n -1.0)) (pow (sqrt t_1) 2.0))
(if (<= (pow n -1.0) 1e-12)
(+
t_0
(/
(-
(/
(fma
(/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)
0.16666666666666666
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0))))
n)
(log x))
n))
(- (exp t_0) t_1)))))
double code(double x, double n) {
double t_0 = log1p(x) / n;
double t_1 = pow(x, pow(n, -1.0));
double tmp;
if (pow(n, -1.0) <= -5e-6) {
tmp = pow((x + 1.0), pow(n, -1.0)) - pow(sqrt(t_1), 2.0);
} else if (pow(n, -1.0) <= 1e-12) {
tmp = t_0 + (((fma(((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n), 0.16666666666666666, (0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0)))) / n) - log(x)) / n);
} else {
tmp = exp(t_0) - t_1;
}
return tmp;
}
function code(x, n) t_0 = Float64(log1p(x) / n) t_1 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -5e-6) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - (sqrt(t_1) ^ 2.0)); elseif ((n ^ -1.0) <= 1e-12) tmp = Float64(t_0 + Float64(Float64(Float64(fma(Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n), 0.16666666666666666, Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)))) / n) - log(x)) / n)); else tmp = Float64(exp(t_0) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5e-6], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - N[Power[N[Sqrt[t$95$1], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 1e-12], N[(t$95$0 + N[(N[(N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666 + N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
t_1 := {x}^{\left({n}^{-1}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -5 \cdot 10^{-6}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - {\left(\sqrt{t\_1}\right)}^{2}\\
\mathbf{elif}\;{n}^{-1} \leq 10^{-12}:\\
\;\;\;\;t\_0 + \frac{\frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}, 0.16666666666666666, 0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right)\right)}{n} - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0} - t\_1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000041e-6Initial program 99.8%
lift-pow.f64N/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
pow-to-expN/A
associate-*r/N/A
exp-sqrt-revN/A
pow-to-expN/A
lift-pow.f64N/A
lower-sqrt.f6499.8
lift-/.f64N/A
inv-powN/A
lower-pow.f6499.8
Applied rewrites99.8%
if -5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 33.6%
Taylor expanded in n around -inf
Applied rewrites82.4%
Applied rewrites82.4%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6499.7
Applied rewrites99.7%
Final simplification90.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -5e-6)
(- (pow (+ x 1.0) (pow n -1.0)) (pow (sqrt t_0) 2.0))
(if (<= (pow n -1.0) 1e-12)
(/
(-
(+
(log1p 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))
(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) <= -5e-6) {
tmp = pow((x + 1.0), pow(n, -1.0)) - pow(sqrt(t_0), 2.0);
} else if (pow(n, -1.0) <= 1e-12) {
tmp = ((log1p(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)) - log(x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -5e-6) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - (sqrt(t_0) ^ 2.0)); elseif ((n ^ -1.0) <= 1e-12) tmp = Float64(Float64(Float64(log1p(x) + 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)) - 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], -5e-6], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - N[Power[N[Sqrt[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 1e-12], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + 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]), $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 -5 \cdot 10^{-6}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - {\left(\sqrt{t\_0}\right)}^{2}\\
\mathbf{elif}\;{n}^{-1} \leq 10^{-12}:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \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}\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) < -5.00000000000000041e-6Initial program 99.8%
lift-pow.f64N/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
pow-to-expN/A
associate-*r/N/A
exp-sqrt-revN/A
pow-to-expN/A
lift-pow.f64N/A
lower-sqrt.f6499.8
lift-/.f64N/A
inv-powN/A
lower-pow.f6499.8
Applied rewrites99.8%
if -5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 33.6%
Taylor expanded in n around -inf
Applied rewrites82.4%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6499.7
Applied rewrites99.7%
Final simplification90.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))) (t_1 (- (pow (+ x 1.0) (pow n -1.0)) t_0)))
(if (<= t_1 -1e-5)
(- 1.0 t_0)
(if (<= t_1 2e-10)
(/ (- (log1p x) (log x)) n)
(-
(fma
(/
(-
(fma
(fma -0.3333333333333333 x 0.5)
x
(/
(fma (/ (* x x) n) 0.16666666666666666 (* (fma -0.5 x 0.5) x))
(- n)))
1.0)
(- n))
x
1.0)
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double t_1 = pow((x + 1.0), pow(n, -1.0)) - t_0;
double tmp;
if (t_1 <= -1e-5) {
tmp = 1.0 - t_0;
} else if (t_1 <= 2e-10) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = fma(((fma(fma(-0.3333333333333333, x, 0.5), x, (fma(((x * x) / n), 0.16666666666666666, (fma(-0.5, x, 0.5) * x)) / -n)) - 1.0) / -n), x, 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) t_1 = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - t_0) tmp = 0.0 if (t_1 <= -1e-5) tmp = Float64(1.0 - t_0); elseif (t_1 <= 2e-10) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(fma(Float64(Float64(fma(fma(-0.3333333333333333, x, 0.5), x, Float64(fma(Float64(Float64(x * x) / n), 0.16666666666666666, Float64(fma(-0.5, x, 0.5) * x)) / Float64(-n))) - 1.0) / Float64(-n)), 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]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-5], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 2e-10], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666 + N[(N[(-0.5 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / (-n)), $MachinePrecision] * x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
t_1 := {\left(x + 1\right)}^{\left({n}^{-1}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-5}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, \frac{\mathsf{fma}\left(\frac{x \cdot x}{n}, 0.16666666666666666, \mathsf{fma}\left(-0.5, x, 0.5\right) \cdot x\right)}{-n}\right) - 1}{-n}, x, 1\right) - t\_0\\
\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))) < -1.00000000000000008e-5Initial program 98.6%
Taylor expanded in x around 0
Applied rewrites98.6%
if -1.00000000000000008e-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))) < 2.00000000000000007e-10Initial program 51.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6486.5
Applied rewrites86.5%
if 2.00000000000000007e-10 < (-.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 56.5%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in n around -inf
Applied rewrites77.6%
Final simplification87.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))) (t_1 (sqrt t_0)))
(if (<= (pow n -1.0) -1e-8)
(fma t_1 (- t_1) (exp (/ x n)))
(if (<= (pow n -1.0) 1e-12)
(/
(-
(fma 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n) (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 t_1 = sqrt(t_0);
double tmp;
if (pow(n, -1.0) <= -1e-8) {
tmp = fma(t_1, -t_1, exp((x / n)));
} else if (pow(n, -1.0) <= 1e-12) {
tmp = (fma(0.5, ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n), log1p(x)) - log(x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) t_1 = sqrt(t_0) tmp = 0.0 if ((n ^ -1.0) <= -1e-8) tmp = fma(t_1, Float64(-t_1), exp(Float64(x / n))); elseif ((n ^ -1.0) <= 1e-12) tmp = Float64(Float64(fma(0.5, Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n), 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]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1e-8], N[(t$95$1 * (-t$95$1) + N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 1e-12], N[(N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[Log[1 + x], $MachinePrecision]), $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)}\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;{n}^{-1} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -t\_1, e^{\frac{x}{n}}\right)\\
\mathbf{elif}\;{n}^{-1} \leq 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}, \mathsf{log1p}\left(x\right)\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) < -1e-8Initial program 98.3%
lift--.f64N/A
lift-pow.f64N/A
sqr-powN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
sqr-powN/A
lift-pow.f64N/A
+-commutativeN/A
lift-pow.f64N/A
sqr-powN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites98.3%
Taylor expanded in x around 0
lower-/.f6498.4
Applied rewrites98.4%
if -1e-8 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 33.2%
Taylor expanded in n around inf
lower-/.f64N/A
Applied rewrites82.8%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6499.7
Applied rewrites99.7%
Final simplification90.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))) (t_1 (sqrt t_0)))
(if (<= (pow n -1.0) -1e-8)
(fma t_1 (- t_1) (exp (/ x n)))
(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 t_1 = sqrt(t_0);
double tmp;
if (pow(n, -1.0) <= -1e-8) {
tmp = fma(t_1, -t_1, exp((x / n)));
} else if (pow(n, -1.0) <= 1e-12) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) t_1 = sqrt(t_0) tmp = 0.0 if ((n ^ -1.0) <= -1e-8) tmp = fma(t_1, Float64(-t_1), exp(Float64(x / n))); 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]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1e-8], N[(t$95$1 * (-t$95$1) + N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision]), $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)}\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;{n}^{-1} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -t\_1, e^{\frac{x}{n}}\right)\\
\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) < -1e-8Initial program 98.3%
lift--.f64N/A
lift-pow.f64N/A
sqr-powN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
sqr-powN/A
lift-pow.f64N/A
+-commutativeN/A
lift-pow.f64N/A
sqr-powN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites98.3%
Taylor expanded in x around 0
lower-/.f6498.4
Applied rewrites98.4%
if -1e-8 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 33.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6482.6
Applied rewrites82.6%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6499.7
Applied rewrites99.7%
Final simplification90.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -2e-8)
(- (pow (+ x 1.0) (pow n -1.0)) (pow (sqrt t_0) 2.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) <= -2e-8) {
tmp = pow((x + 1.0), pow(n, -1.0)) - pow(sqrt(t_0), 2.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) <= -2e-8) {
tmp = Math.pow((x + 1.0), Math.pow(n, -1.0)) - Math.pow(Math.sqrt(t_0), 2.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) <= -2e-8: tmp = math.pow((x + 1.0), math.pow(n, -1.0)) - math.pow(math.sqrt(t_0), 2.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) <= -2e-8) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - (sqrt(t_0) ^ 2.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], -2e-8], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - N[Power[N[Sqrt[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $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 -2 \cdot 10^{-8}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - {\left(\sqrt{t\_0}\right)}^{2}\\
\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) < -2e-8Initial program 99.4%
lift-pow.f64N/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
pow-to-expN/A
associate-*r/N/A
exp-sqrt-revN/A
pow-to-expN/A
lift-pow.f64N/A
lower-sqrt.f6499.4
lift-/.f64N/A
inv-powN/A
lower-pow.f6499.4
Applied rewrites99.4%
if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 32.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6482.0
Applied rewrites82.0%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6499.7
Applied rewrites99.7%
Final simplification90.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -2e-8)
(- (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) <= -2e-8) {
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) <= -2e-8) {
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) <= -2e-8: 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) <= -2e-8) 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], -2e-8], 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 -2 \cdot 10^{-8}:\\
\;\;\;\;{\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) < -2e-8Initial program 99.4%
if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 32.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6482.0
Applied rewrites82.0%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6499.7
Applied rewrites99.7%
Final simplification90.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -2e-8)
(- 1.0 t_0)
(if (<= (pow n -1.0) 2e-24)
(/ (/ (+ (/ (log x) n) 1.0) x) n)
(- (fma (fma (/ (+ -0.5 (/ 0.5 n)) n) x (pow n -1.0)) 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) <= -2e-8) {
tmp = 1.0 - t_0;
} else if (pow(n, -1.0) <= 2e-24) {
tmp = (((log(x) / n) + 1.0) / x) / n;
} else {
tmp = fma(fma(((-0.5 + (0.5 / n)) / n), x, pow(n, -1.0)), x, 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -2e-8) tmp = Float64(1.0 - t_0); elseif ((n ^ -1.0) <= 2e-24) tmp = Float64(Float64(Float64(Float64(log(x) / n) + 1.0) / x) / n); else tmp = Float64(fma(fma(Float64(Float64(-0.5 + Float64(0.5 / n)) / n), x, (n ^ -1.0)), 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], -2e-8], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 2e-24], N[(N[(N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * x + N[Power[n, -1.0], $MachinePrecision]), $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 -2 \cdot 10^{-8}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;{n}^{-1} \leq 2 \cdot 10^{-24}:\\
\;\;\;\;\frac{\frac{\frac{\log x}{n} + 1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{-0.5 + \frac{0.5}{n}}{n}, x, {n}^{-1}\right), x, 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-8Initial program 99.4%
Taylor expanded in x around 0
Applied rewrites45.1%
if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999985e-24Initial program 32.8%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6449.5
Applied rewrites49.5%
Taylor expanded in n around inf
Applied rewrites50.3%
if 1.99999999999999985e-24 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites70.6%
Final simplification51.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -2e-8)
(- (pow (+ x 1.0) (pow n -1.0)) t_0)
(if (<= (pow n -1.0) 1e-12)
(/ (- (log1p x) (log x)) n)
(-
(fma
(/
(-
(fma
(fma -0.3333333333333333 x 0.5)
x
(/
(fma (/ (* x x) n) 0.16666666666666666 (* (fma -0.5 x 0.5) x))
(- n)))
1.0)
(- n))
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) <= -2e-8) {
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 = fma(((fma(fma(-0.3333333333333333, x, 0.5), x, (fma(((x * x) / n), 0.16666666666666666, (fma(-0.5, x, 0.5) * x)) / -n)) - 1.0) / -n), x, 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -2e-8) 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(fma(Float64(Float64(fma(fma(-0.3333333333333333, x, 0.5), x, Float64(fma(Float64(Float64(x * x) / n), 0.16666666666666666, Float64(fma(-0.5, x, 0.5) * x)) / Float64(-n))) - 1.0) / Float64(-n)), 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], -2e-8], 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[(N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666 + N[(N[(-0.5 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / (-n)), $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 -2 \cdot 10^{-8}:\\
\;\;\;\;{\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}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, \frac{\mathsf{fma}\left(\frac{x \cdot x}{n}, 0.16666666666666666, \mathsf{fma}\left(-0.5, x, 0.5\right) \cdot x\right)}{-n}\right) - 1}{-n}, x, 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-8Initial program 99.4%
if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13Initial program 32.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6482.0
Applied rewrites82.0%
if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in n around -inf
Applied rewrites77.6%
Final simplification87.6%
(FPCore (x n)
:precision binary64
(if (<= x 0.025)
(-
(fma
(/
(-
(fma
(fma -0.3333333333333333 x 0.5)
x
(/
(fma (/ (* x x) n) 0.16666666666666666 (* (fma -0.5 x 0.5) x))
(- n)))
1.0)
(- n))
x
1.0)
(pow x (pow n -1.0)))
(* (pow (* x x) -0.5) (pow n -1.0))))
double code(double x, double n) {
double tmp;
if (x <= 0.025) {
tmp = fma(((fma(fma(-0.3333333333333333, x, 0.5), x, (fma(((x * x) / n), 0.16666666666666666, (fma(-0.5, x, 0.5) * x)) / -n)) - 1.0) / -n), x, 1.0) - pow(x, pow(n, -1.0));
} else {
tmp = pow((x * x), -0.5) * pow(n, -1.0);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 0.025) tmp = Float64(fma(Float64(Float64(fma(fma(-0.3333333333333333, x, 0.5), x, Float64(fma(Float64(Float64(x * x) / n), 0.16666666666666666, Float64(fma(-0.5, x, 0.5) * x)) / Float64(-n))) - 1.0) / Float64(-n)), x, 1.0) - (x ^ (n ^ -1.0))); else tmp = Float64((Float64(x * x) ^ -0.5) * (n ^ -1.0)); end return tmp end
code[x_, n_] := If[LessEqual[x, 0.025], N[(N[(N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666 + N[(N[(-0.5 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / (-n)), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(x * x), $MachinePrecision], -0.5], $MachinePrecision] * N[Power[n, -1.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.025:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, \frac{\mathsf{fma}\left(\frac{x \cdot x}{n}, 0.16666666666666666, \mathsf{fma}\left(-0.5, x, 0.5\right) \cdot x\right)}{-n}\right) - 1}{-n}, x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.5} \cdot {n}^{-1}\\
\end{array}
\end{array}
if x < 0.025000000000000001Initial program 44.5%
Taylor expanded in x around 0
Applied rewrites32.0%
Taylor expanded in n around -inf
Applied rewrites48.6%
if 0.025000000000000001 < x Initial program 77.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6496.5
Applied rewrites96.5%
Taylor expanded in n around inf
Applied rewrites55.0%
Applied rewrites55.0%
Applied rewrites68.2%
Final simplification57.6%
(FPCore (x n)
:precision binary64
(if (<= x 1.0)
(-
(fma
(/
(-
(fma
(fma -0.3333333333333333 x 0.5)
x
(/
(fma (/ (* x x) n) 0.16666666666666666 (* (fma -0.5 x 0.5) x))
(- n)))
1.0)
(- n))
x
1.0)
(pow x (pow n -1.0)))
(/ (/ (- 1.0 (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = fma(((fma(fma(-0.3333333333333333, x, 0.5), x, (fma(((x * x) / n), 0.16666666666666666, (fma(-0.5, x, 0.5) * x)) / -n)) - 1.0) / -n), x, 1.0) - pow(x, pow(n, -1.0));
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(fma(Float64(Float64(fma(fma(-0.3333333333333333, x, 0.5), x, Float64(fma(Float64(Float64(x * x) / n), 0.16666666666666666, Float64(fma(-0.5, x, 0.5) * x)) / Float64(-n))) - 1.0) / Float64(-n)), x, 1.0) - (x ^ (n ^ -1.0))); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666 + N[(N[(-0.5 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / (-n)), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, \frac{\mathsf{fma}\left(\frac{x \cdot x}{n}, 0.16666666666666666, \mathsf{fma}\left(-0.5, x, 0.5\right) \cdot x\right)}{-n}\right) - 1}{-n}, x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 1Initial program 44.2%
Taylor expanded in x around 0
Applied rewrites31.8%
Taylor expanded in n around -inf
Applied rewrites48.3%
if 1 < x Initial program 78.0%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites77.2%
Taylor expanded in n around inf
Applied rewrites55.8%
Final simplification51.7%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (- (+ (/ x n) 1.0) (pow x (pow n -1.0))) (/ (/ (- 1.0 (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = ((x / n) + 1.0) - pow(x, pow(n, -1.0));
} else {
tmp = ((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.0d0) then
tmp = ((x / n) + 1.0d0) - (x ** (n ** (-1.0d0)))
else
tmp = ((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.0) {
tmp = ((x / n) + 1.0) - Math.pow(x, Math.pow(n, -1.0));
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = ((x / n) + 1.0) - math.pow(x, math.pow(n, -1.0)) else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(Float64(x / n) + 1.0) - (x ^ (n ^ -1.0))); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = ((x / n) + 1.0) - (x ^ (n ^ -1.0)); else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 1Initial program 44.2%
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-/.f6442.7
Applied rewrites42.7%
if 1 < x Initial program 78.0%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites77.2%
Taylor expanded in n around inf
Applied rewrites55.8%
Final simplification48.6%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (- 1.0 (pow x (pow n -1.0))) (/ (/ (- 1.0 (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = 1.0 - pow(x, pow(n, -1.0));
} else {
tmp = ((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.0d0) then
tmp = 1.0d0 - (x ** (n ** (-1.0d0)))
else
tmp = ((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.0) {
tmp = 1.0 - Math.pow(x, Math.pow(n, -1.0));
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = 1.0 - math.pow(x, math.pow(n, -1.0)) else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(1.0 - (x ^ (n ^ -1.0))); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = 1.0 - (x ^ (n ^ -1.0)); else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(1.0 - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;1 - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 1Initial program 44.2%
Taylor expanded in x around 0
Applied rewrites42.1%
if 1 < x Initial program 78.0%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites77.2%
Taylor expanded in n around inf
Applied rewrites55.8%
Final simplification48.3%
(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 59.5%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
Taylor expanded in n around inf
Applied rewrites36.2%
Applied rewrites36.2%
(FPCore (x n) :precision binary64 (/ (pow n -1.0) x))
double code(double x, double n) {
return pow(n, -1.0) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (n ** (-1.0d0)) / x
end function
public static double code(double x, double n) {
return Math.pow(n, -1.0) / x;
}
def code(x, n): return math.pow(n, -1.0) / x
function code(x, n) return Float64((n ^ -1.0) / x) end
function tmp = code(x, n) tmp = (n ^ -1.0) / x; end
code[x_, n_] := N[(N[Power[n, -1.0], $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{{n}^{-1}}{x}
\end{array}
Initial program 59.5%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
Taylor expanded in n around inf
Applied rewrites36.2%
Final simplification36.2%
(FPCore (x n) :precision binary64 (pow (* n x) -1.0))
double code(double x, double n) {
return pow((n * x), -1.0);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (n * x) ** (-1.0d0)
end function
public static double code(double x, double n) {
return Math.pow((n * x), -1.0);
}
def code(x, n): return math.pow((n * x), -1.0)
function code(x, n) return Float64(n * x) ^ -1.0 end
function tmp = code(x, n) tmp = (n * x) ^ -1.0; end
code[x_, n_] := N[Power[N[(n * x), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(n \cdot x\right)}^{-1}
\end{array}
Initial program 59.5%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
Taylor expanded in n around inf
Applied rewrites36.2%
Applied rewrites35.7%
Final simplification35.7%
herbie shell --seed 2024342
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))