
(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 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-20)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 0.001)
(/ (log1p (/ 1.0 x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 0.001) {
tmp = log1p((1.0 / 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, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 0.001) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-20: tmp = t_0 / (n * x) elif (1.0 / n) <= 0.001: tmp = math.log1p((1.0 / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-20) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 0.001) tmp = Float64(log1p(Float64(1.0 / 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[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-20], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.001], N[(N[Log[1 + N[(1.0 / 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(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999945e-21Initial program 95.3%
Taylor expanded in x around inf 98.8%
log-rec98.8%
mul-1-neg98.8%
neg-mul-198.8%
mul-1-neg98.8%
distribute-frac-neg98.8%
remove-double-neg98.8%
*-rgt-identity98.8%
associate-/l*98.8%
exp-to-pow98.8%
*-commutative98.8%
Simplified98.8%
if -9.99999999999999945e-21 < (/.f64 #s(literal 1 binary64) n) < 1e-3Initial program 25.3%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
log1p-undefine79.5%
diff-log79.6%
Applied egg-rr79.6%
+-commutative79.6%
Simplified79.6%
Taylor expanded in n around 0 79.6%
+-commutative79.6%
*-lft-identity79.6%
associate-*l/73.7%
distribute-rgt-in73.7%
rgt-mult-inverse79.6%
*-lft-identity79.6%
log1p-define98.4%
Simplified98.4%
if 1e-3 < (/.f64 #s(literal 1 binary64) n) Initial program 55.8%
Taylor expanded in n around 0 55.8%
log1p-define98.0%
*-rgt-identity98.0%
associate-*l/98.0%
associate-/l*98.0%
exp-to-pow98.2%
Simplified98.2%
Final simplification98.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-20)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 10.0)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+76)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ x n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 10.0) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+76) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1((x / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 10.0) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+76) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1((x / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-20: tmp = t_0 / (n * x) elif (1.0 / n) <= 10.0: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+76: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1((x / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-20) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+76) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(x / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-20], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+76], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+76}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999945e-21Initial program 95.3%
Taylor expanded in x around inf 98.8%
log-rec98.8%
mul-1-neg98.8%
neg-mul-198.8%
mul-1-neg98.8%
distribute-frac-neg98.8%
remove-double-neg98.8%
*-rgt-identity98.8%
associate-/l*98.8%
exp-to-pow98.8%
*-commutative98.8%
Simplified98.8%
if -9.99999999999999945e-21 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 25.1%
Taylor expanded in n around inf 78.9%
log1p-define78.9%
Simplified78.9%
log1p-undefine78.9%
diff-log79.0%
Applied egg-rr79.0%
+-commutative79.0%
Simplified79.0%
Taylor expanded in n around 0 79.0%
+-commutative79.0%
*-lft-identity79.0%
associate-*l/73.2%
distribute-rgt-in73.2%
rgt-mult-inverse79.0%
*-lft-identity79.0%
log1p-define97.7%
Simplified97.7%
if 10 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e76Initial program 89.1%
Taylor expanded in x around 0 92.0%
if 2.0000000000000001e76 < (/.f64 #s(literal 1 binary64) n) Initial program 44.0%
Taylor expanded in x around 0 29.0%
Taylor expanded in x around inf 5.4%
log1p-expm1-u76.4%
Applied egg-rr76.4%
Final simplification94.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-20)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 0.001) (/ (log1p (/ 1.0 x)) n) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 0.001) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 0.001) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-20: tmp = t_0 / (n * x) elif (1.0 / n) <= 0.001: tmp = math.log1p((1.0 / x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-20) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 0.001) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-20], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.001], N[(N[Log[1 + N[(1.0 / x), $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(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999945e-21Initial program 95.3%
Taylor expanded in x around inf 98.8%
log-rec98.8%
mul-1-neg98.8%
neg-mul-198.8%
mul-1-neg98.8%
distribute-frac-neg98.8%
remove-double-neg98.8%
*-rgt-identity98.8%
associate-/l*98.8%
exp-to-pow98.8%
*-commutative98.8%
Simplified98.8%
if -9.99999999999999945e-21 < (/.f64 #s(literal 1 binary64) n) < 1e-3Initial program 25.3%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
log1p-undefine79.5%
diff-log79.6%
Applied egg-rr79.6%
+-commutative79.6%
Simplified79.6%
Taylor expanded in n around 0 79.6%
+-commutative79.6%
*-lft-identity79.6%
associate-*l/73.7%
distribute-rgt-in73.7%
rgt-mult-inverse79.6%
*-lft-identity79.6%
log1p-define98.4%
Simplified98.4%
if 1e-3 < (/.f64 #s(literal 1 binary64) n) Initial program 55.8%
Taylor expanded in n around 0 55.8%
log1p-define98.0%
*-rgt-identity98.0%
associate-*l/98.0%
associate-/l*98.0%
exp-to-pow98.2%
Simplified98.2%
Taylor expanded in x around 0 98.1%
Final simplification98.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-20)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 10.0)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+94)
(- (+ 1.0 (/ x n)) t_0)
(/
(expm1 (/ (+ 1.0 (/ (+ -1.0 (/ 1.1666666666666667 x)) x)) x))
n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 10.0) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+94) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = expm1(((1.0 + ((-1.0 + (1.1666666666666667 / x)) / x)) / x)) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 10.0) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+94) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.expm1(((1.0 + ((-1.0 + (1.1666666666666667 / x)) / x)) / x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-20: tmp = t_0 / (n * x) elif (1.0 / n) <= 10.0: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+94: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.expm1(((1.0 + ((-1.0 + (1.1666666666666667 / x)) / x)) / x)) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-20) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+94) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(expm1(Float64(Float64(1.0 + Float64(Float64(-1.0 + Float64(1.1666666666666667 / x)) / x)) / x)) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-20], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+94], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(Exp[N[(N[(1.0 + N[(N[(-1.0 + N[(1.1666666666666667 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]] - 1), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+94}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 + \frac{1.1666666666666667}{x}}{x}}{x}\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999945e-21Initial program 95.3%
Taylor expanded in x around inf 98.8%
log-rec98.8%
mul-1-neg98.8%
neg-mul-198.8%
mul-1-neg98.8%
distribute-frac-neg98.8%
remove-double-neg98.8%
*-rgt-identity98.8%
associate-/l*98.8%
exp-to-pow98.8%
*-commutative98.8%
Simplified98.8%
if -9.99999999999999945e-21 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 25.1%
Taylor expanded in n around inf 78.9%
log1p-define78.9%
Simplified78.9%
log1p-undefine78.9%
diff-log79.0%
Applied egg-rr79.0%
+-commutative79.0%
Simplified79.0%
Taylor expanded in n around 0 79.0%
+-commutative79.0%
*-lft-identity79.0%
associate-*l/73.2%
distribute-rgt-in73.2%
rgt-mult-inverse79.0%
*-lft-identity79.0%
log1p-define97.7%
Simplified97.7%
if 10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000001e94Initial program 84.4%
Taylor expanded in x around 0 86.9%
if 5.0000000000000001e94 < (/.f64 #s(literal 1 binary64) n) Initial program 43.6%
Taylor expanded in n around inf 8.7%
log1p-define8.7%
Simplified8.7%
expm1-log1p-u8.7%
Applied egg-rr8.7%
Taylor expanded in x around inf 73.8%
associate--l+73.8%
unpow273.8%
associate-/r*73.8%
metadata-eval73.8%
associate-*r/73.8%
div-sub73.8%
sub-neg73.8%
metadata-eval73.8%
+-commutative73.8%
associate-*r/73.8%
metadata-eval73.8%
Simplified73.8%
Final simplification94.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-20)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 10.0)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 1e+108)
(- (+ 1.0 (/ x n)) t_0)
(/ (log1p (+ x -1.0)) (- n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 10.0) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+108) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p((x + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 10.0) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+108) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p((x + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-20: tmp = t_0 / (n * x) elif (1.0 / n) <= 10.0: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 1e+108: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p((x + -1.0)) / -n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-20) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 1e+108) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-20], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+108], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+108}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999945e-21Initial program 95.3%
Taylor expanded in x around inf 98.8%
log-rec98.8%
mul-1-neg98.8%
neg-mul-198.8%
mul-1-neg98.8%
distribute-frac-neg98.8%
remove-double-neg98.8%
*-rgt-identity98.8%
associate-/l*98.8%
exp-to-pow98.8%
*-commutative98.8%
Simplified98.8%
if -9.99999999999999945e-21 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 25.1%
Taylor expanded in n around inf 78.9%
log1p-define78.9%
Simplified78.9%
log1p-undefine78.9%
diff-log79.0%
Applied egg-rr79.0%
+-commutative79.0%
Simplified79.0%
Taylor expanded in n around 0 79.0%
+-commutative79.0%
*-lft-identity79.0%
associate-*l/73.2%
distribute-rgt-in73.2%
rgt-mult-inverse79.0%
*-lft-identity79.0%
log1p-define97.7%
Simplified97.7%
if 10 < (/.f64 #s(literal 1 binary64) n) < 1e108Initial program 81.8%
Taylor expanded in x around 0 78.8%
if 1e108 < (/.f64 #s(literal 1 binary64) n) Initial program 41.1%
Taylor expanded in x around 0 25.0%
*-rgt-identity25.0%
associate-*l/25.0%
associate-/l*25.0%
exp-to-pow25.0%
Simplified25.0%
Taylor expanded in n around inf 9.1%
neg-mul-19.1%
distribute-neg-frac29.1%
Simplified9.1%
log1p-expm1-u61.7%
expm1-undefine61.7%
add-exp-log61.7%
Applied egg-rr61.7%
Final simplification92.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-20)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 10.0)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+76) (- 1.0 t_0) (/ (log1p (+ x -1.0)) (- n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 10.0) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+76) {
tmp = 1.0 - t_0;
} else {
tmp = log1p((x + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-20) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 10.0) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+76) {
tmp = 1.0 - t_0;
} else {
tmp = Math.log1p((x + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-20: tmp = t_0 / (n * x) elif (1.0 / n) <= 10.0: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+76: tmp = 1.0 - t_0 else: tmp = math.log1p((x + -1.0)) / -n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-20) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+76) tmp = Float64(1.0 - t_0); else tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-20], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+76], N[(1.0 - t$95$0), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+76}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999945e-21Initial program 95.3%
Taylor expanded in x around inf 98.8%
log-rec98.8%
mul-1-neg98.8%
neg-mul-198.8%
mul-1-neg98.8%
distribute-frac-neg98.8%
remove-double-neg98.8%
*-rgt-identity98.8%
associate-/l*98.8%
exp-to-pow98.8%
*-commutative98.8%
Simplified98.8%
if -9.99999999999999945e-21 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 25.1%
Taylor expanded in n around inf 78.9%
log1p-define78.9%
Simplified78.9%
log1p-undefine78.9%
diff-log79.0%
Applied egg-rr79.0%
+-commutative79.0%
Simplified79.0%
Taylor expanded in n around 0 79.0%
+-commutative79.0%
*-lft-identity79.0%
associate-*l/73.2%
distribute-rgt-in73.2%
rgt-mult-inverse79.0%
*-lft-identity79.0%
log1p-define97.7%
Simplified97.7%
if 10 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e76Initial program 89.1%
Taylor expanded in x around 0 89.1%
*-rgt-identity89.1%
associate-*l/89.1%
associate-/l*89.1%
exp-to-pow89.1%
Simplified89.1%
if 2.0000000000000001e76 < (/.f64 #s(literal 1 binary64) n) Initial program 44.0%
Taylor expanded in x around 0 27.4%
*-rgt-identity27.4%
associate-*l/27.4%
associate-/l*27.4%
exp-to-pow27.4%
Simplified27.4%
Taylor expanded in n around inf 8.5%
neg-mul-18.5%
distribute-neg-frac28.5%
Simplified8.5%
log1p-expm1-u58.9%
expm1-undefine58.9%
add-exp-log58.9%
Applied egg-rr58.9%
Final simplification92.3%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -500.0)
(+ (/ 1.0 n) (/ -1.0 n))
(if (<= (/ 1.0 n) 10.0)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+76)
(- 1.0 (pow x (/ 1.0 n)))
(/ (log1p (+ x -1.0)) (- n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (1.0 / n) + (-1.0 / n);
} else if ((1.0 / n) <= 10.0) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+76) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = log1p((x + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (1.0 / n) + (-1.0 / n);
} else if ((1.0 / n) <= 10.0) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+76) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = Math.log1p((x + -1.0)) / -n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -500.0: tmp = (1.0 / n) + (-1.0 / n) elif (1.0 / n) <= 10.0: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+76: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = math.log1p((x + -1.0)) / -n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -500.0) tmp = Float64(Float64(1.0 / n) + Float64(-1.0 / n)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+76) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -500.0], N[(N[(1.0 / n), $MachinePrecision] + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+76], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{1}{n} + \frac{-1}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+76}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -500Initial program 100.0%
Taylor expanded in n around inf 64.5%
log1p-define64.5%
Simplified64.5%
log1p-undefine64.5%
diff-log64.5%
Applied egg-rr64.5%
+-commutative64.5%
Simplified64.5%
log-div64.5%
+-commutative64.5%
log1p-undefine64.5%
expm1-log1p-u64.5%
expm1-undefine64.5%
div-sub64.5%
log1p-undefine64.5%
rem-exp-log64.5%
Applied egg-rr64.5%
sub-neg64.5%
rem-log-exp64.5%
exp-diff64.5%
log1p-define64.5%
+-commutative64.5%
rem-exp-log3.3%
rem-exp-log64.5%
*-lft-identity64.5%
associate-*l/59.3%
distribute-lft-in59.3%
*-rgt-identity59.3%
lft-mult-inverse64.5%
log1p-define64.5%
distribute-neg-frac64.5%
metadata-eval64.5%
Simplified64.5%
Taylor expanded in x around inf 64.6%
if -500 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 25.6%
Taylor expanded in n around inf 75.6%
log1p-define75.6%
Simplified75.6%
log1p-undefine75.6%
diff-log75.7%
Applied egg-rr75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in n around 0 75.7%
+-commutative75.7%
*-lft-identity75.7%
associate-*l/70.1%
distribute-rgt-in70.1%
rgt-mult-inverse75.7%
*-lft-identity75.7%
log1p-define95.5%
Simplified95.5%
if 10 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e76Initial program 89.1%
Taylor expanded in x around 0 89.1%
*-rgt-identity89.1%
associate-*l/89.1%
associate-/l*89.1%
exp-to-pow89.1%
Simplified89.1%
if 2.0000000000000001e76 < (/.f64 #s(literal 1 binary64) n) Initial program 44.0%
Taylor expanded in x around 0 27.4%
*-rgt-identity27.4%
associate-*l/27.4%
associate-/l*27.4%
exp-to-pow27.4%
Simplified27.4%
Taylor expanded in n around inf 8.5%
neg-mul-18.5%
distribute-neg-frac28.5%
Simplified8.5%
log1p-expm1-u58.9%
expm1-undefine58.9%
add-exp-log58.9%
Applied egg-rr58.9%
Final simplification81.1%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -500.0)
(+ (/ 1.0 n) (/ -1.0 n))
(if (<= (/ 1.0 n) 10.0)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+76)
(- 1.0 (pow x (/ 1.0 n)))
(/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (1.0 / n) + (-1.0 / n);
} else if ((1.0 / n) <= 10.0) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+76) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (1.0 / n) + (-1.0 / n);
} else if ((1.0 / n) <= 10.0) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+76) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -500.0: tmp = (1.0 / n) + (-1.0 / n) elif (1.0 / n) <= 10.0: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+76: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -500.0) tmp = Float64(Float64(1.0 / n) + Float64(-1.0 / n)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+76) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -500.0], N[(N[(1.0 / n), $MachinePrecision] + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+76], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{1}{n} + \frac{-1}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+76}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -500Initial program 100.0%
Taylor expanded in n around inf 64.5%
log1p-define64.5%
Simplified64.5%
log1p-undefine64.5%
diff-log64.5%
Applied egg-rr64.5%
+-commutative64.5%
Simplified64.5%
log-div64.5%
+-commutative64.5%
log1p-undefine64.5%
expm1-log1p-u64.5%
expm1-undefine64.5%
div-sub64.5%
log1p-undefine64.5%
rem-exp-log64.5%
Applied egg-rr64.5%
sub-neg64.5%
rem-log-exp64.5%
exp-diff64.5%
log1p-define64.5%
+-commutative64.5%
rem-exp-log3.3%
rem-exp-log64.5%
*-lft-identity64.5%
associate-*l/59.3%
distribute-lft-in59.3%
*-rgt-identity59.3%
lft-mult-inverse64.5%
log1p-define64.5%
distribute-neg-frac64.5%
metadata-eval64.5%
Simplified64.5%
Taylor expanded in x around inf 64.6%
if -500 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 25.6%
Taylor expanded in n around inf 75.6%
log1p-define75.6%
Simplified75.6%
log1p-undefine75.6%
diff-log75.7%
Applied egg-rr75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in n around 0 75.7%
+-commutative75.7%
*-lft-identity75.7%
associate-*l/70.1%
distribute-rgt-in70.1%
rgt-mult-inverse75.7%
*-lft-identity75.7%
log1p-define95.5%
Simplified95.5%
if 10 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e76Initial program 89.1%
Taylor expanded in x around 0 89.1%
*-rgt-identity89.1%
associate-*l/89.1%
associate-/l*89.1%
exp-to-pow89.1%
Simplified89.1%
if 2.0000000000000001e76 < (/.f64 #s(literal 1 binary64) n) Initial program 44.0%
Taylor expanded in n around inf 8.5%
log1p-define8.5%
Simplified8.5%
log1p-undefine8.5%
diff-log8.5%
Applied egg-rr8.5%
+-commutative8.5%
Simplified8.5%
Taylor expanded in x around inf 51.2%
associate--l+51.2%
unpow251.2%
associate-/r*51.2%
metadata-eval51.2%
associate-*r/51.2%
associate-*r/51.2%
metadata-eval51.2%
div-sub51.2%
sub-neg51.2%
metadata-eval51.2%
+-commutative51.2%
associate-*r/51.2%
metadata-eval51.2%
Simplified51.2%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -500.0)
(+ (/ 1.0 n) (/ -1.0 n))
(if (<= (/ 1.0 n) 2e+76)
(/ (log1p (/ 1.0 x)) n)
(/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (1.0 / n) + (-1.0 / n);
} else if ((1.0 / n) <= 2e+76) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (1.0 / n) + (-1.0 / n);
} else if ((1.0 / n) <= 2e+76) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -500.0: tmp = (1.0 / n) + (-1.0 / n) elif (1.0 / n) <= 2e+76: tmp = math.log1p((1.0 / x)) / n else: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -500.0) tmp = Float64(Float64(1.0 / n) + Float64(-1.0 / n)); elseif (Float64(1.0 / n) <= 2e+76) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -500.0], N[(N[(1.0 / n), $MachinePrecision] + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+76], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{1}{n} + \frac{-1}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+76}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -500Initial program 100.0%
Taylor expanded in n around inf 64.5%
log1p-define64.5%
Simplified64.5%
log1p-undefine64.5%
diff-log64.5%
Applied egg-rr64.5%
+-commutative64.5%
Simplified64.5%
log-div64.5%
+-commutative64.5%
log1p-undefine64.5%
expm1-log1p-u64.5%
expm1-undefine64.5%
div-sub64.5%
log1p-undefine64.5%
rem-exp-log64.5%
Applied egg-rr64.5%
sub-neg64.5%
rem-log-exp64.5%
exp-diff64.5%
log1p-define64.5%
+-commutative64.5%
rem-exp-log3.3%
rem-exp-log64.5%
*-lft-identity64.5%
associate-*l/59.3%
distribute-lft-in59.3%
*-rgt-identity59.3%
lft-mult-inverse64.5%
log1p-define64.5%
distribute-neg-frac64.5%
metadata-eval64.5%
Simplified64.5%
Taylor expanded in x around inf 64.6%
if -500 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e76Initial program 31.7%
Taylor expanded in n around inf 69.1%
log1p-define69.1%
Simplified69.1%
log1p-undefine69.1%
diff-log69.1%
Applied egg-rr69.1%
+-commutative69.1%
Simplified69.1%
Taylor expanded in n around 0 69.1%
+-commutative69.1%
*-lft-identity69.1%
associate-*l/64.1%
distribute-rgt-in64.1%
rgt-mult-inverse69.1%
*-lft-identity69.1%
log1p-define87.1%
Simplified87.1%
if 2.0000000000000001e76 < (/.f64 #s(literal 1 binary64) n) Initial program 44.0%
Taylor expanded in n around inf 8.5%
log1p-define8.5%
Simplified8.5%
log1p-undefine8.5%
diff-log8.5%
Applied egg-rr8.5%
+-commutative8.5%
Simplified8.5%
Taylor expanded in x around inf 51.2%
associate--l+51.2%
unpow251.2%
associate-/r*51.2%
metadata-eval51.2%
associate-*r/51.2%
associate-*r/51.2%
metadata-eval51.2%
div-sub51.2%
sub-neg51.2%
metadata-eval51.2%
+-commutative51.2%
associate-*r/51.2%
metadata-eval51.2%
Simplified51.2%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (log x) (- n)) (+ (/ 1.0 n) (/ -1.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = log(x) / -n;
} else {
tmp = (1.0 / n) + (-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 (x <= 1.0d0) then
tmp = log(x) / -n
else
tmp = (1.0d0 / n) + ((-1.0d0) / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = Math.log(x) / -n;
} else {
tmp = (1.0 / n) + (-1.0 / n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = math.log(x) / -n else: tmp = (1.0 / n) + (-1.0 / n) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(1.0 / n) + Float64(-1.0 / n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = log(x) / -n; else tmp = (1.0 / n) + (-1.0 / n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n} + \frac{-1}{n}\\
\end{array}
\end{array}
if x < 1Initial program 40.6%
Taylor expanded in x around 0 36.7%
*-rgt-identity36.7%
associate-*l/36.7%
associate-/l*36.7%
exp-to-pow36.7%
Simplified36.7%
Taylor expanded in n around inf 49.7%
neg-mul-149.7%
distribute-neg-frac249.7%
Simplified49.7%
if 1 < x Initial program 71.5%
Taylor expanded in n around inf 70.9%
log1p-define70.9%
Simplified70.9%
log1p-undefine70.9%
diff-log71.0%
Applied egg-rr71.0%
+-commutative71.0%
Simplified71.0%
log-div70.9%
+-commutative70.9%
log1p-undefine70.9%
expm1-log1p-u70.9%
expm1-undefine70.9%
div-sub70.9%
log1p-undefine70.9%
rem-exp-log70.9%
Applied egg-rr70.9%
sub-neg70.9%
rem-log-exp70.9%
exp-diff70.9%
log1p-define70.9%
+-commutative70.9%
rem-exp-log5.7%
rem-exp-log71.0%
*-lft-identity71.0%
associate-*l/63.1%
distribute-lft-in63.1%
*-rgt-identity63.1%
lft-mult-inverse71.0%
log1p-define71.0%
distribute-neg-frac71.0%
metadata-eval71.0%
Simplified71.0%
Taylor expanded in x around inf 71.5%
(FPCore (x n) :precision binary64 (if (<= x 1.1e+43) (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x) (+ (/ 1.0 n) (/ -1.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 1.1e+43) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
} else {
tmp = (1.0 / n) + (-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 (x <= 1.1d+43) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
else
tmp = (1.0d0 / n) + ((-1.0d0) / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.1e+43) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
} else {
tmp = (1.0 / n) + (-1.0 / n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.1e+43: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x else: tmp = (1.0 / n) + (-1.0 / n) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.1e+43) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x); else tmp = Float64(Float64(1.0 / n) + Float64(-1.0 / n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.1e+43) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x; else tmp = (1.0 / n) + (-1.0 / n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.1e+43], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{+43}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n} + \frac{-1}{n}\\
\end{array}
\end{array}
if x < 1.1e43Initial program 39.8%
Taylor expanded in n around inf 49.5%
log1p-define49.5%
Simplified49.5%
log1p-undefine49.5%
diff-log49.6%
Applied egg-rr49.6%
+-commutative49.6%
Simplified49.6%
Taylor expanded in x around inf 15.8%
Simplified33.5%
if 1.1e43 < x Initial program 75.8%
Taylor expanded in n around inf 75.8%
log1p-define75.8%
Simplified75.8%
log1p-undefine75.8%
diff-log75.8%
Applied egg-rr75.8%
+-commutative75.8%
Simplified75.8%
log-div75.8%
+-commutative75.8%
log1p-undefine75.8%
expm1-log1p-u75.8%
expm1-undefine75.8%
div-sub75.8%
log1p-undefine75.8%
rem-exp-log75.8%
Applied egg-rr75.8%
sub-neg75.8%
rem-log-exp75.8%
exp-diff75.8%
log1p-define75.8%
+-commutative75.8%
rem-exp-log5.6%
rem-exp-log75.8%
*-lft-identity75.8%
associate-*l/67.2%
distribute-lft-in67.2%
*-rgt-identity67.2%
lft-mult-inverse75.8%
log1p-define75.8%
distribute-neg-frac75.8%
metadata-eval75.8%
Simplified75.8%
Taylor expanded in x around inf 75.8%
Final simplification49.5%
(FPCore (x n) :precision binary64 (if (<= x 1.7e+37) (/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n) (+ (/ 1.0 n) (/ -1.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 1.7e+37) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else {
tmp = (1.0 / n) + (-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 (x <= 1.7d+37) then
tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
else
tmp = (1.0d0 / n) + ((-1.0d0) / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.7e+37) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else {
tmp = (1.0 / n) + (-1.0 / n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.7e+37: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n else: tmp = (1.0 / n) + (-1.0 / n) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.7e+37) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); else tmp = Float64(Float64(1.0 / n) + Float64(-1.0 / n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.7e+37) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; else tmp = (1.0 / n) + (-1.0 / n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.7e+37], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7 \cdot 10^{+37}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n} + \frac{-1}{n}\\
\end{array}
\end{array}
if x < 1.70000000000000003e37Initial program 39.8%
Taylor expanded in n around inf 49.5%
log1p-define49.5%
Simplified49.5%
log1p-undefine49.5%
diff-log49.6%
Applied egg-rr49.6%
+-commutative49.6%
Simplified49.6%
Taylor expanded in x around inf 33.5%
associate--l+33.5%
unpow233.5%
associate-/r*33.5%
metadata-eval33.5%
associate-*r/33.5%
associate-*r/33.5%
metadata-eval33.5%
div-sub33.5%
sub-neg33.5%
metadata-eval33.5%
+-commutative33.5%
associate-*r/33.5%
metadata-eval33.5%
Simplified33.5%
if 1.70000000000000003e37 < x Initial program 75.8%
Taylor expanded in n around inf 75.8%
log1p-define75.8%
Simplified75.8%
log1p-undefine75.8%
diff-log75.8%
Applied egg-rr75.8%
+-commutative75.8%
Simplified75.8%
log-div75.8%
+-commutative75.8%
log1p-undefine75.8%
expm1-log1p-u75.8%
expm1-undefine75.8%
div-sub75.8%
log1p-undefine75.8%
rem-exp-log75.8%
Applied egg-rr75.8%
sub-neg75.8%
rem-log-exp75.8%
exp-diff75.8%
log1p-define75.8%
+-commutative75.8%
rem-exp-log5.6%
rem-exp-log75.8%
*-lft-identity75.8%
associate-*l/67.2%
distribute-lft-in67.2%
*-rgt-identity67.2%
lft-mult-inverse75.8%
log1p-define75.8%
distribute-neg-frac75.8%
metadata-eval75.8%
Simplified75.8%
Taylor expanded in x around inf 75.8%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -500.0) (+ (/ 1.0 n) (/ -1.0 n)) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (1.0 / n) + (-1.0 / n);
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-500.0d0)) then
tmp = (1.0d0 / n) + ((-1.0d0) / n)
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (1.0 / n) + (-1.0 / n);
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -500.0: tmp = (1.0 / n) + (-1.0 / n) else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -500.0) tmp = Float64(Float64(1.0 / n) + Float64(-1.0 / n)); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -500.0) tmp = (1.0 / n) + (-1.0 / n); else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -500.0], N[(N[(1.0 / n), $MachinePrecision] + N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{1}{n} + \frac{-1}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -500Initial program 100.0%
Taylor expanded in n around inf 64.5%
log1p-define64.5%
Simplified64.5%
log1p-undefine64.5%
diff-log64.5%
Applied egg-rr64.5%
+-commutative64.5%
Simplified64.5%
log-div64.5%
+-commutative64.5%
log1p-undefine64.5%
expm1-log1p-u64.5%
expm1-undefine64.5%
div-sub64.5%
log1p-undefine64.5%
rem-exp-log64.5%
Applied egg-rr64.5%
sub-neg64.5%
rem-log-exp64.5%
exp-diff64.5%
log1p-define64.5%
+-commutative64.5%
rem-exp-log3.3%
rem-exp-log64.5%
*-lft-identity64.5%
associate-*l/59.3%
distribute-lft-in59.3%
*-rgt-identity59.3%
lft-mult-inverse64.5%
log1p-define64.5%
distribute-neg-frac64.5%
metadata-eval64.5%
Simplified64.5%
Taylor expanded in x around inf 64.6%
if -500 < (/.f64 #s(literal 1 binary64) n) Initial program 34.1%
Taylor expanded in n around inf 57.4%
log1p-define57.4%
Simplified57.4%
Taylor expanded in x around inf 38.5%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 53.4%
Taylor expanded in n around inf 59.5%
log1p-define59.5%
Simplified59.5%
Taylor expanded in x around inf 35.5%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 53.4%
Taylor expanded in n around inf 59.5%
log1p-define59.5%
Simplified59.5%
log1p-undefine59.5%
diff-log59.5%
Applied egg-rr59.5%
+-commutative59.5%
Simplified59.5%
Taylor expanded in x around inf 34.6%
associate-/r*35.5%
Simplified35.5%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 53.4%
Taylor expanded in n around inf 59.5%
log1p-define59.5%
Simplified59.5%
Taylor expanded in x around inf 34.6%
*-commutative34.6%
Simplified34.6%
Final simplification34.6%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 53.4%
Taylor expanded in x around 0 27.1%
Taylor expanded in x around inf 4.4%
herbie shell --seed 2024169
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))