
(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 21 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 2.4e-280)
(- (exp (/ x n)) t_0)
(if (<= x 1400.0)
(/
(log
(/
(exp
(+
(log1p x)
(/ (* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0))) n)))
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.4e-280) {
tmp = exp((x / n)) - t_0;
} else if (x <= 1400.0) {
tmp = log((exp((log1p(x) + ((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) / n))) / x)) / n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 2.4e-280) {
tmp = Math.exp((x / n)) - t_0;
} else if (x <= 1400.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 = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 2.4e-280: tmp = math.exp((x / n)) - t_0 elif x <= 1400.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 = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 2.4e-280) tmp = Float64(exp(Float64(x / n)) - t_0); elseif (x <= 1400.0) tmp = Float64(log(Float64(exp(Float64(log1p(x) + Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) / n))) / x)) / n); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 2.4e-280], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 1400.0], N[(N[Log[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]], $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.4 \cdot 10^{-280}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\mathbf{elif}\;x \leq 1400:\\
\;\;\;\;\frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right)}{n}}}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 2.3999999999999998e-280Initial program 78.1%
Taylor expanded in n around 0 78.1%
log1p-define85.5%
*-rgt-identity85.5%
associate-*l/85.5%
associate-/l*85.5%
exp-to-pow85.5%
Simplified85.5%
Taylor expanded in x around 0 85.5%
if 2.3999999999999998e-280 < x < 1400Initial program 42.6%
Taylor expanded in n around inf 66.3%
associate--l+66.3%
log1p-define66.3%
+-commutative66.3%
associate--r+66.3%
distribute-lft-out--66.3%
div-sub66.3%
log1p-define66.3%
Simplified66.3%
add-log-exp77.4%
associate-+r-77.4%
exp-diff77.3%
add-exp-log77.4%
Applied egg-rr77.4%
+-commutative77.4%
associate-*r/77.4%
Simplified77.4%
if 1400 < x Initial program 63.4%
Taylor expanded in x around inf 98.6%
associate-/r*99.3%
mul-1-neg99.3%
log-rec99.3%
mul-1-neg99.3%
distribute-neg-frac99.3%
mul-1-neg99.3%
remove-double-neg99.3%
*-rgt-identity99.3%
associate-/l*99.3%
exp-to-pow99.3%
Simplified99.3%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1.1e-78)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-23)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1.1e-78) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-23) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1.1e-78) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-23) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1.1e-78: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-23: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1.1e-78) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-23) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.1e-78], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-23], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1.1 \cdot 10^{-78}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-23}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.0999999999999999e-78Initial program 83.2%
Taylor expanded in x around inf 94.4%
associate-/r*94.5%
mul-1-neg94.5%
log-rec94.5%
mul-1-neg94.5%
distribute-neg-frac94.5%
mul-1-neg94.5%
remove-double-neg94.5%
*-rgt-identity94.5%
associate-/l*94.5%
exp-to-pow94.5%
Simplified94.5%
if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000002e-23Initial program 29.3%
Taylor expanded in n around inf 77.5%
log1p-define77.5%
Simplified77.5%
log1p-undefine77.5%
diff-log77.6%
Applied egg-rr77.6%
+-commutative77.6%
Simplified77.6%
if 5.0000000000000002e-23 < (/.f64 #s(literal 1 binary64) n) Initial program 48.7%
Taylor expanded in n around 0 48.7%
log1p-define94.9%
*-rgt-identity94.9%
associate-*l/94.9%
associate-/l*94.9%
exp-to-pow94.9%
Simplified94.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (log1p (expm1 (/ 1.0 (* x n)))))
(t_1 (* x (- (/ 1.0 n) (/ (log x) (* x n))))))
(if (<= x 1.8e-48)
t_1
(if (<= x 1.55e-33)
t_0
(if (<= x 1.25e-7)
t_1
(if (<= x 1.0) t_0 (/ (/ (pow x (/ 1.0 n)) n) x)))))))
double code(double x, double n) {
double t_0 = log1p(expm1((1.0 / (x * n))));
double t_1 = x * ((1.0 / n) - (log(x) / (x * n)));
double tmp;
if (x <= 1.8e-48) {
tmp = t_1;
} else if (x <= 1.55e-33) {
tmp = t_0;
} else if (x <= 1.25e-7) {
tmp = t_1;
} else if (x <= 1.0) {
tmp = t_0;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log1p(Math.expm1((1.0 / (x * n))));
double t_1 = x * ((1.0 / n) - (Math.log(x) / (x * n)));
double tmp;
if (x <= 1.8e-48) {
tmp = t_1;
} else if (x <= 1.55e-33) {
tmp = t_0;
} else if (x <= 1.25e-7) {
tmp = t_1;
} else if (x <= 1.0) {
tmp = t_0;
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log1p(math.expm1((1.0 / (x * n)))) t_1 = x * ((1.0 / n) - (math.log(x) / (x * n))) tmp = 0 if x <= 1.8e-48: tmp = t_1 elif x <= 1.55e-33: tmp = t_0 elif x <= 1.25e-7: tmp = t_1 elif x <= 1.0: tmp = t_0 else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) t_0 = log1p(expm1(Float64(1.0 / Float64(x * n)))) t_1 = Float64(x * Float64(Float64(1.0 / n) - Float64(log(x) / Float64(x * n)))) tmp = 0.0 if (x <= 1.8e-48) tmp = t_1; elseif (x <= 1.55e-33) tmp = t_0; elseif (x <= 1.25e-7) tmp = t_1; elseif (x <= 1.0) tmp = t_0; else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Log[1 + N[(Exp[N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(N[(1.0 / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.8e-48], t$95$1, If[LessEqual[x, 1.55e-33], t$95$0, If[LessEqual[x, 1.25e-7], t$95$1, If[LessEqual[x, 1.0], t$95$0, N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\
t_1 := x \cdot \left(\frac{1}{n} - \frac{\log x}{x \cdot n}\right)\\
\mathbf{if}\;x \leq 1.8 \cdot 10^{-48}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 1.8000000000000001e-48 or 1.54999999999999998e-33 < x < 1.24999999999999994e-7Initial program 44.0%
Taylor expanded in n around inf 52.4%
log1p-define52.4%
Simplified52.4%
clear-num52.4%
inv-pow52.4%
Applied egg-rr52.4%
unpow-152.4%
Simplified52.4%
Taylor expanded in x around 0 52.4%
Taylor expanded in x around inf 74.4%
log-rec74.4%
distribute-frac-neg74.4%
unsub-neg74.4%
*-commutative74.4%
Simplified74.4%
if 1.8000000000000001e-48 < x < 1.54999999999999998e-33 or 1.24999999999999994e-7 < x < 1Initial program 70.2%
Taylor expanded in n around inf 12.6%
log1p-define12.6%
Simplified12.6%
Taylor expanded in x around inf 8.2%
*-commutative8.2%
Simplified8.2%
log1p-expm1-u92.9%
Applied egg-rr92.9%
if 1 < x Initial program 62.4%
Taylor expanded in x around inf 97.4%
associate-/r*98.1%
mul-1-neg98.1%
log-rec98.1%
mul-1-neg98.1%
distribute-neg-frac98.1%
mul-1-neg98.1%
remove-double-neg98.1%
*-rgt-identity98.1%
associate-/l*98.1%
exp-to-pow98.1%
Simplified98.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1.1e-78)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 0.0001)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1.1e-78) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 0.0001) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((x / n)) - t_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 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-1.1d-78)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 0.0001d0) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = exp((x / n)) - t_0
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 ((1.0 / n) <= -1.1e-78) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 0.0001) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1.1e-78: tmp = (t_0 / n) / x elif (1.0 / n) <= 0.0001: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1.1e-78) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 0.0001) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1.1e-78) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 0.0001) tmp = log(((x + 1.0) / x)) / n; else tmp = exp((x / n)) - t_0; end tmp_2 = 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], -1.1e-78], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1.1 \cdot 10^{-78}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.0999999999999999e-78Initial program 83.2%
Taylor expanded in x around inf 94.4%
associate-/r*94.5%
mul-1-neg94.5%
log-rec94.5%
mul-1-neg94.5%
distribute-neg-frac94.5%
mul-1-neg94.5%
remove-double-neg94.5%
*-rgt-identity94.5%
associate-/l*94.5%
exp-to-pow94.5%
Simplified94.5%
if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4Initial program 28.9%
Taylor expanded in n around inf 76.3%
log1p-define76.3%
Simplified76.3%
log1p-undefine76.3%
diff-log76.4%
Applied egg-rr76.4%
+-commutative76.4%
Simplified76.4%
if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) Initial program 51.2%
Taylor expanded in n around 0 51.2%
log1p-define100.0%
*-rgt-identity100.0%
associate-*l/100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5.0)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= (/ 1.0 n) -1.1e-78)
(/ 1.0 (* x (+ n (* 0.5 (/ n x)))))
(if (<= (/ 1.0 n) 0.0001)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+163)
(- 1.0 (pow x (/ 1.0 n)))
(/
(+
(/ 1.0 n)
(/ (+ (/ (+ (/ 0.25 x) -0.3333333333333333) (* x n)) (/ -0.5 n)) x))
x))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5.0) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if ((1.0 / n) <= -1.1e-78) {
tmp = 1.0 / (x * (n + (0.5 * (n / x))));
} else if ((1.0 / n) <= 0.0001) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+163) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-5.0d0)) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if ((1.0d0 / n) <= (-1.1d-78)) then
tmp = 1.0d0 / (x * (n + (0.5d0 * (n / x))))
else if ((1.0d0 / n) <= 0.0001d0) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 5d+163) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = ((1.0d0 / n) + (((((0.25d0 / x) + (-0.3333333333333333d0)) / (x * n)) + ((-0.5d0) / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5.0) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if ((1.0 / n) <= -1.1e-78) {
tmp = 1.0 / (x * (n + (0.5 * (n / x))));
} else if ((1.0 / n) <= 0.0001) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+163) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5.0: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif (1.0 / n) <= -1.1e-78: tmp = 1.0 / (x * (n + (0.5 * (n / x)))) elif (1.0 / n) <= 0.0001: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+163: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5.0) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (Float64(1.0 / n) <= -1.1e-78) tmp = Float64(1.0 / Float64(x * Float64(n + Float64(0.5 * Float64(n / x))))); elseif (Float64(1.0 / n) <= 0.0001) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+163) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -5.0) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif ((1.0 / n) <= -1.1e-78) tmp = 1.0 / (x * (n + (0.5 * (n / x)))); elseif ((1.0 / n) <= 0.0001) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 5e+163) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5.0], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.1e-78], N[(1.0 / N[(x * N[(n + N[(0.5 * N[(n / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+163], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;\frac{1}{n} \leq -1.1 \cdot 10^{-78}:\\
\;\;\;\;\frac{1}{x \cdot \left(n + 0.5 \cdot \frac{n}{x}\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+163}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5Initial program 100.0%
Taylor expanded in n around inf 51.7%
log1p-define51.7%
Simplified51.7%
clear-num51.7%
inv-pow51.7%
Applied egg-rr51.7%
unpow-151.7%
Simplified51.7%
Taylor expanded in x around -inf 42.6%
Taylor expanded in x around 0 74.3%
if -5 < (/.f64 #s(literal 1 binary64) n) < -1.0999999999999999e-78Initial program 17.5%
Taylor expanded in n around inf 23.7%
log1p-define23.7%
Simplified23.7%
clear-num23.7%
inv-pow23.7%
Applied egg-rr23.7%
unpow-123.7%
Simplified23.7%
Taylor expanded in x around inf 63.4%
if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4Initial program 28.9%
Taylor expanded in n around inf 76.3%
log1p-define76.3%
Simplified76.3%
log1p-undefine76.3%
diff-log76.4%
Applied egg-rr76.4%
+-commutative76.4%
Simplified76.4%
if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 5e163Initial program 74.9%
Taylor expanded in x around 0 68.0%
*-rgt-identity68.0%
associate-*l/68.0%
associate-/l*68.0%
exp-to-pow68.0%
Simplified68.0%
if 5e163 < (/.f64 #s(literal 1 binary64) n) Initial program 35.4%
Taylor expanded in n around inf 10.7%
log1p-define10.7%
Simplified10.7%
Taylor expanded in x around -inf 0.2%
mul-1-neg0.2%
Simplified0.2%
*-un-lft-identity0.2%
Applied egg-rr72.5%
*-lft-identity72.5%
associate-/l/72.5%
sub-neg72.5%
metadata-eval72.5%
Simplified72.5%
Final simplification73.9%
(FPCore (x n)
:precision binary64
(if (<= x 4.1e-233)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 1.05e-144)
(/ -1.0 (/ n (log x)))
(if (<= x 4.7e-122)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 1.4e-7)
(- (/ x n) (/ (log x) n))
(if (<= x 9.5e+172)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x)
(/ 0.3333333333333333 (* n (pow x 3.0)))))))))
double code(double x, double n) {
double tmp;
if (x <= 4.1e-233) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.05e-144) {
tmp = -1.0 / (n / log(x));
} else if (x <= 4.7e-122) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x / n) - (log(x) / n);
} else if (x <= 9.5e+172) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 4.1d-233) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.05d-144) then
tmp = (-1.0d0) / (n / log(x))
else if (x <= 4.7d-122) then
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
else if (x <= 1.4d-7) then
tmp = (x / n) - (log(x) / n)
else if (x <= 9.5d+172) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
else
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 4.1e-233) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.05e-144) {
tmp = -1.0 / (n / Math.log(x));
} else if (x <= 4.7e-122) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x / n) - (Math.log(x) / n);
} else if (x <= 9.5e+172) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.1e-233: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.05e-144: tmp = -1.0 / (n / math.log(x)) elif x <= 4.7e-122: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) elif x <= 1.4e-7: tmp = (x / n) - (math.log(x) / n) elif x <= 9.5e+172: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x else: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) return tmp
function code(x, n) tmp = 0.0 if (x <= 4.1e-233) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.05e-144) tmp = Float64(-1.0 / Float64(n / log(x))); elseif (x <= 4.7e-122) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 1.4e-7) tmp = Float64(Float64(x / n) - Float64(log(x) / n)); elseif (x <= 9.5e+172) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); else tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.1e-233) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.05e-144) tmp = -1.0 / (n / log(x)); elseif (x <= 4.7e-122) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); elseif (x <= 1.4e-7) tmp = (x / n) - (log(x) / n); elseif (x <= 9.5e+172) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; else tmp = 0.3333333333333333 / (n * (x ^ 3.0)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.1e-233], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e-144], N[(-1.0 / N[(n / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.7e-122], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e+172], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.1 \cdot 10^{-233}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-144}:\\
\;\;\;\;\frac{-1}{\frac{n}{\log x}}\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-122}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+172}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\end{array}
\end{array}
if x < 4.1000000000000004e-233Initial program 61.9%
Taylor expanded in x around 0 61.9%
*-rgt-identity61.9%
associate-*l/61.9%
associate-/l*61.9%
exp-to-pow61.9%
Simplified61.9%
if 4.1000000000000004e-233 < x < 1.0500000000000001e-144Initial program 34.7%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
clear-num62.0%
inv-pow62.0%
Applied egg-rr62.0%
unpow-162.0%
Simplified62.0%
Taylor expanded in x around 0 62.0%
associate-*r/62.0%
neg-mul-162.0%
Simplified62.0%
if 1.0500000000000001e-144 < x < 4.6999999999999999e-122Initial program 55.5%
Taylor expanded in n around inf 34.2%
log1p-define34.2%
Simplified34.2%
clear-num34.2%
inv-pow34.2%
Applied egg-rr34.2%
unpow-134.2%
Simplified34.2%
Taylor expanded in x around -inf 77.5%
Taylor expanded in n around 0 77.5%
Simplified77.5%
if 4.6999999999999999e-122 < x < 1.4000000000000001e-7Initial program 33.1%
Taylor expanded in n around inf 56.2%
log1p-define56.2%
Simplified56.2%
Taylor expanded in x around 0 56.2%
neg-mul-156.2%
distribute-neg-frac56.2%
log-rec56.2%
+-commutative56.2%
log-rec56.2%
distribute-neg-frac56.2%
unsub-neg56.2%
Simplified56.2%
if 1.4000000000000001e-7 < x < 9.50000000000000027e172Initial program 50.5%
Taylor expanded in n around inf 44.7%
log1p-define44.7%
Simplified44.7%
Taylor expanded in x around -inf 65.8%
mul-1-neg65.8%
mul-1-neg65.8%
associate-*r/65.8%
metadata-eval65.8%
*-commutative65.8%
associate-*r/65.8%
metadata-eval65.8%
Simplified65.8%
if 9.50000000000000027e172 < x Initial program 81.9%
Taylor expanded in n around inf 81.9%
log1p-define81.9%
Simplified81.9%
clear-num81.9%
inv-pow81.9%
Applied egg-rr81.9%
unpow-181.9%
Simplified81.9%
Taylor expanded in x around -inf 53.6%
Taylor expanded in x around 0 81.9%
Final simplification66.7%
(FPCore (x n)
:precision binary64
(if (<= x 6e-232)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 2.4e-144)
(/ -1.0 (/ n (log x)))
(if (<= x 1.48e-120)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 1.4e-7)
(/ (- x (log x)) n)
(if (<= x 1e+173)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x)
(/ 0.3333333333333333 (* n (pow x 3.0)))))))))
double code(double x, double n) {
double tmp;
if (x <= 6e-232) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 2.4e-144) {
tmp = -1.0 / (n / log(x));
} else if (x <= 1.48e-120) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x - log(x)) / n;
} else if (x <= 1e+173) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 6d-232) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 2.4d-144) then
tmp = (-1.0d0) / (n / log(x))
else if (x <= 1.48d-120) then
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
else if (x <= 1.4d-7) then
tmp = (x - log(x)) / n
else if (x <= 1d+173) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
else
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 6e-232) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 2.4e-144) {
tmp = -1.0 / (n / Math.log(x));
} else if (x <= 1.48e-120) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1e+173) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 6e-232: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 2.4e-144: tmp = -1.0 / (n / math.log(x)) elif x <= 1.48e-120: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) elif x <= 1.4e-7: tmp = (x - math.log(x)) / n elif x <= 1e+173: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x else: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) return tmp
function code(x, n) tmp = 0.0 if (x <= 6e-232) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 2.4e-144) tmp = Float64(-1.0 / Float64(n / log(x))); elseif (x <= 1.48e-120) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 1.4e-7) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1e+173) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); else tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6e-232) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 2.4e-144) tmp = -1.0 / (n / log(x)); elseif (x <= 1.48e-120) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); elseif (x <= 1.4e-7) tmp = (x - log(x)) / n; elseif (x <= 1e+173) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; else tmp = 0.3333333333333333 / (n * (x ^ 3.0)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 6e-232], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.4e-144], N[(-1.0 / N[(n / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.48e-120], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1e+173], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-232}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-144}:\\
\;\;\;\;\frac{-1}{\frac{n}{\log x}}\\
\mathbf{elif}\;x \leq 1.48 \cdot 10^{-120}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 10^{+173}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\end{array}
\end{array}
if x < 5.99999999999999979e-232Initial program 61.9%
Taylor expanded in x around 0 61.9%
*-rgt-identity61.9%
associate-*l/61.9%
associate-/l*61.9%
exp-to-pow61.9%
Simplified61.9%
if 5.99999999999999979e-232 < x < 2.39999999999999994e-144Initial program 34.7%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
clear-num62.0%
inv-pow62.0%
Applied egg-rr62.0%
unpow-162.0%
Simplified62.0%
Taylor expanded in x around 0 62.0%
associate-*r/62.0%
neg-mul-162.0%
Simplified62.0%
if 2.39999999999999994e-144 < x < 1.4800000000000001e-120Initial program 55.5%
Taylor expanded in n around inf 34.2%
log1p-define34.2%
Simplified34.2%
clear-num34.2%
inv-pow34.2%
Applied egg-rr34.2%
unpow-134.2%
Simplified34.2%
Taylor expanded in x around -inf 77.5%
Taylor expanded in n around 0 77.5%
Simplified77.5%
if 1.4800000000000001e-120 < x < 1.4000000000000001e-7Initial program 33.1%
Taylor expanded in n around inf 56.2%
log1p-define56.2%
Simplified56.2%
Taylor expanded in x around 0 56.2%
if 1.4000000000000001e-7 < x < 1e173Initial program 50.5%
Taylor expanded in n around inf 44.7%
log1p-define44.7%
Simplified44.7%
Taylor expanded in x around -inf 65.8%
mul-1-neg65.8%
mul-1-neg65.8%
associate-*r/65.8%
metadata-eval65.8%
*-commutative65.8%
associate-*r/65.8%
metadata-eval65.8%
Simplified65.8%
if 1e173 < x Initial program 81.9%
Taylor expanded in n around inf 81.9%
log1p-define81.9%
Simplified81.9%
clear-num81.9%
inv-pow81.9%
Applied egg-rr81.9%
unpow-181.9%
Simplified81.9%
Taylor expanded in x around -inf 53.6%
Taylor expanded in x around 0 81.9%
Final simplification66.7%
(FPCore (x n)
:precision binary64
(if (<= x 1.05e-232)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 1.95e-144)
(/ (log x) (- n))
(if (<= x 4.2e-122)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 1.4e-7)
(/ (- x (log x)) n)
(if (<= x 8.6e+172)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x)
(/ 0.3333333333333333 (* n (pow x 3.0)))))))))
double code(double x, double n) {
double tmp;
if (x <= 1.05e-232) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.95e-144) {
tmp = log(x) / -n;
} else if (x <= 4.2e-122) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x - log(x)) / n;
} else if (x <= 8.6e+172) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 0.3333333333333333 / (n * pow(x, 3.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.05d-232) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.95d-144) then
tmp = log(x) / -n
else if (x <= 4.2d-122) then
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
else if (x <= 1.4d-7) then
tmp = (x - log(x)) / n
else if (x <= 8.6d+172) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
else
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.05e-232) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.95e-144) {
tmp = Math.log(x) / -n;
} else if (x <= 4.2e-122) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 8.6e+172) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.05e-232: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.95e-144: tmp = math.log(x) / -n elif x <= 4.2e-122: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) elif x <= 1.4e-7: tmp = (x - math.log(x)) / n elif x <= 8.6e+172: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x else: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.05e-232) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.95e-144) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 4.2e-122) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 1.4e-7) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 8.6e+172) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); else tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.05e-232) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.95e-144) tmp = log(x) / -n; elseif (x <= 4.2e-122) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); elseif (x <= 1.4e-7) tmp = (x - log(x)) / n; elseif (x <= 8.6e+172) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; else tmp = 0.3333333333333333 / (n * (x ^ 3.0)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.05e-232], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.95e-144], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 4.2e-122], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 8.6e+172], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{-232}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{-144}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-122}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 8.6 \cdot 10^{+172}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\end{array}
\end{array}
if x < 1.05e-232Initial program 61.9%
Taylor expanded in x around 0 61.9%
*-rgt-identity61.9%
associate-*l/61.9%
associate-/l*61.9%
exp-to-pow61.9%
Simplified61.9%
if 1.05e-232 < x < 1.95000000000000007e-144Initial program 34.7%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
Taylor expanded in x around 0 61.9%
neg-mul-161.9%
Simplified61.9%
if 1.95000000000000007e-144 < x < 4.19999999999999985e-122Initial program 55.5%
Taylor expanded in n around inf 34.2%
log1p-define34.2%
Simplified34.2%
clear-num34.2%
inv-pow34.2%
Applied egg-rr34.2%
unpow-134.2%
Simplified34.2%
Taylor expanded in x around -inf 77.5%
Taylor expanded in n around 0 77.5%
Simplified77.5%
if 4.19999999999999985e-122 < x < 1.4000000000000001e-7Initial program 33.1%
Taylor expanded in n around inf 56.2%
log1p-define56.2%
Simplified56.2%
Taylor expanded in x around 0 56.2%
if 1.4000000000000001e-7 < x < 8.6000000000000005e172Initial program 50.5%
Taylor expanded in n around inf 44.7%
log1p-define44.7%
Simplified44.7%
Taylor expanded in x around -inf 65.8%
mul-1-neg65.8%
mul-1-neg65.8%
associate-*r/65.8%
metadata-eval65.8%
*-commutative65.8%
associate-*r/65.8%
metadata-eval65.8%
Simplified65.8%
if 8.6000000000000005e172 < x Initial program 81.9%
Taylor expanded in n around inf 81.9%
log1p-define81.9%
Simplified81.9%
clear-num81.9%
inv-pow81.9%
Applied egg-rr81.9%
unpow-181.9%
Simplified81.9%
Taylor expanded in x around -inf 53.6%
Taylor expanded in x around 0 81.9%
Final simplification66.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1.1e-78)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 0.0001)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+163)
(- (+ (/ x n) 1.0) t_0)
(/
(+
(/ 1.0 n)
(/ (+ (/ (+ (/ 0.25 x) -0.3333333333333333) (* x n)) (/ -0.5 n)) x))
x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1.1e-78) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 0.0001) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+163) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / 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 ((1.0d0 / n) <= (-1.1d-78)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 0.0001d0) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 5d+163) then
tmp = ((x / n) + 1.0d0) - t_0
else
tmp = ((1.0d0 / n) + (((((0.25d0 / x) + (-0.3333333333333333d0)) / (x * n)) + ((-0.5d0) / n)) / x)) / 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 ((1.0 / n) <= -1.1e-78) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 0.0001) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+163) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1.1e-78: tmp = (t_0 / n) / x elif (1.0 / n) <= 0.0001: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+163: tmp = ((x / n) + 1.0) - t_0 else: tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1.1e-78) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 0.0001) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+163) tmp = Float64(Float64(Float64(x / n) + 1.0) - t_0); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1.1e-78) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 0.0001) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 5e+163) tmp = ((x / n) + 1.0) - t_0; else tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x; end tmp_2 = 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], -1.1e-78], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+163], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1.1 \cdot 10^{-78}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+163}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.0999999999999999e-78Initial program 83.2%
Taylor expanded in x around inf 94.4%
associate-/r*94.5%
mul-1-neg94.5%
log-rec94.5%
mul-1-neg94.5%
distribute-neg-frac94.5%
mul-1-neg94.5%
remove-double-neg94.5%
*-rgt-identity94.5%
associate-/l*94.5%
exp-to-pow94.5%
Simplified94.5%
if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4Initial program 28.9%
Taylor expanded in n around inf 76.3%
log1p-define76.3%
Simplified76.3%
log1p-undefine76.3%
diff-log76.4%
Applied egg-rr76.4%
+-commutative76.4%
Simplified76.4%
if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 5e163Initial program 74.9%
Taylor expanded in x around 0 69.6%
if 5e163 < (/.f64 #s(literal 1 binary64) n) Initial program 35.4%
Taylor expanded in n around inf 10.7%
log1p-define10.7%
Simplified10.7%
Taylor expanded in x around -inf 0.2%
mul-1-neg0.2%
Simplified0.2%
*-un-lft-identity0.2%
Applied egg-rr72.5%
*-lft-identity72.5%
associate-/l/72.5%
sub-neg72.5%
metadata-eval72.5%
Simplified72.5%
Final simplification83.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1.1e-78)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 0.0001)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+163)
(- 1.0 t_0)
(/
(+
(/ 1.0 n)
(/ (+ (/ (+ (/ 0.25 x) -0.3333333333333333) (* x n)) (/ -0.5 n)) x))
x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1.1e-78) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 0.0001) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+163) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / 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 ((1.0d0 / n) <= (-1.1d-78)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 0.0001d0) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 5d+163) then
tmp = 1.0d0 - t_0
else
tmp = ((1.0d0 / n) + (((((0.25d0 / x) + (-0.3333333333333333d0)) / (x * n)) + ((-0.5d0) / n)) / x)) / 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 ((1.0 / n) <= -1.1e-78) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 0.0001) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+163) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1.1e-78: tmp = (t_0 / n) / x elif (1.0 / n) <= 0.0001: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+163: tmp = 1.0 - t_0 else: tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1.1e-78) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 0.0001) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+163) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1.1e-78) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 0.0001) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 5e+163) tmp = 1.0 - t_0; else tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x; end tmp_2 = 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], -1.1e-78], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+163], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1.1 \cdot 10^{-78}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+163}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.0999999999999999e-78Initial program 83.2%
Taylor expanded in x around inf 94.4%
associate-/r*94.5%
mul-1-neg94.5%
log-rec94.5%
mul-1-neg94.5%
distribute-neg-frac94.5%
mul-1-neg94.5%
remove-double-neg94.5%
*-rgt-identity94.5%
associate-/l*94.5%
exp-to-pow94.5%
Simplified94.5%
if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4Initial program 28.9%
Taylor expanded in n around inf 76.3%
log1p-define76.3%
Simplified76.3%
log1p-undefine76.3%
diff-log76.4%
Applied egg-rr76.4%
+-commutative76.4%
Simplified76.4%
if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 5e163Initial program 74.9%
Taylor expanded in x around 0 68.0%
*-rgt-identity68.0%
associate-*l/68.0%
associate-/l*68.0%
exp-to-pow68.0%
Simplified68.0%
if 5e163 < (/.f64 #s(literal 1 binary64) n) Initial program 35.4%
Taylor expanded in n around inf 10.7%
log1p-define10.7%
Simplified10.7%
Taylor expanded in x around -inf 0.2%
mul-1-neg0.2%
Simplified0.2%
*-un-lft-identity0.2%
Applied egg-rr72.5%
*-lft-identity72.5%
associate-/l/72.5%
sub-neg72.5%
metadata-eval72.5%
Simplified72.5%
Final simplification82.9%
(FPCore (x n)
:precision binary64
(if (<= x 7.5e-233)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 1.65e-144)
(/ (log x) (- n))
(if (<= x 5.8e-122)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 1.4e-7)
(/ (- x (log x)) n)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x))))))
double code(double x, double n) {
double tmp;
if (x <= 7.5e-233) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.65e-144) {
tmp = log(x) / -n;
} else if (x <= 5.8e-122) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 7.5d-233) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.65d-144) then
tmp = log(x) / -n
else if (x <= 5.8d-122) then
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
else if (x <= 1.4d-7) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 7.5e-233) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.65e-144) {
tmp = Math.log(x) / -n;
} else if (x <= 5.8e-122) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 7.5e-233: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.65e-144: tmp = math.log(x) / -n elif x <= 5.8e-122: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) elif x <= 1.4e-7: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 7.5e-233) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.65e-144) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 5.8e-122) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 1.4e-7) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 7.5e-233) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.65e-144) tmp = log(x) / -n; elseif (x <= 5.8e-122) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); elseif (x <= 1.4e-7) tmp = (x - log(x)) / n; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 7.5e-233], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.65e-144], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 5.8e-122], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.5 \cdot 10^{-233}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-144}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-122}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 7.49999999999999974e-233Initial program 61.9%
Taylor expanded in x around 0 61.9%
*-rgt-identity61.9%
associate-*l/61.9%
associate-/l*61.9%
exp-to-pow61.9%
Simplified61.9%
if 7.49999999999999974e-233 < x < 1.64999999999999998e-144Initial program 34.7%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
Taylor expanded in x around 0 61.9%
neg-mul-161.9%
Simplified61.9%
if 1.64999999999999998e-144 < x < 5.8000000000000005e-122Initial program 55.5%
Taylor expanded in n around inf 34.2%
log1p-define34.2%
Simplified34.2%
clear-num34.2%
inv-pow34.2%
Applied egg-rr34.2%
unpow-134.2%
Simplified34.2%
Taylor expanded in x around -inf 77.5%
Taylor expanded in n around 0 77.5%
Simplified77.5%
if 5.8000000000000005e-122 < x < 1.4000000000000001e-7Initial program 33.1%
Taylor expanded in n around inf 56.2%
log1p-define56.2%
Simplified56.2%
Taylor expanded in x around 0 56.2%
if 1.4000000000000001e-7 < x Initial program 63.6%
Taylor expanded in n around inf 60.2%
log1p-define60.2%
Simplified60.2%
Taylor expanded in x around -inf 60.9%
mul-1-neg60.9%
mul-1-neg60.9%
associate-*r/60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*r/60.9%
metadata-eval60.9%
Simplified60.9%
Final simplification61.1%
(FPCore (x n)
:precision binary64
(if (<= x 2.5e-144)
(/ (log x) (- n))
(if (<= x 2.1e-121)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 1.4e-7)
(/ (- x (log x)) n)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x)))))
double code(double x, double n) {
double tmp;
if (x <= 2.5e-144) {
tmp = log(x) / -n;
} else if (x <= 2.1e-121) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.5d-144) then
tmp = log(x) / -n
else if (x <= 2.1d-121) then
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
else if (x <= 1.4d-7) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.5e-144) {
tmp = Math.log(x) / -n;
} else if (x <= 2.1e-121) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.5e-144: tmp = math.log(x) / -n elif x <= 2.1e-121: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) elif x <= 1.4e-7: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 2.5e-144) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 2.1e-121) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 1.4e-7) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.5e-144) tmp = log(x) / -n; elseif (x <= 2.1e-121) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); elseif (x <= 1.4e-7) tmp = (x - log(x)) / n; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.5e-144], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.1e-121], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5 \cdot 10^{-144}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-121}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 2.4999999999999999e-144Initial program 51.2%
Taylor expanded in n around inf 48.4%
log1p-define48.4%
Simplified48.4%
Taylor expanded in x around 0 48.4%
neg-mul-148.4%
Simplified48.4%
if 2.4999999999999999e-144 < x < 2.0999999999999999e-121Initial program 55.5%
Taylor expanded in n around inf 34.2%
log1p-define34.2%
Simplified34.2%
clear-num34.2%
inv-pow34.2%
Applied egg-rr34.2%
unpow-134.2%
Simplified34.2%
Taylor expanded in x around -inf 77.5%
Taylor expanded in n around 0 77.5%
Simplified77.5%
if 2.0999999999999999e-121 < x < 1.4000000000000001e-7Initial program 33.1%
Taylor expanded in n around inf 56.2%
log1p-define56.2%
Simplified56.2%
Taylor expanded in x around 0 56.2%
if 1.4000000000000001e-7 < x Initial program 63.6%
Taylor expanded in n around inf 60.2%
log1p-define60.2%
Simplified60.2%
Taylor expanded in x around -inf 60.9%
mul-1-neg60.9%
mul-1-neg60.9%
associate-*r/60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*r/60.9%
metadata-eval60.9%
Simplified60.9%
Final simplification57.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 2e-144)
t_0
(if (<= x 4.5e-122)
(/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
(if (<= x 1.4e-7)
t_0
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 2e-144) {
tmp = t_0;
} else if (x <= 4.5e-122) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / 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 = log(x) / -n
if (x <= 2d-144) then
tmp = t_0
else if (x <= 4.5d-122) then
tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
else if (x <= 1.4d-7) then
tmp = t_0
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
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 <= 2e-144) {
tmp = t_0;
} else if (x <= 4.5e-122) {
tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
} else if (x <= 1.4e-7) {
tmp = t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 2e-144: tmp = t_0 elif x <= 4.5e-122: tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n) elif x <= 1.4e-7: tmp = t_0 else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 2e-144) tmp = t_0; elseif (x <= 4.5e-122) tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)); elseif (x <= 1.4e-7) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 2e-144) tmp = t_0; elseif (x <= 4.5e-122) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); elseif (x <= 1.4e-7) tmp = t_0; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 2e-144], t$95$0, If[LessEqual[x, 4.5e-122], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], t$95$0, N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 2 \cdot 10^{-144}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-122}:\\
\;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 1.9999999999999999e-144 or 4.4999999999999998e-122 < x < 1.4000000000000001e-7Initial program 43.7%
Taylor expanded in n around inf 51.6%
log1p-define51.6%
Simplified51.6%
Taylor expanded in x around 0 51.3%
neg-mul-151.3%
Simplified51.3%
if 1.9999999999999999e-144 < x < 4.4999999999999998e-122Initial program 55.5%
Taylor expanded in n around inf 34.2%
log1p-define34.2%
Simplified34.2%
clear-num34.2%
inv-pow34.2%
Applied egg-rr34.2%
unpow-134.2%
Simplified34.2%
Taylor expanded in x around -inf 77.5%
Taylor expanded in n around 0 77.5%
Simplified77.5%
if 1.4000000000000001e-7 < x Initial program 63.6%
Taylor expanded in n around inf 60.2%
log1p-define60.2%
Simplified60.2%
Taylor expanded in x around -inf 60.9%
mul-1-neg60.9%
mul-1-neg60.9%
associate-*r/60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*r/60.9%
metadata-eval60.9%
Simplified60.9%
Final simplification57.2%
(FPCore (x n) :precision binary64 (if (<= x 7.2e-6) (* x (- (/ 1.0 n) (/ (log x) (* x n)))) (/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 7.2e-6) {
tmp = x * ((1.0 / n) - (log(x) / (x * n)));
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 7.2d-6) then
tmp = x * ((1.0d0 / n) - (log(x) / (x * n)))
else
tmp = ((x ** (1.0d0 / n)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 7.2e-6) {
tmp = x * ((1.0 / n) - (Math.log(x) / (x * n)));
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 7.2e-6: tmp = x * ((1.0 / n) - (math.log(x) / (x * n))) else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 7.2e-6) tmp = Float64(x * Float64(Float64(1.0 / n) - Float64(log(x) / Float64(x * n)))); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 7.2e-6) tmp = x * ((1.0 / n) - (log(x) / (x * n))); else tmp = ((x ^ (1.0 / n)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 7.2e-6], N[(x * N[(N[(1.0 / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 7.2 \cdot 10^{-6}:\\
\;\;\;\;x \cdot \left(\frac{1}{n} - \frac{\log x}{x \cdot n}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 7.19999999999999967e-6Initial program 45.7%
Taylor expanded in n around inf 49.3%
log1p-define49.3%
Simplified49.3%
clear-num49.3%
inv-pow49.3%
Applied egg-rr49.3%
unpow-149.3%
Simplified49.3%
Taylor expanded in x around 0 49.3%
Taylor expanded in x around inf 70.2%
log-rec70.2%
distribute-frac-neg70.2%
unsub-neg70.2%
*-commutative70.2%
Simplified70.2%
if 7.19999999999999967e-6 < x Initial program 63.0%
Taylor expanded in x around inf 96.7%
associate-/r*97.3%
mul-1-neg97.3%
log-rec97.3%
mul-1-neg97.3%
distribute-neg-frac97.3%
mul-1-neg97.3%
remove-double-neg97.3%
*-rgt-identity97.3%
associate-/l*97.3%
exp-to-pow97.3%
Simplified97.3%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ (/ (+ (/ 0.25 x) -0.3333333333333333) (* x n)) (/ -0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((((0.25d0 / x) + (-0.3333333333333333d0)) / (x * n)) + ((-0.5d0) / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}
\end{array}
Initial program 53.8%
Taylor expanded in n around inf 54.9%
log1p-define54.9%
Simplified54.9%
Taylor expanded in x around -inf 29.1%
mul-1-neg29.1%
Simplified29.1%
*-un-lft-identity29.1%
Applied egg-rr49.1%
*-lft-identity49.1%
associate-/l/49.1%
sub-neg49.1%
metadata-eval49.1%
Simplified49.1%
Final simplification49.1%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}
\end{array}
Initial program 53.8%
Taylor expanded in n around inf 54.9%
log1p-define54.9%
Simplified54.9%
Taylor expanded in x around -inf 49.0%
mul-1-neg49.0%
mul-1-neg49.0%
associate-*r/49.0%
metadata-eval49.0%
*-commutative49.0%
associate-*r/49.0%
metadata-eval49.0%
Simplified49.0%
Final simplification49.0%
(FPCore (x n) :precision binary64 (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))
double code(double x, double n) {
return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
def code(x, n): return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Initial program 53.8%
Taylor expanded in n around inf 54.9%
log1p-define54.9%
Simplified54.9%
add-sqr-sqrt54.7%
pow254.7%
Applied egg-rr54.7%
Taylor expanded in x around -inf 48.9%
mul-1-neg48.9%
distribute-neg-frac248.9%
sub-neg48.9%
associate-*r/48.9%
sub-neg48.9%
metadata-eval48.9%
distribute-lft-in48.9%
neg-mul-148.9%
associate-*r/48.9%
metadata-eval48.9%
distribute-neg-frac48.9%
metadata-eval48.9%
metadata-eval48.9%
metadata-eval48.9%
Simplified48.9%
Final simplification48.9%
(FPCore (x n) :precision binary64 (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n)))
double code(double x, double n) {
return (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
end function
public static double code(double x, double n) {
return (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
}
def code(x, n): return (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n)
function code(x, n) return Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n)) end
function tmp = code(x, n) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n); end
code[x_, n_] := N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}
\end{array}
Initial program 53.8%
Taylor expanded in n around inf 54.9%
log1p-define54.9%
Simplified54.9%
clear-num54.8%
inv-pow54.8%
Applied egg-rr54.8%
unpow-154.8%
Simplified54.8%
Taylor expanded in x around -inf 48.6%
Taylor expanded in n around 0 48.7%
Simplified48.7%
Final simplification48.7%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 53.8%
Taylor expanded in x around inf 62.0%
associate-/r*62.5%
mul-1-neg62.5%
log-rec62.5%
mul-1-neg62.5%
distribute-neg-frac62.5%
mul-1-neg62.5%
remove-double-neg62.5%
*-rgt-identity62.5%
associate-/l*62.5%
exp-to-pow62.5%
Simplified62.5%
Taylor expanded in n around inf 42.9%
(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(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 53.8%
Taylor expanded in n around inf 54.9%
log1p-define54.9%
Simplified54.9%
Taylor expanded in x around inf 42.6%
*-commutative42.6%
Simplified42.6%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 53.8%
Taylor expanded in n around inf 54.9%
log1p-define54.9%
Simplified54.9%
clear-num54.8%
inv-pow54.8%
Applied egg-rr54.8%
unpow-154.8%
Simplified54.8%
Taylor expanded in x around 0 27.8%
Taylor expanded in x around inf 4.4%
herbie shell --seed 2024089
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))