
(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 16 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 (<= x 260000.0)
(/
(log
(/
(exp
(+ (log1p x) (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n))))
x))
n)
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 260000.0) {
tmp = log((exp((log1p(x) + (0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)))) / x)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 260000.0) {
tmp = Math.log((Math.exp((Math.log1p(x) + (0.5 * ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n)))) / x)) / n;
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 260000.0: tmp = math.log((math.exp((math.log1p(x) + (0.5 * ((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n)))) / x)) / n else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 260000.0) tmp = Float64(log(Float64(exp(Float64(log1p(x) + Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)))) / x)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 260000.0], N[(N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 260000:\\
\;\;\;\;\frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 2.6e5Initial program 48.0%
Taylor expanded in n around inf 68.0%
associate--l+68.0%
log1p-define68.0%
+-commutative68.0%
associate--r+68.0%
distribute-lft-out--68.0%
div-sub68.0%
log1p-define68.0%
Simplified68.0%
associate-+r-68.0%
add-log-exp80.5%
exp-diff80.5%
add-exp-log80.6%
Applied egg-rr80.6%
if 2.6e5 < x Initial program 69.9%
Taylor expanded in x around inf 98.5%
associate-/r*99.8%
mul-1-neg99.8%
log-rec99.8%
mul-1-neg99.8%
distribute-neg-frac99.8%
mul-1-neg99.8%
remove-double-neg99.8%
*-rgt-identity99.8%
associate-/l*99.8%
exp-to-pow99.8%
Simplified99.8%
Final simplification88.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (exp (/ (log1p x) n)))
(t_1 (pow x (/ 1.0 n)))
(t_2 (- (pow (+ x 1.0) (/ 1.0 n)) t_1)))
(if (<= t_2 -0.01)
(fma (pow x (/ 0.5 n)) (- (sqrt t_1)) t_0)
(if (<= t_2 5e-11)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(- t_0 t_1)))))
double code(double x, double n) {
double t_0 = exp((log1p(x) / n));
double t_1 = pow(x, (1.0 / n));
double t_2 = pow((x + 1.0), (1.0 / n)) - t_1;
double tmp;
if (t_2 <= -0.01) {
tmp = fma(pow(x, (0.5 / n)), -sqrt(t_1), t_0);
} else if (t_2 <= 5e-11) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else {
tmp = t_0 - t_1;
}
return tmp;
}
function code(x, n) t_0 = exp(Float64(log1p(x) / n)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_1) tmp = 0.0 if (t_2 <= -0.01) tmp = fma((x ^ Float64(0.5 / n)), Float64(-sqrt(t_1)), t_0); elseif (t_2 <= 5e-11) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); else tmp = Float64(t_0 - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -0.01], N[(N[Power[x, N[(0.5 / n), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$1], $MachinePrecision]) + t$95$0), $MachinePrecision], If[LessEqual[t$95$2, 5e-11], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 - t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_1\\
\mathbf{if}\;t\_2 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left({x}^{\left(\frac{0.5}{n}\right)}, -\sqrt{t\_1}, t\_0\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0 - t\_1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -0.0100000000000000002Initial program 99.8%
sub-neg99.8%
+-commutative99.8%
sqr-pow99.7%
distribute-rgt-neg-in99.7%
fma-define99.8%
sqrt-pow199.8%
sqrt-pow199.8%
pow-to-exp99.8%
un-div-inv99.8%
+-commutative99.8%
log1p-define99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.8%
*-rgt-identity99.8%
associate-*r/99.8%
exp-to-pow99.8%
unpow1/299.8%
exp-to-pow99.8%
associate-*r/99.8%
*-rgt-identity99.8%
exp-prod99.8%
*-rgt-identity99.8%
associate-*r/99.8%
associate-*r*99.8%
exp-to-pow99.8%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
if -0.0100000000000000002 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 5.00000000000000018e-11Initial program 42.0%
Taylor expanded in n around inf 81.7%
associate--l+64.5%
log1p-define64.5%
+-commutative64.5%
associate--r+81.7%
distribute-lft-out--81.7%
div-sub81.7%
log1p-define81.7%
Simplified81.7%
if 5.00000000000000018e-11 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 67.2%
Taylor expanded in n around 0 67.2%
log1p-define99.9%
*-rgt-identity99.9%
associate-*l/99.9%
associate-/l*99.9%
exp-to-pow99.9%
Simplified99.9%
Final simplification87.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (exp (/ (log1p x) n)))
(t_1 (pow x (/ 1.0 n)))
(t_2 (- (pow (+ x 1.0) (/ 1.0 n)) t_1)))
(if (<= t_2 -0.01)
(fma (pow x (/ 0.5 n)) (- (sqrt t_1)) t_0)
(if (<= t_2 5e-11) (/ (- (log1p x) (log x)) n) (- t_0 t_1)))))
double code(double x, double n) {
double t_0 = exp((log1p(x) / n));
double t_1 = pow(x, (1.0 / n));
double t_2 = pow((x + 1.0), (1.0 / n)) - t_1;
double tmp;
if (t_2 <= -0.01) {
tmp = fma(pow(x, (0.5 / n)), -sqrt(t_1), t_0);
} else if (t_2 <= 5e-11) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = t_0 - t_1;
}
return tmp;
}
function code(x, n) t_0 = exp(Float64(log1p(x) / n)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_1) tmp = 0.0 if (t_2 <= -0.01) tmp = fma((x ^ Float64(0.5 / n)), Float64(-sqrt(t_1)), t_0); elseif (t_2 <= 5e-11) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(t_0 - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -0.01], N[(N[Power[x, N[(0.5 / n), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$1], $MachinePrecision]) + t$95$0), $MachinePrecision], If[LessEqual[t$95$2, 5e-11], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 - t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_1\\
\mathbf{if}\;t\_2 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left({x}^{\left(\frac{0.5}{n}\right)}, -\sqrt{t\_1}, t\_0\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0 - t\_1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -0.0100000000000000002Initial program 99.8%
sub-neg99.8%
+-commutative99.8%
sqr-pow99.7%
distribute-rgt-neg-in99.7%
fma-define99.8%
sqrt-pow199.8%
sqrt-pow199.8%
pow-to-exp99.8%
un-div-inv99.8%
+-commutative99.8%
log1p-define99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.8%
*-rgt-identity99.8%
associate-*r/99.8%
exp-to-pow99.8%
unpow1/299.8%
exp-to-pow99.8%
associate-*r/99.8%
*-rgt-identity99.8%
exp-prod99.8%
*-rgt-identity99.8%
associate-*r/99.8%
associate-*r*99.8%
exp-to-pow99.8%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
if -0.0100000000000000002 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 5.00000000000000018e-11Initial program 42.0%
Taylor expanded in n around inf 81.4%
log1p-define81.4%
Simplified81.4%
if 5.00000000000000018e-11 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 67.2%
Taylor expanded in n around 0 67.2%
log1p-define99.9%
*-rgt-identity99.9%
associate-*l/99.9%
associate-/l*99.9%
exp-to-pow99.9%
Simplified99.9%
Final simplification87.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -0.01)
(log (exp (- 1.0 t_0)))
(if (<= t_1 5e-11)
(/ (- (log1p x) (log x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -0.01) {
tmp = log(exp((1.0 - t_0)));
} else if (t_1 <= 5e-11) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -0.01) {
tmp = Math.log(Math.exp((1.0 - t_0)));
} else if (t_1 <= 5e-11) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -0.01: tmp = math.log(math.exp((1.0 - t_0))) elif t_1 <= 5e-11: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -0.01) tmp = log(exp(Float64(1.0 - t_0))); elseif (t_1 <= 5e-11) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -0.01], N[Log[N[Exp[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 5e-11], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -0.01:\\
\;\;\;\;\log \left(e^{1 - t\_0}\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -0.0100000000000000002Initial program 99.8%
add-log-exp99.8%
pow-to-exp99.8%
un-div-inv99.8%
+-commutative99.8%
log1p-define99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.8%
exp-diff99.8%
*-rgt-identity99.8%
associate-*r/99.8%
exp-to-pow99.8%
div-exp99.8%
Simplified99.8%
if -0.0100000000000000002 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 5.00000000000000018e-11Initial program 42.0%
Taylor expanded in n around inf 81.4%
log1p-define81.4%
Simplified81.4%
if 5.00000000000000018e-11 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 67.2%
Taylor expanded in n around 0 67.2%
log1p-define99.9%
*-rgt-identity99.9%
associate-*l/99.9%
associate-/l*99.9%
exp-to-pow99.9%
Simplified99.9%
Final simplification87.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -0.01)
(- 1.0 t_0)
(if (<= t_1 5e-11)
(/ (- (log1p x) (log x)) n)
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n)))))))
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -0.01) {
tmp = 1.0 - t_0;
} else if (t_1 <= 5e-11) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -0.01) {
tmp = 1.0 - t_0;
} else if (t_1 <= 5e-11) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -0.01: tmp = 1.0 - t_0 elif t_1 <= 5e-11: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -0.01) tmp = Float64(1.0 - t_0); elseif (t_1 <= 5e-11) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) + Float64(0.5 * Float64(-1.0 / n))))))) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -0.01], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 5e-11], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -0.01:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -0.0100000000000000002Initial program 99.8%
Taylor expanded in x around 0 99.8%
*-rgt-identity99.8%
associate-*l/99.8%
associate-/l*99.8%
exp-to-pow99.8%
Simplified99.8%
if -0.0100000000000000002 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 5.00000000000000018e-11Initial program 42.0%
Taylor expanded in n around inf 81.4%
log1p-define81.4%
Simplified81.4%
if 5.00000000000000018e-11 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 67.2%
Taylor expanded in x around 0 70.1%
Final simplification83.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -0.01)
(log (exp (- 1.0 t_0)))
(if (<= t_1 5e-11)
(/ (- (log1p x) (log x)) n)
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n)))))))
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -0.01) {
tmp = log(exp((1.0 - t_0)));
} else if (t_1 <= 5e-11) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -0.01) {
tmp = Math.log(Math.exp((1.0 - t_0)));
} else if (t_1 <= 5e-11) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -0.01: tmp = math.log(math.exp((1.0 - t_0))) elif t_1 <= 5e-11: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * (1.0 / math.pow(n, 2.0))) + (0.5 * (-1.0 / n))))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -0.01) tmp = log(exp(Float64(1.0 - t_0))); elseif (t_1 <= 5e-11) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) + Float64(0.5 * Float64(-1.0 / n))))))) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -0.01], N[Log[N[Exp[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 5e-11], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -0.01:\\
\;\;\;\;\log \left(e^{1 - t\_0}\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -0.0100000000000000002Initial program 99.8%
add-log-exp99.8%
pow-to-exp99.8%
un-div-inv99.8%
+-commutative99.8%
log1p-define99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.8%
exp-diff99.8%
*-rgt-identity99.8%
associate-*r/99.8%
exp-to-pow99.8%
div-exp99.8%
Simplified99.8%
if -0.0100000000000000002 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 5.00000000000000018e-11Initial program 42.0%
Taylor expanded in n around inf 81.4%
log1p-define81.4%
Simplified81.4%
if 5.00000000000000018e-11 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 67.2%
Taylor expanded in x around 0 70.1%
Final simplification83.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -0.01)
(- 1.0 t_0)
(if (<= t_1 5e-11) (/ (- (log1p x) (log x)) n) t_1))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -0.01) {
tmp = 1.0 - t_0;
} else if (t_1 <= 5e-11) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -0.01) {
tmp = 1.0 - t_0;
} else if (t_1 <= 5e-11) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -0.01: tmp = 1.0 - t_0 elif t_1 <= 5e-11: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = t_1 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -0.01) tmp = Float64(1.0 - t_0); elseif (t_1 <= 5e-11) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = t_1; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -0.01], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 5e-11], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -0.01:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -0.0100000000000000002Initial program 99.8%
Taylor expanded in x around 0 99.8%
*-rgt-identity99.8%
associate-*l/99.8%
associate-/l*99.8%
exp-to-pow99.8%
Simplified99.8%
if -0.0100000000000000002 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 5.00000000000000018e-11Initial program 42.0%
Taylor expanded in n around inf 81.4%
log1p-define81.4%
Simplified81.4%
if 5.00000000000000018e-11 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 67.2%
Final simplification83.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (- (log1p x) (log x)) n)))
(if (<= (/ 1.0 n) -40000.0)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) -2e-75)
t_1
(if (<= (/ 1.0 n) -5e-90)
(/ (+ (/ 1.0 n) (/ (/ -0.5 n) x)) x)
(if (<= (/ 1.0 n) 2e-6) t_1 (- (+ (+ 2.0 (/ x n)) -1.0) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (log1p(x) - log(x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= -2e-75) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 / n) + ((-0.5 / n) / x)) / x;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_1;
} else {
tmp = ((2.0 + (x / n)) + -1.0) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (Math.log1p(x) - Math.log(x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= -2e-75) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 / n) + ((-0.5 / n) / x)) / x;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_1;
} else {
tmp = ((2.0 + (x / n)) + -1.0) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (math.log1p(x) - math.log(x)) / n tmp = 0 if (1.0 / n) <= -40000.0: tmp = (t_0 / n) / x elif (1.0 / n) <= -2e-75: tmp = t_1 elif (1.0 / n) <= -5e-90: tmp = ((1.0 / n) + ((-0.5 / n) / x)) / x elif (1.0 / n) <= 2e-6: tmp = t_1 else: tmp = ((2.0 + (x / n)) + -1.0) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(log1p(x) - log(x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -40000.0) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= -2e-75) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-90) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(-0.5 / n) / x)) / x); elseif (Float64(1.0 / n) <= 2e-6) tmp = t_1; else tmp = Float64(Float64(Float64(2.0 + Float64(x / n)) + -1.0) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40000.0], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-75], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-90], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(-0.5 / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], t$95$1, N[(N[(N[(2.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -40000:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-75}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-90}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{-0.5}{n}}{x}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(2 + \frac{x}{n}\right) + -1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -4e4Initial program 100.0%
Taylor expanded in x around inf 100.0%
associate-/r*100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if -4e4 < (/.f64 1 n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 1 n) < 1.99999999999999991e-6Initial program 31.2%
Taylor expanded in n around inf 81.3%
log1p-define81.3%
Simplified81.3%
if -1.9999999999999999e-75 < (/.f64 1 n) < -5.00000000000000019e-90Initial program 4.6%
add-log-exp4.6%
pow-to-exp4.6%
un-div-inv4.6%
+-commutative4.6%
log1p-define4.6%
Applied egg-rr4.6%
Taylor expanded in x around inf 86.1%
Simplified86.1%
Taylor expanded in n around inf 86.1%
associate-/r*86.1%
Simplified86.1%
Taylor expanded in n around inf 86.1%
if 1.99999999999999991e-6 < (/.f64 1 n) Initial program 67.2%
Taylor expanded in x around 0 66.7%
expm1-log1p-u66.7%
expm1-undefine66.7%
Applied egg-rr66.7%
sub-neg66.7%
log1p-undefine66.7%
rem-exp-log66.7%
associate-+r+66.8%
metadata-eval66.8%
metadata-eval66.8%
Simplified66.8%
Final simplification85.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n)))
(t_1 (- 1.0 t_0))
(t_2 (- (+ 1.0 (/ x n)) t_0))
(t_3 (/ (log x) (- n))))
(if (<= x 4.2e-287)
t_1
(if (<= x 2e-224)
t_3
(if (<= x 4.6e-189)
t_1
(if (<= x 7.8e-135)
t_3
(if (<= x 2e-101)
t_2
(if (<= x 6.6e-65)
t_3
(if (<= x 1.4e-50)
t_2
(if (<= x 6.8e-39) t_3 (/ (/ t_0 n) x)))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double t_2 = (1.0 + (x / n)) - t_0;
double t_3 = log(x) / -n;
double tmp;
if (x <= 4.2e-287) {
tmp = t_1;
} else if (x <= 2e-224) {
tmp = t_3;
} else if (x <= 4.6e-189) {
tmp = t_1;
} else if (x <= 7.8e-135) {
tmp = t_3;
} else if (x <= 2e-101) {
tmp = t_2;
} else if (x <= 6.6e-65) {
tmp = t_3;
} else if (x <= 1.4e-50) {
tmp = t_2;
} else if (x <= 6.8e-39) {
tmp = t_3;
} else {
tmp = (t_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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = 1.0d0 - t_0
t_2 = (1.0d0 + (x / n)) - t_0
t_3 = log(x) / -n
if (x <= 4.2d-287) then
tmp = t_1
else if (x <= 2d-224) then
tmp = t_3
else if (x <= 4.6d-189) then
tmp = t_1
else if (x <= 7.8d-135) then
tmp = t_3
else if (x <= 2d-101) then
tmp = t_2
else if (x <= 6.6d-65) then
tmp = t_3
else if (x <= 1.4d-50) then
tmp = t_2
else if (x <= 6.8d-39) then
tmp = t_3
else
tmp = (t_0 / 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 = 1.0 - t_0;
double t_2 = (1.0 + (x / n)) - t_0;
double t_3 = Math.log(x) / -n;
double tmp;
if (x <= 4.2e-287) {
tmp = t_1;
} else if (x <= 2e-224) {
tmp = t_3;
} else if (x <= 4.6e-189) {
tmp = t_1;
} else if (x <= 7.8e-135) {
tmp = t_3;
} else if (x <= 2e-101) {
tmp = t_2;
} else if (x <= 6.6e-65) {
tmp = t_3;
} else if (x <= 1.4e-50) {
tmp = t_2;
} else if (x <= 6.8e-39) {
tmp = t_3;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 - t_0 t_2 = (1.0 + (x / n)) - t_0 t_3 = math.log(x) / -n tmp = 0 if x <= 4.2e-287: tmp = t_1 elif x <= 2e-224: tmp = t_3 elif x <= 4.6e-189: tmp = t_1 elif x <= 7.8e-135: tmp = t_3 elif x <= 2e-101: tmp = t_2 elif x <= 6.6e-65: tmp = t_3 elif x <= 1.4e-50: tmp = t_2 elif x <= 6.8e-39: tmp = t_3 else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 - t_0) t_2 = Float64(Float64(1.0 + Float64(x / n)) - t_0) t_3 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 4.2e-287) tmp = t_1; elseif (x <= 2e-224) tmp = t_3; elseif (x <= 4.6e-189) tmp = t_1; elseif (x <= 7.8e-135) tmp = t_3; elseif (x <= 2e-101) tmp = t_2; elseif (x <= 6.6e-65) tmp = t_3; elseif (x <= 1.4e-50) tmp = t_2; elseif (x <= 6.8e-39) tmp = t_3; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = 1.0 - t_0; t_2 = (1.0 + (x / n)) - t_0; t_3 = log(x) / -n; tmp = 0.0; if (x <= 4.2e-287) tmp = t_1; elseif (x <= 2e-224) tmp = t_3; elseif (x <= 4.6e-189) tmp = t_1; elseif (x <= 7.8e-135) tmp = t_3; elseif (x <= 2e-101) tmp = t_2; elseif (x <= 6.6e-65) tmp = t_3; elseif (x <= 1.4e-50) tmp = t_2; elseif (x <= 6.8e-39) tmp = t_3; else tmp = (t_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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 4.2e-287], t$95$1, If[LessEqual[x, 2e-224], t$95$3, If[LessEqual[x, 4.6e-189], t$95$1, If[LessEqual[x, 7.8e-135], t$95$3, If[LessEqual[x, 2e-101], t$95$2, If[LessEqual[x, 6.6e-65], t$95$3, If[LessEqual[x, 1.4e-50], t$95$2, If[LessEqual[x, 6.8e-39], t$95$3, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := 1 - t\_0\\
t_2 := \left(1 + \frac{x}{n}\right) - t\_0\\
t_3 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 4.2 \cdot 10^{-287}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-224}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{-189}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-135}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-101}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{-65}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-50}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-39}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 4.1999999999999998e-287 or 2e-224 < x < 4.5999999999999996e-189Initial program 72.4%
Taylor expanded in x around 0 72.4%
*-rgt-identity72.4%
associate-*l/72.4%
associate-/l*72.4%
exp-to-pow72.4%
Simplified72.4%
if 4.1999999999999998e-287 < x < 2e-224 or 4.5999999999999996e-189 < x < 7.80000000000000043e-135 or 2.0000000000000001e-101 < x < 6.6000000000000002e-65 or 1.3999999999999999e-50 < x < 6.7999999999999998e-39Initial program 33.3%
Taylor expanded in x around 0 33.3%
*-rgt-identity33.3%
associate-*l/33.3%
associate-/l*33.3%
exp-to-pow33.3%
Simplified33.3%
Taylor expanded in n around inf 66.8%
mul-1-neg66.8%
distribute-frac-neg66.8%
Simplified66.8%
if 7.80000000000000043e-135 < x < 2.0000000000000001e-101 or 6.6000000000000002e-65 < x < 1.3999999999999999e-50Initial program 63.4%
Taylor expanded in x around 0 65.8%
if 6.7999999999999998e-39 < x Initial program 68.3%
Taylor expanded in x around inf 94.4%
associate-/r*95.6%
mul-1-neg95.6%
log-rec95.6%
mul-1-neg95.6%
distribute-neg-frac95.6%
mul-1-neg95.6%
remove-double-neg95.6%
*-rgt-identity95.6%
associate-/l*95.6%
exp-to-pow95.6%
Simplified95.6%
Final simplification79.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- 1.0 t_0)) (t_2 (/ (log x) (- n))))
(if (<= x 8.2e-287)
t_1
(if (<= x 1.9e-224)
t_2
(if (<= x 2.7e-189)
t_1
(if (<= x 6.2e-134)
t_2
(if (<= x 2.1e-101)
(- (+ 1.0 (/ x n)) t_0)
(if (<= x 6.6e-65)
t_2
(if (<= x 1.4e-50)
(- (+ (+ 2.0 (/ x n)) -1.0) t_0)
(if (<= x 3.3e-36) t_2 (/ (/ t_0 n) x)))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double t_2 = log(x) / -n;
double tmp;
if (x <= 8.2e-287) {
tmp = t_1;
} else if (x <= 1.9e-224) {
tmp = t_2;
} else if (x <= 2.7e-189) {
tmp = t_1;
} else if (x <= 6.2e-134) {
tmp = t_2;
} else if (x <= 2.1e-101) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 6.6e-65) {
tmp = t_2;
} else if (x <= 1.4e-50) {
tmp = ((2.0 + (x / n)) + -1.0) - t_0;
} else if (x <= 3.3e-36) {
tmp = t_2;
} else {
tmp = (t_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) :: t_2
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = 1.0d0 - t_0
t_2 = log(x) / -n
if (x <= 8.2d-287) then
tmp = t_1
else if (x <= 1.9d-224) then
tmp = t_2
else if (x <= 2.7d-189) then
tmp = t_1
else if (x <= 6.2d-134) then
tmp = t_2
else if (x <= 2.1d-101) then
tmp = (1.0d0 + (x / n)) - t_0
else if (x <= 6.6d-65) then
tmp = t_2
else if (x <= 1.4d-50) then
tmp = ((2.0d0 + (x / n)) + (-1.0d0)) - t_0
else if (x <= 3.3d-36) then
tmp = t_2
else
tmp = (t_0 / 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 = 1.0 - t_0;
double t_2 = Math.log(x) / -n;
double tmp;
if (x <= 8.2e-287) {
tmp = t_1;
} else if (x <= 1.9e-224) {
tmp = t_2;
} else if (x <= 2.7e-189) {
tmp = t_1;
} else if (x <= 6.2e-134) {
tmp = t_2;
} else if (x <= 2.1e-101) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 6.6e-65) {
tmp = t_2;
} else if (x <= 1.4e-50) {
tmp = ((2.0 + (x / n)) + -1.0) - t_0;
} else if (x <= 3.3e-36) {
tmp = t_2;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 - t_0 t_2 = math.log(x) / -n tmp = 0 if x <= 8.2e-287: tmp = t_1 elif x <= 1.9e-224: tmp = t_2 elif x <= 2.7e-189: tmp = t_1 elif x <= 6.2e-134: tmp = t_2 elif x <= 2.1e-101: tmp = (1.0 + (x / n)) - t_0 elif x <= 6.6e-65: tmp = t_2 elif x <= 1.4e-50: tmp = ((2.0 + (x / n)) + -1.0) - t_0 elif x <= 3.3e-36: tmp = t_2 else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 - t_0) t_2 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 8.2e-287) tmp = t_1; elseif (x <= 1.9e-224) tmp = t_2; elseif (x <= 2.7e-189) tmp = t_1; elseif (x <= 6.2e-134) tmp = t_2; elseif (x <= 2.1e-101) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif (x <= 6.6e-65) tmp = t_2; elseif (x <= 1.4e-50) tmp = Float64(Float64(Float64(2.0 + Float64(x / n)) + -1.0) - t_0); elseif (x <= 3.3e-36) tmp = t_2; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = 1.0 - t_0; t_2 = log(x) / -n; tmp = 0.0; if (x <= 8.2e-287) tmp = t_1; elseif (x <= 1.9e-224) tmp = t_2; elseif (x <= 2.7e-189) tmp = t_1; elseif (x <= 6.2e-134) tmp = t_2; elseif (x <= 2.1e-101) tmp = (1.0 + (x / n)) - t_0; elseif (x <= 6.6e-65) tmp = t_2; elseif (x <= 1.4e-50) tmp = ((2.0 + (x / n)) + -1.0) - t_0; elseif (x <= 3.3e-36) tmp = t_2; else tmp = (t_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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 8.2e-287], t$95$1, If[LessEqual[x, 1.9e-224], t$95$2, If[LessEqual[x, 2.7e-189], t$95$1, If[LessEqual[x, 6.2e-134], t$95$2, If[LessEqual[x, 2.1e-101], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 6.6e-65], t$95$2, If[LessEqual[x, 1.4e-50], N[(N[(N[(2.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 3.3e-36], t$95$2, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := 1 - t\_0\\
t_2 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 8.2 \cdot 10^{-287}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-224}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-189}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-134}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-101}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{-65}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-50}:\\
\;\;\;\;\left(\left(2 + \frac{x}{n}\right) + -1\right) - t\_0\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-36}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 8.2000000000000004e-287 or 1.90000000000000001e-224 < x < 2.6999999999999999e-189Initial program 72.4%
Taylor expanded in x around 0 72.4%
*-rgt-identity72.4%
associate-*l/72.4%
associate-/l*72.4%
exp-to-pow72.4%
Simplified72.4%
if 8.2000000000000004e-287 < x < 1.90000000000000001e-224 or 2.6999999999999999e-189 < x < 6.20000000000000012e-134 or 2.10000000000000016e-101 < x < 6.6000000000000002e-65 or 1.3999999999999999e-50 < x < 3.29999999999999991e-36Initial program 33.3%
Taylor expanded in x around 0 33.3%
*-rgt-identity33.3%
associate-*l/33.3%
associate-/l*33.3%
exp-to-pow33.3%
Simplified33.3%
Taylor expanded in n around inf 66.8%
mul-1-neg66.8%
distribute-frac-neg66.8%
Simplified66.8%
if 6.20000000000000012e-134 < x < 2.10000000000000016e-101Initial program 64.2%
Taylor expanded in x around 0 66.2%
if 6.6000000000000002e-65 < x < 1.3999999999999999e-50Initial program 62.5%
Taylor expanded in x around 0 65.3%
expm1-log1p-u29.5%
expm1-undefine29.5%
Applied egg-rr29.5%
sub-neg29.5%
log1p-undefine29.5%
rem-exp-log65.2%
associate-+r+65.4%
metadata-eval65.4%
metadata-eval65.4%
Simplified65.4%
if 3.29999999999999991e-36 < x Initial program 68.3%
Taylor expanded in x around inf 94.4%
associate-/r*95.6%
mul-1-neg95.6%
log-rec95.6%
mul-1-neg95.6%
distribute-neg-frac95.6%
mul-1-neg95.6%
remove-double-neg95.6%
*-rgt-identity95.6%
associate-/l*95.6%
exp-to-pow95.6%
Simplified95.6%
Final simplification79.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log x) (- n))))
(if (<= x 7.5e-286)
t_0
(if (<= x 2e-224)
t_1
(if (<= x 4.6e-188)
t_0
(if (<= x 9e-135)
t_1
(if (<= x 7.5e-108)
t_0
(if (<= x 2.55e-69)
t_1
(if (<= x 0.9)
t_0
(if (<= x 1.18e+128)
(/ (+ (/ 1.0 n) (/ (/ -0.5 n) x)) x)
0.0))))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(x) / -n;
double tmp;
if (x <= 7.5e-286) {
tmp = t_0;
} else if (x <= 2e-224) {
tmp = t_1;
} else if (x <= 4.6e-188) {
tmp = t_0;
} else if (x <= 9e-135) {
tmp = t_1;
} else if (x <= 7.5e-108) {
tmp = t_0;
} else if (x <= 2.55e-69) {
tmp = t_1;
} else if (x <= 0.9) {
tmp = t_0;
} else if (x <= 1.18e+128) {
tmp = ((1.0 / n) + ((-0.5 / n) / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(x) / -n
if (x <= 7.5d-286) then
tmp = t_0
else if (x <= 2d-224) then
tmp = t_1
else if (x <= 4.6d-188) then
tmp = t_0
else if (x <= 9d-135) then
tmp = t_1
else if (x <= 7.5d-108) then
tmp = t_0
else if (x <= 2.55d-69) then
tmp = t_1
else if (x <= 0.9d0) then
tmp = t_0
else if (x <= 1.18d+128) then
tmp = ((1.0d0 / n) + (((-0.5d0) / n) / x)) / x
else
tmp = 0.0d0
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(x) / -n;
double tmp;
if (x <= 7.5e-286) {
tmp = t_0;
} else if (x <= 2e-224) {
tmp = t_1;
} else if (x <= 4.6e-188) {
tmp = t_0;
} else if (x <= 9e-135) {
tmp = t_1;
} else if (x <= 7.5e-108) {
tmp = t_0;
} else if (x <= 2.55e-69) {
tmp = t_1;
} else if (x <= 0.9) {
tmp = t_0;
} else if (x <= 1.18e+128) {
tmp = ((1.0 / n) + ((-0.5 / n) / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(x) / -n tmp = 0 if x <= 7.5e-286: tmp = t_0 elif x <= 2e-224: tmp = t_1 elif x <= 4.6e-188: tmp = t_0 elif x <= 9e-135: tmp = t_1 elif x <= 7.5e-108: tmp = t_0 elif x <= 2.55e-69: tmp = t_1 elif x <= 0.9: tmp = t_0 elif x <= 1.18e+128: tmp = ((1.0 / n) + ((-0.5 / n) / x)) / x else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 7.5e-286) tmp = t_0; elseif (x <= 2e-224) tmp = t_1; elseif (x <= 4.6e-188) tmp = t_0; elseif (x <= 9e-135) tmp = t_1; elseif (x <= 7.5e-108) tmp = t_0; elseif (x <= 2.55e-69) tmp = t_1; elseif (x <= 0.9) tmp = t_0; elseif (x <= 1.18e+128) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(-0.5 / n) / x)) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(x) / -n; tmp = 0.0; if (x <= 7.5e-286) tmp = t_0; elseif (x <= 2e-224) tmp = t_1; elseif (x <= 4.6e-188) tmp = t_0; elseif (x <= 9e-135) tmp = t_1; elseif (x <= 7.5e-108) tmp = t_0; elseif (x <= 2.55e-69) tmp = t_1; elseif (x <= 0.9) tmp = t_0; elseif (x <= 1.18e+128) tmp = ((1.0 / n) + ((-0.5 / n) / x)) / x; else tmp = 0.0; 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[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 7.5e-286], t$95$0, If[LessEqual[x, 2e-224], t$95$1, If[LessEqual[x, 4.6e-188], t$95$0, If[LessEqual[x, 9e-135], t$95$1, If[LessEqual[x, 7.5e-108], t$95$0, If[LessEqual[x, 2.55e-69], t$95$1, If[LessEqual[x, 0.9], t$95$0, If[LessEqual[x, 1.18e+128], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(-0.5 / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 7.5 \cdot 10^{-286}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-224}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{-188}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-108}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-69}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.18 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{-0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 7.50000000000000009e-286 or 2e-224 < x < 4.6e-188 or 8.99999999999999975e-135 < x < 7.4999999999999993e-108 or 2.54999999999999993e-69 < x < 0.900000000000000022Initial program 65.6%
Taylor expanded in x around 0 64.2%
*-rgt-identity64.2%
associate-*l/64.2%
associate-/l*64.2%
exp-to-pow64.2%
Simplified64.2%
if 7.50000000000000009e-286 < x < 2e-224 or 4.6e-188 < x < 8.99999999999999975e-135 or 7.4999999999999993e-108 < x < 2.54999999999999993e-69Initial program 34.6%
Taylor expanded in x around 0 34.6%
*-rgt-identity34.6%
associate-*l/34.6%
associate-/l*34.6%
exp-to-pow34.6%
Simplified34.6%
Taylor expanded in n around inf 66.2%
mul-1-neg66.2%
distribute-frac-neg66.2%
Simplified66.2%
if 0.900000000000000022 < x < 1.18000000000000009e128Initial program 46.4%
add-log-exp46.4%
pow-to-exp46.4%
un-div-inv46.4%
+-commutative46.4%
log1p-define46.4%
Applied egg-rr46.4%
Taylor expanded in x around inf 82.7%
Simplified82.7%
Taylor expanded in n around inf 66.4%
associate-/r*66.4%
Simplified66.4%
Taylor expanded in n around inf 65.0%
if 1.18000000000000009e128 < x Initial program 89.1%
sub-neg89.1%
+-commutative89.1%
sqr-pow89.1%
distribute-rgt-neg-in89.1%
fma-define89.1%
sqrt-pow189.1%
sqrt-pow189.1%
pow-to-exp89.1%
un-div-inv89.1%
+-commutative89.1%
log1p-define89.1%
Applied egg-rr89.1%
Taylor expanded in x around inf 89.1%
distribute-rgt1-in89.1%
metadata-eval89.1%
mul0-lft89.1%
Simplified89.1%
Final simplification69.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- 1.0 t_0)) (t_2 (/ (log x) (- n))))
(if (<= x 1.55e-286)
t_1
(if (<= x 1.95e-224)
t_2
(if (<= x 3.3e-189)
t_1
(if (<= x 2e-134)
t_2
(if (<= x 6.3e-108)
t_1
(if (<= x 7.4e-40) t_2 (/ (/ t_0 n) x)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double t_2 = log(x) / -n;
double tmp;
if (x <= 1.55e-286) {
tmp = t_1;
} else if (x <= 1.95e-224) {
tmp = t_2;
} else if (x <= 3.3e-189) {
tmp = t_1;
} else if (x <= 2e-134) {
tmp = t_2;
} else if (x <= 6.3e-108) {
tmp = t_1;
} else if (x <= 7.4e-40) {
tmp = t_2;
} else {
tmp = (t_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) :: t_2
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = 1.0d0 - t_0
t_2 = log(x) / -n
if (x <= 1.55d-286) then
tmp = t_1
else if (x <= 1.95d-224) then
tmp = t_2
else if (x <= 3.3d-189) then
tmp = t_1
else if (x <= 2d-134) then
tmp = t_2
else if (x <= 6.3d-108) then
tmp = t_1
else if (x <= 7.4d-40) then
tmp = t_2
else
tmp = (t_0 / 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 = 1.0 - t_0;
double t_2 = Math.log(x) / -n;
double tmp;
if (x <= 1.55e-286) {
tmp = t_1;
} else if (x <= 1.95e-224) {
tmp = t_2;
} else if (x <= 3.3e-189) {
tmp = t_1;
} else if (x <= 2e-134) {
tmp = t_2;
} else if (x <= 6.3e-108) {
tmp = t_1;
} else if (x <= 7.4e-40) {
tmp = t_2;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 - t_0 t_2 = math.log(x) / -n tmp = 0 if x <= 1.55e-286: tmp = t_1 elif x <= 1.95e-224: tmp = t_2 elif x <= 3.3e-189: tmp = t_1 elif x <= 2e-134: tmp = t_2 elif x <= 6.3e-108: tmp = t_1 elif x <= 7.4e-40: tmp = t_2 else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 - t_0) t_2 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.55e-286) tmp = t_1; elseif (x <= 1.95e-224) tmp = t_2; elseif (x <= 3.3e-189) tmp = t_1; elseif (x <= 2e-134) tmp = t_2; elseif (x <= 6.3e-108) tmp = t_1; elseif (x <= 7.4e-40) tmp = t_2; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = 1.0 - t_0; t_2 = log(x) / -n; tmp = 0.0; if (x <= 1.55e-286) tmp = t_1; elseif (x <= 1.95e-224) tmp = t_2; elseif (x <= 3.3e-189) tmp = t_1; elseif (x <= 2e-134) tmp = t_2; elseif (x <= 6.3e-108) tmp = t_1; elseif (x <= 7.4e-40) tmp = t_2; else tmp = (t_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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.55e-286], t$95$1, If[LessEqual[x, 1.95e-224], t$95$2, If[LessEqual[x, 3.3e-189], t$95$1, If[LessEqual[x, 2e-134], t$95$2, If[LessEqual[x, 6.3e-108], t$95$1, If[LessEqual[x, 7.4e-40], t$95$2, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := 1 - t\_0\\
t_2 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.55 \cdot 10^{-286}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{-224}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-189}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-134}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 6.3 \cdot 10^{-108}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{-40}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.54999999999999991e-286 or 1.9499999999999999e-224 < x < 3.3000000000000001e-189 or 2.00000000000000008e-134 < x < 6.2999999999999997e-108Initial program 70.9%
Taylor expanded in x around 0 70.9%
*-rgt-identity70.9%
associate-*l/70.9%
associate-/l*70.8%
exp-to-pow70.9%
Simplified70.9%
if 1.54999999999999991e-286 < x < 1.9499999999999999e-224 or 3.3000000000000001e-189 < x < 2.00000000000000008e-134 or 6.2999999999999997e-108 < x < 7.39999999999999997e-40Initial program 37.9%
Taylor expanded in x around 0 37.9%
*-rgt-identity37.9%
associate-*l/37.9%
associate-/l*37.9%
exp-to-pow37.9%
Simplified37.9%
Taylor expanded in n around inf 61.8%
mul-1-neg61.8%
distribute-frac-neg61.8%
Simplified61.8%
if 7.39999999999999997e-40 < x Initial program 68.3%
Taylor expanded in x around inf 94.4%
associate-/r*95.6%
mul-1-neg95.6%
log-rec95.6%
mul-1-neg95.6%
distribute-neg-frac95.6%
mul-1-neg95.6%
remove-double-neg95.6%
*-rgt-identity95.6%
associate-/l*95.6%
exp-to-pow95.6%
Simplified95.6%
Final simplification77.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.9e-224)
t_0
(if (<= x 7.2e-211)
(/ 1.0 (* x n))
(if (<= x 4.9e-36) t_0 (if (<= x 8.5e+126) (/ (/ 1.0 x) n) 0.0))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.9e-224) {
tmp = t_0;
} else if (x <= 7.2e-211) {
tmp = 1.0 / (x * n);
} else if (x <= 4.9e-36) {
tmp = t_0;
} else if (x <= 8.5e+126) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 1.9d-224) then
tmp = t_0
else if (x <= 7.2d-211) then
tmp = 1.0d0 / (x * n)
else if (x <= 4.9d-36) then
tmp = t_0
else if (x <= 8.5d+126) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 1.9e-224) {
tmp = t_0;
} else if (x <= 7.2e-211) {
tmp = 1.0 / (x * n);
} else if (x <= 4.9e-36) {
tmp = t_0;
} else if (x <= 8.5e+126) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.9e-224: tmp = t_0 elif x <= 7.2e-211: tmp = 1.0 / (x * n) elif x <= 4.9e-36: tmp = t_0 elif x <= 8.5e+126: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.9e-224) tmp = t_0; elseif (x <= 7.2e-211) tmp = Float64(1.0 / Float64(x * n)); elseif (x <= 4.9e-36) tmp = t_0; elseif (x <= 8.5e+126) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.9e-224) tmp = t_0; elseif (x <= 7.2e-211) tmp = 1.0 / (x * n); elseif (x <= 4.9e-36) tmp = t_0; elseif (x <= 8.5e+126) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.9e-224], t$95$0, If[LessEqual[x, 7.2e-211], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.9e-36], t$95$0, If[LessEqual[x, 8.5e+126], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.9 \cdot 10^{-224}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-211}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+126}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.90000000000000001e-224 or 7.1999999999999998e-211 < x < 4.8999999999999997e-36Initial program 45.4%
Taylor expanded in x around 0 45.4%
*-rgt-identity45.4%
associate-*l/45.4%
associate-/l*45.3%
exp-to-pow45.4%
Simplified45.4%
Taylor expanded in n around inf 55.5%
mul-1-neg55.5%
distribute-frac-neg55.5%
Simplified55.5%
if 1.90000000000000001e-224 < x < 7.1999999999999998e-211Initial program 88.2%
Taylor expanded in x around inf 75.5%
mul-1-neg75.5%
log-rec75.5%
mul-1-neg75.5%
distribute-neg-frac75.5%
mul-1-neg75.5%
remove-double-neg75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in n around inf 75.9%
if 4.8999999999999997e-36 < x < 8.49999999999999944e126Initial program 50.3%
Taylor expanded in x around inf 90.9%
mul-1-neg90.9%
log-rec90.9%
mul-1-neg90.9%
distribute-neg-frac90.9%
mul-1-neg90.9%
remove-double-neg90.9%
*-commutative90.9%
Simplified90.9%
Taylor expanded in n around inf 58.2%
*-commutative58.2%
associate-/r*59.2%
Simplified59.2%
if 8.49999999999999944e126 < x Initial program 89.1%
sub-neg89.1%
+-commutative89.1%
sqr-pow89.1%
distribute-rgt-neg-in89.1%
fma-define89.1%
sqrt-pow189.1%
sqrt-pow189.1%
pow-to-exp89.1%
un-div-inv89.1%
+-commutative89.1%
log1p-define89.1%
Applied egg-rr89.1%
Taylor expanded in x around inf 89.1%
distribute-rgt1-in89.1%
metadata-eval89.1%
mul0-lft89.1%
Simplified89.1%
Final simplification63.5%
(FPCore (x n) :precision binary64 (if (<= x 5.2e+127) (/ 1.0 (* x n)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 5.2e+127) {
tmp = 1.0 / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 5.2d+127) then
tmp = 1.0d0 / (x * n)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 5.2e+127) {
tmp = 1.0 / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5.2e+127: tmp = 1.0 / (x * n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 5.2e+127) tmp = Float64(1.0 / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5.2e+127) tmp = 1.0 / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5.2e+127], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.2 \cdot 10^{+127}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 5.2000000000000004e127Initial program 48.4%
Taylor expanded in x around inf 49.4%
mul-1-neg49.4%
log-rec49.4%
mul-1-neg49.4%
distribute-neg-frac49.4%
mul-1-neg49.4%
remove-double-neg49.4%
*-commutative49.4%
Simplified49.4%
Taylor expanded in n around inf 35.2%
if 5.2000000000000004e127 < x Initial program 89.1%
sub-neg89.1%
+-commutative89.1%
sqr-pow89.1%
distribute-rgt-neg-in89.1%
fma-define89.1%
sqrt-pow189.1%
sqrt-pow189.1%
pow-to-exp89.1%
un-div-inv89.1%
+-commutative89.1%
log1p-define89.1%
Applied egg-rr89.1%
Taylor expanded in x around inf 89.1%
distribute-rgt1-in89.1%
metadata-eval89.1%
mul0-lft89.1%
Simplified89.1%
Final simplification45.7%
(FPCore (x n) :precision binary64 (if (<= x 1.8e+128) (/ (/ 1.0 x) n) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.8e+128) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.8d+128) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.8e+128) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.8e+128: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.8e+128) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.8e+128) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.8e+128], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.80000000000000014e128Initial program 48.4%
Taylor expanded in x around inf 49.4%
mul-1-neg49.4%
log-rec49.4%
mul-1-neg49.4%
distribute-neg-frac49.4%
mul-1-neg49.4%
remove-double-neg49.4%
*-commutative49.4%
Simplified49.4%
Taylor expanded in n around inf 35.2%
*-commutative35.2%
associate-/r*35.5%
Simplified35.5%
if 1.80000000000000014e128 < x Initial program 89.1%
sub-neg89.1%
+-commutative89.1%
sqr-pow89.1%
distribute-rgt-neg-in89.1%
fma-define89.1%
sqrt-pow189.1%
sqrt-pow189.1%
pow-to-exp89.1%
un-div-inv89.1%
+-commutative89.1%
log1p-define89.1%
Applied egg-rr89.1%
Taylor expanded in x around inf 89.1%
distribute-rgt1-in89.1%
metadata-eval89.1%
mul0-lft89.1%
Simplified89.1%
Final simplification45.9%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 56.4%
sub-neg56.4%
+-commutative56.4%
sqr-pow56.3%
distribute-rgt-neg-in56.3%
fma-define56.3%
sqrt-pow156.4%
sqrt-pow156.3%
pow-to-exp56.3%
un-div-inv56.3%
+-commutative56.3%
log1p-define60.0%
Applied egg-rr60.0%
Taylor expanded in x around inf 28.6%
distribute-rgt1-in28.6%
metadata-eval28.6%
mul0-lft28.9%
Simplified28.9%
Final simplification28.9%
herbie shell --seed 2024096
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))