
(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
(if (<= (/ 1.0 n) -2e-16)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(exp (log (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = exp(log((exp((log1p(x) / n)) - pow(x, (1.0 / n)))));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = Math.exp(Math.log((Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n)))));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e-16: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n else: tmp = math.exp(math.log((math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n))))) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); else tmp = exp(log(Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[Exp[N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) Initial program 58.4%
add-exp-log58.5%
add-exp-log58.5%
log-pow58.5%
+-commutative58.5%
log1p-udef95.4%
*-commutative95.4%
un-div-inv95.4%
Applied egg-rr95.4%
Final simplification91.5%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -2e-16)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e-16: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n else: tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) Initial program 58.4%
Taylor expanded in n around 0 58.4%
log1p-def95.4%
Simplified95.4%
Final simplification91.5%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -2e-16)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(- (exp (/ x n)) (pow x (/ 1.0 n)))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e-16: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n else: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) Initial program 58.4%
Taylor expanded in n around 0 58.4%
log1p-def95.4%
Simplified95.4%
Taylor expanded in x around 0 95.3%
Final simplification91.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e+214)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) -5e+29)
(- 1.0 t_0)
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e+193)
(- (+ 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+214) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -5e+29) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
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+214) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -5e+29) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
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+214: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= -5e+29: tmp = 1.0 - t_0 elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e+193: 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+214) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= -5e+29) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e+193) 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+214], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+29], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], 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^{+214}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+29}:\\
\;\;\;\;1 - t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999953e214Initial program 100.0%
Taylor expanded in n around inf 71.2%
log1p-def71.2%
Simplified71.2%
log1p-udef71.2%
diff-log71.2%
+-commutative71.2%
Applied egg-rr71.2%
if -4.99999999999999953e214 < (/.f64 1 n) < -5.0000000000000001e29Initial program 100.0%
Taylor expanded in x around 0 67.7%
if -5.0000000000000001e29 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 37.0%
Taylor expanded in n around inf 81.1%
log1p-def81.1%
Simplified81.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 76.7%
Taylor expanded in x around 0 70.9%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification76.6%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -2e-16)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e+193)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(/ 1.0 (* n x)))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-69) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e-16: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 2e-69: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e+193: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e+193) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 94.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
if -2e-16 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 33.5%
Taylor expanded in n around inf 86.1%
log1p-def86.1%
Simplified86.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 76.7%
Taylor expanded in x around 0 70.9%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification87.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 x) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -5e+214)
(+ 1.0 (cbrt -1.0))
(if (<= (/ 1.0 n) -5000.0)
t_1
(if (<= (/ 1.0 n) -2e-134)
(/ (- x (log x)) n)
(if (<= (/ 1.0 n) -5e-251)
t_0
(if (<= (/ 1.0 n) 2e-69)
(/ (- (log x)) n)
(if (<= (/ 1.0 n) 5e-21)
t_0
(if (<= (/ 1.0 n) 5e+193) t_1 (/ 1.0 (* n x)))))))))))
double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = 1.0 + cbrt(-1.0);
} else if ((1.0 / n) <= -5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= -2e-134) {
tmp = (x - log(x)) / n;
} else if ((1.0 / n) <= -5e-251) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = -log(x) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = t_0;
} else if ((1.0 / n) <= 5e+193) {
tmp = t_1;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = 1.0 + Math.cbrt(-1.0);
} else if ((1.0 / n) <= -5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= -2e-134) {
tmp = (x - Math.log(x)) / n;
} else if ((1.0 / n) <= -5e-251) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = -Math.log(x) / n;
} else if ((1.0 / n) <= 5e-21) {
tmp = t_0;
} else if ((1.0 / n) <= 5e+193) {
tmp = t_1;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
function code(x, n) t_0 = Float64(Float64(1.0 / x) / n) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -5e+214) tmp = Float64(1.0 + cbrt(-1.0)); elseif (Float64(1.0 / n) <= -5000.0) tmp = t_1; elseif (Float64(1.0 / n) <= -2e-134) tmp = Float64(Float64(x - log(x)) / n); elseif (Float64(1.0 / n) <= -5e-251) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-69) tmp = Float64(Float64(-log(x)) / n); elseif (Float64(1.0 / n) <= 5e-21) tmp = t_0; elseif (Float64(1.0 / n) <= 5e+193) tmp = t_1; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] / n), $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], -5e+214], N[(1.0 + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-134], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-251], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], t$95$1, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+214}:\\
\;\;\;\;1 + \sqrt[3]{-1}\\
\mathbf{elif}\;\frac{1}{n} \leq -5000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-134}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-251}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999953e214Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
add-cube-cbrt100.0%
fma-def100.0%
add-exp-log100.0%
log-pow100.0%
+-commutative100.0%
log1p-udef100.0%
*-commutative100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
cbrt-unprod100.0%
sqr-neg100.0%
pow-sqr100.0%
div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in n around inf 69.2%
if -4.99999999999999953e214 < (/.f64 1 n) < -5e3 or 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 90.7%
Taylor expanded in x around 0 66.7%
if -5e3 < (/.f64 1 n) < -2.00000000000000008e-134Initial program 14.3%
Taylor expanded in n around 0 14.3%
log1p-def14.3%
Simplified14.3%
Taylor expanded in x around 0 4.0%
Taylor expanded in n around inf 59.7%
if -2.00000000000000008e-134 < (/.f64 1 n) < -5.0000000000000003e-251 or 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 38.7%
Taylor expanded in n around inf 65.8%
log1p-def65.9%
Simplified65.9%
Taylor expanded in x around inf 73.1%
if -5.0000000000000003e-251 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 30.3%
Taylor expanded in x around 0 30.3%
Taylor expanded in n around inf 64.7%
associate-*r/64.7%
mul-1-neg64.7%
Simplified64.7%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification67.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -5e+214)
t_1
(if (<= (/ 1.0 n) -5e+29)
(- 1.0 t_0)
(if (<= (/ 1.0 n) 2e-69)
t_1
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e+193)
(- (+ 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 t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = t_1;
} else if ((1.0 / n) <= -5e+29) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-5d+214)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d+29)) then
tmp = 1.0d0 - t_0
else if ((1.0d0 / n) <= 2d-69) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-21) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 5d+193) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = t_1;
} else if ((1.0 / n) <= -5e+29) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
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)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -5e+214: tmp = t_1 elif (1.0 / n) <= -5e+29: tmp = 1.0 - t_0 elif (1.0 / n) <= 2e-69: tmp = t_1 elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e+193: 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) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+214) tmp = t_1; elseif (Float64(1.0 / n) <= -5e+29) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= 2e-69) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e+193) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -5e+214) tmp = t_1; elseif ((1.0 / n) <= -5e+29) tmp = 1.0 - t_0; elseif ((1.0 / n) <= 2e-69) tmp = t_1; elseif ((1.0 / n) <= 5e-21) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 5e+193) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+214], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+29], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], 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)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+214}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+29}:\\
\;\;\;\;1 - t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999953e214 or -5.0000000000000001e29 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 43.5%
Taylor expanded in n around inf 80.1%
log1p-def80.1%
Simplified80.1%
log1p-udef80.1%
diff-log80.1%
+-commutative80.1%
Applied egg-rr80.1%
if -4.99999999999999953e214 < (/.f64 1 n) < -5.0000000000000001e29Initial program 100.0%
Taylor expanded in x around 0 67.7%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 76.7%
Taylor expanded in x around 0 70.9%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification76.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -5e+214)
t_1
(if (<= (/ 1.0 n) -5e+29)
t_0
(if (<= (/ 1.0 n) 2e-69)
t_1
(if (<= (/ 1.0 n) 5e-21)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e+193) t_0 (/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = t_1;
} else if ((1.0 / n) <= -5e+29) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-5d+214)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d+29)) then
tmp = t_0
else if ((1.0d0 / n) <= 2d-69) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-21) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 5d+193) then
tmp = t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+214) {
tmp = t_1;
} else if ((1.0 / n) <= -5e+29) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-69) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-21) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e+193) {
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)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -5e+214: tmp = t_1 elif (1.0 / n) <= -5e+29: tmp = t_0 elif (1.0 / n) <= 2e-69: tmp = t_1 elif (1.0 / n) <= 5e-21: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e+193: 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))) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+214) tmp = t_1; elseif (Float64(1.0 / n) <= -5e+29) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-69) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-21) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e+193) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -5e+214) tmp = t_1; elseif ((1.0 / n) <= -5e+29) tmp = t_0; elseif ((1.0 / n) <= 2e-69) tmp = t_1; elseif ((1.0 / n) <= 5e-21) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 5e+193) tmp = t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+214], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+29], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-69], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-21], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+193], 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)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+214}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+193}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999953e214 or -5.0000000000000001e29 < (/.f64 1 n) < 1.9999999999999999e-69Initial program 43.5%
Taylor expanded in n around inf 80.1%
log1p-def80.1%
Simplified80.1%
log1p-udef80.1%
diff-log80.1%
+-commutative80.1%
Applied egg-rr80.1%
if -4.99999999999999953e214 < (/.f64 1 n) < -5.0000000000000001e29 or 4.99999999999999973e-21 < (/.f64 1 n) < 4.99999999999999972e193Initial program 89.6%
Taylor expanded in x around 0 69.1%
if 1.9999999999999999e-69 < (/.f64 1 n) < 4.99999999999999973e-21Initial program 6.4%
Taylor expanded in n around inf 25.6%
log1p-def25.6%
Simplified25.6%
Taylor expanded in x around inf 80.7%
if 4.99999999999999972e193 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 6.3%
log1p-def6.3%
Simplified6.3%
Taylor expanded in x around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification76.5%
(FPCore (x n)
:precision binary64
(if (<= x 1.0)
(/ (- (log x)) n)
(if (or (<= x 2e+59) (not (<= x 1.25e+181)))
(+ 1.0 (cbrt -1.0))
(/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = -log(x) / n;
} else if ((x <= 2e+59) || !(x <= 1.25e+181)) {
tmp = 1.0 + cbrt(-1.0);
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = -Math.log(x) / n;
} else if ((x <= 2e+59) || !(x <= 1.25e+181)) {
tmp = 1.0 + Math.cbrt(-1.0);
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(-log(x)) / n); elseif ((x <= 2e+59) || !(x <= 1.25e+181)) tmp = Float64(1.0 + cbrt(-1.0)); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
code[x_, n_] := If[LessEqual[x, 1.0], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[Or[LessEqual[x, 2e+59], N[Not[LessEqual[x, 1.25e+181]], $MachinePrecision]], N[(1.0 + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+59} \lor \neg \left(x \leq 1.25 \cdot 10^{+181}\right):\\
\;\;\;\;1 + \sqrt[3]{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1Initial program 44.6%
Taylor expanded in x around 0 42.7%
Taylor expanded in n around inf 47.8%
associate-*r/47.8%
mul-1-neg47.8%
Simplified47.8%
if 1 < x < 1.99999999999999994e59 or 1.2500000000000001e181 < x Initial program 81.8%
sub-neg81.8%
+-commutative81.8%
add-cube-cbrt81.7%
fma-def81.7%
add-exp-log81.7%
log-pow81.7%
+-commutative81.7%
log1p-udef81.7%
*-commutative81.7%
un-div-inv81.7%
Applied egg-rr81.7%
expm1-log1p-u81.7%
expm1-udef81.7%
cbrt-unprod81.7%
sqr-neg81.7%
pow-sqr81.7%
div-inv81.7%
Applied egg-rr81.7%
expm1-def81.7%
expm1-log1p81.7%
Simplified81.7%
Taylor expanded in n around inf 81.8%
if 1.99999999999999994e59 < x < 1.2500000000000001e181Initial program 50.3%
Taylor expanded in n around inf 50.3%
log1p-def50.3%
Simplified50.3%
Taylor expanded in x around inf 74.5%
Final simplification59.9%
(FPCore (x n)
:precision binary64
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (or (<= x 7.5e+57) (not (<= x 1.9e+183)))
(+ 1.0 (cbrt -1.0))
(/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if ((x <= 7.5e+57) || !(x <= 1.9e+183)) {
tmp = 1.0 + cbrt(-1.0);
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if ((x <= 7.5e+57) || !(x <= 1.9e+183)) {
tmp = 1.0 + Math.cbrt(-1.0);
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif ((x <= 7.5e+57) || !(x <= 1.9e+183)) tmp = Float64(1.0 + cbrt(-1.0)); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[x, 7.5e+57], N[Not[LessEqual[x, 1.9e+183]], $MachinePrecision]], N[(1.0 + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+57} \lor \neg \left(x \leq 1.9 \cdot 10^{+183}\right):\\
\;\;\;\;1 + \sqrt[3]{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1Initial program 44.6%
Taylor expanded in n around 0 44.6%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around 0 56.2%
Taylor expanded in n around inf 48.2%
if 1 < x < 7.5000000000000006e57 or 1.9e183 < x Initial program 81.8%
sub-neg81.8%
+-commutative81.8%
add-cube-cbrt81.7%
fma-def81.7%
add-exp-log81.7%
log-pow81.7%
+-commutative81.7%
log1p-udef81.7%
*-commutative81.7%
un-div-inv81.7%
Applied egg-rr81.7%
expm1-log1p-u81.7%
expm1-udef81.7%
cbrt-unprod81.7%
sqr-neg81.7%
pow-sqr81.7%
div-inv81.7%
Applied egg-rr81.7%
expm1-def81.7%
expm1-log1p81.7%
Simplified81.7%
Taylor expanded in n around inf 81.8%
if 7.5000000000000006e57 < x < 1.9e183Initial program 50.3%
Taylor expanded in n around inf 50.3%
log1p-def50.3%
Simplified50.3%
Taylor expanded in x around inf 74.5%
Final simplification60.2%
(FPCore (x n) :precision binary64 (if (or (<= n -3.3e-9) (not (<= n -4.5e-308))) (/ (/ 1.0 x) n) (+ 1.0 (cbrt -1.0))))
double code(double x, double n) {
double tmp;
if ((n <= -3.3e-9) || !(n <= -4.5e-308)) {
tmp = (1.0 / x) / n;
} else {
tmp = 1.0 + cbrt(-1.0);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((n <= -3.3e-9) || !(n <= -4.5e-308)) {
tmp = (1.0 / x) / n;
} else {
tmp = 1.0 + Math.cbrt(-1.0);
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n <= -3.3e-9) || !(n <= -4.5e-308)) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(1.0 + cbrt(-1.0)); end return tmp end
code[x_, n_] := If[Or[LessEqual[n, -3.3e-9], N[Not[LessEqual[n, -4.5e-308]], $MachinePrecision]], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(1.0 + N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.3 \cdot 10^{-9} \lor \neg \left(n \leq -4.5 \cdot 10^{-308}\right):\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;1 + \sqrt[3]{-1}\\
\end{array}
\end{array}
if n < -3.30000000000000018e-9 or -4.50000000000000009e-308 < n Initial program 38.6%
Taylor expanded in n around inf 60.3%
log1p-def60.3%
Simplified60.3%
Taylor expanded in x around inf 43.5%
if -3.30000000000000018e-9 < n < -4.50000000000000009e-308Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
add-cube-cbrt100.0%
fma-def100.0%
add-exp-log100.0%
log-pow100.0%
+-commutative100.0%
log1p-udef100.0%
*-commutative100.0%
un-div-inv100.0%
Applied egg-rr100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
cbrt-unprod100.0%
sqr-neg100.0%
pow-sqr100.0%
div-inv100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in n around inf 47.0%
Final simplification44.4%
(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 54.2%
Taylor expanded in n around inf 56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around inf 38.5%
*-commutative38.5%
Simplified38.5%
Final simplification38.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 54.2%
Taylor expanded in n around inf 56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around inf 39.2%
Final simplification39.2%
(FPCore (x n) :precision binary64 2.0)
double code(double x, double n) {
return 2.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 2.0d0
end function
public static double code(double x, double n) {
return 2.0;
}
def code(x, n): return 2.0
function code(x, n) return 2.0 end
function tmp = code(x, n) tmp = 2.0; end
code[x_, n_] := 2.0
\begin{array}{l}
\\
2
\end{array}
Initial program 54.2%
add-sqr-sqrt39.7%
pow239.7%
add-exp-log39.7%
log-pow39.7%
+-commutative39.7%
log1p-udef46.8%
*-commutative46.8%
un-div-inv46.8%
Applied egg-rr46.8%
add-cbrt-cube46.8%
add-sqr-sqrt46.8%
pow146.8%
pow1/246.8%
pow-prod-up46.8%
Applied egg-rr30.9%
Taylor expanded in n around inf 4.5%
unpow24.5%
rem-square-sqrt4.5%
Simplified4.5%
Final simplification4.5%
herbie shell --seed 2024024
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))