
(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 19 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 (sqrt (exp (/ (log1p x) n))))
(t_1 (pow x (/ 1.0 n)))
(t_2 (sqrt t_1)))
(if (<= (/ 1.0 n) -2e-61)
(/ t_1 (* x n))
(if (<= (/ 1.0 n) 2e-20)
(/ (log (/ (+ x 1.0) x)) n)
(* (+ t_0 t_2) (- t_0 t_2))))))
double code(double x, double n) {
double t_0 = sqrt(exp((log1p(x) / n)));
double t_1 = pow(x, (1.0 / n));
double t_2 = sqrt(t_1);
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_1 / (x * n);
} else if ((1.0 / n) <= 2e-20) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = (t_0 + t_2) * (t_0 - t_2);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.sqrt(Math.exp((Math.log1p(x) / n)));
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = Math.sqrt(t_1);
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_1 / (x * n);
} else if ((1.0 / n) <= 2e-20) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = (t_0 + t_2) * (t_0 - t_2);
}
return tmp;
}
def code(x, n): t_0 = math.sqrt(math.exp((math.log1p(x) / n))) t_1 = math.pow(x, (1.0 / n)) t_2 = math.sqrt(t_1) tmp = 0 if (1.0 / n) <= -2e-61: tmp = t_1 / (x * n) elif (1.0 / n) <= 2e-20: tmp = math.log(((x + 1.0) / x)) / n else: tmp = (t_0 + t_2) * (t_0 - t_2) return tmp
function code(x, n) t_0 = sqrt(exp(Float64(log1p(x) / n))) t_1 = x ^ Float64(1.0 / n) t_2 = sqrt(t_1) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_1 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-20) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(Float64(t_0 + t_2) * Float64(t_0 - t_2)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Sqrt[N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[t$95$1], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(t$95$1 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-20], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(t$95$0 + t$95$2), $MachinePrecision] * N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \sqrt{t\_1}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\
\;\;\;\;\frac{t\_1}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 + t\_2\right) \cdot \left(t\_0 - t\_2\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999989e-20Initial program 25.9%
Taylor expanded in n around inf 78.0%
log1p-define78.0%
Simplified78.0%
log1p-undefine78.0%
diff-log78.1%
Applied egg-rr78.1%
if 1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n) Initial program 62.8%
sqr-pow62.6%
sqr-pow62.8%
difference-of-squares62.9%
sqrt-pow162.9%
pow-to-exp62.9%
un-div-inv62.9%
+-commutative62.9%
log1p-define88.5%
sqrt-pow188.5%
Applied egg-rr92.1%
Final simplification86.1%
(FPCore (x n)
:precision binary64
(if (<= x 1550.0)
(/
(-
(+
(log1p x)
(/
(+
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0)))
(/
(+
(* -0.16666666666666666 (- (pow (log x) 3.0) (pow (log1p x) 3.0)))
(*
-0.041666666666666664
(/ (- (pow (log x) 4.0) (pow (log1p x) 4.0)) n)))
n))
n))
(log x))
n)
(* (/ (cbrt (pow x (/ 2.0 n))) x) (/ (cbrt (pow x (/ 1.0 n))) n))))
double code(double x, double n) {
double tmp;
if (x <= 1550.0) {
tmp = ((log1p(x) + (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) + (((-0.16666666666666666 * (pow(log(x), 3.0) - pow(log1p(x), 3.0))) + (-0.041666666666666664 * ((pow(log(x), 4.0) - pow(log1p(x), 4.0)) / n))) / n)) / n)) - log(x)) / n;
} else {
tmp = (cbrt(pow(x, (2.0 / n))) / x) * (cbrt(pow(x, (1.0 / n))) / n);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 1550.0) {
tmp = ((Math.log1p(x) + (((0.5 * (Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0))) + (((-0.16666666666666666 * (Math.pow(Math.log(x), 3.0) - Math.pow(Math.log1p(x), 3.0))) + (-0.041666666666666664 * ((Math.pow(Math.log(x), 4.0) - Math.pow(Math.log1p(x), 4.0)) / n))) / n)) / n)) - Math.log(x)) / n;
} else {
tmp = (Math.cbrt(Math.pow(x, (2.0 / n))) / x) * (Math.cbrt(Math.pow(x, (1.0 / n))) / n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1550.0) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) + Float64(Float64(Float64(-0.16666666666666666 * Float64((log(x) ^ 3.0) - (log1p(x) ^ 3.0))) + Float64(-0.041666666666666664 * Float64(Float64((log(x) ^ 4.0) - (log1p(x) ^ 4.0)) / n))) / n)) / n)) - log(x)) / n); else tmp = Float64(Float64(cbrt((x ^ Float64(2.0 / n))) / x) * Float64(cbrt((x ^ Float64(1.0 / n))) / n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 1550.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-0.16666666666666666 * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.041666666666666664 * N[(N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[N[Power[x, N[(2.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / x), $MachinePrecision] * N[(N[Power[N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1550:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + \frac{-0.16666666666666666 \cdot \left({\log x}^{3} - {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) + -0.041666666666666664 \cdot \frac{{\log x}^{4} - {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n}}{n}}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{2}{n}\right)}}}{x} \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{n}\\
\end{array}
\end{array}
if x < 1550Initial program 49.5%
Taylor expanded in n around -inf 75.7%
Simplified75.7%
if 1550 < x Initial program 59.8%
Taylor expanded in x around inf 98.1%
log-rec98.1%
mul-1-neg98.1%
neg-mul-198.1%
mul-1-neg98.1%
distribute-frac-neg98.1%
remove-double-neg98.1%
*-rgt-identity98.1%
associate-/l*98.1%
exp-to-pow98.1%
*-commutative98.1%
Simplified98.1%
add-cube-cbrt98.1%
associate-/l*98.1%
cbrt-unprod98.1%
pow-sqr98.1%
Applied egg-rr98.1%
associate-*r/98.1%
times-frac99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification84.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (sqrt t_0)))
(if (<= (/ 1.0 n) -2e-61)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-15)
(/ (log (/ (+ x 1.0) x)) n)
(fma t_1 (- t_1) (exp (/ (log1p x) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = sqrt(t_0);
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-15) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = fma(t_1, -t_1, exp((log1p(x) / n)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = sqrt(t_0) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-15) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = fma(t_1, Float64(-t_1), exp(Float64(log1p(x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-15], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(t$95$1 * (-t$95$1) + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -t\_1, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000002e-15Initial program 25.8%
Taylor expanded in n around inf 77.5%
log1p-define77.5%
Simplified77.5%
log1p-undefine77.5%
diff-log77.6%
Applied egg-rr77.6%
if 2.0000000000000002e-15 < (/.f64 #s(literal 1 binary64) n) Initial program 64.2%
sub-neg64.2%
+-commutative64.2%
sqr-pow64.1%
distribute-rgt-neg-in64.1%
fma-define64.3%
sqrt-pow164.3%
sqrt-pow164.3%
pow-to-exp64.3%
un-div-inv64.3%
+-commutative64.3%
log1p-define94.4%
Applied egg-rr94.4%
Final simplification86.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-61)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-20)
(/ (log (/ (+ x 1.0) x)) n)
(log (exp (- (exp (/ (log1p x) n)) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-20) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = log(exp((exp((log1p(x) / n)) - t_0)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-20) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.log(Math.exp((Math.exp((Math.log1p(x) / n)) - t_0)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-61: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-20: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.log(math.exp((math.exp((math.log1p(x) / n)) - t_0))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-20) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = log(exp(Float64(exp(Float64(log1p(x) / n)) - t_0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-20], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Log[N[Exp[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]], $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^{-61}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999989e-20Initial program 25.9%
Taylor expanded in n around inf 78.0%
log1p-define78.0%
Simplified78.0%
log1p-undefine78.0%
diff-log78.1%
Applied egg-rr78.1%
if 1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n) Initial program 62.8%
add-log-exp62.8%
pow-to-exp62.8%
un-div-inv62.8%
+-commutative62.8%
log1p-define92.1%
Applied egg-rr92.1%
Final simplification86.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-61)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-20)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-20) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-20) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-61: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-20: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-20) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-20], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999989e-20Initial program 25.9%
Taylor expanded in n around inf 78.0%
log1p-define78.0%
Simplified78.0%
log1p-undefine78.0%
diff-log78.1%
Applied egg-rr78.1%
if 1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n) Initial program 62.8%
Taylor expanded in n around 0 62.8%
log1p-define92.1%
*-rgt-identity92.1%
associate-*l/92.1%
associate-/l*92.1%
exp-to-pow92.1%
Simplified92.1%
Final simplification86.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-61)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 4e-7)
(/ (log (/ (+ x 1.0) x)) n)
(-
(+
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n))))))
1.0)
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = ((x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) + (0.5 * (-1.0 / n)))))) + 1.0) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-61)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 4d-7) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = ((x * ((1.0d0 / n) + (x * ((0.5d0 * (1.0d0 / (n ** 2.0d0))) + (0.5d0 * ((-1.0d0) / n)))))) + 1.0d0) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = ((x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) + (0.5 * (-1.0 / n)))))) + 1.0) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-61: tmp = t_0 / (x * n) elif (1.0 / n) <= 4e-7: tmp = math.log(((x + 1.0) / x)) / n else: tmp = ((x * ((1.0 / n) + (x * ((0.5 * (1.0 / math.pow(n, 2.0))) + (0.5 * (-1.0 / n)))))) + 1.0) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 4e-7) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(Float64(Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) + Float64(0.5 * Float64(-1.0 / n)))))) + 1.0) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-61) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 4e-7) tmp = log(((x + 1.0) / x)) / n; else tmp = ((x * ((1.0 / n) + (x * ((0.5 * (1.0 / (n ^ 2.0))) + (0.5 * (-1.0 / n)))))) + 1.0) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-7], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $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^{-61}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right) + 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7Initial program 25.6%
Taylor expanded in n around inf 76.9%
log1p-define76.9%
Simplified76.9%
log1p-undefine76.9%
diff-log77.0%
Applied egg-rr77.0%
if 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) Initial program 65.9%
Taylor expanded in x around 0 85.9%
Final simplification84.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-61)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-20)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 1e+189)
(- (pow (+ x 1.0) (/ 1.0 n)) t_0)
(log1p (expm1 (/ x n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-20) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+189) {
tmp = pow((x + 1.0), (1.0 / n)) - t_0;
} else {
tmp = log1p(expm1((x / n)));
}
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-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-20) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+189) {
tmp = Math.pow((x + 1.0), (1.0 / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1((x / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-61: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-20: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+189: tmp = math.pow((x + 1.0), (1.0 / n)) - t_0 else: tmp = math.log1p(math.expm1((x / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-20) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+189) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0); else tmp = log1p(expm1(Float64(x / n))); 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-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-20], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+189], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $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^{-61}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+189}:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999989e-20Initial program 25.9%
Taylor expanded in n around inf 78.0%
log1p-define78.0%
Simplified78.0%
log1p-undefine78.0%
diff-log78.1%
Applied egg-rr78.1%
if 1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n) < 1e189Initial program 80.6%
if 1e189 < (/.f64 #s(literal 1 binary64) n) Initial program 12.8%
Taylor expanded in x around 0 4.7%
Taylor expanded in x around inf 4.7%
log1p-expm1-u100.0%
Applied egg-rr100.0%
Final simplification85.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-61)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 4e-7)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 1e+189)
(- (+ (/ x n) 1.0) t_0)
(log1p (expm1 (/ x n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+189) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = log1p(expm1((x / n)));
}
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-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+189) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = Math.log1p(Math.expm1((x / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-61: tmp = t_0 / (x * n) elif (1.0 / n) <= 4e-7: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+189: tmp = ((x / n) + 1.0) - t_0 else: tmp = math.log1p(math.expm1((x / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 4e-7) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+189) tmp = Float64(Float64(Float64(x / n) + 1.0) - t_0); else tmp = log1p(expm1(Float64(x / n))); 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-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-7], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+189], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $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^{-61}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+189}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7Initial program 25.6%
Taylor expanded in n around inf 76.9%
log1p-define76.9%
Simplified76.9%
log1p-undefine76.9%
diff-log77.0%
Applied egg-rr77.0%
if 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) < 1e189Initial program 86.3%
Taylor expanded in x around 0 83.3%
if 1e189 < (/.f64 #s(literal 1 binary64) n) Initial program 12.8%
Taylor expanded in x around 0 4.7%
Taylor expanded in x around inf 4.7%
log1p-expm1-u100.0%
Applied egg-rr100.0%
Final simplification84.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -5e-5)
t_0
(if (<= (/ 1.0 n) -2e-61)
(/ 1.0 (* x n))
(if (<= (/ 1.0 n) 4e-7)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 1e+189)
t_0
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-5) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-61) {
tmp = 1.0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+189) {
tmp = t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-5d-5)) then
tmp = t_0
else if ((1.0d0 / n) <= (-2d-61)) then
tmp = 1.0d0 / (x * n)
else if ((1.0d0 / n) <= 4d-7) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 1d+189) then
tmp = t_0
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-5) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-61) {
tmp = 1.0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+189) {
tmp = t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-5: tmp = t_0 elif (1.0 / n) <= -2e-61: tmp = 1.0 / (x * n) elif (1.0 / n) <= 4e-7: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+189: tmp = t_0 else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -5e-5) tmp = t_0; elseif (Float64(1.0 / n) <= -2e-61) tmp = Float64(1.0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 4e-7) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+189) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -5e-5) tmp = t_0; elseif ((1.0 / n) <= -2e-61) tmp = 1.0 / (x * n); elseif ((1.0 / n) <= 4e-7) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 1e+189) tmp = t_0; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-5], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-7], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+189], t$95$0, N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+189}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000024e-5 or 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) < 1e189Initial program 96.5%
Taylor expanded in x around 0 69.7%
*-rgt-identity69.7%
associate-*l/69.7%
associate-/l*69.7%
exp-to-pow69.7%
Simplified69.7%
if -5.00000000000000024e-5 < (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 8.0%
Taylor expanded in n around inf 28.1%
log1p-define28.1%
Simplified28.1%
Taylor expanded in x around inf 74.2%
*-commutative74.2%
Simplified74.2%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7Initial program 25.6%
Taylor expanded in n around inf 76.9%
log1p-define76.9%
Simplified76.9%
log1p-undefine76.9%
diff-log77.0%
Applied egg-rr77.0%
if 1e189 < (/.f64 #s(literal 1 binary64) n) Initial program 12.8%
Taylor expanded in n around inf 7.7%
log1p-define7.7%
Simplified7.7%
Taylor expanded in x around -inf 81.5%
mul-1-neg81.5%
mul-1-neg81.5%
associate-*r/81.5%
metadata-eval81.5%
*-commutative81.5%
associate-*r/81.5%
metadata-eval81.5%
Simplified81.5%
Final simplification74.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-61)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 4e-7)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 1e+201)
(- (+ (/ x n) 1.0) t_0)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+201) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-61)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 4d-7) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 1d+201) then
tmp = ((x / n) + 1.0d0) - t_0
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+201) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-61: tmp = t_0 / (x * n) elif (1.0 / n) <= 4e-7: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+201: tmp = ((x / n) + 1.0) - t_0 else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 4e-7) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+201) tmp = Float64(Float64(Float64(x / n) + 1.0) - t_0); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-61) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 4e-7) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 1e+201) tmp = ((x / n) + 1.0) - t_0; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-7], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+201], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+201}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7Initial program 25.6%
Taylor expanded in n around inf 76.9%
log1p-define76.9%
Simplified76.9%
log1p-undefine76.9%
diff-log77.0%
Applied egg-rr77.0%
if 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000004e201Initial program 86.8%
Taylor expanded in x around 0 80.4%
if 1.00000000000000004e201 < (/.f64 #s(literal 1 binary64) n) Initial program 3.1%
Taylor expanded in n around inf 8.0%
log1p-define8.0%
Simplified8.0%
Taylor expanded in x around -inf 90.0%
mul-1-neg90.0%
mul-1-neg90.0%
associate-*r/90.0%
metadata-eval90.0%
*-commutative90.0%
associate-*r/90.0%
metadata-eval90.0%
Simplified90.0%
Final simplification84.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-61)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 4e-7)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 1e+189)
(- 1.0 t_0)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+189) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-61)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 4d-7) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 1d+189) then
tmp = 1.0d0 - t_0
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-61) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 4e-7) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+189) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-61: tmp = t_0 / (x * n) elif (1.0 / n) <= 4e-7: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+189: tmp = 1.0 - t_0 else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-61) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 4e-7) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+189) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-61) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 4e-7) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 1e+189) tmp = 1.0 - t_0; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-7], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+189], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+189}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61Initial program 87.8%
Taylor expanded in x around inf 94.8%
log-rec94.8%
mul-1-neg94.8%
neg-mul-194.8%
mul-1-neg94.8%
distribute-frac-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7Initial program 25.6%
Taylor expanded in n around inf 76.9%
log1p-define76.9%
Simplified76.9%
log1p-undefine76.9%
diff-log77.0%
Applied egg-rr77.0%
if 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) < 1e189Initial program 86.3%
Taylor expanded in x around 0 82.4%
*-rgt-identity82.4%
associate-*l/82.4%
associate-/l*82.4%
exp-to-pow82.4%
Simplified82.4%
if 1e189 < (/.f64 #s(literal 1 binary64) n) Initial program 12.8%
Taylor expanded in n around inf 7.7%
log1p-define7.7%
Simplified7.7%
Taylor expanded in x around -inf 81.5%
mul-1-neg81.5%
mul-1-neg81.5%
associate-*r/81.5%
metadata-eval81.5%
*-commutative81.5%
associate-*r/81.5%
metadata-eval81.5%
Simplified81.5%
Final simplification84.1%
(FPCore (x n)
:precision binary64
(if (<= x 1.2e-164)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.92)
(/ (- x (log x)) n)
(if (<= x 1.85e+123) (/ (/ 1.0 n) x) 0.0))))
double code(double x, double n) {
double tmp;
if (x <= 1.2e-164) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.92) {
tmp = (x - log(x)) / n;
} else if (x <= 1.85e+123) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.2d-164) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.92d0) then
tmp = (x - log(x)) / n
else if (x <= 1.85d+123) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.2e-164) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.92) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.85e+123) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.2e-164: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.92: tmp = (x - math.log(x)) / n elif x <= 1.85e+123: tmp = (1.0 / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.2e-164) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.92) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.85e+123) tmp = Float64(Float64(1.0 / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.2e-164) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.92) tmp = (x - log(x)) / n; elseif (x <= 1.85e+123) tmp = (1.0 / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.2e-164], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.92], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.85e+123], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2 \cdot 10^{-164}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+123}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.19999999999999992e-164Initial program 57.9%
Taylor expanded in x around 0 57.9%
*-rgt-identity57.9%
associate-*l/57.9%
associate-/l*57.9%
exp-to-pow57.9%
Simplified57.9%
if 1.19999999999999992e-164 < x < 0.92000000000000004Initial program 41.8%
Taylor expanded in n around inf 54.5%
log1p-define54.5%
Simplified54.5%
Taylor expanded in x around 0 53.6%
if 0.92000000000000004 < x < 1.84999999999999998e123Initial program 37.1%
Taylor expanded in x around inf 93.6%
log-rec93.6%
mul-1-neg93.6%
neg-mul-193.6%
mul-1-neg93.6%
distribute-frac-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
*-commutative93.6%
Simplified93.6%
add-cube-cbrt93.6%
associate-/l*93.6%
cbrt-unprod93.6%
pow-sqr93.6%
Applied egg-rr93.6%
associate-*r/93.6%
times-frac97.3%
associate-*r/97.3%
metadata-eval97.3%
Simplified97.3%
Taylor expanded in n around inf 73.2%
associate-/r*77.1%
Simplified77.1%
if 1.84999999999999998e123 < x Initial program 78.3%
add-log-exp78.3%
pow-to-exp78.3%
un-div-inv78.3%
+-commutative78.3%
log1p-define78.3%
Applied egg-rr78.3%
Taylor expanded in x around inf 78.3%
Final simplification64.0%
(FPCore (x n) :precision binary64 (if (<= x 0.92) (/ (- x (log x)) n) (if (<= x 1.8e+123) (/ (/ 1.0 n) x) 0.0)))
double code(double x, double n) {
double tmp;
if (x <= 0.92) {
tmp = (x - log(x)) / n;
} else if (x <= 1.8e+123) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.92d0) then
tmp = (x - log(x)) / n
else if (x <= 1.8d+123) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.92) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.8e+123) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.92: tmp = (x - math.log(x)) / n elif x <= 1.8e+123: tmp = (1.0 / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.92) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.8e+123) tmp = Float64(Float64(1.0 / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.92) tmp = (x - log(x)) / n; elseif (x <= 1.8e+123) tmp = (1.0 / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.92], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.8e+123], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.92:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+123}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.92000000000000004Initial program 49.1%
Taylor expanded in n around inf 49.8%
log1p-define49.8%
Simplified49.8%
Taylor expanded in x around 0 49.2%
if 0.92000000000000004 < x < 1.79999999999999999e123Initial program 37.1%
Taylor expanded in x around inf 93.6%
log-rec93.6%
mul-1-neg93.6%
neg-mul-193.6%
mul-1-neg93.6%
distribute-frac-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
*-commutative93.6%
Simplified93.6%
add-cube-cbrt93.6%
associate-/l*93.6%
cbrt-unprod93.6%
pow-sqr93.6%
Applied egg-rr93.6%
associate-*r/93.6%
times-frac97.3%
associate-*r/97.3%
metadata-eval97.3%
Simplified97.3%
Taylor expanded in n around inf 73.2%
associate-/r*77.1%
Simplified77.1%
if 1.79999999999999999e123 < x Initial program 78.3%
add-log-exp78.3%
pow-to-exp78.3%
un-div-inv78.3%
+-commutative78.3%
log1p-define78.3%
Applied egg-rr78.3%
Taylor expanded in x around inf 78.3%
Final simplification60.1%
(FPCore (x n) :precision binary64 (if (<= x 0.56) (/ (log x) (- n)) (if (<= x 1.8e+123) (/ (/ 1.0 n) x) 0.0)))
double code(double x, double n) {
double tmp;
if (x <= 0.56) {
tmp = log(x) / -n;
} else if (x <= 1.8e+123) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.56d0) then
tmp = log(x) / -n
else if (x <= 1.8d+123) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.56) {
tmp = Math.log(x) / -n;
} else if (x <= 1.8e+123) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.56: tmp = math.log(x) / -n elif x <= 1.8e+123: tmp = (1.0 / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.56) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.8e+123) tmp = Float64(Float64(1.0 / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.56) tmp = log(x) / -n; elseif (x <= 1.8e+123) tmp = (1.0 / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.56], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.8e+123], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.56:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+123}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.56000000000000005Initial program 49.1%
Taylor expanded in x around 0 48.5%
*-rgt-identity48.5%
associate-*l/48.5%
associate-/l*48.5%
exp-to-pow48.5%
Simplified48.5%
Taylor expanded in n around inf 48.8%
neg-mul-148.8%
distribute-neg-frac48.8%
Simplified48.8%
if 0.56000000000000005 < x < 1.79999999999999999e123Initial program 37.1%
Taylor expanded in x around inf 93.6%
log-rec93.6%
mul-1-neg93.6%
neg-mul-193.6%
mul-1-neg93.6%
distribute-frac-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
*-commutative93.6%
Simplified93.6%
add-cube-cbrt93.6%
associate-/l*93.6%
cbrt-unprod93.6%
pow-sqr93.6%
Applied egg-rr93.6%
associate-*r/93.6%
times-frac97.3%
associate-*r/97.3%
metadata-eval97.3%
Simplified97.3%
Taylor expanded in n around inf 73.2%
associate-/r*77.1%
Simplified77.1%
if 1.79999999999999999e123 < x Initial program 78.3%
add-log-exp78.3%
pow-to-exp78.3%
un-div-inv78.3%
+-commutative78.3%
log1p-define78.3%
Applied egg-rr78.3%
Taylor expanded in x around inf 78.3%
Final simplification59.9%
(FPCore (x n) :precision binary64 (if (<= x 1.8e+123) (/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x)) x) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.8e+123) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.8d+123) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.8e+123) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.8e+123: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.8e+123) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.8e+123) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.8e+123], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{+123}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.79999999999999999e123Initial program 46.6%
Taylor expanded in n around inf 46.7%
log1p-define46.7%
Simplified46.7%
Taylor expanded in x around -inf 44.8%
mul-1-neg44.8%
mul-1-neg44.8%
associate-*r/44.8%
metadata-eval44.8%
*-commutative44.8%
associate-*r/44.8%
metadata-eval44.8%
Simplified44.8%
if 1.79999999999999999e123 < x Initial program 78.3%
add-log-exp78.3%
pow-to-exp78.3%
un-div-inv78.3%
+-commutative78.3%
log1p-define78.3%
Applied egg-rr78.3%
Taylor expanded in x around inf 78.3%
Final simplification52.0%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}
\end{array}
Initial program 53.4%
Taylor expanded in n around inf 53.5%
log1p-define53.5%
Simplified53.5%
Taylor expanded in x around -inf 48.8%
mul-1-neg48.8%
mul-1-neg48.8%
associate-*r/48.8%
metadata-eval48.8%
*-commutative48.8%
associate-*r/48.8%
metadata-eval48.8%
Simplified48.8%
Final simplification48.8%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 53.4%
Taylor expanded in x around inf 58.2%
log-rec58.2%
mul-1-neg58.2%
neg-mul-158.2%
mul-1-neg58.2%
distribute-frac-neg58.2%
remove-double-neg58.2%
*-rgt-identity58.2%
associate-/l*58.2%
exp-to-pow58.2%
*-commutative58.2%
Simplified58.2%
add-cube-cbrt58.2%
associate-/l*58.2%
cbrt-unprod58.2%
pow-sqr58.2%
Applied egg-rr58.2%
associate-*r/58.2%
times-frac58.9%
associate-*r/58.9%
metadata-eval58.9%
Simplified58.9%
Taylor expanded in n around inf 41.9%
associate-/r*42.5%
Simplified42.5%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 53.4%
Taylor expanded in n around inf 53.5%
log1p-define53.5%
Simplified53.5%
Taylor expanded in x around inf 41.9%
*-commutative41.9%
Simplified41.9%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 53.4%
Taylor expanded in x around 0 35.3%
Taylor expanded in x around inf 4.6%
herbie shell --seed 2024186
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))