
(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 13 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 (<= (/ 1.0 n) -2e-22)
(/ (/ (exp (/ (log x) n)) n) x)
(if (<= (/ 1.0 n) 4e-52)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1000.0)
(/ t_0 (* n x))
(pow (sqrt (- (exp (/ (log1p x) n)) t_0)) 2.0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = (exp((log(x) / n)) / n) / x;
} else if ((1.0 / n) <= 4e-52) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else {
tmp = pow(sqrt((exp((log1p(x) / n)) - t_0)), 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) <= -2e-22) {
tmp = (Math.exp((Math.log(x) / n)) / n) / x;
} else if ((1.0 / n) <= 4e-52) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else {
tmp = Math.pow(Math.sqrt((Math.exp((Math.log1p(x) / n)) - t_0)), 2.0);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-22: tmp = (math.exp((math.log(x) / n)) / n) / x elif (1.0 / n) <= 4e-52: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 1000.0: tmp = t_0 / (n * x) else: tmp = math.pow(math.sqrt((math.exp((math.log1p(x) / n)) - t_0)), 2.0) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-22) tmp = Float64(Float64(exp(Float64(log(x) / n)) / n) / x); elseif (Float64(1.0 / n) <= 4e-52) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1000.0) tmp = Float64(t_0 / Float64(n * x)); else tmp = sqrt(Float64(exp(Float64(log1p(x) / n)) - t_0)) ^ 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], -2e-22], N[(N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-52], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[Power[N[Sqrt[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{e^{\frac{\log x}{n}}}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-52}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1000:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0}\right)}^{2}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-22Initial program 95.1%
Taylor expanded in x around inf 97.1%
log-rec97.1%
mul-1-neg97.1%
associate-*r/97.1%
neg-mul-197.1%
mul-1-neg97.1%
remove-double-neg97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in x around 0 97.1%
associate-/r*97.2%
*-lft-identity97.2%
associate-*r/97.2%
associate-*l/97.2%
*-commutative97.2%
exp-to-pow97.1%
Simplified97.1%
Taylor expanded in x around 0 97.2%
if -2.0000000000000001e-22 < (/.f64 1 n) < 4e-52Initial program 35.4%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
if 4e-52 < (/.f64 1 n) < 1e3Initial program 5.0%
Taylor expanded in x around inf 82.7%
log-rec82.7%
mul-1-neg82.7%
associate-*r/82.7%
neg-mul-182.7%
mul-1-neg82.7%
remove-double-neg82.7%
*-commutative82.7%
Simplified82.7%
Taylor expanded in x around 0 82.7%
associate-/r*82.4%
*-lft-identity82.4%
associate-*r/82.4%
associate-*l/82.4%
*-commutative82.4%
exp-to-pow82.4%
Simplified82.4%
add082.4%
associate-/l/82.7%
Applied egg-rr82.7%
add082.7%
Simplified82.7%
if 1e3 < (/.f64 1 n) Initial program 67.2%
add-sqr-sqrt67.2%
pow267.2%
pow-to-exp67.2%
un-div-inv67.2%
+-commutative67.2%
log1p-define99.8%
Applied egg-rr99.8%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n))
(t_1 (log1p (expm1 (/ 1.0 (* n x)))))
(t_2 (pow x (/ 1.0 n))))
(if (<= x 1.7e-142)
t_0
(if (<= x 8.4e-134)
(- 1.0 t_2)
(if (<= x 1.55e-116)
t_0
(if (<= x 7.2e-96)
t_1
(if (<= x 4.1e-84)
t_0
(if (<= x 1.75e-74)
(- (+ 1.0 (/ x n)) t_2)
(if (<= x 2.85e-68)
t_1
(if (<= x 2.55e-11)
(/ (- x (log x)) n)
(/ (/ t_2 n) x)))))))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double t_1 = log1p(expm1((1.0 / (n * x))));
double t_2 = pow(x, (1.0 / n));
double tmp;
if (x <= 1.7e-142) {
tmp = t_0;
} else if (x <= 8.4e-134) {
tmp = 1.0 - t_2;
} else if (x <= 1.55e-116) {
tmp = t_0;
} else if (x <= 7.2e-96) {
tmp = t_1;
} else if (x <= 4.1e-84) {
tmp = t_0;
} else if (x <= 1.75e-74) {
tmp = (1.0 + (x / n)) - t_2;
} else if (x <= 2.85e-68) {
tmp = t_1;
} else if (x <= 2.55e-11) {
tmp = (x - log(x)) / n;
} else {
tmp = (t_2 / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double t_1 = Math.log1p(Math.expm1((1.0 / (n * x))));
double t_2 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.7e-142) {
tmp = t_0;
} else if (x <= 8.4e-134) {
tmp = 1.0 - t_2;
} else if (x <= 1.55e-116) {
tmp = t_0;
} else if (x <= 7.2e-96) {
tmp = t_1;
} else if (x <= 4.1e-84) {
tmp = t_0;
} else if (x <= 1.75e-74) {
tmp = (1.0 + (x / n)) - t_2;
} else if (x <= 2.85e-68) {
tmp = t_1;
} else if (x <= 2.55e-11) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (t_2 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n t_1 = math.log1p(math.expm1((1.0 / (n * x)))) t_2 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.7e-142: tmp = t_0 elif x <= 8.4e-134: tmp = 1.0 - t_2 elif x <= 1.55e-116: tmp = t_0 elif x <= 7.2e-96: tmp = t_1 elif x <= 4.1e-84: tmp = t_0 elif x <= 1.75e-74: tmp = (1.0 + (x / n)) - t_2 elif x <= 2.85e-68: tmp = t_1 elif x <= 2.55e-11: tmp = (x - math.log(x)) / n else: tmp = (t_2 / n) / x return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) t_1 = log1p(expm1(Float64(1.0 / Float64(n * x)))) t_2 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1.7e-142) tmp = t_0; elseif (x <= 8.4e-134) tmp = Float64(1.0 - t_2); elseif (x <= 1.55e-116) tmp = t_0; elseif (x <= 7.2e-96) tmp = t_1; elseif (x <= 4.1e-84) tmp = t_0; elseif (x <= 1.75e-74) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_2); elseif (x <= 2.85e-68) tmp = t_1; elseif (x <= 2.55e-11) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(t_2 / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[Log[1 + N[(Exp[N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.7e-142], t$95$0, If[LessEqual[x, 8.4e-134], N[(1.0 - t$95$2), $MachinePrecision], If[LessEqual[x, 1.55e-116], t$95$0, If[LessEqual[x, 7.2e-96], t$95$1, If[LessEqual[x, 4.1e-84], t$95$0, If[LessEqual[x, 1.75e-74], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision], If[LessEqual[x, 2.85e-68], t$95$1, If[LessEqual[x, 2.55e-11], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(t$95$2 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n \cdot x}\right)\right)\\
t_2 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.7 \cdot 10^{-142}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.4 \cdot 10^{-134}:\\
\;\;\;\;1 - t\_2\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-116}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-96}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{-84}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-74}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_2\\
\mathbf{elif}\;x \leq 2.85 \cdot 10^{-68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-11}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_2}{n}}{x}\\
\end{array}
\end{array}
if x < 1.70000000000000014e-142 or 8.3999999999999996e-134 < x < 1.55000000000000009e-116 or 7.20000000000000016e-96 < x < 4.10000000000000005e-84Initial program 34.4%
Taylor expanded in x around 0 34.4%
Taylor expanded in n around inf 64.5%
associate-*r/64.5%
mul-1-neg64.5%
Simplified64.5%
if 1.70000000000000014e-142 < x < 8.3999999999999996e-134Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.55000000000000009e-116 < x < 7.20000000000000016e-96 or 1.75000000000000007e-74 < x < 2.8500000000000001e-68Initial program 51.9%
Taylor expanded in x around inf 51.4%
log-rec51.4%
mul-1-neg51.4%
associate-*r/51.4%
neg-mul-151.4%
mul-1-neg51.4%
remove-double-neg51.4%
*-commutative51.4%
Simplified51.4%
Taylor expanded in n around inf 34.3%
log1p-expm1-u81.2%
Applied egg-rr81.2%
if 4.10000000000000005e-84 < x < 1.75000000000000007e-74Initial program 81.7%
Taylor expanded in x around 0 82.2%
if 2.8500000000000001e-68 < x < 2.54999999999999992e-11Initial program 35.9%
Taylor expanded in x around 0 32.2%
Taylor expanded in n around inf 65.9%
if 2.54999999999999992e-11 < x Initial program 67.1%
Taylor expanded in x around inf 95.2%
log-rec95.2%
mul-1-neg95.2%
associate-*r/95.2%
neg-mul-195.2%
mul-1-neg95.2%
remove-double-neg95.2%
*-commutative95.2%
Simplified95.2%
Taylor expanded in x around 0 95.2%
associate-/r*96.8%
*-lft-identity96.8%
associate-*r/96.8%
associate-*l/96.8%
*-commutative96.8%
exp-to-pow96.7%
Simplified96.7%
Final simplification82.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-22)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 4e-52)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1000.0)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e+179)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 4e-52) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+179) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 4e-52) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+179) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-22: tmp = (t_0 / n) / x elif (1.0 / n) <= 4e-52: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 1000.0: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e+179: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-22) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 4e-52) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1000.0) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e+179) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-22], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-52], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+179], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-52}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1000:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+179}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-22Initial program 95.1%
Taylor expanded in x around inf 97.1%
log-rec97.1%
mul-1-neg97.1%
associate-*r/97.1%
neg-mul-197.1%
mul-1-neg97.1%
remove-double-neg97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in x around 0 97.1%
associate-/r*97.2%
*-lft-identity97.2%
associate-*r/97.2%
associate-*l/97.2%
*-commutative97.2%
exp-to-pow97.1%
Simplified97.1%
if -2.0000000000000001e-22 < (/.f64 1 n) < 4e-52Initial program 35.4%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
if 4e-52 < (/.f64 1 n) < 1e3Initial program 5.0%
Taylor expanded in x around inf 82.7%
log-rec82.7%
mul-1-neg82.7%
associate-*r/82.7%
neg-mul-182.7%
mul-1-neg82.7%
remove-double-neg82.7%
*-commutative82.7%
Simplified82.7%
Taylor expanded in x around 0 82.7%
associate-/r*82.4%
*-lft-identity82.4%
associate-*r/82.4%
associate-*l/82.4%
*-commutative82.4%
exp-to-pow82.4%
Simplified82.4%
add082.4%
associate-/l/82.7%
Applied egg-rr82.7%
add082.7%
Simplified82.7%
if 1e3 < (/.f64 1 n) < 1.99999999999999996e179Initial program 95.9%
Taylor expanded in x around 0 86.5%
if 1.99999999999999996e179 < (/.f64 1 n) Initial program 15.2%
Taylor expanded in x around inf 0.4%
log-rec0.4%
mul-1-neg0.4%
associate-*r/0.4%
neg-mul-10.4%
mul-1-neg0.4%
remove-double-neg0.4%
*-commutative0.4%
Simplified0.4%
Taylor expanded in n around inf 57.2%
add-sqr-sqrt57.2%
sqrt-unprod82.5%
inv-pow82.5%
inv-pow82.5%
pow-prod-up82.5%
metadata-eval82.5%
Applied egg-rr82.5%
Final simplification85.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-22)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 4e-52)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1000.0)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e+179)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 4e-52) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+179) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 4e-52) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+179) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-22: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 4e-52: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 1000.0: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e+179: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-22) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e-52) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1000.0) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e+179) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-22], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-52], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+179], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-22}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-52}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1000:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+179}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-22Initial program 95.1%
Taylor expanded in x around inf 97.1%
log-rec97.1%
mul-1-neg97.1%
associate-*r/97.1%
neg-mul-197.1%
mul-1-neg97.1%
remove-double-neg97.1%
*-commutative97.1%
Simplified97.1%
if -2.0000000000000001e-22 < (/.f64 1 n) < 4e-52Initial program 35.4%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
if 4e-52 < (/.f64 1 n) < 1e3Initial program 5.0%
Taylor expanded in x around inf 82.7%
log-rec82.7%
mul-1-neg82.7%
associate-*r/82.7%
neg-mul-182.7%
mul-1-neg82.7%
remove-double-neg82.7%
*-commutative82.7%
Simplified82.7%
Taylor expanded in x around 0 82.7%
associate-/r*82.4%
*-lft-identity82.4%
associate-*r/82.4%
associate-*l/82.4%
*-commutative82.4%
exp-to-pow82.4%
Simplified82.4%
add082.4%
associate-/l/82.7%
Applied egg-rr82.7%
add082.7%
Simplified82.7%
if 1e3 < (/.f64 1 n) < 1.99999999999999996e179Initial program 95.9%
Taylor expanded in x around 0 86.5%
if 1.99999999999999996e179 < (/.f64 1 n) Initial program 15.2%
Taylor expanded in x around inf 0.4%
log-rec0.4%
mul-1-neg0.4%
associate-*r/0.4%
neg-mul-10.4%
mul-1-neg0.4%
remove-double-neg0.4%
*-commutative0.4%
Simplified0.4%
Taylor expanded in n around inf 57.2%
add-sqr-sqrt57.2%
sqrt-unprod82.5%
inv-pow82.5%
inv-pow82.5%
pow-prod-up82.5%
metadata-eval82.5%
Applied egg-rr82.5%
Final simplification85.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-22)
(/ (/ (exp (/ (log x) n)) n) x)
(if (<= (/ 1.0 n) 4e-52)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1000.0)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e+179)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = (exp((log(x) / n)) / n) / x;
} else if ((1.0 / n) <= 4e-52) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+179) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = (Math.exp((Math.log(x) / n)) / n) / x;
} else if ((1.0 / n) <= 4e-52) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+179) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-22: tmp = (math.exp((math.log(x) / n)) / n) / x elif (1.0 / n) <= 4e-52: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 1000.0: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e+179: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-22) tmp = Float64(Float64(exp(Float64(log(x) / n)) / n) / x); elseif (Float64(1.0 / n) <= 4e-52) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1000.0) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e+179) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-22], N[(N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-52], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+179], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{e^{\frac{\log x}{n}}}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-52}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1000:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+179}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-22Initial program 95.1%
Taylor expanded in x around inf 97.1%
log-rec97.1%
mul-1-neg97.1%
associate-*r/97.1%
neg-mul-197.1%
mul-1-neg97.1%
remove-double-neg97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in x around 0 97.1%
associate-/r*97.2%
*-lft-identity97.2%
associate-*r/97.2%
associate-*l/97.2%
*-commutative97.2%
exp-to-pow97.1%
Simplified97.1%
Taylor expanded in x around 0 97.2%
if -2.0000000000000001e-22 < (/.f64 1 n) < 4e-52Initial program 35.4%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
if 4e-52 < (/.f64 1 n) < 1e3Initial program 5.0%
Taylor expanded in x around inf 82.7%
log-rec82.7%
mul-1-neg82.7%
associate-*r/82.7%
neg-mul-182.7%
mul-1-neg82.7%
remove-double-neg82.7%
*-commutative82.7%
Simplified82.7%
Taylor expanded in x around 0 82.7%
associate-/r*82.4%
*-lft-identity82.4%
associate-*r/82.4%
associate-*l/82.4%
*-commutative82.4%
exp-to-pow82.4%
Simplified82.4%
add082.4%
associate-/l/82.7%
Applied egg-rr82.7%
add082.7%
Simplified82.7%
if 1e3 < (/.f64 1 n) < 1.99999999999999996e179Initial program 95.9%
Taylor expanded in x around 0 86.5%
if 1.99999999999999996e179 < (/.f64 1 n) Initial program 15.2%
Taylor expanded in x around inf 0.4%
log-rec0.4%
mul-1-neg0.4%
associate-*r/0.4%
neg-mul-10.4%
mul-1-neg0.4%
remove-double-neg0.4%
*-commutative0.4%
Simplified0.4%
Taylor expanded in n around inf 57.2%
add-sqr-sqrt57.2%
sqrt-unprod82.5%
inv-pow82.5%
inv-pow82.5%
pow-prod-up82.5%
metadata-eval82.5%
Applied egg-rr82.5%
Final simplification85.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-22)
(/ (/ (exp (/ (log x) n)) n) x)
(if (<= (/ 1.0 n) 4e-52)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1000.0) (/ t_0 (* n x)) (- (exp (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = (exp((log(x) / n)) / n) / x;
} else if ((1.0 / n) <= 4e-52) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-22) {
tmp = (Math.exp((Math.log(x) / n)) / n) / x;
} else if ((1.0 / n) <= 4e-52) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_0 / (n * x);
} 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) <= -2e-22: tmp = (math.exp((math.log(x) / n)) / n) / x elif (1.0 / n) <= 4e-52: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 1000.0: tmp = t_0 / (n * x) else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-22) tmp = Float64(Float64(exp(Float64(log(x) / n)) / n) / x); elseif (Float64(1.0 / n) <= 4e-52) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1000.0) tmp = Float64(t_0 / Float64(n * x)); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-22], N[(N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-52], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $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 -2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\frac{e^{\frac{\log x}{n}}}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-52}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1000:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-22Initial program 95.1%
Taylor expanded in x around inf 97.1%
log-rec97.1%
mul-1-neg97.1%
associate-*r/97.1%
neg-mul-197.1%
mul-1-neg97.1%
remove-double-neg97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in x around 0 97.1%
associate-/r*97.2%
*-lft-identity97.2%
associate-*r/97.2%
associate-*l/97.2%
*-commutative97.2%
exp-to-pow97.1%
Simplified97.1%
Taylor expanded in x around 0 97.2%
if -2.0000000000000001e-22 < (/.f64 1 n) < 4e-52Initial program 35.4%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
if 4e-52 < (/.f64 1 n) < 1e3Initial program 5.0%
Taylor expanded in x around inf 82.7%
log-rec82.7%
mul-1-neg82.7%
associate-*r/82.7%
neg-mul-182.7%
mul-1-neg82.7%
remove-double-neg82.7%
*-commutative82.7%
Simplified82.7%
Taylor expanded in x around 0 82.7%
associate-/r*82.4%
*-lft-identity82.4%
associate-*r/82.4%
associate-*l/82.4%
*-commutative82.4%
exp-to-pow82.4%
Simplified82.4%
add082.4%
associate-/l/82.7%
Applied egg-rr82.7%
add082.7%
Simplified82.7%
if 1e3 < (/.f64 1 n) Initial program 67.2%
Taylor expanded in n around 0 67.2%
log1p-define99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 1.7e-142)
(/ (- (log x)) n)
(if (<= x 7.5e-134)
(- 1.0 t_0)
(if (<= x 2.55e-11) (/ (- x (log x)) n) (/ (/ t_0 n) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 1.7e-142) {
tmp = -log(x) / n;
} else if (x <= 7.5e-134) {
tmp = 1.0 - t_0;
} else if (x <= 2.55e-11) {
tmp = (x - log(x)) / n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 1.7d-142) then
tmp = -log(x) / n
else if (x <= 7.5d-134) then
tmp = 1.0d0 - t_0
else if (x <= 2.55d-11) then
tmp = (x - log(x)) / n
else
tmp = (t_0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.7e-142) {
tmp = -Math.log(x) / n;
} else if (x <= 7.5e-134) {
tmp = 1.0 - t_0;
} else if (x <= 2.55e-11) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.7e-142: tmp = -math.log(x) / n elif x <= 7.5e-134: tmp = 1.0 - t_0 elif x <= 2.55e-11: tmp = (x - math.log(x)) / n else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1.7e-142) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 7.5e-134) tmp = Float64(1.0 - t_0); elseif (x <= 2.55e-11) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 1.7e-142) tmp = -log(x) / n; elseif (x <= 7.5e-134) tmp = 1.0 - t_0; elseif (x <= 2.55e-11) tmp = (x - log(x)) / n; else tmp = (t_0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.7e-142], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 7.5e-134], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 2.55e-11], N[(N[(x - N[Log[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 1.7 \cdot 10^{-142}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-134}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-11}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.70000000000000014e-142Initial program 37.4%
Taylor expanded in x around 0 37.4%
Taylor expanded in n around inf 60.7%
associate-*r/60.7%
mul-1-neg60.7%
Simplified60.7%
if 1.70000000000000014e-142 < x < 7.50000000000000048e-134Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 7.50000000000000048e-134 < x < 2.54999999999999992e-11Initial program 39.3%
Taylor expanded in x around 0 37.5%
Taylor expanded in n around inf 57.0%
if 2.54999999999999992e-11 < x Initial program 67.1%
Taylor expanded in x around inf 95.2%
log-rec95.2%
mul-1-neg95.2%
associate-*r/95.2%
neg-mul-195.2%
mul-1-neg95.2%
remove-double-neg95.2%
*-commutative95.2%
Simplified95.2%
Taylor expanded in x around 0 95.2%
associate-/r*96.8%
*-lft-identity96.8%
associate-*r/96.8%
associate-*l/96.8%
*-commutative96.8%
exp-to-pow96.7%
Simplified96.7%
Final simplification79.2%
(FPCore (x n)
:precision binary64
(if (<= x 1.7e-142)
(/ (- (log x)) n)
(if (<= x 2.1e-133)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.000114)
(/ (- x (log x)) n)
(if (<= x 2.42e+123) (/ (/ 1.0 n) x) (/ 0.0 n))))))
double code(double x, double n) {
double tmp;
if (x <= 1.7e-142) {
tmp = -log(x) / n;
} else if (x <= 2.1e-133) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.000114) {
tmp = (x - log(x)) / n;
} else if (x <= 2.42e+123) {
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 (x <= 1.7d-142) then
tmp = -log(x) / n
else if (x <= 2.1d-133) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.000114d0) then
tmp = (x - log(x)) / n
else if (x <= 2.42d+123) 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 (x <= 1.7e-142) {
tmp = -Math.log(x) / n;
} else if (x <= 2.1e-133) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.000114) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.42e+123) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.7e-142: tmp = -math.log(x) / n elif x <= 2.1e-133: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.000114: tmp = (x - math.log(x)) / n elif x <= 2.42e+123: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.7e-142) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.1e-133) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.000114) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.42e+123) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.7e-142) tmp = -log(x) / n; elseif (x <= 2.1e-133) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.000114) tmp = (x - log(x)) / n; elseif (x <= 2.42e+123) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.7e-142], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.1e-133], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.000114], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.42e+123], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7 \cdot 10^{-142}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-133}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.000114:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.42 \cdot 10^{+123}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.70000000000000014e-142Initial program 37.4%
Taylor expanded in x around 0 37.4%
Taylor expanded in n around inf 60.7%
associate-*r/60.7%
mul-1-neg60.7%
Simplified60.7%
if 1.70000000000000014e-142 < x < 2.1000000000000001e-133Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 2.1000000000000001e-133 < x < 1.1400000000000001e-4Initial program 42.0%
Taylor expanded in x around 0 38.6%
Taylor expanded in n around inf 54.7%
if 1.1400000000000001e-4 < x < 2.4200000000000001e123Initial program 42.5%
Taylor expanded in x around inf 94.1%
log-rec94.1%
mul-1-neg94.1%
associate-*r/94.1%
neg-mul-194.1%
mul-1-neg94.1%
remove-double-neg94.1%
*-commutative94.1%
Simplified94.1%
Taylor expanded in x around 0 94.1%
associate-/r*95.2%
*-lft-identity95.2%
associate-*r/95.2%
associate-*l/95.2%
*-commutative95.2%
exp-to-pow95.2%
Simplified95.2%
Taylor expanded in n around inf 69.7%
if 2.4200000000000001e123 < x Initial program 81.7%
flip3--50.9%
div-inv50.9%
pow-to-exp50.9%
un-div-inv50.9%
+-commutative50.9%
log1p-define50.9%
pow-pow50.8%
Applied egg-rr50.9%
associate-*r/50.9%
*-rgt-identity50.9%
associate-*l/50.9%
metadata-eval50.9%
+-commutative50.9%
+-commutative50.9%
associate-+l+50.9%
Simplified50.9%
Taylor expanded in n around -inf 81.7%
*-commutative81.7%
cancel-sign-sub-inv81.7%
distribute-rgt-out81.7%
log1p-define81.7%
metadata-eval81.7%
metadata-eval81.7%
*-commutative81.7%
Simplified81.7%
Taylor expanded in x around inf 81.7%
associate-*r/81.7%
distribute-rgt-out81.7%
metadata-eval81.7%
mul0-rgt81.7%
metadata-eval81.7%
Simplified81.7%
Final simplification68.5%
(FPCore (x n) :precision binary64 (if (<= x 0.000114) (/ (- x (log x)) n) (if (<= x 2.95e+122) (/ (/ 1.0 n) x) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.000114) {
tmp = (x - log(x)) / n;
} else if (x <= 2.95e+122) {
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 (x <= 0.000114d0) then
tmp = (x - log(x)) / n
else if (x <= 2.95d+122) 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 (x <= 0.000114) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.95e+122) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.000114: tmp = (x - math.log(x)) / n elif x <= 2.95e+122: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.000114) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.95e+122) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.000114) tmp = (x - log(x)) / n; elseif (x <= 2.95e+122) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.000114], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.95e+122], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.000114:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.95 \cdot 10^{+122}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.1400000000000001e-4Initial program 42.2%
Taylor expanded in x around 0 40.9%
Taylor expanded in n around inf 55.7%
if 1.1400000000000001e-4 < x < 2.95000000000000016e122Initial program 42.5%
Taylor expanded in x around inf 94.1%
log-rec94.1%
mul-1-neg94.1%
associate-*r/94.1%
neg-mul-194.1%
mul-1-neg94.1%
remove-double-neg94.1%
*-commutative94.1%
Simplified94.1%
Taylor expanded in x around 0 94.1%
associate-/r*95.2%
*-lft-identity95.2%
associate-*r/95.2%
associate-*l/95.2%
*-commutative95.2%
exp-to-pow95.2%
Simplified95.2%
Taylor expanded in n around inf 69.7%
if 2.95000000000000016e122 < x Initial program 81.7%
flip3--50.9%
div-inv50.9%
pow-to-exp50.9%
un-div-inv50.9%
+-commutative50.9%
log1p-define50.9%
pow-pow50.8%
Applied egg-rr50.9%
associate-*r/50.9%
*-rgt-identity50.9%
associate-*l/50.9%
metadata-eval50.9%
+-commutative50.9%
+-commutative50.9%
associate-+l+50.9%
Simplified50.9%
Taylor expanded in n around -inf 81.7%
*-commutative81.7%
cancel-sign-sub-inv81.7%
distribute-rgt-out81.7%
log1p-define81.7%
metadata-eval81.7%
metadata-eval81.7%
*-commutative81.7%
Simplified81.7%
Taylor expanded in x around inf 81.7%
associate-*r/81.7%
distribute-rgt-out81.7%
metadata-eval81.7%
mul0-rgt81.7%
metadata-eval81.7%
Simplified81.7%
Final simplification66.3%
(FPCore (x n) :precision binary64 (if (<= x 0.000114) (/ (- (log x)) n) (if (<= x 1.55e+123) (/ (/ 1.0 n) x) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.000114) {
tmp = -log(x) / n;
} else if (x <= 1.55e+123) {
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 (x <= 0.000114d0) then
tmp = -log(x) / n
else if (x <= 1.55d+123) 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 (x <= 0.000114) {
tmp = -Math.log(x) / n;
} else if (x <= 1.55e+123) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.000114: tmp = -math.log(x) / n elif x <= 1.55e+123: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.000114) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.55e+123) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.000114) tmp = -log(x) / n; elseif (x <= 1.55e+123) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.000114], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.55e+123], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.000114:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+123}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.1400000000000001e-4Initial program 42.2%
Taylor expanded in x around 0 40.7%
Taylor expanded in n around inf 55.3%
associate-*r/55.3%
mul-1-neg55.3%
Simplified55.3%
if 1.1400000000000001e-4 < x < 1.55000000000000003e123Initial program 42.5%
Taylor expanded in x around inf 94.1%
log-rec94.1%
mul-1-neg94.1%
associate-*r/94.1%
neg-mul-194.1%
mul-1-neg94.1%
remove-double-neg94.1%
*-commutative94.1%
Simplified94.1%
Taylor expanded in x around 0 94.1%
associate-/r*95.2%
*-lft-identity95.2%
associate-*r/95.2%
associate-*l/95.2%
*-commutative95.2%
exp-to-pow95.2%
Simplified95.2%
Taylor expanded in n around inf 69.7%
if 1.55000000000000003e123 < x Initial program 81.7%
flip3--50.9%
div-inv50.9%
pow-to-exp50.9%
un-div-inv50.9%
+-commutative50.9%
log1p-define50.9%
pow-pow50.8%
Applied egg-rr50.9%
associate-*r/50.9%
*-rgt-identity50.9%
associate-*l/50.9%
metadata-eval50.9%
+-commutative50.9%
+-commutative50.9%
associate-+l+50.9%
Simplified50.9%
Taylor expanded in n around -inf 81.7%
*-commutative81.7%
cancel-sign-sub-inv81.7%
distribute-rgt-out81.7%
log1p-define81.7%
metadata-eval81.7%
metadata-eval81.7%
*-commutative81.7%
Simplified81.7%
Taylor expanded in x around inf 81.7%
associate-*r/81.7%
distribute-rgt-out81.7%
metadata-eval81.7%
mul0-rgt81.7%
metadata-eval81.7%
Simplified81.7%
Final simplification66.0%
(FPCore (x n) :precision binary64 (if (or (<= n -22.0) (not (<= n -3.7e-291))) (/ 1.0 (* n x)) (/ 0.0 n)))
double code(double x, double n) {
double tmp;
if ((n <= -22.0) || !(n <= -3.7e-291)) {
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 <= (-22.0d0)) .or. (.not. (n <= (-3.7d-291)))) 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 <= -22.0) || !(n <= -3.7e-291)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -22.0) or not (n <= -3.7e-291): tmp = 1.0 / (n * x) else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if ((n <= -22.0) || !(n <= -3.7e-291)) 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 <= -22.0) || ~((n <= -3.7e-291))) tmp = 1.0 / (n * x); else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -22.0], N[Not[LessEqual[n, -3.7e-291]], $MachinePrecision]], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -22 \lor \neg \left(n \leq -3.7 \cdot 10^{-291}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if n < -22 or -3.7000000000000001e-291 < n Initial program 39.8%
Taylor expanded in x around inf 48.1%
log-rec48.1%
mul-1-neg48.1%
associate-*r/48.1%
neg-mul-148.1%
mul-1-neg48.1%
remove-double-neg48.1%
*-commutative48.1%
Simplified48.1%
Taylor expanded in n around inf 49.2%
if -22 < n < -3.7000000000000001e-291Initial program 98.6%
flip3--0.0%
div-inv0.0%
pow-to-exp0.0%
un-div-inv0.0%
+-commutative0.0%
log1p-define0.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%
associate-+l+0.0%
Simplified0.0%
Taylor expanded in n around -inf 51.7%
*-commutative51.7%
cancel-sign-sub-inv51.7%
distribute-rgt-out51.7%
log1p-define51.7%
metadata-eval51.7%
metadata-eval51.7%
*-commutative51.7%
Simplified51.7%
Taylor expanded in x around inf 54.8%
associate-*r/54.8%
distribute-rgt-out54.8%
metadata-eval54.8%
mul0-rgt54.8%
metadata-eval54.8%
Simplified54.8%
Final simplification50.6%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -2.0) (/ 0.0 n) (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2.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) <= (-2.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) <= -2.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2.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) <= -2.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) <= -2.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], -2.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 -2:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2Initial program 98.6%
flip3--0.0%
div-inv0.0%
pow-to-exp0.0%
un-div-inv0.0%
+-commutative0.0%
log1p-define0.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%
associate-+l+0.0%
Simplified0.0%
Taylor expanded in n around -inf 51.2%
*-commutative51.2%
cancel-sign-sub-inv51.2%
distribute-rgt-out51.2%
log1p-define51.2%
metadata-eval51.2%
metadata-eval51.2%
*-commutative51.2%
Simplified51.2%
Taylor expanded in x around inf 53.9%
associate-*r/53.9%
distribute-rgt-out53.9%
metadata-eval53.9%
mul0-rgt53.9%
metadata-eval53.9%
Simplified53.9%
if -2 < (/.f64 1 n) Initial program 38.9%
Taylor expanded in x around inf 47.3%
log-rec47.3%
mul-1-neg47.3%
associate-*r/47.3%
neg-mul-147.3%
mul-1-neg47.3%
remove-double-neg47.3%
*-commutative47.3%
Simplified47.3%
Taylor expanded in x around 0 47.3%
associate-/r*48.5%
*-lft-identity48.5%
associate-*r/48.5%
associate-*l/48.5%
*-commutative48.5%
exp-to-pow48.5%
Simplified48.5%
Taylor expanded in n around inf 50.0%
Final simplification51.0%
(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 54.3%
flip3--27.7%
div-inv27.7%
pow-to-exp27.7%
un-div-inv27.7%
+-commutative27.7%
log1p-define30.7%
pow-pow30.7%
Applied egg-rr28.2%
associate-*r/28.2%
*-rgt-identity28.2%
associate-*l/28.2%
metadata-eval28.2%
+-commutative28.2%
+-commutative28.2%
associate-+l+28.2%
Simplified28.2%
Taylor expanded in n around -inf 60.1%
*-commutative60.1%
cancel-sign-sub-inv60.1%
distribute-rgt-out60.1%
log1p-define60.1%
metadata-eval60.1%
metadata-eval60.1%
*-commutative60.1%
Simplified60.1%
Taylor expanded in x around inf 34.4%
associate-*r/34.4%
distribute-rgt-out34.4%
metadata-eval34.4%
mul0-rgt34.4%
metadata-eval34.4%
Simplified34.4%
Final simplification34.4%
herbie shell --seed 2024034
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))