
(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 11 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) -1e-79)
(/ (/ (cbrt (pow x (/ 3.0 n))) n) x)
(if (<= (/ 1.0 n) -5e-94)
(/ (- (log x)) n)
(if (<= (/ 1.0 n) -5e-129)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e-139)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 100.0)
(/ (/ (exp (/ (log x) n)) n) x)
(- (exp (/ x n)) (pow x (/ 1.0 n)))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-79) {
tmp = (cbrt(pow(x, (3.0 / n))) / n) / x;
} else if ((1.0 / n) <= -5e-94) {
tmp = -log(x) / n;
} else if ((1.0 / n) <= -5e-129) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-139) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 100.0) {
tmp = (exp((log(x) / n)) / n) / x;
} 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) <= -1e-79) {
tmp = (Math.cbrt(Math.pow(x, (3.0 / n))) / n) / x;
} else if ((1.0 / n) <= -5e-94) {
tmp = -Math.log(x) / n;
} else if ((1.0 / n) <= -5e-129) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-139) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 100.0) {
tmp = (Math.exp((Math.log(x) / n)) / n) / x;
} 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) <= -1e-79) tmp = Float64(Float64(cbrt((x ^ Float64(3.0 / n))) / n) / x); elseif (Float64(1.0 / n) <= -5e-94) tmp = Float64(Float64(-log(x)) / n); elseif (Float64(1.0 / n) <= -5e-129) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e-139) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 100.0) tmp = Float64(Float64(exp(Float64(log(x) / n)) / n) / x); 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], -1e-79], N[(N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-94], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-129], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-139], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100.0], N[(N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $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 -1 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-94}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-129}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-139}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 100:\\
\;\;\;\;\frac{\frac{e^{\frac{\log x}{n}}}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-79Initial program 80.6%
Taylor expanded in x around inf 92.1%
mul-1-neg92.1%
log-rec92.1%
mul-1-neg92.1%
distribute-neg-frac92.1%
mul-1-neg92.1%
remove-double-neg92.1%
*-commutative92.1%
Simplified92.1%
add-cube-cbrt91.9%
pow391.9%
associate-/r*93.0%
div-inv93.0%
pow-to-exp93.0%
pow193.0%
pow-div93.0%
Applied egg-rr93.0%
rem-cube-cbrt93.1%
pow-sub93.3%
pow193.3%
associate-/l/92.1%
associate-/r*93.3%
Applied egg-rr93.3%
add-cbrt-cube93.3%
pow393.3%
pow-pow93.3%
Applied egg-rr93.3%
associate-*l/93.3%
metadata-eval93.3%
Simplified93.3%
if -1e-79 < (/.f64 1 n) < -4.9999999999999995e-94Initial program 3.8%
Taylor expanded in x around 0 3.8%
Taylor expanded in n around inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -4.9999999999999995e-94 < (/.f64 1 n) < -5.00000000000000027e-129Initial program 15.7%
Taylor expanded in x around inf 69.6%
mul-1-neg69.6%
log-rec69.6%
mul-1-neg69.6%
distribute-neg-frac69.6%
mul-1-neg69.6%
remove-double-neg69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in n around inf 69.6%
*-commutative69.6%
associate-/r*73.2%
Simplified73.2%
if -5.00000000000000027e-129 < (/.f64 1 n) < 5.00000000000000034e-139Initial program 30.8%
Taylor expanded in n around inf 86.8%
+-rgt-identity86.8%
+-rgt-identity86.8%
log1p-def86.8%
Simplified86.8%
if 5.00000000000000034e-139 < (/.f64 1 n) < 100Initial program 30.4%
Taylor expanded in x around inf 64.9%
mul-1-neg64.9%
log-rec64.9%
mul-1-neg64.9%
distribute-neg-frac64.9%
mul-1-neg64.9%
remove-double-neg64.9%
*-commutative64.9%
Simplified64.9%
add-cube-cbrt64.2%
pow364.3%
associate-/r*68.6%
div-inv68.6%
pow-to-exp68.6%
pow168.6%
pow-div68.4%
Applied egg-rr68.4%
rem-cube-cbrt68.9%
pow-sub69.2%
pow169.2%
associate-/l/64.9%
associate-/r*69.2%
Applied egg-rr69.2%
pow169.2%
pow-to-exp69.3%
pow-exp69.3%
un-div-inv69.3%
Applied egg-rr69.3%
if 100 < (/.f64 1 n) Initial program 50.6%
Taylor expanded in n around 0 50.6%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -1e-79)
t_1
(if (<= (/ 1.0 n) -5e-94)
(/ (- (log x)) n)
(if (<= (/ 1.0 n) -5e-129)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e-139)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 100.0)
t_1
(if (<= (/ 1.0 n) 5e+179)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1e-79) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-94) {
tmp = -log(x) / n;
} else if ((1.0 / n) <= -5e-129) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-139) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 100.0) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+179) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1e-79) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-94) {
tmp = -Math.log(x) / n;
} else if ((1.0 / n) <= -5e-129) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-139) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 100.0) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+179) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -1e-79: tmp = t_1 elif (1.0 / n) <= -5e-94: tmp = -math.log(x) / n elif (1.0 / n) <= -5e-129: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e-139: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 100.0: tmp = t_1 elif (1.0 / n) <= 5e+179: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1e-79) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-94) tmp = Float64(Float64(-log(x)) / n); elseif (Float64(1.0 / n) <= -5e-129) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e-139) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 100.0) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+179) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.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[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-79], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-94], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-129], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-139], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+179], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{t_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-79}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-94}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-129}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-139}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 100:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+179}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-79 or 5.00000000000000034e-139 < (/.f64 1 n) < 100Initial program 67.7%
Taylor expanded in x around inf 85.2%
mul-1-neg85.2%
log-rec85.2%
mul-1-neg85.2%
distribute-neg-frac85.2%
mul-1-neg85.2%
remove-double-neg85.2%
*-commutative85.2%
Simplified85.2%
add-cube-cbrt84.8%
pow384.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
rem-cube-cbrt86.9%
pow-sub87.1%
pow187.1%
associate-/l/85.2%
associate-/r*87.1%
Applied egg-rr87.1%
if -1e-79 < (/.f64 1 n) < -4.9999999999999995e-94Initial program 3.8%
Taylor expanded in x around 0 3.8%
Taylor expanded in n around inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -4.9999999999999995e-94 < (/.f64 1 n) < -5.00000000000000027e-129Initial program 15.7%
Taylor expanded in x around inf 69.6%
mul-1-neg69.6%
log-rec69.6%
mul-1-neg69.6%
distribute-neg-frac69.6%
mul-1-neg69.6%
remove-double-neg69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in n around inf 69.6%
*-commutative69.6%
associate-/r*73.2%
Simplified73.2%
if -5.00000000000000027e-129 < (/.f64 1 n) < 5.00000000000000034e-139Initial program 30.8%
Taylor expanded in n around inf 86.8%
+-rgt-identity86.8%
+-rgt-identity86.8%
log1p-def86.8%
Simplified86.8%
if 100 < (/.f64 1 n) < 5e179Initial program 73.8%
Taylor expanded in x around 0 64.3%
if 5e179 < (/.f64 1 n) Initial program 22.5%
Taylor expanded in x around inf 0.7%
mul-1-neg0.7%
log-rec0.7%
mul-1-neg0.7%
distribute-neg-frac0.7%
mul-1-neg0.7%
remove-double-neg0.7%
*-commutative0.7%
Simplified0.7%
Taylor expanded in n around inf 60.2%
add-sqr-sqrt60.2%
sqrt-unprod93.1%
inv-pow93.1%
inv-pow93.1%
pow-prod-up93.1%
metadata-eval93.1%
Applied egg-rr93.1%
Final simplification85.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -1e-79)
t_1
(if (<= (/ 1.0 n) -5e-94)
(/ (- (log x)) n)
(if (<= (/ 1.0 n) -5e-129)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e-139)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 100.0) t_1 (- (exp (/ x n)) t_0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1e-79) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-94) {
tmp = -log(x) / n;
} else if ((1.0 / n) <= -5e-129) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-139) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 100.0) {
tmp = t_1;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1e-79) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-94) {
tmp = -Math.log(x) / n;
} else if ((1.0 / n) <= -5e-129) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-139) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 100.0) {
tmp = t_1;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -1e-79: tmp = t_1 elif (1.0 / n) <= -5e-94: tmp = -math.log(x) / n elif (1.0 / n) <= -5e-129: tmp = (1.0 / x) / n elif (1.0 / n) <= 5e-139: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 100.0: tmp = t_1 else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1e-79) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-94) tmp = Float64(Float64(-log(x)) / n); elseif (Float64(1.0 / n) <= -5e-129) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e-139) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 100.0) tmp = t_1; else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-79], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-94], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-129], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-139], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100.0], t$95$1, N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{t_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-79}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-94}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-129}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-139}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 100:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-79 or 5.00000000000000034e-139 < (/.f64 1 n) < 100Initial program 67.7%
Taylor expanded in x around inf 85.2%
mul-1-neg85.2%
log-rec85.2%
mul-1-neg85.2%
distribute-neg-frac85.2%
mul-1-neg85.2%
remove-double-neg85.2%
*-commutative85.2%
Simplified85.2%
add-cube-cbrt84.8%
pow384.8%
associate-/r*86.8%
div-inv86.8%
pow-to-exp86.8%
pow186.8%
pow-div86.7%
Applied egg-rr86.7%
rem-cube-cbrt86.9%
pow-sub87.1%
pow187.1%
associate-/l/85.2%
associate-/r*87.1%
Applied egg-rr87.1%
if -1e-79 < (/.f64 1 n) < -4.9999999999999995e-94Initial program 3.8%
Taylor expanded in x around 0 3.8%
Taylor expanded in n around inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -4.9999999999999995e-94 < (/.f64 1 n) < -5.00000000000000027e-129Initial program 15.7%
Taylor expanded in x around inf 69.6%
mul-1-neg69.6%
log-rec69.6%
mul-1-neg69.6%
distribute-neg-frac69.6%
mul-1-neg69.6%
remove-double-neg69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in n around inf 69.6%
*-commutative69.6%
associate-/r*73.2%
Simplified73.2%
if -5.00000000000000027e-129 < (/.f64 1 n) < 5.00000000000000034e-139Initial program 30.8%
Taylor expanded in n around inf 86.8%
+-rgt-identity86.8%
+-rgt-identity86.8%
log1p-def86.8%
Simplified86.8%
if 100 < (/.f64 1 n) Initial program 50.6%
Taylor expanded in n around 0 50.6%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-79)
(/ (/ (cbrt (pow x (/ 3.0 n))) n) x)
(if (<= (/ 1.0 n) -5e-94)
(/ (- (log x)) n)
(if (<= (/ 1.0 n) -5e-129)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 5e-139)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 100.0)
(/ (/ t_0 n) x)
(- (exp (/ x n)) t_0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-79) {
tmp = (cbrt(pow(x, (3.0 / n))) / n) / x;
} else if ((1.0 / n) <= -5e-94) {
tmp = -log(x) / n;
} else if ((1.0 / n) <= -5e-129) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-139) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 100.0) {
tmp = (t_0 / n) / x;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-79) {
tmp = (Math.cbrt(Math.pow(x, (3.0 / n))) / n) / x;
} else if ((1.0 / n) <= -5e-94) {
tmp = -Math.log(x) / n;
} else if ((1.0 / n) <= -5e-129) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 5e-139) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 100.0) {
tmp = (t_0 / n) / x;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-79) tmp = Float64(Float64(cbrt((x ^ Float64(3.0 / n))) / n) / x); elseif (Float64(1.0 / n) <= -5e-94) tmp = Float64(Float64(-log(x)) / n); elseif (Float64(1.0 / n) <= -5e-129) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 5e-139) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 100.0) tmp = Float64(Float64(t_0 / n) / x); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-79], N[(N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-94], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-129], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-139], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100.0], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-94}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-129}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-139}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 100:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-79Initial program 80.6%
Taylor expanded in x around inf 92.1%
mul-1-neg92.1%
log-rec92.1%
mul-1-neg92.1%
distribute-neg-frac92.1%
mul-1-neg92.1%
remove-double-neg92.1%
*-commutative92.1%
Simplified92.1%
add-cube-cbrt91.9%
pow391.9%
associate-/r*93.0%
div-inv93.0%
pow-to-exp93.0%
pow193.0%
pow-div93.0%
Applied egg-rr93.0%
rem-cube-cbrt93.1%
pow-sub93.3%
pow193.3%
associate-/l/92.1%
associate-/r*93.3%
Applied egg-rr93.3%
add-cbrt-cube93.3%
pow393.3%
pow-pow93.3%
Applied egg-rr93.3%
associate-*l/93.3%
metadata-eval93.3%
Simplified93.3%
if -1e-79 < (/.f64 1 n) < -4.9999999999999995e-94Initial program 3.8%
Taylor expanded in x around 0 3.8%
Taylor expanded in n around inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -4.9999999999999995e-94 < (/.f64 1 n) < -5.00000000000000027e-129Initial program 15.7%
Taylor expanded in x around inf 69.6%
mul-1-neg69.6%
log-rec69.6%
mul-1-neg69.6%
distribute-neg-frac69.6%
mul-1-neg69.6%
remove-double-neg69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in n around inf 69.6%
*-commutative69.6%
associate-/r*73.2%
Simplified73.2%
if -5.00000000000000027e-129 < (/.f64 1 n) < 5.00000000000000034e-139Initial program 30.8%
Taylor expanded in n around inf 86.8%
+-rgt-identity86.8%
+-rgt-identity86.8%
log1p-def86.8%
Simplified86.8%
if 5.00000000000000034e-139 < (/.f64 1 n) < 100Initial program 30.4%
Taylor expanded in x around inf 64.9%
mul-1-neg64.9%
log-rec64.9%
mul-1-neg64.9%
distribute-neg-frac64.9%
mul-1-neg64.9%
remove-double-neg64.9%
*-commutative64.9%
Simplified64.9%
add-cube-cbrt64.2%
pow364.3%
associate-/r*68.6%
div-inv68.6%
pow-to-exp68.6%
pow168.6%
pow-div68.4%
Applied egg-rr68.4%
rem-cube-cbrt68.9%
pow-sub69.2%
pow169.2%
associate-/l/64.9%
associate-/r*69.2%
Applied egg-rr69.2%
if 100 < (/.f64 1 n) Initial program 50.6%
Taylor expanded in n around 0 50.6%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)) (t_1 (pow x (/ 1.0 n))))
(if (<= x 9e-211)
(- (+ 1.0 (/ x n)) t_1)
(if (<= x 7e-124)
t_0
(if (<= x 1.5e-94)
(log1p (expm1 (/ 1.0 (* n x))))
(if (<= x 0.1) t_0 (/ (/ t_1 n) x)))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double t_1 = pow(x, (1.0 / n));
double tmp;
if (x <= 9e-211) {
tmp = (1.0 + (x / n)) - t_1;
} else if (x <= 7e-124) {
tmp = t_0;
} else if (x <= 1.5e-94) {
tmp = log1p(expm1((1.0 / (n * x))));
} else if (x <= 0.1) {
tmp = t_0;
} else {
tmp = (t_1 / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 9e-211) {
tmp = (1.0 + (x / n)) - t_1;
} else if (x <= 7e-124) {
tmp = t_0;
} else if (x <= 1.5e-94) {
tmp = Math.log1p(Math.expm1((1.0 / (n * x))));
} else if (x <= 0.1) {
tmp = t_0;
} else {
tmp = (t_1 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n t_1 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 9e-211: tmp = (1.0 + (x / n)) - t_1 elif x <= 7e-124: tmp = t_0 elif x <= 1.5e-94: tmp = math.log1p(math.expm1((1.0 / (n * x)))) elif x <= 0.1: tmp = t_0 else: tmp = (t_1 / n) / x return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 9e-211) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); elseif (x <= 7e-124) tmp = t_0; elseif (x <= 1.5e-94) tmp = log1p(expm1(Float64(1.0 / Float64(n * x)))); elseif (x <= 0.1) tmp = t_0; else tmp = Float64(Float64(t_1 / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 9e-211], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[x, 7e-124], t$95$0, If[LessEqual[x, 1.5e-94], N[Log[1 + N[(Exp[N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 0.1], t$95$0, N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 9 \cdot 10^{-211}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-124}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-94}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n \cdot x}\right)\right)\\
\mathbf{elif}\;x \leq 0.1:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_1}{n}}{x}\\
\end{array}
\end{array}
if x < 8.9999999999999997e-211Initial program 56.0%
Taylor expanded in x around 0 56.6%
if 8.9999999999999997e-211 < x < 6.9999999999999997e-124 or 1.5000000000000001e-94 < x < 0.10000000000000001Initial program 33.3%
Taylor expanded in x around 0 28.5%
Taylor expanded in n around inf 61.1%
associate-*r/61.1%
mul-1-neg61.1%
Simplified61.1%
if 6.9999999999999997e-124 < x < 1.5000000000000001e-94Initial program 38.4%
Taylor expanded in x around inf 30.8%
mul-1-neg30.8%
log-rec30.8%
mul-1-neg30.8%
distribute-neg-frac30.8%
mul-1-neg30.8%
remove-double-neg30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in n around inf 19.5%
log1p-expm1-u65.8%
Applied egg-rr65.8%
if 0.10000000000000001 < x Initial program 62.3%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
add-cube-cbrt95.1%
pow395.1%
associate-/r*97.6%
div-inv97.6%
pow-to-exp97.6%
pow197.6%
pow-div97.5%
Applied egg-rr97.5%
rem-cube-cbrt98.0%
pow-sub98.2%
pow198.2%
associate-/l/95.7%
associate-/r*98.2%
Applied egg-rr98.2%
Final simplification79.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 2.9e-209)
(- 1.0 t_0)
(if (<= x 0.0105) (/ (- (log x)) n) (/ (/ t_0 n) x)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 2.9e-209) {
tmp = 1.0 - t_0;
} else if (x <= 0.0105) {
tmp = -log(x) / n;
} 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) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 2.9d-209) then
tmp = 1.0d0 - t_0
else if (x <= 0.0105d0) then
tmp = -log(x) / n
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 tmp;
if (x <= 2.9e-209) {
tmp = 1.0 - t_0;
} else if (x <= 0.0105) {
tmp = -Math.log(x) / n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 2.9e-209: tmp = 1.0 - t_0 elif x <= 0.0105: tmp = -math.log(x) / n else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 2.9e-209) tmp = Float64(1.0 - t_0); elseif (x <= 0.0105) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 2.9e-209) tmp = 1.0 - t_0; elseif (x <= 0.0105) tmp = -log(x) / n; 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]}, If[LessEqual[x, 2.9e-209], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 0.0105], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 2.9 \cdot 10^{-209}:\\
\;\;\;\;1 - t_0\\
\mathbf{elif}\;x \leq 0.0105:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\end{array}
\end{array}
if x < 2.90000000000000026e-209Initial program 56.0%
Taylor expanded in x around 0 56.0%
if 2.90000000000000026e-209 < x < 0.0105000000000000007Initial program 34.1%
Taylor expanded in x around 0 30.0%
Taylor expanded in n around inf 56.8%
associate-*r/56.8%
mul-1-neg56.8%
Simplified56.8%
if 0.0105000000000000007 < x Initial program 62.3%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
add-cube-cbrt95.1%
pow395.1%
associate-/r*97.6%
div-inv97.6%
pow-to-exp97.6%
pow197.6%
pow-div97.5%
Applied egg-rr97.5%
rem-cube-cbrt98.0%
pow-sub98.2%
pow198.2%
associate-/l/95.7%
associate-/r*98.2%
Applied egg-rr98.2%
Final simplification77.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 3.4e-211)
(- (+ 1.0 (/ x n)) t_0)
(if (<= x 0.018) (/ (- (log x)) n) (/ (/ t_0 n) x)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 3.4e-211) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 0.018) {
tmp = -log(x) / n;
} 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) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 3.4d-211) then
tmp = (1.0d0 + (x / n)) - t_0
else if (x <= 0.018d0) then
tmp = -log(x) / n
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 tmp;
if (x <= 3.4e-211) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 0.018) {
tmp = -Math.log(x) / n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 3.4e-211: tmp = (1.0 + (x / n)) - t_0 elif x <= 0.018: tmp = -math.log(x) / n else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 3.4e-211) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif (x <= 0.018) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 3.4e-211) tmp = (1.0 + (x / n)) - t_0; elseif (x <= 0.018) tmp = -log(x) / n; 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]}, If[LessEqual[x, 3.4e-211], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 0.018], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 3.4 \cdot 10^{-211}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{elif}\;x \leq 0.018:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\end{array}
\end{array}
if x < 3.4000000000000001e-211Initial program 56.0%
Taylor expanded in x around 0 56.6%
if 3.4000000000000001e-211 < x < 0.0179999999999999986Initial program 34.1%
Taylor expanded in x around 0 30.0%
Taylor expanded in n around inf 56.8%
associate-*r/56.8%
mul-1-neg56.8%
Simplified56.8%
if 0.0179999999999999986 < x Initial program 62.3%
Taylor expanded in x around inf 95.7%
mul-1-neg95.7%
log-rec95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
mul-1-neg95.7%
remove-double-neg95.7%
*-commutative95.7%
Simplified95.7%
add-cube-cbrt95.1%
pow395.1%
associate-/r*97.6%
div-inv97.6%
pow-to-exp97.6%
pow197.6%
pow-div97.5%
Applied egg-rr97.5%
rem-cube-cbrt98.0%
pow-sub98.2%
pow198.2%
associate-/l/95.7%
associate-/r*98.2%
Applied egg-rr98.2%
Final simplification77.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 5.5e-225)
t_0
(if (<= x 1.6e-212)
(/ 1.0 (* n x))
(if (<= x 0.0102) t_0 (/ (/ 1.0 x) n))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 5.5e-225) {
tmp = t_0;
} else if (x <= 1.6e-212) {
tmp = 1.0 / (n * x);
} else if (x <= 0.0102) {
tmp = t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = -log(x) / n
if (x <= 5.5d-225) then
tmp = t_0
else if (x <= 1.6d-212) then
tmp = 1.0d0 / (n * x)
else if (x <= 0.0102d0) then
tmp = t_0
else
tmp = (1.0d0 / x) / n
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 <= 5.5e-225) {
tmp = t_0;
} else if (x <= 1.6e-212) {
tmp = 1.0 / (n * x);
} else if (x <= 0.0102) {
tmp = t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 5.5e-225: tmp = t_0 elif x <= 1.6e-212: tmp = 1.0 / (n * x) elif x <= 0.0102: tmp = t_0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 5.5e-225) tmp = t_0; elseif (x <= 1.6e-212) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 0.0102) tmp = t_0; else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (x <= 5.5e-225) tmp = t_0; elseif (x <= 1.6e-212) tmp = 1.0 / (n * x); elseif (x <= 0.0102) tmp = t_0; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 5.5e-225], t$95$0, If[LessEqual[x, 1.6e-212], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0102], t$95$0, N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-225}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-212}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 0.0102:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 5.5000000000000002e-225 or 1.5999999999999999e-212 < x < 0.010200000000000001Initial program 35.9%
Taylor expanded in x around 0 33.5%
Taylor expanded in n around inf 56.4%
associate-*r/56.4%
mul-1-neg56.4%
Simplified56.4%
if 5.5000000000000002e-225 < x < 1.5999999999999999e-212Initial program 97.1%
Taylor expanded in x around inf 85.7%
mul-1-neg85.7%
log-rec85.7%
mul-1-neg85.7%
distribute-neg-frac85.7%
mul-1-neg85.7%
remove-double-neg85.7%
*-commutative85.7%
Simplified85.7%
Taylor expanded in n around inf 86.2%
if 0.010200000000000001 < x Initial program 62.6%
Taylor expanded in x around inf 95.0%
mul-1-neg95.0%
log-rec95.0%
mul-1-neg95.0%
distribute-neg-frac95.0%
mul-1-neg95.0%
remove-double-neg95.0%
*-commutative95.0%
Simplified95.0%
Taylor expanded in n around inf 58.1%
*-commutative58.1%
associate-/r*60.5%
Simplified60.5%
Final simplification59.3%
(FPCore (x n) :precision binary64 (if (<= x 6.2e-210) (- 1.0 (pow x (/ 1.0 n))) (if (<= x 0.0102) (/ (- (log x)) n) (/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (x <= 6.2e-210) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.0102) {
tmp = -log(x) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 6.2d-210) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.0102d0) then
tmp = -log(x) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 6.2e-210) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.0102) {
tmp = -Math.log(x) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 6.2e-210: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.0102: tmp = -math.log(x) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 6.2e-210) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.0102) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6.2e-210) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.0102) tmp = -log(x) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 6.2e-210], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0102], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.2 \cdot 10^{-210}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.0102:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 6.19999999999999973e-210Initial program 56.0%
Taylor expanded in x around 0 56.0%
if 6.19999999999999973e-210 < x < 0.010200000000000001Initial program 33.4%
Taylor expanded in x around 0 30.3%
Taylor expanded in n around inf 57.4%
associate-*r/57.4%
mul-1-neg57.4%
Simplified57.4%
if 0.010200000000000001 < x Initial program 62.6%
Taylor expanded in x around inf 95.0%
mul-1-neg95.0%
log-rec95.0%
mul-1-neg95.0%
distribute-neg-frac95.0%
mul-1-neg95.0%
remove-double-neg95.0%
*-commutative95.0%
Simplified95.0%
Taylor expanded in n around inf 58.1%
*-commutative58.1%
associate-/r*60.5%
Simplified60.5%
Final simplification58.8%
(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 51.0%
Taylor expanded in x around inf 60.9%
mul-1-neg60.9%
log-rec60.9%
mul-1-neg60.9%
distribute-neg-frac60.9%
mul-1-neg60.9%
remove-double-neg60.9%
*-commutative60.9%
Simplified60.9%
Taylor expanded in n around inf 40.3%
Final simplification40.3%
(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 51.0%
Taylor expanded in x around inf 60.9%
mul-1-neg60.9%
log-rec60.9%
mul-1-neg60.9%
distribute-neg-frac60.9%
mul-1-neg60.9%
remove-double-neg60.9%
*-commutative60.9%
Simplified60.9%
Taylor expanded in n around inf 40.3%
*-commutative40.3%
associate-/r*41.5%
Simplified41.5%
Final simplification41.5%
herbie shell --seed 2023319
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))