
(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 20 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 (<= (pow n -1.0) -2e-8)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (pow n -1.0) 2e-23)
(/ (log1p (pow x -1.0)) n)
(- (exp (/ x n)) (pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -2e-8) {
tmp = exp((log(x) / n)) / (n * x);
} else if (pow(n, -1.0) <= 2e-23) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = exp((x / n)) - pow(x, pow(n, -1.0));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -2e-8) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if (Math.pow(n, -1.0) <= 2e-23) {
tmp = Math.log1p(Math.pow(x, -1.0)) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, Math.pow(n, -1.0));
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -2e-8: tmp = math.exp((math.log(x) / n)) / (n * x) elif math.pow(n, -1.0) <= 2e-23: tmp = math.log1p(math.pow(x, -1.0)) / n else: tmp = math.exp((x / n)) - math.pow(x, math.pow(n, -1.0)) return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -2e-8) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif ((n ^ -1.0) <= 2e-23) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -2e-8], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 2e-23], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -2 \cdot 10^{-8}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;{n}^{-1} \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-8Initial program 96.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-*.f6498.7
Applied rewrites98.7%
if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999992e-23Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6478.6
Applied rewrites78.6%
Applied rewrites78.8%
Applied rewrites98.5%
if 1.99999999999999992e-23 < (/.f64 #s(literal 1 binary64) n) Initial program 58.2%
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.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-/.f64100.0
Applied rewrites100.0%
Final simplification98.8%
(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 -5e-8)
(- 1.0 t_0)
(if (<= t_1 0.0)
(/ (log (/ (+ 1.0 x) 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 t_1 = pow((x + 1.0), pow(n, -1.0)) - t_0;
double tmp;
if (t_1 <= -5e-8) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.0) {
tmp = log(((1.0 + x) / 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) t_1 = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - t_0) tmp = 0.0 if (t_1 <= -5e-8) tmp = Float64(1.0 - t_0); elseif (t_1 <= 0.0) tmp = Float64(log(Float64(Float64(1.0 + x) / 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]}, 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, -5e-8], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $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)}\\
t_1 := {\left(x + 1\right)}^{\left({n}^{-1}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-8}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{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 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -4.9999999999999998e-8Initial program 98.7%
Taylor expanded in x around 0
Applied rewrites98.7%
if -4.9999999999999998e-8 < (-.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.0Initial program 42.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6481.0
Applied rewrites81.0%
Applied rewrites81.2%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 58.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites75.3%
Final simplification83.3%
(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 -5e-8)
(- 1.0 t_0)
(if (<= t_1 0.0) (/ (log (/ (+ 1.0 x) x)) n) (- (+ (/ x n) 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 <= -5e-8) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.0) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = ((x / n) + 1.0) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (n ** (-1.0d0))
t_1 = ((x + 1.0d0) ** (n ** (-1.0d0))) - t_0
if (t_1 <= (-5d-8)) then
tmp = 1.0d0 - t_0
else if (t_1 <= 0.0d0) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = ((x / n) + 1.0d0) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, Math.pow(n, -1.0));
double t_1 = Math.pow((x + 1.0), Math.pow(n, -1.0)) - t_0;
double tmp;
if (t_1 <= -5e-8) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.0) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = ((x / n) + 1.0) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, math.pow(n, -1.0)) t_1 = math.pow((x + 1.0), math.pow(n, -1.0)) - t_0 tmp = 0 if t_1 <= -5e-8: tmp = 1.0 - t_0 elif t_1 <= 0.0: tmp = math.log(((1.0 + x) / x)) / n else: tmp = ((x / n) + 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 <= -5e-8) tmp = Float64(1.0 - t_0); elseif (t_1 <= 0.0) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(Float64(Float64(x / n) + 1.0) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (n ^ -1.0); t_1 = ((x + 1.0) ^ (n ^ -1.0)) - t_0; tmp = 0.0; if (t_1 <= -5e-8) tmp = 1.0 - t_0; elseif (t_1 <= 0.0) tmp = log(((1.0 + x) / x)) / n; else tmp = ((x / n) + 1.0) - t_0; end tmp_2 = 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, -5e-8], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(x / n), $MachinePrecision] + 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 -5 \cdot 10^{-8}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{n} + 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))) < -4.9999999999999998e-8Initial program 98.7%
Taylor expanded in x around 0
Applied rewrites98.7%
if -4.9999999999999998e-8 < (-.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.0Initial program 42.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6481.0
Applied rewrites81.0%
Applied rewrites81.2%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 58.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-/.f6452.6
Applied rewrites52.6%
Final simplification79.8%
(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 (or (<= t_1 -5e-8) (not (<= t_1 0.0)))
(- 1.0 t_0)
(/ (log (/ (+ 1.0 x) x)) n))))
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 <= -5e-8) || !(t_1 <= 0.0)) {
tmp = 1.0 - t_0;
} else {
tmp = log(((1.0 + x) / 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 ** (n ** (-1.0d0))
t_1 = ((x + 1.0d0) ** (n ** (-1.0d0))) - t_0
if ((t_1 <= (-5d-8)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = 1.0d0 - t_0
else
tmp = log(((1.0d0 + x) / x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, Math.pow(n, -1.0));
double t_1 = Math.pow((x + 1.0), Math.pow(n, -1.0)) - t_0;
double tmp;
if ((t_1 <= -5e-8) || !(t_1 <= 0.0)) {
tmp = 1.0 - t_0;
} else {
tmp = Math.log(((1.0 + x) / x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, math.pow(n, -1.0)) t_1 = math.pow((x + 1.0), math.pow(n, -1.0)) - t_0 tmp = 0 if (t_1 <= -5e-8) or not (t_1 <= 0.0): tmp = 1.0 - t_0 else: tmp = math.log(((1.0 + x) / x)) / n 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 <= -5e-8) || !(t_1 <= 0.0)) tmp = Float64(1.0 - t_0); else tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (n ^ -1.0); t_1 = ((x + 1.0) ^ (n ^ -1.0)) - t_0; tmp = 0.0; if ((t_1 <= -5e-8) || ~((t_1 <= 0.0))) tmp = 1.0 - t_0; else tmp = log(((1.0 + x) / x)) / n; end tmp_2 = 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[Or[LessEqual[t$95$1, -5e-8], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(1.0 - t$95$0), $MachinePrecision], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $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 -5 \cdot 10^{-8} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{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))) < -4.9999999999999998e-8 or 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 79.7%
Taylor expanded in x around 0
Applied rewrites76.2%
if -4.9999999999999998e-8 < (-.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.0Initial program 42.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6481.0
Applied rewrites81.0%
Applied rewrites81.2%
Final simplification79.5%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -5000.0)
(/ 0.3333333333333333 (* (pow x 3.0) n))
(if (<= (pow n -1.0) -5e-78)
(/ (pow x -1.0) n)
(if (<= (pow n -1.0) 5e-217)
(/ (- (log x)) n)
(if (<= (pow n -1.0) 5e-159)
(/
(/
(- (/ (+ (/ (- (/ 0.25 x) 0.3333333333333333) x) 0.5) x) 1.0)
(- x))
n)
(if (<= (pow n -1.0) 5e-29)
(/ (- x (log x)) n)
(if (<= (pow n -1.0) 5e+177)
(- 1.0 (pow x (pow n -1.0)))
(/ (/ n x) (* n n)))))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / (pow(x, 3.0) * n);
} else if (pow(n, -1.0) <= -5e-78) {
tmp = pow(x, -1.0) / n;
} else if (pow(n, -1.0) <= 5e-217) {
tmp = -log(x) / n;
} else if (pow(n, -1.0) <= 5e-159) {
tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n;
} else if (pow(n, -1.0) <= 5e-29) {
tmp = (x - log(x)) / n;
} else if (pow(n, -1.0) <= 5e+177) {
tmp = 1.0 - pow(x, pow(n, -1.0));
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n ** (-1.0d0)) <= (-5000.0d0)) then
tmp = 0.3333333333333333d0 / ((x ** 3.0d0) * n)
else if ((n ** (-1.0d0)) <= (-5d-78)) then
tmp = (x ** (-1.0d0)) / n
else if ((n ** (-1.0d0)) <= 5d-217) then
tmp = -log(x) / n
else if ((n ** (-1.0d0)) <= 5d-159) then
tmp = (((((((0.25d0 / x) - 0.3333333333333333d0) / x) + 0.5d0) / x) - 1.0d0) / -x) / n
else if ((n ** (-1.0d0)) <= 5d-29) then
tmp = (x - log(x)) / n
else if ((n ** (-1.0d0)) <= 5d+177) then
tmp = 1.0d0 - (x ** (n ** (-1.0d0)))
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / (Math.pow(x, 3.0) * n);
} else if (Math.pow(n, -1.0) <= -5e-78) {
tmp = Math.pow(x, -1.0) / n;
} else if (Math.pow(n, -1.0) <= 5e-217) {
tmp = -Math.log(x) / n;
} else if (Math.pow(n, -1.0) <= 5e-159) {
tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n;
} else if (Math.pow(n, -1.0) <= 5e-29) {
tmp = (x - Math.log(x)) / n;
} else if (Math.pow(n, -1.0) <= 5e+177) {
tmp = 1.0 - Math.pow(x, Math.pow(n, -1.0));
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -5000.0: tmp = 0.3333333333333333 / (math.pow(x, 3.0) * n) elif math.pow(n, -1.0) <= -5e-78: tmp = math.pow(x, -1.0) / n elif math.pow(n, -1.0) <= 5e-217: tmp = -math.log(x) / n elif math.pow(n, -1.0) <= 5e-159: tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n elif math.pow(n, -1.0) <= 5e-29: tmp = (x - math.log(x)) / n elif math.pow(n, -1.0) <= 5e+177: tmp = 1.0 - math.pow(x, math.pow(n, -1.0)) else: tmp = (n / x) / (n * n) return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -5000.0) tmp = Float64(0.3333333333333333 / Float64((x ^ 3.0) * n)); elseif ((n ^ -1.0) <= -5e-78) tmp = Float64((x ^ -1.0) / n); elseif ((n ^ -1.0) <= 5e-217) tmp = Float64(Float64(-log(x)) / n); elseif ((n ^ -1.0) <= 5e-159) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / Float64(-x)) / n); elseif ((n ^ -1.0) <= 5e-29) tmp = Float64(Float64(x - log(x)) / n); elseif ((n ^ -1.0) <= 5e+177) tmp = Float64(1.0 - (x ^ (n ^ -1.0))); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -5000.0) tmp = 0.3333333333333333 / ((x ^ 3.0) * n); elseif ((n ^ -1.0) <= -5e-78) tmp = (x ^ -1.0) / n; elseif ((n ^ -1.0) <= 5e-217) tmp = -log(x) / n; elseif ((n ^ -1.0) <= 5e-159) tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n; elseif ((n ^ -1.0) <= 5e-29) tmp = (x - log(x)) / n; elseif ((n ^ -1.0) <= 5e+177) tmp = 1.0 - (x ^ (n ^ -1.0)); else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5000.0], N[(0.3333333333333333 / N[(N[Power[x, 3.0], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5e-78], N[(N[Power[x, -1.0], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-217], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-159], N[(N[(N[(N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] / x), $MachinePrecision] + 0.5), $MachinePrecision] / x), $MachinePrecision] - 1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-29], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e+177], N[(1.0 - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -5000:\\
\;\;\;\;\frac{0.3333333333333333}{{x}^{3} \cdot n}\\
\mathbf{elif}\;{n}^{-1} \leq -5 \cdot 10^{-78}:\\
\;\;\;\;\frac{{x}^{-1}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-217}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-159}:\\
\;\;\;\;\frac{\frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{x} + 0.5}{x} - 1}{-x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-29}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{+177}:\\
\;\;\;\;1 - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e3Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6445.5
Applied rewrites45.5%
Taylor expanded in x around inf
Applied rewrites22.3%
Taylor expanded in x around 0
Applied rewrites84.2%
if -5e3 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999996e-78Initial program 29.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6446.9
Applied rewrites46.9%
Taylor expanded in x around inf
Applied rewrites54.5%
if -4.9999999999999996e-78 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000002e-217Initial program 34.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6490.4
Applied rewrites90.4%
Taylor expanded in x around 0
Applied rewrites60.9%
if 5.0000000000000002e-217 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000032e-159Initial program 47.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6471.4
Applied rewrites71.4%
Taylor expanded in x around -inf
Applied rewrites81.2%
if 5.00000000000000032e-159 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999986e-29Initial program 8.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6471.8
Applied rewrites71.8%
Taylor expanded in x around 0
Applied rewrites67.9%
if 4.99999999999999986e-29 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e177Initial program 85.7%
Taylor expanded in x around 0
Applied rewrites76.9%
if 5.0000000000000003e177 < (/.f64 #s(literal 1 binary64) n) Initial program 26.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.5
Applied rewrites6.5%
Applied rewrites78.5%
Taylor expanded in x around inf
Applied rewrites78.5%
Final simplification71.5%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -5000.0)
(/ 0.3333333333333333 (* (* x x) (* n x)))
(if (<= (pow n -1.0) -5e-78)
(/ (pow x -1.0) n)
(if (<= (pow n -1.0) 5e-217)
(/ (- (log x)) n)
(if (<= (pow n -1.0) 5e-159)
(/
(/
(- (/ (+ (/ (- (/ 0.25 x) 0.3333333333333333) x) 0.5) x) 1.0)
(- x))
n)
(if (<= (pow n -1.0) 5e-29)
(/ (- x (log x)) n)
(if (<= (pow n -1.0) 5e+177)
(- 1.0 (pow x (pow n -1.0)))
(/ (/ n x) (* n n)))))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else if (pow(n, -1.0) <= -5e-78) {
tmp = pow(x, -1.0) / n;
} else if (pow(n, -1.0) <= 5e-217) {
tmp = -log(x) / n;
} else if (pow(n, -1.0) <= 5e-159) {
tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n;
} else if (pow(n, -1.0) <= 5e-29) {
tmp = (x - log(x)) / n;
} else if (pow(n, -1.0) <= 5e+177) {
tmp = 1.0 - pow(x, pow(n, -1.0));
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n ** (-1.0d0)) <= (-5000.0d0)) then
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
else if ((n ** (-1.0d0)) <= (-5d-78)) then
tmp = (x ** (-1.0d0)) / n
else if ((n ** (-1.0d0)) <= 5d-217) then
tmp = -log(x) / n
else if ((n ** (-1.0d0)) <= 5d-159) then
tmp = (((((((0.25d0 / x) - 0.3333333333333333d0) / x) + 0.5d0) / x) - 1.0d0) / -x) / n
else if ((n ** (-1.0d0)) <= 5d-29) then
tmp = (x - log(x)) / n
else if ((n ** (-1.0d0)) <= 5d+177) then
tmp = 1.0d0 - (x ** (n ** (-1.0d0)))
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else if (Math.pow(n, -1.0) <= -5e-78) {
tmp = Math.pow(x, -1.0) / n;
} else if (Math.pow(n, -1.0) <= 5e-217) {
tmp = -Math.log(x) / n;
} else if (Math.pow(n, -1.0) <= 5e-159) {
tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n;
} else if (Math.pow(n, -1.0) <= 5e-29) {
tmp = (x - Math.log(x)) / n;
} else if (Math.pow(n, -1.0) <= 5e+177) {
tmp = 1.0 - Math.pow(x, Math.pow(n, -1.0));
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -5000.0: tmp = 0.3333333333333333 / ((x * x) * (n * x)) elif math.pow(n, -1.0) <= -5e-78: tmp = math.pow(x, -1.0) / n elif math.pow(n, -1.0) <= 5e-217: tmp = -math.log(x) / n elif math.pow(n, -1.0) <= 5e-159: tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n elif math.pow(n, -1.0) <= 5e-29: tmp = (x - math.log(x)) / n elif math.pow(n, -1.0) <= 5e+177: tmp = 1.0 - math.pow(x, math.pow(n, -1.0)) else: tmp = (n / x) / (n * n) return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -5000.0) tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); elseif ((n ^ -1.0) <= -5e-78) tmp = Float64((x ^ -1.0) / n); elseif ((n ^ -1.0) <= 5e-217) tmp = Float64(Float64(-log(x)) / n); elseif ((n ^ -1.0) <= 5e-159) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / Float64(-x)) / n); elseif ((n ^ -1.0) <= 5e-29) tmp = Float64(Float64(x - log(x)) / n); elseif ((n ^ -1.0) <= 5e+177) tmp = Float64(1.0 - (x ^ (n ^ -1.0))); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -5000.0) tmp = 0.3333333333333333 / ((x * x) * (n * x)); elseif ((n ^ -1.0) <= -5e-78) tmp = (x ^ -1.0) / n; elseif ((n ^ -1.0) <= 5e-217) tmp = -log(x) / n; elseif ((n ^ -1.0) <= 5e-159) tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n; elseif ((n ^ -1.0) <= 5e-29) tmp = (x - log(x)) / n; elseif ((n ^ -1.0) <= 5e+177) tmp = 1.0 - (x ^ (n ^ -1.0)); else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5000.0], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5e-78], N[(N[Power[x, -1.0], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-217], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-159], N[(N[(N[(N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] / x), $MachinePrecision] + 0.5), $MachinePrecision] / x), $MachinePrecision] - 1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-29], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e+177], N[(1.0 - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -5000:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{elif}\;{n}^{-1} \leq -5 \cdot 10^{-78}:\\
\;\;\;\;\frac{{x}^{-1}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-217}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-159}:\\
\;\;\;\;\frac{\frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{x} + 0.5}{x} - 1}{-x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-29}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{+177}:\\
\;\;\;\;1 - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e3Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6445.5
Applied rewrites45.5%
Taylor expanded in x around inf
Applied rewrites22.3%
Taylor expanded in x around 0
Applied rewrites84.2%
Applied rewrites79.0%
if -5e3 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999996e-78Initial program 29.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6446.9
Applied rewrites46.9%
Taylor expanded in x around inf
Applied rewrites54.5%
if -4.9999999999999996e-78 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000002e-217Initial program 34.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6490.4
Applied rewrites90.4%
Taylor expanded in x around 0
Applied rewrites60.9%
if 5.0000000000000002e-217 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000032e-159Initial program 47.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6471.4
Applied rewrites71.4%
Taylor expanded in x around -inf
Applied rewrites81.2%
if 5.00000000000000032e-159 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999986e-29Initial program 8.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6471.8
Applied rewrites71.8%
Taylor expanded in x around 0
Applied rewrites67.9%
if 4.99999999999999986e-29 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e177Initial program 85.7%
Taylor expanded in x around 0
Applied rewrites76.9%
if 5.0000000000000003e177 < (/.f64 #s(literal 1 binary64) n) Initial program 26.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.5
Applied rewrites6.5%
Applied rewrites78.5%
Taylor expanded in x around inf
Applied rewrites78.5%
Final simplification70.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -2e-8)
(/ (/ t_0 n) x)
(if (<= (pow n -1.0) 2e-23)
(/ (log1p (pow x -1.0)) 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 = (t_0 / n) / x;
} else if (pow(n, -1.0) <= 2e-23) {
tmp = log1p(pow(x, -1.0)) / 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(Float64(t_0 / n) / x); elseif ((n ^ -1.0) <= 2e-23) tmp = Float64(log1p((x ^ -1.0)) / 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[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 2e-23], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $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}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;{n}^{-1} \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{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 96.3%
Taylor expanded in x around inf
Applied rewrites40.3%
Applied rewrites40.3%
Taylor expanded in x around inf
Applied rewrites98.7%
Applied rewrites98.7%
if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999992e-23Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6478.6
Applied rewrites78.6%
Applied rewrites78.8%
Applied rewrites98.5%
if 1.99999999999999992e-23 < (/.f64 #s(literal 1 binary64) n) Initial program 58.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites75.3%
Final simplification95.0%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -5000.0)
(/ 0.3333333333333333 (* (pow x 3.0) n))
(if (<= (pow n -1.0) 2e-23)
(/ (log1p (pow x -1.0)) n)
(-
(fma (fma (/ (+ -0.5 (/ 0.5 n)) n) x (pow n -1.0)) x 1.0)
(pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / (pow(x, 3.0) * n);
} else if (pow(n, -1.0) <= 2e-23) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = fma(fma(((-0.5 + (0.5 / n)) / n), x, pow(n, -1.0)), x, 1.0) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -5000.0) tmp = Float64(0.3333333333333333 / Float64((x ^ 3.0) * n)); elseif ((n ^ -1.0) <= 2e-23) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(fma(fma(Float64(Float64(-0.5 + Float64(0.5 / n)) / n), x, (n ^ -1.0)), x, 1.0) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5000.0], N[(0.3333333333333333 / N[(N[Power[x, 3.0], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 2e-23], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $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] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -5000:\\
\;\;\;\;\frac{0.3333333333333333}{{x}^{3} \cdot n}\\
\mathbf{elif}\;{n}^{-1} \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{-0.5 + \frac{0.5}{n}}{n}, x, {n}^{-1}\right), x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e3Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6445.5
Applied rewrites45.5%
Taylor expanded in x around inf
Applied rewrites22.3%
Taylor expanded in x around 0
Applied rewrites84.2%
if -5e3 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999992e-23Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6476.7
Applied rewrites76.7%
Applied rewrites76.8%
Applied rewrites96.5%
if 1.99999999999999992e-23 < (/.f64 #s(literal 1 binary64) n) Initial program 58.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites75.3%
Final simplification89.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -2e-8)
(/ (/ t_0 n) x)
(if (<= (pow n -1.0) 2e-23)
(/ (log1p (pow x -1.0)) n)
(- (exp (/ 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 = (t_0 / n) / x;
} else if (pow(n, -1.0) <= 2e-23) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = exp((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 = (t_0 / n) / x;
} else if (Math.pow(n, -1.0) <= 2e-23) {
tmp = Math.log1p(Math.pow(x, -1.0)) / n;
} else {
tmp = Math.exp((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 = (t_0 / n) / x elif math.pow(n, -1.0) <= 2e-23: tmp = math.log1p(math.pow(x, -1.0)) / n else: tmp = math.exp((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(t_0 / n) / x); elseif ((n ^ -1.0) <= 2e-23) tmp = Float64(log1p((x ^ -1.0)) / 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[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -2e-8], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 2e-23], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;{n}^{-1} \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-8Initial program 96.3%
Taylor expanded in x around inf
Applied rewrites40.3%
Applied rewrites40.3%
Taylor expanded in x around inf
Applied rewrites98.7%
Applied rewrites98.7%
if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999992e-23Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6478.6
Applied rewrites78.6%
Applied rewrites78.8%
Applied rewrites98.5%
if 1.99999999999999992e-23 < (/.f64 #s(literal 1 binary64) n) Initial program 58.2%
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.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-/.f64100.0
Applied rewrites100.0%
Final simplification98.8%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -5000.0) (/ 0.3333333333333333 (* (* x x) (* n x))) (if (<= (pow n -1.0) 1e-39) (/ (pow x -1.0) n) (/ (/ n x) (* n n)))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else if (pow(n, -1.0) <= 1e-39) {
tmp = pow(x, -1.0) / n;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n ** (-1.0d0)) <= (-5000.0d0)) then
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
else if ((n ** (-1.0d0)) <= 1d-39) then
tmp = (x ** (-1.0d0)) / n
else
tmp = (n / x) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else if (Math.pow(n, -1.0) <= 1e-39) {
tmp = Math.pow(x, -1.0) / n;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -5000.0: tmp = 0.3333333333333333 / ((x * x) * (n * x)) elif math.pow(n, -1.0) <= 1e-39: tmp = math.pow(x, -1.0) / n else: tmp = (n / x) / (n * n) return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -5000.0) tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); elseif ((n ^ -1.0) <= 1e-39) tmp = Float64((x ^ -1.0) / n); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -5000.0) tmp = 0.3333333333333333 / ((x * x) * (n * x)); elseif ((n ^ -1.0) <= 1e-39) tmp = (x ^ -1.0) / n; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5000.0], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 1e-39], N[(N[Power[x, -1.0], $MachinePrecision] / n), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -5000:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{elif}\;{n}^{-1} \leq 10^{-39}:\\
\;\;\;\;\frac{{x}^{-1}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e3Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6445.5
Applied rewrites45.5%
Taylor expanded in x around inf
Applied rewrites22.3%
Taylor expanded in x around 0
Applied rewrites84.2%
Applied rewrites79.0%
if -5e3 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999929e-40Initial program 30.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6476.9
Applied rewrites76.9%
Taylor expanded in x around inf
Applied rewrites47.9%
if 9.99999999999999929e-40 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6410.3
Applied rewrites10.3%
Applied rewrites43.3%
Taylor expanded in x around inf
Applied rewrites43.0%
Final simplification55.9%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -5000.0) (/ 0.3333333333333333 (* (* x x) (* n x))) (/ (pow x -1.0) n)))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = pow(x, -1.0) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n ** (-1.0d0)) <= (-5000.0d0)) then
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
else
tmp = (x ** (-1.0d0)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -5000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = Math.pow(x, -1.0) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -5000.0: tmp = 0.3333333333333333 / ((x * x) * (n * x)) else: tmp = math.pow(x, -1.0) / n return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -5000.0) tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); else tmp = Float64((x ^ -1.0) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -5000.0) tmp = 0.3333333333333333 / ((x * x) * (n * x)); else tmp = (x ^ -1.0) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5000.0], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -1.0], $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -5000:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-1}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e3Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6445.5
Applied rewrites45.5%
Taylor expanded in x around inf
Applied rewrites22.3%
Taylor expanded in x around 0
Applied rewrites84.2%
Applied rewrites79.0%
if -5e3 < (/.f64 #s(literal 1 binary64) n) Initial program 36.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6461.6
Applied rewrites61.6%
Taylor expanded in x around inf
Applied rewrites44.2%
Final simplification54.1%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -111000000.0) (/ 0.3333333333333333 (* (* x x) (* n x))) (/ (/ (- (/ (- (/ 0.3333333333333333 x) 0.5) x) -1.0) x) n)))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -111000000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = (((((0.3333333333333333 / x) - 0.5) / 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) :: tmp
if ((n ** (-1.0d0)) <= (-111000000.0d0)) then
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
else
tmp = (((((0.3333333333333333d0 / x) - 0.5d0) / x) - (-1.0d0)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -111000000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = (((((0.3333333333333333 / x) - 0.5) / x) - -1.0) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -111000000.0: tmp = 0.3333333333333333 / ((x * x) * (n * x)) else: tmp = (((((0.3333333333333333 / x) - 0.5) / x) - -1.0) / x) / n return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -111000000.0) tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x) - -1.0) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -111000000.0) tmp = 0.3333333333333333 / ((x * x) * (n * x)); else tmp = (((((0.3333333333333333 / x) - 0.5) / x) - -1.0) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -111000000.0], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision] - -1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -111000000:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{0.3333333333333333}{x} - 0.5}{x} - -1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.11e8Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6446.7
Applied rewrites46.7%
Taylor expanded in x around inf
Applied rewrites21.5%
Taylor expanded in x around 0
Applied rewrites85.1%
Applied rewrites79.8%
if -1.11e8 < (/.f64 #s(literal 1 binary64) n) Initial program 37.1%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6461.0
Applied rewrites61.0%
Taylor expanded in x around -inf
Applied rewrites46.0%
Final simplification55.3%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -111000000.0) (/ 0.3333333333333333 (* (* x x) (* n x))) (/ (/ (/ (- (+ (/ 0.3333333333333333 x) x) 0.5) x) n) x)))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -111000000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = (((((0.3333333333333333 / x) + x) - 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 ((n ** (-1.0d0)) <= (-111000000.0d0)) then
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
else
tmp = (((((0.3333333333333333d0 / x) + x) - 0.5d0) / x) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -111000000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = (((((0.3333333333333333 / x) + x) - 0.5) / x) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -111000000.0: tmp = 0.3333333333333333 / ((x * x) * (n * x)) else: tmp = (((((0.3333333333333333 / x) + x) - 0.5) / x) / n) / x return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -111000000.0) tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / x) + x) - 0.5) / x) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -111000000.0) tmp = 0.3333333333333333 / ((x * x) * (n * x)); else tmp = (((((0.3333333333333333 / x) + x) - 0.5) / x) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -111000000.0], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -111000000:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\left(\frac{0.3333333333333333}{x} + x\right) - 0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.11e8Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6446.7
Applied rewrites46.7%
Taylor expanded in x around inf
Applied rewrites21.5%
Taylor expanded in x around 0
Applied rewrites85.1%
Applied rewrites79.8%
if -1.11e8 < (/.f64 #s(literal 1 binary64) n) Initial program 37.1%
Taylor expanded in x around inf
Applied rewrites39.8%
Applied rewrites39.3%
Taylor expanded in x around inf
Applied rewrites40.6%
Taylor expanded in n around inf
Applied rewrites45.9%
Final simplification55.3%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -111000000.0) (/ 0.3333333333333333 (* (* x x) (* n x))) (/ (/ (/ (- (+ (/ 0.3333333333333333 x) x) 0.5) n) x) x)))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -111000000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = (((((0.3333333333333333 / x) + x) - 0.5) / n) / x) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n ** (-1.0d0)) <= (-111000000.0d0)) then
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
else
tmp = (((((0.3333333333333333d0 / x) + x) - 0.5d0) / n) / x) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -111000000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = (((((0.3333333333333333 / x) + x) - 0.5) / n) / x) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -111000000.0: tmp = 0.3333333333333333 / ((x * x) * (n * x)) else: tmp = (((((0.3333333333333333 / x) + x) - 0.5) / n) / x) / x return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -111000000.0) tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / x) + x) - 0.5) / n) / x) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -111000000.0) tmp = 0.3333333333333333 / ((x * x) * (n * x)); else tmp = (((((0.3333333333333333 / x) + x) - 0.5) / n) / x) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -111000000.0], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + x), $MachinePrecision] - 0.5), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -111000000:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\left(\frac{0.3333333333333333}{x} + x\right) - 0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.11e8Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6446.7
Applied rewrites46.7%
Taylor expanded in x around inf
Applied rewrites21.5%
Taylor expanded in x around 0
Applied rewrites85.1%
Applied rewrites79.8%
if -1.11e8 < (/.f64 #s(literal 1 binary64) n) Initial program 37.1%
Taylor expanded in x around inf
Applied rewrites39.8%
Applied rewrites39.3%
Taylor expanded in n around inf
Applied rewrites45.9%
Final simplification55.3%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -111000000.0) (/ 0.3333333333333333 (* (* x x) (* n x))) (/ (/ (- (+ (/ 0.3333333333333333 x) x) 0.5) (* n x)) x)))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -111000000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = ((((0.3333333333333333 / x) + x) - 0.5) / (n * x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n ** (-1.0d0)) <= (-111000000.0d0)) then
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
else
tmp = ((((0.3333333333333333d0 / x) + x) - 0.5d0) / (n * x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -111000000.0) {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
} else {
tmp = ((((0.3333333333333333 / x) + x) - 0.5) / (n * x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -111000000.0: tmp = 0.3333333333333333 / ((x * x) * (n * x)) else: tmp = ((((0.3333333333333333 / x) + x) - 0.5) / (n * x)) / x return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -111000000.0) tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); else tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / x) + x) - 0.5) / Float64(n * x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n ^ -1.0) <= -111000000.0) tmp = 0.3333333333333333 / ((x * x) * (n * x)); else tmp = ((((0.3333333333333333 / x) + x) - 0.5) / (n * x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -111000000.0], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + x), $MachinePrecision] - 0.5), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -111000000:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\frac{0.3333333333333333}{x} + x\right) - 0.5}{n \cdot x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.11e8Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6446.7
Applied rewrites46.7%
Taylor expanded in x around inf
Applied rewrites21.5%
Taylor expanded in x around 0
Applied rewrites85.1%
Applied rewrites79.8%
if -1.11e8 < (/.f64 #s(literal 1 binary64) n) Initial program 37.1%
Taylor expanded in x around inf
Applied rewrites39.8%
Applied rewrites39.3%
Taylor expanded in n around inf
Applied rewrites45.3%
Final simplification54.9%
(FPCore (x n)
:precision binary64
(if (<= x 0.88)
(/ (- x (log x)) n)
(if (<= x 3.3e+183)
(/
(/ (- (/ (+ (/ (- (/ 0.25 x) 0.3333333333333333) x) 0.5) x) 1.0) (- x))
n)
(/ 0.3333333333333333 (* (* x x) (* n x))))))
double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else if (x <= 3.3e+183) {
tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n;
} else {
tmp = 0.3333333333333333 / ((x * 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 <= 0.88d0) then
tmp = (x - log(x)) / n
else if (x <= 3.3d+183) then
tmp = (((((((0.25d0 / x) - 0.3333333333333333d0) / x) + 0.5d0) / x) - 1.0d0) / -x) / n
else
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 3.3e+183) {
tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n;
} else {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.88: tmp = (x - math.log(x)) / n elif x <= 3.3e+183: tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n else: tmp = 0.3333333333333333 / ((x * x) * (n * x)) return tmp
function code(x, n) tmp = 0.0 if (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 3.3e+183) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / Float64(-x)) / n); else tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.88) tmp = (x - log(x)) / n; elseif (x <= 3.3e+183) tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n; else tmp = 0.3333333333333333 / ((x * x) * (n * x)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3.3e+183], N[(N[(N[(N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] / x), $MachinePrecision] + 0.5), $MachinePrecision] / x), $MachinePrecision] - 1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+183}:\\
\;\;\;\;\frac{\frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{x} + 0.5}{x} - 1}{-x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\end{array}
\end{array}
if x < 0.880000000000000004Initial program 45.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6449.5
Applied rewrites49.5%
Taylor expanded in x around 0
Applied rewrites49.5%
if 0.880000000000000004 < x < 3.3000000000000001e183Initial program 45.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6447.3
Applied rewrites47.3%
Taylor expanded in x around -inf
Applied rewrites69.1%
if 3.3000000000000001e183 < x Initial program 94.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6494.0
Applied rewrites94.0%
Taylor expanded in x around inf
Applied rewrites64.1%
Taylor expanded in x around 0
Applied rewrites94.0%
Applied rewrites94.0%
Final simplification61.8%
(FPCore (x n)
:precision binary64
(if (<= x 0.71)
(/ (- (log x)) n)
(if (<= x 3.3e+183)
(/
(/ (- (/ (+ (/ (- (/ 0.25 x) 0.3333333333333333) x) 0.5) x) 1.0) (- x))
n)
(/ 0.3333333333333333 (* (* x x) (* n x))))))
double code(double x, double n) {
double tmp;
if (x <= 0.71) {
tmp = -log(x) / n;
} else if (x <= 3.3e+183) {
tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n;
} else {
tmp = 0.3333333333333333 / ((x * 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 <= 0.71d0) then
tmp = -log(x) / n
else if (x <= 3.3d+183) then
tmp = (((((((0.25d0 / x) - 0.3333333333333333d0) / x) + 0.5d0) / x) - 1.0d0) / -x) / n
else
tmp = 0.3333333333333333d0 / ((x * x) * (n * x))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.71) {
tmp = -Math.log(x) / n;
} else if (x <= 3.3e+183) {
tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n;
} else {
tmp = 0.3333333333333333 / ((x * x) * (n * x));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.71: tmp = -math.log(x) / n elif x <= 3.3e+183: tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n else: tmp = 0.3333333333333333 / ((x * x) * (n * x)) return tmp
function code(x, n) tmp = 0.0 if (x <= 0.71) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 3.3e+183) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / Float64(-x)) / n); else tmp = Float64(0.3333333333333333 / Float64(Float64(x * x) * Float64(n * x))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.71) tmp = -log(x) / n; elseif (x <= 3.3e+183) tmp = (((((((0.25 / x) - 0.3333333333333333) / x) + 0.5) / x) - 1.0) / -x) / n; else tmp = 0.3333333333333333 / ((x * x) * (n * x)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.71], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 3.3e+183], N[(N[(N[(N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] / x), $MachinePrecision] + 0.5), $MachinePrecision] / x), $MachinePrecision] - 1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision], N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.71:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+183}:\\
\;\;\;\;\frac{\frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{x} + 0.5}{x} - 1}{-x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot \left(n \cdot x\right)}\\
\end{array}
\end{array}
if x < 0.70999999999999996Initial program 45.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6449.5
Applied rewrites49.5%
Taylor expanded in x around 0
Applied rewrites49.3%
if 0.70999999999999996 < x < 3.3000000000000001e183Initial program 45.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6447.3
Applied rewrites47.3%
Taylor expanded in x around -inf
Applied rewrites69.1%
if 3.3000000000000001e183 < x Initial program 94.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6494.0
Applied rewrites94.0%
Taylor expanded in x around inf
Applied rewrites64.1%
Taylor expanded in x around 0
Applied rewrites94.0%
Applied rewrites94.0%
Final simplification61.7%
(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 54.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6457.0
Applied rewrites57.0%
Taylor expanded in x around inf
Applied rewrites41.5%
Final simplification41.5%
(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 54.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6457.0
Applied rewrites57.0%
Taylor expanded in x around inf
Applied rewrites41.5%
Final simplification41.5%
(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 54.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6457.0
Applied rewrites57.0%
Taylor expanded in x around inf
Applied rewrites41.5%
Applied rewrites41.0%
Final simplification41.0%
herbie shell --seed 2024343
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))