
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-6)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-12)
(/ (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) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
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) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
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) <= -5e-6: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-12: 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) <= -5e-6) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-12) 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], -5e-6], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], 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 -5 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\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 1 n) < -5.00000000000000041e-6Initial program 98.9%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
div-inv100.0%
pow-to-exp100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -5.00000000000000041e-6 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 31.3%
Taylor expanded in n around inf 81.0%
log1p-udef81.0%
expm1-log1p-u80.3%
Applied egg-rr80.3%
Taylor expanded in n around 0 81.0%
log-div81.5%
*-lft-identity81.5%
associate-*l/77.6%
+-commutative77.6%
distribute-lft-in77.6%
lft-mult-inverse81.5%
*-rgt-identity81.5%
log1p-def97.8%
Simplified97.8%
if 1.99999999999999996e-12 < (/.f64 1 n) Initial program 61.6%
Taylor expanded in n around 0 61.6%
log1p-def96.2%
Simplified96.2%
Final simplification98.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-6)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-12)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 4e+212)
(- (pow (+ 1.0 x) (/ 1.0 n)) t_0)
(log1p (expm1 (/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = log1p(expm1((1.0 / (n * x))));
}
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) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1((1.0 / (n * x))));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-6: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-12: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 4e+212: tmp = math.pow((1.0 + x), (1.0 / n)) - t_0 else: tmp = math.log1p(math.expm1((1.0 / (n * x)))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-6) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 4e+212) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0); else tmp = log1p(expm1(Float64(1.0 / Float64(n * x)))); 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], -5e-6], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+212], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+212}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n \cdot x}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000041e-6Initial program 98.9%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
div-inv100.0%
pow-to-exp100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -5.00000000000000041e-6 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 31.3%
Taylor expanded in n around inf 81.0%
log1p-udef81.0%
expm1-log1p-u80.3%
Applied egg-rr80.3%
Taylor expanded in n around 0 81.0%
log-div81.5%
*-lft-identity81.5%
associate-*l/77.6%
+-commutative77.6%
distribute-lft-in77.6%
lft-mult-inverse81.5%
*-rgt-identity81.5%
log1p-def97.8%
Simplified97.8%
if 1.99999999999999996e-12 < (/.f64 1 n) < 3.9999999999999996e212Initial program 74.3%
if 3.9999999999999996e212 < (/.f64 1 n) Initial program 38.8%
Taylor expanded in n around inf 7.3%
Taylor expanded in x around inf 71.8%
*-commutative71.8%
Simplified71.8%
log1p-expm1-u90.3%
Applied egg-rr90.3%
Final simplification96.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-6)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-12)
(/ (log1p (/ 1.0 x)) n)
(-
(+ (* (- (/ 0.5 (* n n)) (/ 0.5 n)) (* x x)) (+ 1.0 (/ x n)))
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (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) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (x / n))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-6: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-12: tmp = math.log1p((1.0 / x)) / n else: tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (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) <= -5e-6) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(Float64(Float64(Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)) * Float64(x * x)) + Float64(1.0 + 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], -5e-6], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(x / n), $MachinePrecision]), $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 -5 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \left(x \cdot x\right) + \left(1 + \frac{x}{n}\right)\right) - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000041e-6Initial program 98.9%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
div-inv100.0%
pow-to-exp100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -5.00000000000000041e-6 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 31.3%
Taylor expanded in n around inf 81.0%
log1p-udef81.0%
expm1-log1p-u80.3%
Applied egg-rr80.3%
Taylor expanded in n around 0 81.0%
log-div81.5%
*-lft-identity81.5%
associate-*l/77.6%
+-commutative77.6%
distribute-lft-in77.6%
lft-mult-inverse81.5%
*-rgt-identity81.5%
log1p-def97.8%
Simplified97.8%
if 1.99999999999999996e-12 < (/.f64 1 n) Initial program 61.6%
Taylor expanded in x around 0 64.3%
associate-+r+64.3%
+-commutative64.3%
associate-*r/64.3%
metadata-eval64.3%
unpow264.3%
associate-*r/64.3%
metadata-eval64.3%
unpow264.3%
Simplified64.3%
Final simplification94.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* (/ 0.0 n) -0.3333333333333333))
(t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -2.5e+239)
t_0
(if (<= (/ 1.0 n) -2e+108)
t_1
(if (<= (/ 1.0 n) -2e+19)
t_0
(if (<= (/ 1.0 n) 2e-12)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 4e+212) t_1 (/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = (0.0 / n) * -0.3333333333333333;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2.5e+239) {
tmp = t_0;
} else if ((1.0 / n) <= -2e+108) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+19) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-12) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = t_1;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (0.0 / n) * -0.3333333333333333;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2.5e+239) {
tmp = t_0;
} else if ((1.0 / n) <= -2e+108) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+19) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-12) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = t_1;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = (0.0 / n) * -0.3333333333333333 t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2.5e+239: tmp = t_0 elif (1.0 / n) <= -2e+108: tmp = t_1 elif (1.0 / n) <= -2e+19: tmp = t_0 elif (1.0 / n) <= 2e-12: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 4e+212: tmp = t_1 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(Float64(0.0 / n) * -0.3333333333333333) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -2.5e+239) tmp = t_0; elseif (Float64(1.0 / n) <= -2e+108) tmp = t_1; elseif (Float64(1.0 / n) <= -2e+19) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 4e+212) tmp = t_1; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(0.0 / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2.5e+239], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+108], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+19], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+212], t$95$1, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0}{n} \cdot -0.3333333333333333\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2.5 \cdot 10^{+239}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+108}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+19}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+212}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.50000000000000003e239 or -2.0000000000000001e108 < (/.f64 1 n) < -2e19Initial program 100.0%
flip3--0.0%
div-inv0.0%
pow-to-exp0.0%
pow-exp0.0%
un-div-inv0.0%
+-commutative0.0%
log1p-udef0.0%
inv-pow0.0%
Applied egg-rr0.0%
Simplified0.0%
Taylor expanded in n around -inf 67.2%
*-commutative67.2%
Simplified28.1%
Taylor expanded in x around inf 68.0%
log-rec68.0%
log-rec68.0%
distribute-rgt-out68.0%
metadata-eval68.0%
mul0-rgt68.0%
Simplified68.0%
if -2.50000000000000003e239 < (/.f64 1 n) < -2.0000000000000001e108 or 1.99999999999999996e-12 < (/.f64 1 n) < 3.9999999999999996e212Initial program 92.1%
Taylor expanded in x around 0 67.5%
if -2e19 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 31.6%
Taylor expanded in n around inf 80.0%
log1p-udef80.0%
expm1-log1p-u79.3%
Applied egg-rr79.3%
Taylor expanded in n around 0 80.0%
log-div80.5%
*-lft-identity80.5%
associate-*l/76.6%
+-commutative76.6%
distribute-lft-in76.5%
lft-mult-inverse80.5%
*-rgt-identity80.5%
log1p-def96.7%
Simplified96.7%
if 3.9999999999999996e212 < (/.f64 1 n) Initial program 38.8%
Taylor expanded in n around inf 7.3%
Taylor expanded in x around inf 71.8%
*-commutative71.8%
Simplified71.8%
Final simplification84.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -4e+221)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) -2e+108)
t_0
(if (<= (/ 1.0 n) -2e+19)
(* (/ 0.0 n) -0.3333333333333333)
(if (<= (/ 1.0 n) 2e-12)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 4e+212) t_0 (/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e+221) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -2e+108) {
tmp = t_0;
} else if ((1.0 / n) <= -2e+19) {
tmp = (0.0 / n) * -0.3333333333333333;
} else if ((1.0 / n) <= 2e-12) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e+221) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -2e+108) {
tmp = t_0;
} else if ((1.0 / n) <= -2e+19) {
tmp = (0.0 / n) * -0.3333333333333333;
} else if ((1.0 / n) <= 2e-12) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e+221: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= -2e+108: tmp = t_0 elif (1.0 / n) <= -2e+19: tmp = (0.0 / n) * -0.3333333333333333 elif (1.0 / n) <= 2e-12: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 4e+212: tmp = t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -4e+221) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= -2e+108) tmp = t_0; elseif (Float64(1.0 / n) <= -2e+19) tmp = Float64(Float64(0.0 / n) * -0.3333333333333333); elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 4e+212) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e+221], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+108], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+19], N[(N[(0.0 / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+212], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{+221}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+108}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+19}:\\
\;\;\;\;\frac{0}{n} \cdot -0.3333333333333333\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+212}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.0000000000000002e221Initial program 100.0%
Taylor expanded in n around inf 63.4%
diff-log63.4%
Applied egg-rr63.4%
if -4.0000000000000002e221 < (/.f64 1 n) < -2.0000000000000001e108 or 1.99999999999999996e-12 < (/.f64 1 n) < 3.9999999999999996e212Initial program 91.3%
Taylor expanded in x around 0 69.3%
if -2.0000000000000001e108 < (/.f64 1 n) < -2e19Initial program 100.0%
flip3--0.0%
div-inv0.0%
pow-to-exp0.0%
pow-exp0.0%
un-div-inv0.0%
+-commutative0.0%
log1p-udef0.0%
inv-pow0.0%
Applied egg-rr0.0%
Simplified0.0%
Taylor expanded in n around -inf 67.8%
*-commutative67.8%
Simplified30.8%
Taylor expanded in x around inf 71.9%
log-rec71.9%
log-rec71.9%
distribute-rgt-out71.9%
metadata-eval71.9%
mul0-rgt71.9%
Simplified71.9%
if -2e19 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 31.6%
Taylor expanded in n around inf 80.0%
log1p-udef80.0%
expm1-log1p-u79.3%
Applied egg-rr79.3%
Taylor expanded in n around 0 80.0%
log-div80.5%
*-lft-identity80.5%
associate-*l/76.6%
+-commutative76.6%
distribute-lft-in76.5%
lft-mult-inverse80.5%
*-rgt-identity80.5%
log1p-def96.7%
Simplified96.7%
if 3.9999999999999996e212 < (/.f64 1 n) Initial program 38.8%
Taylor expanded in n around inf 7.3%
Taylor expanded in x around inf 71.8%
*-commutative71.8%
Simplified71.8%
Final simplification84.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-6)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-12)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 4e+212) (- (+ 1.0 (/ x n)) t_0) (/ 1.0 (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
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) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-6: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-12: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 4e+212: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-6) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 4e+212) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); 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], -5e-6], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+212], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+212}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000041e-6Initial program 98.9%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
div-inv100.0%
pow-to-exp100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -5.00000000000000041e-6 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 31.3%
Taylor expanded in n around inf 81.0%
log1p-udef81.0%
expm1-log1p-u80.3%
Applied egg-rr80.3%
Taylor expanded in n around 0 81.0%
log-div81.5%
*-lft-identity81.5%
associate-*l/77.6%
+-commutative77.6%
distribute-lft-in77.6%
lft-mult-inverse81.5%
*-rgt-identity81.5%
log1p-def97.8%
Simplified97.8%
if 1.99999999999999996e-12 < (/.f64 1 n) < 3.9999999999999996e212Initial program 74.3%
Taylor expanded in x around 0 70.1%
if 3.9999999999999996e212 < (/.f64 1 n) Initial program 38.8%
Taylor expanded in n around inf 7.3%
Taylor expanded in x around inf 71.8%
*-commutative71.8%
Simplified71.8%
Final simplification95.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* (/ 0.0 n) -0.3333333333333333)) (t_1 (/ 1.0 (* n x))))
(if (<= (/ 1.0 n) -2.5e+239)
t_0
(if (<= (/ 1.0 n) -1e+202)
t_1
(if (<= (/ 1.0 n) -2e+19)
t_0
(if (<= (/ 1.0 n) 4e+212) (/ (log1p (/ 1.0 x)) n) t_1))))))
double code(double x, double n) {
double t_0 = (0.0 / n) * -0.3333333333333333;
double t_1 = 1.0 / (n * x);
double tmp;
if ((1.0 / n) <= -2.5e+239) {
tmp = t_0;
} else if ((1.0 / n) <= -1e+202) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+19) {
tmp = t_0;
} else if ((1.0 / n) <= 4e+212) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (0.0 / n) * -0.3333333333333333;
double t_1 = 1.0 / (n * x);
double tmp;
if ((1.0 / n) <= -2.5e+239) {
tmp = t_0;
} else if ((1.0 / n) <= -1e+202) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+19) {
tmp = t_0;
} else if ((1.0 / n) <= 4e+212) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = (0.0 / n) * -0.3333333333333333 t_1 = 1.0 / (n * x) tmp = 0 if (1.0 / n) <= -2.5e+239: tmp = t_0 elif (1.0 / n) <= -1e+202: tmp = t_1 elif (1.0 / n) <= -2e+19: tmp = t_0 elif (1.0 / n) <= 4e+212: tmp = math.log1p((1.0 / x)) / n else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64(Float64(0.0 / n) * -0.3333333333333333) t_1 = Float64(1.0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2.5e+239) tmp = t_0; elseif (Float64(1.0 / n) <= -1e+202) tmp = t_1; elseif (Float64(1.0 / n) <= -2e+19) tmp = t_0; elseif (Float64(1.0 / n) <= 4e+212) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = t_1; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(0.0 / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2.5e+239], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+202], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+19], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+212], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0}{n} \cdot -0.3333333333333333\\
t_1 := \frac{1}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2.5 \cdot 10^{+239}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{+202}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+19}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+212}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.50000000000000003e239 or -9.999999999999999e201 < (/.f64 1 n) < -2e19Initial program 100.0%
flip3--0.0%
div-inv0.0%
pow-to-exp0.0%
pow-exp0.0%
un-div-inv0.0%
+-commutative0.0%
log1p-udef0.0%
inv-pow0.0%
Applied egg-rr0.0%
Simplified0.0%
Taylor expanded in n around -inf 55.4%
*-commutative55.4%
Simplified23.3%
Taylor expanded in x around inf 55.0%
log-rec55.0%
log-rec55.0%
distribute-rgt-out55.0%
metadata-eval55.0%
mul0-rgt55.0%
Simplified55.0%
if -2.50000000000000003e239 < (/.f64 1 n) < -9.999999999999999e201 or 3.9999999999999996e212 < (/.f64 1 n) Initial program 70.9%
Taylor expanded in n around inf 20.1%
Taylor expanded in x around inf 72.6%
*-commutative72.6%
Simplified72.6%
if -2e19 < (/.f64 1 n) < 3.9999999999999996e212Initial program 36.3%
Taylor expanded in n around inf 72.0%
log1p-udef72.0%
expm1-log1p-u71.4%
Applied egg-rr71.4%
Taylor expanded in n around 0 72.0%
log-div72.5%
*-lft-identity72.5%
associate-*l/69.0%
+-commutative69.0%
distribute-lft-in69.0%
lft-mult-inverse72.5%
*-rgt-identity72.5%
log1p-def86.9%
Simplified86.9%
Final simplification77.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-6)
(/ (/ t_0 x) n)
(if (<= (/ 1.0 n) 2e-12)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 4e+212) (- 1.0 t_0) (/ 1.0 (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-6) {
tmp = (t_0 / x) / n;
} else if ((1.0 / n) <= 2e-12) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
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) <= -5e-6) {
tmp = (t_0 / x) / n;
} else if ((1.0 / n) <= 2e-12) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-6: tmp = (t_0 / x) / n elif (1.0 / n) <= 2e-12: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 4e+212: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-6) tmp = Float64(Float64(t_0 / x) / n); elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 4e+212) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); 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], -5e-6], N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+212], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{t_0}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+212}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000041e-6Initial program 98.9%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
div-inv100.0%
pow-to-exp100.0%
Applied egg-rr100.0%
un-div-inv100.0%
associate-/r*100.0%
Applied egg-rr100.0%
if -5.00000000000000041e-6 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 31.3%
Taylor expanded in n around inf 81.0%
log1p-udef81.0%
expm1-log1p-u80.3%
Applied egg-rr80.3%
Taylor expanded in n around 0 81.0%
log-div81.5%
*-lft-identity81.5%
associate-*l/77.6%
+-commutative77.6%
distribute-lft-in77.6%
lft-mult-inverse81.5%
*-rgt-identity81.5%
log1p-def97.8%
Simplified97.8%
if 1.99999999999999996e-12 < (/.f64 1 n) < 3.9999999999999996e212Initial program 74.3%
Taylor expanded in x around 0 68.9%
if 3.9999999999999996e212 < (/.f64 1 n) Initial program 38.8%
Taylor expanded in n around inf 7.3%
Taylor expanded in x around inf 71.8%
*-commutative71.8%
Simplified71.8%
Final simplification95.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-6)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-12)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 4e+212) (- 1.0 t_0) (/ 1.0 (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
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) <= -5e-6) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 4e+212) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-6: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-12: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 4e+212: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-6) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 4e+212) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); 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], -5e-6], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+212], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+212}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000041e-6Initial program 98.9%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
div-inv100.0%
pow-to-exp100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -5.00000000000000041e-6 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 31.3%
Taylor expanded in n around inf 81.0%
log1p-udef81.0%
expm1-log1p-u80.3%
Applied egg-rr80.3%
Taylor expanded in n around 0 81.0%
log-div81.5%
*-lft-identity81.5%
associate-*l/77.6%
+-commutative77.6%
distribute-lft-in77.6%
lft-mult-inverse81.5%
*-rgt-identity81.5%
log1p-def97.8%
Simplified97.8%
if 1.99999999999999996e-12 < (/.f64 1 n) < 3.9999999999999996e212Initial program 74.3%
Taylor expanded in x around 0 68.9%
if 3.9999999999999996e212 < (/.f64 1 n) Initial program 38.8%
Taylor expanded in n around inf 7.3%
Taylor expanded in x around inf 71.8%
*-commutative71.8%
Simplified71.8%
Final simplification95.5%
(FPCore (x n)
:precision binary64
(if (<= x 0.68)
(- (/ (log x) n))
(if (<= x 1.02e+49)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)
(* (/ 0.0 n) -0.3333333333333333))))
double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = -(log(x) / n);
} else if (x <= 1.02e+49) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = (0.0 / n) * -0.3333333333333333;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.68d0) then
tmp = -(log(x) / n)
else if (x <= 1.02d+49) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = (0.0d0 / n) * (-0.3333333333333333d0)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = -(Math.log(x) / n);
} else if (x <= 1.02e+49) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = (0.0 / n) * -0.3333333333333333;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.68: tmp = -(math.log(x) / n) elif x <= 1.02e+49: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = (0.0 / n) * -0.3333333333333333 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.68) tmp = Float64(-Float64(log(x) / n)); elseif (x <= 1.02e+49) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = Float64(Float64(0.0 / n) * -0.3333333333333333); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.68) tmp = -(log(x) / n); elseif (x <= 1.02e+49) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = (0.0 / n) * -0.3333333333333333; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.68], (-N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), If[LessEqual[x, 1.02e+49], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(0.0 / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;-\frac{\log x}{n}\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+49}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n} \cdot -0.3333333333333333\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 44.3%
Taylor expanded in n around inf 55.2%
Taylor expanded in x around 0 54.4%
neg-mul-154.4%
Simplified54.4%
if 0.680000000000000049 < x < 1.02e49Initial program 29.8%
Taylor expanded in n around inf 35.4%
Taylor expanded in x around inf 63.6%
associate-*r/63.6%
metadata-eval63.6%
unpow263.6%
Simplified63.6%
if 1.02e49 < x Initial program 82.2%
flip3--42.2%
div-inv42.2%
pow-to-exp42.2%
pow-exp42.1%
un-div-inv42.1%
+-commutative42.1%
log1p-udef42.1%
inv-pow42.1%
Applied egg-rr42.1%
Simplified42.1%
Taylor expanded in n around -inf 82.2%
*-commutative82.2%
Simplified35.5%
Taylor expanded in x around inf 82.2%
log-rec82.2%
log-rec82.2%
distribute-rgt-out82.2%
metadata-eval82.2%
mul0-rgt82.2%
Simplified82.2%
Final simplification64.9%
(FPCore (x n) :precision binary64 (if (<= x 1.02e+49) (* -0.3333333333333333 (/ -3.0 (* n x))) (* (/ 0.0 n) -0.3333333333333333)))
double code(double x, double n) {
double tmp;
if (x <= 1.02e+49) {
tmp = -0.3333333333333333 * (-3.0 / (n * x));
} else {
tmp = (0.0 / n) * -0.3333333333333333;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.02d+49) then
tmp = (-0.3333333333333333d0) * ((-3.0d0) / (n * x))
else
tmp = (0.0d0 / n) * (-0.3333333333333333d0)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.02e+49) {
tmp = -0.3333333333333333 * (-3.0 / (n * x));
} else {
tmp = (0.0 / n) * -0.3333333333333333;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.02e+49: tmp = -0.3333333333333333 * (-3.0 / (n * x)) else: tmp = (0.0 / n) * -0.3333333333333333 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.02e+49) tmp = Float64(-0.3333333333333333 * Float64(-3.0 / Float64(n * x))); else tmp = Float64(Float64(0.0 / n) * -0.3333333333333333); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.02e+49) tmp = -0.3333333333333333 * (-3.0 / (n * x)); else tmp = (0.0 / n) * -0.3333333333333333; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.02e+49], N[(-0.3333333333333333 * N[(-3.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.0 / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{+49}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{-3}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n} \cdot -0.3333333333333333\\
\end{array}
\end{array}
if x < 1.02e49Initial program 42.6%
flip3--12.5%
div-inv12.5%
pow-to-exp12.5%
pow-exp12.5%
un-div-inv12.5%
+-commutative12.5%
log1p-udef17.7%
inv-pow17.7%
Applied egg-rr12.9%
Simplified12.3%
Taylor expanded in n around -inf 52.7%
*-commutative52.7%
Simplified51.6%
Taylor expanded in x around inf 27.9%
distribute-rgt-out27.9%
log-rec27.9%
metadata-eval27.9%
mul0-rgt27.9%
neg-sub027.9%
associate-*r/28.0%
metadata-eval28.0%
*-commutative28.0%
distribute-neg-frac28.0%
metadata-eval28.0%
Simplified28.0%
if 1.02e49 < x Initial program 82.2%
flip3--42.2%
div-inv42.2%
pow-to-exp42.2%
pow-exp42.1%
un-div-inv42.1%
+-commutative42.1%
log1p-udef42.1%
inv-pow42.1%
Applied egg-rr42.1%
Simplified42.1%
Taylor expanded in n around -inf 82.2%
*-commutative82.2%
Simplified35.5%
Taylor expanded in x around inf 82.2%
log-rec82.2%
log-rec82.2%
distribute-rgt-out82.2%
metadata-eval82.2%
mul0-rgt82.2%
Simplified82.2%
Final simplification47.0%
(FPCore (x n) :precision binary64 (if (<= x 1.02e+49) (/ 1.0 (* n x)) (* (/ 0.0 n) -0.3333333333333333)))
double code(double x, double n) {
double tmp;
if (x <= 1.02e+49) {
tmp = 1.0 / (n * x);
} else {
tmp = (0.0 / n) * -0.3333333333333333;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.02d+49) then
tmp = 1.0d0 / (n * x)
else
tmp = (0.0d0 / n) * (-0.3333333333333333d0)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.02e+49) {
tmp = 1.0 / (n * x);
} else {
tmp = (0.0 / n) * -0.3333333333333333;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.02e+49: tmp = 1.0 / (n * x) else: tmp = (0.0 / n) * -0.3333333333333333 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.02e+49) tmp = Float64(1.0 / Float64(n * x)); else tmp = Float64(Float64(0.0 / n) * -0.3333333333333333); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.02e+49) tmp = 1.0 / (n * x); else tmp = (0.0 / n) * -0.3333333333333333; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.02e+49], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(0.0 / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{+49}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n} \cdot -0.3333333333333333\\
\end{array}
\end{array}
if x < 1.02e49Initial program 42.6%
Taylor expanded in n around inf 52.9%
Taylor expanded in x around inf 27.9%
*-commutative27.9%
Simplified27.9%
if 1.02e49 < x Initial program 82.2%
flip3--42.2%
div-inv42.2%
pow-to-exp42.2%
pow-exp42.1%
un-div-inv42.1%
+-commutative42.1%
log1p-udef42.1%
inv-pow42.1%
Applied egg-rr42.1%
Simplified42.1%
Taylor expanded in n around -inf 82.2%
*-commutative82.2%
Simplified35.5%
Taylor expanded in x around inf 82.2%
log-rec82.2%
log-rec82.2%
distribute-rgt-out82.2%
metadata-eval82.2%
mul0-rgt82.2%
Simplified82.2%
Final simplification47.0%
(FPCore (x n) :precision binary64 (if (<= x 1.02e+49) (/ (/ 1.0 x) n) (* (/ 0.0 n) -0.3333333333333333)))
double code(double x, double n) {
double tmp;
if (x <= 1.02e+49) {
tmp = (1.0 / x) / n;
} else {
tmp = (0.0 / n) * -0.3333333333333333;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.02d+49) then
tmp = (1.0d0 / x) / n
else
tmp = (0.0d0 / n) * (-0.3333333333333333d0)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.02e+49) {
tmp = (1.0 / x) / n;
} else {
tmp = (0.0 / n) * -0.3333333333333333;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.02e+49: tmp = (1.0 / x) / n else: tmp = (0.0 / n) * -0.3333333333333333 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.02e+49) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(Float64(0.0 / n) * -0.3333333333333333); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.02e+49) tmp = (1.0 / x) / n; else tmp = (0.0 / n) * -0.3333333333333333; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.02e+49], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(0.0 / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{+49}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n} \cdot -0.3333333333333333\\
\end{array}
\end{array}
if x < 1.02e49Initial program 42.6%
Taylor expanded in n around inf 52.9%
Taylor expanded in x around inf 27.9%
if 1.02e49 < x Initial program 82.2%
flip3--42.2%
div-inv42.2%
pow-to-exp42.2%
pow-exp42.1%
un-div-inv42.1%
+-commutative42.1%
log1p-udef42.1%
inv-pow42.1%
Applied egg-rr42.1%
Simplified42.1%
Taylor expanded in n around -inf 82.2%
*-commutative82.2%
Simplified35.5%
Taylor expanded in x around inf 82.2%
log-rec82.2%
log-rec82.2%
distribute-rgt-out82.2%
metadata-eval82.2%
mul0-rgt82.2%
Simplified82.2%
Final simplification47.0%
(FPCore (x n) :precision binary64 (* (/ 0.0 n) -0.3333333333333333))
double code(double x, double n) {
return (0.0 / n) * -0.3333333333333333;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (0.0d0 / n) * (-0.3333333333333333d0)
end function
public static double code(double x, double n) {
return (0.0 / n) * -0.3333333333333333;
}
def code(x, n): return (0.0 / n) * -0.3333333333333333
function code(x, n) return Float64(Float64(0.0 / n) * -0.3333333333333333) end
function tmp = code(x, n) tmp = (0.0 / n) * -0.3333333333333333; end
code[x_, n_] := N[(N[(0.0 / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{n} \cdot -0.3333333333333333
\end{array}
Initial program 56.5%
flip3--22.9%
div-inv22.9%
pow-to-exp22.9%
pow-exp22.9%
un-div-inv22.9%
+-commutative22.9%
log1p-udef26.3%
inv-pow26.3%
Applied egg-rr23.1%
Simplified22.8%
Taylor expanded in n around -inf 63.1%
*-commutative63.1%
Simplified45.9%
Taylor expanded in x around inf 33.3%
log-rec33.3%
log-rec33.3%
distribute-rgt-out33.3%
metadata-eval33.3%
mul0-rgt33.3%
Simplified33.3%
Final simplification33.3%
herbie shell --seed 2023230
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))