
(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 15 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) -5e-198)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 2e-12)
(/ (- (log (/ x (+ 1.0 x)))) n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-198) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = -log((x / (1.0 + x))) / n;
} else {
tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-198) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 2e-12) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5e-198: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 2e-12: tmp = -math.log((x / (1.0 + x))) / n else: tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-198) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-12) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-198], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-12], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999999e-198Initial program 71.2%
Taylor expanded in x around inf 87.8%
mul-1-neg87.8%
log-rec87.8%
mul-1-neg87.8%
distribute-neg-frac87.8%
mul-1-neg87.8%
remove-double-neg87.8%
*-commutative87.8%
Simplified87.8%
if -4.9999999999999999e-198 < (/.f64 1 n) < 1.99999999999999996e-12Initial program 37.6%
Taylor expanded in n around inf 88.1%
log1p-def88.1%
Simplified88.1%
log1p-udef88.1%
diff-log88.2%
+-commutative88.2%
Applied egg-rr88.2%
clear-num88.2%
log-rec88.2%
Applied egg-rr88.2%
if 1.99999999999999996e-12 < (/.f64 1 n) Initial program 56.8%
Taylor expanded in n around 0 56.8%
log1p-def97.2%
Simplified97.2%
Final simplification89.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (- (log (/ x (+ 1.0 x)))) n)))
(if (<= (/ 1.0 n) -5e+184)
(- 1.0 t_0)
(if (<= (/ 1.0 n) -2e-20)
t_1
(if (<= (/ 1.0 n) -5e-198)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 0.0002)
t_1
(if (<= (/ 1.0 n) 1e+166)
(- (+ 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 = -log((x / (1.0 + x))) / n;
double tmp;
if ((1.0 / n) <= -5e+184) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+166) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = -log((x / (1.0d0 + x))) / n
if ((1.0d0 / n) <= (-5d+184)) then
tmp = 1.0d0 - t_0
else if ((1.0d0 / n) <= (-2d-20)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d-198)) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 0.0002d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+166) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = sqrt(((n * x) ** (-2.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = -Math.log((x / (1.0 + x))) / n;
double tmp;
if ((1.0 / n) <= -5e+184) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+166) {
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 = -math.log((x / (1.0 + x))) / n tmp = 0 if (1.0 / n) <= -5e+184: tmp = 1.0 - t_0 elif (1.0 / n) <= -2e-20: tmp = t_1 elif (1.0 / n) <= -5e-198: tmp = (1.0 / n) / x elif (1.0 / n) <= 0.0002: tmp = t_1 elif (1.0 / n) <= 1e+166: 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(-log(Float64(x / Float64(1.0 + x)))) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+184) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= -2e-20) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-198) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 0.0002) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+166) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = -log((x / (1.0 + x))) / n; tmp = 0.0; if ((1.0 / n) <= -5e+184) tmp = 1.0 - t_0; elseif ((1.0 / n) <= -2e-20) tmp = t_1; elseif ((1.0 / n) <= -5e-198) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 0.0002) tmp = t_1; elseif ((1.0 / n) <= 1e+166) tmp = (1.0 + (x / n)) - t_0; else tmp = sqrt(((n * x) ^ -2.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+184], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-20], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-198], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+166], 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{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+184}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+166}:\\
\;\;\;\;\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) < -4.9999999999999999e184Initial program 100.0%
Taylor expanded in x around 0 58.0%
if -4.9999999999999999e184 < (/.f64 1 n) < -1.99999999999999989e-20 or -4.9999999999999999e-198 < (/.f64 1 n) < 2.0000000000000001e-4Initial program 54.4%
Taylor expanded in n around inf 80.0%
log1p-def80.0%
Simplified80.0%
log1p-udef80.0%
diff-log80.1%
+-commutative80.1%
Applied egg-rr80.1%
clear-num80.1%
log-rec80.1%
Applied egg-rr80.1%
if -1.99999999999999989e-20 < (/.f64 1 n) < -4.9999999999999999e-198Initial program 22.7%
Taylor expanded in n around inf 44.7%
log1p-def44.7%
Simplified44.7%
Taylor expanded in x around inf 76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in x around 0 76.5%
associate-/r*78.3%
Simplified78.3%
if 2.0000000000000001e-4 < (/.f64 1 n) < 9.9999999999999994e165Initial program 85.9%
Taylor expanded in x around 0 86.0%
if 9.9999999999999994e165 < (/.f64 1 n) Initial program 12.1%
Taylor expanded in n around inf 8.6%
log1p-def8.6%
Simplified8.6%
Taylor expanded in x around inf 61.8%
*-commutative61.8%
Simplified61.8%
add-sqr-sqrt61.8%
sqrt-unprod91.9%
inv-pow91.9%
inv-pow91.9%
pow-prod-up91.9%
metadata-eval91.9%
Applied egg-rr91.9%
Final simplification78.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e+184)
(- 1.0 t_0)
(if (<= (/ 1.0 n) -2e-20)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) -5e-198)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 0.0002)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e+166)
(- (+ 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 tmp;
if ((1.0 / n) <= -5e+184) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+166) {
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 tmp;
if ((1.0 / n) <= -5e+184) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+166) {
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)) tmp = 0 if (1.0 / n) <= -5e+184: tmp = 1.0 - t_0 elif (1.0 / n) <= -2e-20: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= -5e-198: tmp = (1.0 / n) / x elif (1.0 / n) <= 0.0002: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e+166: 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) tmp = 0.0 if (Float64(1.0 / n) <= -5e+184) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= -2e-20) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= -5e-198) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 0.0002) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e+166) 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]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+184], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-20], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-198], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+166], 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)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+184}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-20}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+166}:\\
\;\;\;\;\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) < -4.9999999999999999e184Initial program 100.0%
Taylor expanded in x around 0 58.0%
if -4.9999999999999999e184 < (/.f64 1 n) < -1.99999999999999989e-20Initial program 94.5%
Taylor expanded in n around inf 62.7%
log1p-def62.7%
Simplified62.7%
if -1.99999999999999989e-20 < (/.f64 1 n) < -4.9999999999999999e-198Initial program 22.7%
Taylor expanded in n around inf 44.7%
log1p-def44.7%
Simplified44.7%
Taylor expanded in x around inf 76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in x around 0 76.5%
associate-/r*78.3%
Simplified78.3%
if -4.9999999999999999e-198 < (/.f64 1 n) < 2.0000000000000001e-4Initial program 37.3%
Taylor expanded in n around inf 87.4%
log1p-def87.4%
Simplified87.4%
log1p-udef87.4%
diff-log87.5%
+-commutative87.5%
Applied egg-rr87.5%
clear-num87.5%
log-rec87.5%
Applied egg-rr87.5%
if 2.0000000000000001e-4 < (/.f64 1 n) < 9.9999999999999994e165Initial program 85.9%
Taylor expanded in x around 0 86.0%
if 9.9999999999999994e165 < (/.f64 1 n) Initial program 12.1%
Taylor expanded in n around inf 8.6%
log1p-def8.6%
Simplified8.6%
Taylor expanded in x around inf 61.8%
*-commutative61.8%
Simplified61.8%
add-sqr-sqrt61.8%
sqrt-unprod91.9%
inv-pow91.9%
inv-pow91.9%
pow-prod-up91.9%
metadata-eval91.9%
Applied egg-rr91.9%
Final simplification78.2%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-198)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 0.0002)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e+166)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(sqrt (pow (* n x) -2.0))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-198) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 0.0002) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+166) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else {
tmp = sqrt(pow((n * x), -2.0));
}
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) <= (-5d-198)) then
tmp = exp((log(x) / n)) / (n * x)
else if ((1.0d0 / n) <= 0.0002d0) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d+166) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else
tmp = sqrt(((n * x) ** (-2.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-198) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 0.0002) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+166) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5e-198: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 0.0002: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e+166: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-198) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 0.0002) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e+166) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -5e-198) tmp = exp((log(x) / n)) / (n * x); elseif ((1.0 / n) <= 0.0002) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e+166) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); else tmp = sqrt(((n * x) ^ -2.0)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-198], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+166], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+166}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999999e-198Initial program 71.2%
Taylor expanded in x around inf 87.8%
mul-1-neg87.8%
log-rec87.8%
mul-1-neg87.8%
distribute-neg-frac87.8%
mul-1-neg87.8%
remove-double-neg87.8%
*-commutative87.8%
Simplified87.8%
if -4.9999999999999999e-198 < (/.f64 1 n) < 2.0000000000000001e-4Initial program 37.3%
Taylor expanded in n around inf 87.4%
log1p-def87.4%
Simplified87.4%
log1p-udef87.4%
diff-log87.5%
+-commutative87.5%
Applied egg-rr87.5%
clear-num87.5%
log-rec87.5%
Applied egg-rr87.5%
if 2.0000000000000001e-4 < (/.f64 1 n) < 9.9999999999999994e165Initial program 85.9%
Taylor expanded in x around 0 86.0%
if 9.9999999999999994e165 < (/.f64 1 n) Initial program 12.1%
Taylor expanded in n around inf 8.6%
log1p-def8.6%
Simplified8.6%
Taylor expanded in x around inf 61.8%
*-commutative61.8%
Simplified61.8%
add-sqr-sqrt61.8%
sqrt-unprod91.9%
inv-pow91.9%
inv-pow91.9%
pow-prod-up91.9%
metadata-eval91.9%
Applied egg-rr91.9%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-198)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 0.0002)
(/ (- (log (/ x (+ 1.0 x)))) n)
(- (exp (/ x n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-198) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 0.0002) {
tmp = -log((x / (1.0 + x))) / n;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
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) <= (-5d-198)) then
tmp = exp((log(x) / n)) / (n * x)
else if ((1.0d0 / n) <= 0.0002d0) then
tmp = -log((x / (1.0d0 + x))) / n
else
tmp = exp((x / n)) - (x ** (1.0d0 / n))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-198) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 0.0002) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5e-198: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 0.0002: tmp = -math.log((x / (1.0 + x))) / n else: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-198) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 0.0002) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -5e-198) tmp = exp((log(x) / n)) / (n * x); elseif ((1.0 / n) <= 0.0002) tmp = -log((x / (1.0 + x))) / n; else tmp = exp((x / n)) - (x ^ (1.0 / n)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-198], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999999e-198Initial program 71.2%
Taylor expanded in x around inf 87.8%
mul-1-neg87.8%
log-rec87.8%
mul-1-neg87.8%
distribute-neg-frac87.8%
mul-1-neg87.8%
remove-double-neg87.8%
*-commutative87.8%
Simplified87.8%
if -4.9999999999999999e-198 < (/.f64 1 n) < 2.0000000000000001e-4Initial program 37.3%
Taylor expanded in n around inf 87.4%
log1p-def87.4%
Simplified87.4%
log1p-udef87.4%
diff-log87.5%
+-commutative87.5%
Applied egg-rr87.5%
clear-num87.5%
log-rec87.5%
Applied egg-rr87.5%
if 2.0000000000000001e-4 < (/.f64 1 n) Initial program 58.2%
Taylor expanded in n around 0 58.2%
log1p-def99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
Final simplification89.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (- (log (/ x (+ 1.0 x)))) n)))
(if (<= (/ 1.0 n) -5e+184)
(- 1.0 t_0)
(if (<= (/ 1.0 n) -2e-20)
t_1
(if (<= (/ 1.0 n) -5e-198)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 0.0002)
t_1
(if (<= (/ 1.0 n) 1e+166)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = -log((x / (1.0 + x))) / n;
double tmp;
if ((1.0 / n) <= -5e+184) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+166) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = -log((x / (1.0d0 + x))) / n
if ((1.0d0 / n) <= (-5d+184)) then
tmp = 1.0d0 - t_0
else if ((1.0d0 / n) <= (-2d-20)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d-198)) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 0.0002d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+166) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = -Math.log((x / (1.0 + x))) / n;
double tmp;
if ((1.0 / n) <= -5e+184) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+166) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = -math.log((x / (1.0 + x))) / n tmp = 0 if (1.0 / n) <= -5e+184: tmp = 1.0 - t_0 elif (1.0 / n) <= -2e-20: tmp = t_1 elif (1.0 / n) <= -5e-198: tmp = (1.0 / n) / x elif (1.0 / n) <= 0.0002: tmp = t_1 elif (1.0 / n) <= 1e+166: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+184) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= -2e-20) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-198) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 0.0002) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+166) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = -log((x / (1.0 + x))) / n; tmp = 0.0; if ((1.0 / n) <= -5e+184) tmp = 1.0 - t_0; elseif ((1.0 / n) <= -2e-20) tmp = t_1; elseif ((1.0 / n) <= -5e-198) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 0.0002) tmp = t_1; elseif ((1.0 / n) <= 1e+166) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+184], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-20], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-198], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+166], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+184}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+166}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999999e184Initial program 100.0%
Taylor expanded in x around 0 58.0%
if -4.9999999999999999e184 < (/.f64 1 n) < -1.99999999999999989e-20 or -4.9999999999999999e-198 < (/.f64 1 n) < 2.0000000000000001e-4Initial program 54.4%
Taylor expanded in n around inf 80.0%
log1p-def80.0%
Simplified80.0%
log1p-udef80.0%
diff-log80.1%
+-commutative80.1%
Applied egg-rr80.1%
clear-num80.1%
log-rec80.1%
Applied egg-rr80.1%
if -1.99999999999999989e-20 < (/.f64 1 n) < -4.9999999999999999e-198Initial program 22.7%
Taylor expanded in n around inf 44.7%
log1p-def44.7%
Simplified44.7%
Taylor expanded in x around inf 76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in x around 0 76.5%
associate-/r*78.3%
Simplified78.3%
if 2.0000000000000001e-4 < (/.f64 1 n) < 9.9999999999999994e165Initial program 85.9%
Taylor expanded in x around 0 86.0%
if 9.9999999999999994e165 < (/.f64 1 n) Initial program 12.1%
Taylor expanded in n around inf 8.6%
log1p-def8.6%
Simplified8.6%
Taylor expanded in x around inf 61.8%
*-commutative61.8%
Simplified61.8%
Final simplification76.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -5e+184)
t_0
(if (<= (/ 1.0 n) -2e-20)
t_1
(if (<= (/ 1.0 n) -5e-198)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 0.0002)
t_1
(if (<= (/ 1.0 n) 1e+166) t_0 (/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+184) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+166) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-5d+184)) then
tmp = t_0
else if ((1.0d0 / n) <= (-2d-20)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d-198)) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 0.0002d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+166) then
tmp = t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+184) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+166) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -5e+184: tmp = t_0 elif (1.0 / n) <= -2e-20: tmp = t_1 elif (1.0 / n) <= -5e-198: tmp = (1.0 / n) / x elif (1.0 / n) <= 0.0002: tmp = t_1 elif (1.0 / n) <= 1e+166: tmp = t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+184) tmp = t_0; elseif (Float64(1.0 / n) <= -2e-20) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-198) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 0.0002) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+166) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -5e+184) tmp = t_0; elseif ((1.0 / n) <= -2e-20) tmp = t_1; elseif ((1.0 / n) <= -5e-198) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 0.0002) tmp = t_1; elseif ((1.0 / n) <= 1e+166) tmp = t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+184], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-20], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-198], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+166], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+184}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+166}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999999e184 or 2.0000000000000001e-4 < (/.f64 1 n) < 9.9999999999999994e165Initial program 94.4%
Taylor expanded in x around 0 69.2%
if -4.9999999999999999e184 < (/.f64 1 n) < -1.99999999999999989e-20 or -4.9999999999999999e-198 < (/.f64 1 n) < 2.0000000000000001e-4Initial program 54.4%
Taylor expanded in n around inf 80.0%
log1p-def80.0%
Simplified80.0%
log1p-udef80.0%
diff-log80.1%
+-commutative80.1%
Applied egg-rr80.1%
if -1.99999999999999989e-20 < (/.f64 1 n) < -4.9999999999999999e-198Initial program 22.7%
Taylor expanded in n around inf 44.7%
log1p-def44.7%
Simplified44.7%
Taylor expanded in x around inf 76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in x around 0 76.5%
associate-/r*78.3%
Simplified78.3%
if 9.9999999999999994e165 < (/.f64 1 n) Initial program 12.1%
Taylor expanded in n around inf 8.6%
log1p-def8.6%
Simplified8.6%
Taylor expanded in x around inf 61.8%
*-commutative61.8%
Simplified61.8%
Final simplification76.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (- (log (/ x (+ 1.0 x)))) n)))
(if (<= (/ 1.0 n) -5e+184)
t_0
(if (<= (/ 1.0 n) -2e-20)
t_1
(if (<= (/ 1.0 n) -5e-198)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 0.0002)
t_1
(if (<= (/ 1.0 n) 1e+166) t_0 (/ 1.0 (* n x)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = -log((x / (1.0 + x))) / n;
double tmp;
if ((1.0 / n) <= -5e+184) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+166) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = -log((x / (1.0d0 + x))) / n
if ((1.0d0 / n) <= (-5d+184)) then
tmp = t_0
else if ((1.0d0 / n) <= (-2d-20)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d-198)) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 0.0002d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+166) then
tmp = t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = -Math.log((x / (1.0 + x))) / n;
double tmp;
if ((1.0 / n) <= -5e+184) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-20) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-198) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+166) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = -math.log((x / (1.0 + x))) / n tmp = 0 if (1.0 / n) <= -5e+184: tmp = t_0 elif (1.0 / n) <= -2e-20: tmp = t_1 elif (1.0 / n) <= -5e-198: tmp = (1.0 / n) / x elif (1.0 / n) <= 0.0002: tmp = t_1 elif (1.0 / n) <= 1e+166: tmp = t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+184) tmp = t_0; elseif (Float64(1.0 / n) <= -2e-20) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-198) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 0.0002) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+166) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = -log((x / (1.0 + x))) / n; tmp = 0.0; if ((1.0 / n) <= -5e+184) tmp = t_0; elseif ((1.0 / n) <= -2e-20) tmp = t_1; elseif ((1.0 / n) <= -5e-198) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 0.0002) tmp = t_1; elseif ((1.0 / n) <= 1e+166) tmp = t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+184], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-20], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-198], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+166], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+184}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-198}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+166}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999999e184 or 2.0000000000000001e-4 < (/.f64 1 n) < 9.9999999999999994e165Initial program 94.4%
Taylor expanded in x around 0 69.2%
if -4.9999999999999999e184 < (/.f64 1 n) < -1.99999999999999989e-20 or -4.9999999999999999e-198 < (/.f64 1 n) < 2.0000000000000001e-4Initial program 54.4%
Taylor expanded in n around inf 80.0%
log1p-def80.0%
Simplified80.0%
log1p-udef80.0%
diff-log80.1%
+-commutative80.1%
Applied egg-rr80.1%
clear-num80.1%
log-rec80.1%
Applied egg-rr80.1%
if -1.99999999999999989e-20 < (/.f64 1 n) < -4.9999999999999999e-198Initial program 22.7%
Taylor expanded in n around inf 44.7%
log1p-def44.7%
Simplified44.7%
Taylor expanded in x around inf 76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in x around 0 76.5%
associate-/r*78.3%
Simplified78.3%
if 9.9999999999999994e165 < (/.f64 1 n) Initial program 12.1%
Taylor expanded in n around inf 8.6%
log1p-def8.6%
Simplified8.6%
Taylor expanded in x around inf 61.8%
*-commutative61.8%
Simplified61.8%
Final simplification76.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 4.5e-268)
(/ (- (log x)) n)
(if (<= x 1.06e-240)
t_0
(if (<= x 3.9e-229)
(* (log x) (/ -1.0 n))
(if (<= x 7e-208)
(/ 1.0 (* n x))
(if (<= x 1.1e-205)
t_0
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (<= x 7.4e+98)
(/ (/ 1.0 n) x)
(if (or (<= x 2e+198) (not (<= x 1.35e+216)))
(/ 0.0 n)
(/ (/ 1.0 x) n)))))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 4.5e-268) {
tmp = -log(x) / n;
} else if (x <= 1.06e-240) {
tmp = t_0;
} else if (x <= 3.9e-229) {
tmp = log(x) * (-1.0 / n);
} else if (x <= 7e-208) {
tmp = 1.0 / (n * x);
} else if (x <= 1.1e-205) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 7.4e+98) {
tmp = (1.0 / n) / x;
} else if ((x <= 2e+198) || !(x <= 1.35e+216)) {
tmp = 0.0 / 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 4.5d-268) then
tmp = -log(x) / n
else if (x <= 1.06d-240) then
tmp = t_0
else if (x <= 3.9d-229) then
tmp = log(x) * ((-1.0d0) / n)
else if (x <= 7d-208) then
tmp = 1.0d0 / (n * x)
else if (x <= 1.1d-205) then
tmp = t_0
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 7.4d+98) then
tmp = (1.0d0 / n) / x
else if ((x <= 2d+198) .or. (.not. (x <= 1.35d+216))) then
tmp = 0.0d0 / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 4.5e-268) {
tmp = -Math.log(x) / n;
} else if (x <= 1.06e-240) {
tmp = t_0;
} else if (x <= 3.9e-229) {
tmp = Math.log(x) * (-1.0 / n);
} else if (x <= 7e-208) {
tmp = 1.0 / (n * x);
} else if (x <= 1.1e-205) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 7.4e+98) {
tmp = (1.0 / n) / x;
} else if ((x <= 2e+198) || !(x <= 1.35e+216)) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 4.5e-268: tmp = -math.log(x) / n elif x <= 1.06e-240: tmp = t_0 elif x <= 3.9e-229: tmp = math.log(x) * (-1.0 / n) elif x <= 7e-208: tmp = 1.0 / (n * x) elif x <= 1.1e-205: tmp = t_0 elif x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 7.4e+98: tmp = (1.0 / n) / x elif (x <= 2e+198) or not (x <= 1.35e+216): tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 4.5e-268) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.06e-240) tmp = t_0; elseif (x <= 3.9e-229) tmp = Float64(log(x) * Float64(-1.0 / n)); elseif (x <= 7e-208) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 1.1e-205) tmp = t_0; elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 7.4e+98) tmp = Float64(Float64(1.0 / n) / x); elseif ((x <= 2e+198) || !(x <= 1.35e+216)) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 4.5e-268) tmp = -log(x) / n; elseif (x <= 1.06e-240) tmp = t_0; elseif (x <= 3.9e-229) tmp = log(x) * (-1.0 / n); elseif (x <= 7e-208) tmp = 1.0 / (n * x); elseif (x <= 1.1e-205) tmp = t_0; elseif (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 7.4e+98) tmp = (1.0 / n) / x; elseif ((x <= 2e+198) || ~((x <= 1.35e+216))) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4.5e-268], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.06e-240], t$95$0, If[LessEqual[x, 3.9e-229], N[(N[Log[x], $MachinePrecision] * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7e-208], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.1e-205], t$95$0, If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 7.4e+98], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[Or[LessEqual[x, 2e+198], N[Not[LessEqual[x, 1.35e+216]], $MachinePrecision]], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 4.5 \cdot 10^{-268}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-240}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-229}:\\
\;\;\;\;\log x \cdot \frac{-1}{n}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-208}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-205}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+98}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+198} \lor \neg \left(x \leq 1.35 \cdot 10^{+216}\right):\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 4.5000000000000001e-268Initial program 34.6%
Taylor expanded in n around inf 67.0%
log1p-def67.0%
Simplified67.0%
Taylor expanded in x around 0 67.0%
neg-mul-167.0%
Simplified67.0%
if 4.5000000000000001e-268 < x < 1.06e-240 or 6.99999999999999982e-208 < x < 1.10000000000000005e-205Initial program 68.4%
Taylor expanded in x around 0 68.4%
if 1.06e-240 < x < 3.89999999999999985e-229Initial program 32.9%
Taylor expanded in n around inf 72.7%
log1p-def72.7%
Simplified72.7%
div-inv73.2%
Applied egg-rr73.2%
Taylor expanded in x around 0 73.2%
neg-mul-172.7%
Simplified73.2%
if 3.89999999999999985e-229 < x < 6.99999999999999982e-208Initial program 51.5%
Taylor expanded in n around inf 22.4%
log1p-def22.4%
Simplified22.4%
Taylor expanded in x around inf 68.3%
*-commutative68.3%
Simplified68.3%
if 1.10000000000000005e-205 < x < 1Initial program 39.0%
Taylor expanded in n around inf 58.9%
log1p-def58.9%
Simplified58.9%
log1p-udef58.9%
diff-log58.9%
+-commutative58.9%
Applied egg-rr58.9%
Taylor expanded in x around 0 58.9%
neg-mul-158.9%
sub-neg58.9%
Simplified58.9%
if 1 < x < 7.3999999999999997e98Initial program 41.0%
Taylor expanded in n around inf 38.2%
log1p-def38.2%
Simplified38.2%
Taylor expanded in x around inf 64.7%
*-commutative64.7%
Simplified64.7%
Taylor expanded in x around 0 64.7%
associate-/r*65.9%
Simplified65.9%
if 7.3999999999999997e98 < x < 2.00000000000000004e198 or 1.3500000000000001e216 < x Initial program 82.9%
flip3--46.6%
div-inv46.6%
add-exp-log46.6%
log-pow46.6%
+-commutative46.6%
log1p-udef46.6%
*-commutative46.6%
un-div-inv46.6%
pow-pow46.5%
Applied egg-rr46.6%
associate-*r/46.6%
*-rgt-identity46.6%
associate-*l/46.6%
metadata-eval46.6%
*-commutative46.6%
+-commutative46.6%
Simplified46.6%
Taylor expanded in n around -inf 82.9%
*-commutative82.9%
cancel-sign-sub-inv82.9%
log1p-def82.9%
log1p-def82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
metadata-eval82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in x around inf 82.9%
associate-*r/82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
mul0-rgt82.9%
metadata-eval82.9%
Simplified82.9%
if 2.00000000000000004e198 < x < 1.3500000000000001e216Initial program 53.8%
Taylor expanded in n around inf 53.8%
log1p-def53.8%
Simplified53.8%
Taylor expanded in x around inf 100.0%
Final simplification71.0%
(FPCore (x n)
:precision binary64
(if (<= x 3.1e-229)
(/ (- (log x)) n)
(if (<= x 7e-208)
(/ 1.0 (* n x))
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (<= x 6.2e+98)
(/ (/ 1.0 n) x)
(if (or (<= x 1.55e+202) (not (<= x 1.35e+216)))
(/ 0.0 n)
(/ (/ 1.0 x) n)))))))
double code(double x, double n) {
double tmp;
if (x <= 3.1e-229) {
tmp = -log(x) / n;
} else if (x <= 7e-208) {
tmp = 1.0 / (n * x);
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 6.2e+98) {
tmp = (1.0 / n) / x;
} else if ((x <= 1.55e+202) || !(x <= 1.35e+216)) {
tmp = 0.0 / 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 <= 3.1d-229) then
tmp = -log(x) / n
else if (x <= 7d-208) then
tmp = 1.0d0 / (n * x)
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 6.2d+98) then
tmp = (1.0d0 / n) / x
else if ((x <= 1.55d+202) .or. (.not. (x <= 1.35d+216))) then
tmp = 0.0d0 / 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 <= 3.1e-229) {
tmp = -Math.log(x) / n;
} else if (x <= 7e-208) {
tmp = 1.0 / (n * x);
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 6.2e+98) {
tmp = (1.0 / n) / x;
} else if ((x <= 1.55e+202) || !(x <= 1.35e+216)) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.1e-229: tmp = -math.log(x) / n elif x <= 7e-208: tmp = 1.0 / (n * x) elif x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 6.2e+98: tmp = (1.0 / n) / x elif (x <= 1.55e+202) or not (x <= 1.35e+216): tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 3.1e-229) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 7e-208) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 6.2e+98) tmp = Float64(Float64(1.0 / n) / x); elseif ((x <= 1.55e+202) || !(x <= 1.35e+216)) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.1e-229) tmp = -log(x) / n; elseif (x <= 7e-208) tmp = 1.0 / (n * x); elseif (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 6.2e+98) tmp = (1.0 / n) / x; elseif ((x <= 1.55e+202) || ~((x <= 1.35e+216))) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.1e-229], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 7e-208], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 6.2e+98], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[Or[LessEqual[x, 1.55e+202], N[Not[LessEqual[x, 1.35e+216]], $MachinePrecision]], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.1 \cdot 10^{-229}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-208}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{+98}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+202} \lor \neg \left(x \leq 1.35 \cdot 10^{+216}\right):\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 3.1000000000000001e-229Initial program 44.0%
Taylor expanded in n around inf 55.5%
log1p-def55.5%
Simplified55.5%
Taylor expanded in x around 0 55.5%
neg-mul-155.5%
Simplified55.5%
if 3.1000000000000001e-229 < x < 6.99999999999999982e-208Initial program 51.5%
Taylor expanded in n around inf 22.4%
log1p-def22.4%
Simplified22.4%
Taylor expanded in x around inf 68.3%
*-commutative68.3%
Simplified68.3%
if 6.99999999999999982e-208 < x < 1Initial program 40.1%
Taylor expanded in n around inf 58.1%
log1p-def58.1%
Simplified58.1%
log1p-udef58.1%
diff-log58.1%
+-commutative58.1%
Applied egg-rr58.1%
Taylor expanded in x around 0 58.1%
neg-mul-158.1%
sub-neg58.1%
Simplified58.1%
if 1 < x < 6.20000000000000038e98Initial program 41.0%
Taylor expanded in n around inf 38.2%
log1p-def38.2%
Simplified38.2%
Taylor expanded in x around inf 64.7%
*-commutative64.7%
Simplified64.7%
Taylor expanded in x around 0 64.7%
associate-/r*65.9%
Simplified65.9%
if 6.20000000000000038e98 < x < 1.54999999999999996e202 or 1.3500000000000001e216 < x Initial program 82.9%
flip3--46.6%
div-inv46.6%
add-exp-log46.6%
log-pow46.6%
+-commutative46.6%
log1p-udef46.6%
*-commutative46.6%
un-div-inv46.6%
pow-pow46.5%
Applied egg-rr46.6%
associate-*r/46.6%
*-rgt-identity46.6%
associate-*l/46.6%
metadata-eval46.6%
*-commutative46.6%
+-commutative46.6%
Simplified46.6%
Taylor expanded in n around -inf 82.9%
*-commutative82.9%
cancel-sign-sub-inv82.9%
log1p-def82.9%
log1p-def82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
metadata-eval82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in x around inf 82.9%
associate-*r/82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
mul0-rgt82.9%
metadata-eval82.9%
Simplified82.9%
if 1.54999999999999996e202 < x < 1.3500000000000001e216Initial program 53.8%
Taylor expanded in n around inf 53.8%
log1p-def53.8%
Simplified53.8%
Taylor expanded in x around inf 100.0%
Final simplification68.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 3.9e-229)
t_0
(if (<= x 7e-208)
(/ 1.0 (* n x))
(if (<= x 0.55)
t_0
(if (<= x 2.45e+97)
(/ (/ 1.0 n) x)
(if (or (<= x 4.7e+198) (not (<= x 1.35e+216)))
(/ 0.0 n)
(/ (/ 1.0 x) n))))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 3.9e-229) {
tmp = t_0;
} else if (x <= 7e-208) {
tmp = 1.0 / (n * x);
} else if (x <= 0.55) {
tmp = t_0;
} else if (x <= 2.45e+97) {
tmp = (1.0 / n) / x;
} else if ((x <= 4.7e+198) || !(x <= 1.35e+216)) {
tmp = 0.0 / 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) :: t_0
real(8) :: tmp
t_0 = -log(x) / n
if (x <= 3.9d-229) then
tmp = t_0
else if (x <= 7d-208) then
tmp = 1.0d0 / (n * x)
else if (x <= 0.55d0) then
tmp = t_0
else if (x <= 2.45d+97) then
tmp = (1.0d0 / n) / x
else if ((x <= 4.7d+198) .or. (.not. (x <= 1.35d+216))) then
tmp = 0.0d0 / n
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 <= 3.9e-229) {
tmp = t_0;
} else if (x <= 7e-208) {
tmp = 1.0 / (n * x);
} else if (x <= 0.55) {
tmp = t_0;
} else if (x <= 2.45e+97) {
tmp = (1.0 / n) / x;
} else if ((x <= 4.7e+198) || !(x <= 1.35e+216)) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 3.9e-229: tmp = t_0 elif x <= 7e-208: tmp = 1.0 / (n * x) elif x <= 0.55: tmp = t_0 elif x <= 2.45e+97: tmp = (1.0 / n) / x elif (x <= 4.7e+198) or not (x <= 1.35e+216): tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 3.9e-229) tmp = t_0; elseif (x <= 7e-208) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 0.55) tmp = t_0; elseif (x <= 2.45e+97) tmp = Float64(Float64(1.0 / n) / x); elseif ((x <= 4.7e+198) || !(x <= 1.35e+216)) tmp = Float64(0.0 / n); 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 <= 3.9e-229) tmp = t_0; elseif (x <= 7e-208) tmp = 1.0 / (n * x); elseif (x <= 0.55) tmp = t_0; elseif (x <= 2.45e+97) tmp = (1.0 / n) / x; elseif ((x <= 4.7e+198) || ~((x <= 1.35e+216))) tmp = 0.0 / n; 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, 3.9e-229], t$95$0, If[LessEqual[x, 7e-208], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.55], t$95$0, If[LessEqual[x, 2.45e+97], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[Or[LessEqual[x, 4.7e+198], N[Not[LessEqual[x, 1.35e+216]], $MachinePrecision]], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 3.9 \cdot 10^{-229}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-208}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 0.55:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.45 \cdot 10^{+97}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{+198} \lor \neg \left(x \leq 1.35 \cdot 10^{+216}\right):\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 3.89999999999999985e-229 or 6.99999999999999982e-208 < x < 0.55000000000000004Initial program 41.4%
Taylor expanded in n around inf 57.2%
log1p-def57.2%
Simplified57.2%
Taylor expanded in x around 0 57.0%
neg-mul-157.0%
Simplified57.0%
if 3.89999999999999985e-229 < x < 6.99999999999999982e-208Initial program 51.5%
Taylor expanded in n around inf 22.4%
log1p-def22.4%
Simplified22.4%
Taylor expanded in x around inf 68.3%
*-commutative68.3%
Simplified68.3%
if 0.55000000000000004 < x < 2.44999999999999982e97Initial program 41.0%
Taylor expanded in n around inf 38.2%
log1p-def38.2%
Simplified38.2%
Taylor expanded in x around inf 64.7%
*-commutative64.7%
Simplified64.7%
Taylor expanded in x around 0 64.7%
associate-/r*65.9%
Simplified65.9%
if 2.44999999999999982e97 < x < 4.7000000000000002e198 or 1.3500000000000001e216 < x Initial program 82.9%
flip3--46.6%
div-inv46.6%
add-exp-log46.6%
log-pow46.6%
+-commutative46.6%
log1p-udef46.6%
*-commutative46.6%
un-div-inv46.6%
pow-pow46.5%
Applied egg-rr46.6%
associate-*r/46.6%
*-rgt-identity46.6%
associate-*l/46.6%
metadata-eval46.6%
*-commutative46.6%
+-commutative46.6%
Simplified46.6%
Taylor expanded in n around -inf 82.9%
*-commutative82.9%
cancel-sign-sub-inv82.9%
log1p-def82.9%
log1p-def82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
metadata-eval82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in x around inf 82.9%
associate-*r/82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
mul0-rgt82.9%
metadata-eval82.9%
Simplified82.9%
if 4.7000000000000002e198 < x < 1.3500000000000001e216Initial program 53.8%
Taylor expanded in n around inf 53.8%
log1p-def53.8%
Simplified53.8%
Taylor expanded in x around inf 100.0%
Final simplification68.4%
(FPCore (x n) :precision binary64 (if (or (<= n -0.017) (not (<= n -3.3e-183))) (/ 1.0 (* n x)) (/ 0.0 n)))
double code(double x, double n) {
double tmp;
if ((n <= -0.017) || !(n <= -3.3e-183)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-0.017d0)) .or. (.not. (n <= (-3.3d-183)))) then
tmp = 1.0d0 / (n * x)
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -0.017) || !(n <= -3.3e-183)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -0.017) or not (n <= -3.3e-183): tmp = 1.0 / (n * x) else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if ((n <= -0.017) || !(n <= -3.3e-183)) tmp = Float64(1.0 / Float64(n * x)); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -0.017) || ~((n <= -3.3e-183))) tmp = 1.0 / (n * x); else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -0.017], N[Not[LessEqual[n, -3.3e-183]], $MachinePrecision]], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.017 \lor \neg \left(n \leq -3.3 \cdot 10^{-183}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if n < -0.017000000000000001 or -3.3e-183 < n Initial program 47.0%
Taylor expanded in n around inf 60.7%
log1p-def60.7%
Simplified60.7%
Taylor expanded in x around inf 48.1%
*-commutative48.1%
Simplified48.1%
if -0.017000000000000001 < n < -3.3e-183Initial program 100.0%
flip3--0.0%
div-inv0.0%
add-exp-log0.0%
log-pow0.0%
+-commutative0.0%
log1p-udef0.0%
*-commutative0.0%
un-div-inv0.0%
pow-pow0.0%
Applied egg-rr0.0%
associate-*r/0.0%
*-rgt-identity0.0%
associate-*l/0.0%
metadata-eval0.0%
*-commutative0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in n around -inf 64.0%
*-commutative64.0%
cancel-sign-sub-inv64.0%
log1p-def64.0%
log1p-def64.0%
distribute-rgt-out64.0%
metadata-eval64.0%
metadata-eval64.0%
*-commutative64.0%
Simplified64.0%
Taylor expanded in x around inf 65.5%
associate-*r/65.5%
distribute-rgt-out65.5%
metadata-eval65.5%
mul0-rgt65.5%
metadata-eval65.5%
Simplified65.5%
Final simplification50.8%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -20000000.0) (/ 0.0 n) (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000000.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-20000000.0d0)) then
tmp = 0.0d0 / n
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000000.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -20000000.0: tmp = 0.0 / n else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -20000000.0) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -20000000.0) tmp = 0.0 / n; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -20000000.0], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -20000000:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e7Initial program 100.0%
flip3--0.0%
div-inv0.0%
add-exp-log0.0%
log-pow0.0%
+-commutative0.0%
log1p-udef0.0%
*-commutative0.0%
un-div-inv0.0%
pow-pow0.0%
Applied egg-rr0.0%
associate-*r/0.0%
*-rgt-identity0.0%
associate-*l/0.0%
metadata-eval0.0%
*-commutative0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in n around -inf 55.3%
*-commutative55.3%
cancel-sign-sub-inv55.3%
log1p-def55.3%
log1p-def55.3%
distribute-rgt-out55.3%
metadata-eval55.3%
metadata-eval55.3%
*-commutative55.3%
Simplified55.3%
Taylor expanded in x around inf 56.4%
associate-*r/56.4%
distribute-rgt-out56.4%
metadata-eval56.4%
mul0-rgt56.4%
metadata-eval56.4%
Simplified56.4%
if -2e7 < (/.f64 1 n) Initial program 38.4%
Taylor expanded in n around inf 63.4%
log1p-def63.4%
Simplified63.4%
Taylor expanded in x around inf 48.5%
*-commutative48.5%
Simplified48.5%
Taylor expanded in x around 0 48.5%
associate-/r*49.6%
Simplified49.6%
Final simplification51.4%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -20000000.0) (/ 0.0 n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000000.0) {
tmp = 0.0 / 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 ((1.0d0 / n) <= (-20000000.0d0)) then
tmp = 0.0d0 / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000000.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -20000000.0: tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -20000000.0) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -20000000.0) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -20000000.0], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -20000000:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e7Initial program 100.0%
flip3--0.0%
div-inv0.0%
add-exp-log0.0%
log-pow0.0%
+-commutative0.0%
log1p-udef0.0%
*-commutative0.0%
un-div-inv0.0%
pow-pow0.0%
Applied egg-rr0.0%
associate-*r/0.0%
*-rgt-identity0.0%
associate-*l/0.0%
metadata-eval0.0%
*-commutative0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in n around -inf 55.3%
*-commutative55.3%
cancel-sign-sub-inv55.3%
log1p-def55.3%
log1p-def55.3%
distribute-rgt-out55.3%
metadata-eval55.3%
metadata-eval55.3%
*-commutative55.3%
Simplified55.3%
Taylor expanded in x around inf 56.4%
associate-*r/56.4%
distribute-rgt-out56.4%
metadata-eval56.4%
mul0-rgt56.4%
metadata-eval56.4%
Simplified56.4%
if -2e7 < (/.f64 1 n) Initial program 38.4%
Taylor expanded in n around inf 63.4%
log1p-def63.4%
Simplified63.4%
Taylor expanded in x around inf 49.6%
Final simplification51.5%
(FPCore (x n) :precision binary64 (/ 0.0 n))
double code(double x, double n) {
return 0.0 / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0 / n
end function
public static double code(double x, double n) {
return 0.0 / n;
}
def code(x, n): return 0.0 / n
function code(x, n) return Float64(0.0 / n) end
function tmp = code(x, n) tmp = 0.0 / n; end
code[x_, n_] := N[(0.0 / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{n}
\end{array}
Initial program 55.3%
flip3--27.2%
div-inv27.2%
add-exp-log27.2%
log-pow27.2%
+-commutative27.2%
log1p-udef31.7%
*-commutative31.7%
un-div-inv31.7%
pow-pow31.7%
Applied egg-rr27.2%
associate-*r/27.2%
*-rgt-identity27.2%
associate-*l/27.2%
metadata-eval27.2%
*-commutative27.2%
+-commutative27.2%
Simplified27.2%
Taylor expanded in n around -inf 61.4%
*-commutative61.4%
cancel-sign-sub-inv61.4%
log1p-def61.4%
log1p-def61.4%
distribute-rgt-out61.4%
metadata-eval61.4%
metadata-eval61.4%
*-commutative61.4%
Simplified61.4%
Taylor expanded in x around inf 35.1%
associate-*r/35.1%
distribute-rgt-out35.1%
metadata-eval35.1%
mul0-rgt35.1%
metadata-eval35.1%
Simplified35.1%
Final simplification35.1%
herbie shell --seed 2024029
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))