
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(if (<= x 380000.0)
(/
(log
(/
x
(exp
(+
(log1p x)
(/
(fma
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
0.5
(*
0.16666666666666666
(/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)))
n)))))
(- n))
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 380000.0) {
tmp = log((x / exp((log1p(x) + (fma((pow(log1p(x), 2.0) - pow(log(x), 2.0)), 0.5, (0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n))) / n))))) / -n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 380000.0) tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), 0.5, Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n))))) / Float64(-n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 380000.0], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 380000:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}\right)}{n}}}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 3.8e5Initial program 43.4%
Taylor expanded in n around -inf 75.8%
Simplified75.9%
add-log-exp87.4%
diff-log87.4%
Applied egg-rr87.4%
if 3.8e5 < x Initial program 69.3%
Taylor expanded in x around inf 98.4%
associate-/r*99.4%
mul-1-neg99.4%
log-rec99.4%
mul-1-neg99.4%
distribute-neg-frac99.4%
mul-1-neg99.4%
remove-double-neg99.4%
*-rgt-identity99.4%
associate-/l*99.4%
exp-to-pow99.4%
Simplified99.4%
(FPCore (x n)
:precision binary64
(if (<= x 0.0225)
(/
(-
(+
(log1p x)
(/
(+
(* 0.16666666666666666 (/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n))
(* (- (pow (log1p x) 2.0) (pow (log x) 2.0)) 0.5))
n))
(log x))
n)
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.0225) {
tmp = ((log1p(x) + (((0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n)) + ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) * 0.5)) / n)) - log(x)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 0.0225) {
tmp = ((Math.log1p(x) + (((0.16666666666666666 * ((Math.pow(Math.log1p(x), 3.0) - Math.pow(Math.log(x), 3.0)) / n)) + ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) * 0.5)) / n)) - Math.log(x)) / n;
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.0225: tmp = ((math.log1p(x) + (((0.16666666666666666 * ((math.pow(math.log1p(x), 3.0) - math.pow(math.log(x), 3.0)) / n)) + ((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) * 0.5)) / n)) - math.log(x)) / n else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.0225) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n)) + Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) * 0.5)) / n)) - log(x)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 0.0225], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0225:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n} + \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) \cdot 0.5}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 0.022499999999999999Initial program 42.9%
Taylor expanded in n around -inf 76.6%
Simplified76.6%
if 0.022499999999999999 < x Initial program 69.3%
Taylor expanded in x around inf 97.2%
associate-/r*98.2%
mul-1-neg98.2%
log-rec98.2%
mul-1-neg98.2%
distribute-neg-frac98.2%
mul-1-neg98.2%
remove-double-neg98.2%
*-rgt-identity98.2%
associate-/l*98.2%
exp-to-pow98.2%
Simplified98.2%
Final simplification87.0%
(FPCore (x n)
:precision binary64
(if (<= x 0.014)
(/
(-
(/
(+
(* -0.16666666666666666 (/ (pow (log x) 3.0) n))
(* (pow (log x) 2.0) -0.5))
n)
(log x))
n)
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.014) {
tmp = ((((-0.16666666666666666 * (pow(log(x), 3.0) / n)) + (pow(log(x), 2.0) * -0.5)) / n) - log(x)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.014d0) then
tmp = (((((-0.16666666666666666d0) * ((log(x) ** 3.0d0) / n)) + ((log(x) ** 2.0d0) * (-0.5d0))) / n) - log(x)) / n
else
tmp = ((x ** (1.0d0 / n)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.014) {
tmp = ((((-0.16666666666666666 * (Math.pow(Math.log(x), 3.0) / n)) + (Math.pow(Math.log(x), 2.0) * -0.5)) / n) - Math.log(x)) / n;
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.014: tmp = ((((-0.16666666666666666 * (math.pow(math.log(x), 3.0) / n)) + (math.pow(math.log(x), 2.0) * -0.5)) / n) - math.log(x)) / n else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.014) tmp = Float64(Float64(Float64(Float64(Float64(-0.16666666666666666 * Float64((log(x) ^ 3.0) / n)) + Float64((log(x) ^ 2.0) * -0.5)) / n) - log(x)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.014) tmp = ((((-0.16666666666666666 * ((log(x) ^ 3.0) / n)) + ((log(x) ^ 2.0) * -0.5)) / n) - log(x)) / n; else tmp = ((x ^ (1.0 / n)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.014], N[(N[(N[(N[(N[(-0.16666666666666666 * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.014:\\
\;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 0.0140000000000000003Initial program 42.9%
Taylor expanded in x around 0 40.7%
*-rgt-identity40.7%
associate-*l/40.7%
associate-/l*40.7%
exp-to-pow40.7%
Simplified40.7%
Taylor expanded in n around -inf 76.5%
mul-1-neg76.5%
Simplified76.5%
if 0.0140000000000000003 < x Initial program 69.3%
Taylor expanded in x around inf 97.2%
associate-/r*98.2%
mul-1-neg98.2%
log-rec98.2%
mul-1-neg98.2%
distribute-neg-frac98.2%
mul-1-neg98.2%
remove-double-neg98.2%
*-rgt-identity98.2%
associate-/l*98.2%
exp-to-pow98.2%
Simplified98.2%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-35)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-14)
(/ (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-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-14) {
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-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-14) {
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-35: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-14: 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-35) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-14) 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-35], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], 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^{-35}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\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.00000000000000002e-35Initial program 92.3%
Taylor expanded in x around inf 97.6%
associate-/r*97.6%
mul-1-neg97.6%
log-rec97.6%
mul-1-neg97.6%
distribute-neg-frac97.6%
mul-1-neg97.6%
remove-double-neg97.6%
*-rgt-identity97.6%
associate-/l*97.6%
exp-to-pow97.6%
Simplified97.6%
if -2.00000000000000002e-35 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 35.2%
Taylor expanded in n around inf 78.7%
log1p-define78.7%
Simplified78.7%
log1p-undefine78.7%
diff-log78.8%
Applied egg-rr78.8%
+-commutative78.8%
Simplified78.8%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) Initial program 48.9%
Taylor expanded in n around 0 48.9%
log1p-define90.2%
*-rgt-identity90.2%
associate-*l/90.2%
associate-/l*90.2%
exp-to-pow90.2%
Simplified90.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-35)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-10)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-35)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-10) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = exp((x / n)) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-35: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-10: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-35) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-35) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-10) tmp = log(((x + 1.0) / x)) / n; else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-35], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-35}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000002e-35Initial program 92.3%
Taylor expanded in x around inf 97.6%
associate-/r*97.6%
mul-1-neg97.6%
log-rec97.6%
mul-1-neg97.6%
distribute-neg-frac97.6%
mul-1-neg97.6%
remove-double-neg97.6%
*-rgt-identity97.6%
associate-/l*97.6%
exp-to-pow97.6%
Simplified97.6%
if -2.00000000000000002e-35 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 35.0%
Taylor expanded in n around inf 78.1%
log1p-define78.1%
Simplified78.1%
log1p-undefine78.1%
diff-log78.2%
Applied egg-rr78.2%
+-commutative78.2%
Simplified78.2%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) Initial program 50.0%
Taylor expanded in n around 0 50.0%
log1p-define92.3%
*-rgt-identity92.3%
associate-*l/92.3%
associate-/l*92.3%
exp-to-pow92.3%
Simplified92.3%
Taylor expanded in x around 0 90.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -2e+98)
(/ 0.0 n)
(if (<= (/ 1.0 n) -100000000000.0)
t_0
(if (<= (/ 1.0 n) 2e-10)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+162) t_0 (/ (/ n x) (pow n 2.0))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+98) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -100000000000.0) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-10) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+162) {
tmp = t_0;
} else {
tmp = (n / x) / pow(n, 2.0);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-2d+98)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= (-100000000000.0d0)) then
tmp = t_0
else if ((1.0d0 / n) <= 2d-10) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+162) then
tmp = t_0
else
tmp = (n / x) / (n ** 2.0d0)
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) <= -2e+98) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -100000000000.0) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-10) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+162) {
tmp = t_0;
} else {
tmp = (n / x) / Math.pow(n, 2.0);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e+98: tmp = 0.0 / n elif (1.0 / n) <= -100000000000.0: tmp = t_0 elif (1.0 / n) <= 2e-10: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+162: tmp = t_0 else: tmp = (n / x) / math.pow(n, 2.0) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -2e+98) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -100000000000.0) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+162) tmp = t_0; else tmp = Float64(Float64(n / x) / (n ^ 2.0)); 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) <= -2e+98) tmp = 0.0 / n; elseif ((1.0 / n) <= -100000000000.0) tmp = t_0; elseif ((1.0 / n) <= 2e-10) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+162) tmp = t_0; else tmp = (n / x) / (n ^ 2.0); 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], -2e+98], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -100000000000.0], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+162], t$95$0, N[(N[(n / x), $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+98}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -100000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+162}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{{n}^{2}}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e98Initial program 100.0%
Taylor expanded in n around inf 67.5%
log1p-define67.5%
Simplified67.5%
log1p-undefine67.5%
diff-log67.5%
Applied egg-rr67.5%
+-commutative67.5%
Simplified67.5%
Taylor expanded in x around inf 67.8%
if -2e98 < (/.f64 #s(literal 1 binary64) n) < -1e11 or 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e162Initial program 83.1%
Taylor expanded in x around 0 72.3%
*-rgt-identity72.3%
associate-*l/72.3%
associate-/l*72.3%
exp-to-pow72.3%
Simplified72.3%
if -1e11 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 34.7%
Taylor expanded in n around inf 75.5%
log1p-define75.5%
Simplified75.5%
log1p-undefine75.5%
diff-log75.6%
Applied egg-rr75.6%
+-commutative75.6%
Simplified75.6%
if 1.9999999999999999e162 < (/.f64 #s(literal 1 binary64) n) Initial program 24.7%
Taylor expanded in n around inf 13.0%
log1p-define13.0%
Simplified13.0%
div-inv13.0%
Applied egg-rr13.0%
div-inv13.0%
div-sub13.0%
frac-sub94.6%
pow294.6%
Applied egg-rr94.6%
*-commutative94.6%
distribute-lft-out--94.6%
Simplified94.6%
Taylor expanded in x around inf 94.6%
Final simplification74.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-35)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+119)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* t_0 (* x n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+119) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (t_0 * (x * n));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-35)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-14) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 5d+119) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (t_0 * (x * n))
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-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+119) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (t_0 * (x * n));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-35: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+119: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (t_0 * (x * n)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-35) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+119) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(t_0 * Float64(x * n))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-35) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-14) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 5e+119) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (t_0 * (x * n)); 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-35], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+119], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(t$95$0 * N[(x * n), $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^{-35}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+119}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0 \cdot \left(x \cdot n\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000002e-35Initial program 92.3%
Taylor expanded in x around inf 97.6%
associate-/r*97.6%
mul-1-neg97.6%
log-rec97.6%
mul-1-neg97.6%
distribute-neg-frac97.6%
mul-1-neg97.6%
remove-double-neg97.6%
*-rgt-identity97.6%
associate-/l*97.6%
exp-to-pow97.6%
Simplified97.6%
if -2.00000000000000002e-35 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 35.2%
Taylor expanded in n around inf 78.7%
log1p-define78.7%
Simplified78.7%
log1p-undefine78.7%
diff-log78.8%
Applied egg-rr78.8%
+-commutative78.8%
Simplified78.8%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e119Initial program 72.5%
Taylor expanded in x around 0 70.6%
if 4.9999999999999999e119 < (/.f64 #s(literal 1 binary64) n) Initial program 28.4%
Taylor expanded in x around inf 0.7%
associate-/r*1.8%
mul-1-neg1.8%
log-rec1.8%
mul-1-neg1.8%
distribute-neg-frac1.8%
mul-1-neg1.8%
remove-double-neg1.8%
*-rgt-identity1.8%
associate-/l*1.8%
exp-to-pow1.8%
Simplified1.8%
clear-num1.8%
inv-pow1.8%
Applied egg-rr87.4%
unpow-187.4%
associate-*r*87.4%
Simplified87.4%
Final simplification84.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-35)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+162)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ n x) (pow n 2.0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+162) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (n / x) / pow(n, 2.0);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-35)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-14) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+162) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (n / x) / (n ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+162) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (n / x) / Math.pow(n, 2.0);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-35: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+162: tmp = (1.0 + (x / n)) - t_0 else: tmp = (n / x) / math.pow(n, 2.0) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-35) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+162) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(n / x) / (n ^ 2.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-35) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-14) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+162) tmp = (1.0 + (x / n)) - t_0; else tmp = (n / x) / (n ^ 2.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-35], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+162], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[Power[n, 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^{-35}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+162}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{{n}^{2}}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000002e-35Initial program 92.3%
Taylor expanded in x around inf 97.6%
associate-/r*97.6%
mul-1-neg97.6%
log-rec97.6%
mul-1-neg97.6%
distribute-neg-frac97.6%
mul-1-neg97.6%
remove-double-neg97.6%
*-rgt-identity97.6%
associate-/l*97.6%
exp-to-pow97.6%
Simplified97.6%
if -2.00000000000000002e-35 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 35.2%
Taylor expanded in n around inf 78.7%
log1p-define78.7%
Simplified78.7%
log1p-undefine78.7%
diff-log78.8%
Applied egg-rr78.8%
+-commutative78.8%
Simplified78.8%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e162Initial program 66.4%
Taylor expanded in x around 0 64.9%
if 1.9999999999999999e162 < (/.f64 #s(literal 1 binary64) n) Initial program 24.7%
Taylor expanded in n around inf 13.0%
log1p-define13.0%
Simplified13.0%
div-inv13.0%
Applied egg-rr13.0%
div-inv13.0%
div-sub13.0%
frac-sub94.6%
pow294.6%
Applied egg-rr94.6%
*-commutative94.6%
distribute-lft-out--94.6%
Simplified94.6%
Taylor expanded in x around inf 94.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n)))
(t_1
(/
(+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* x n)) (/ -0.5 n)) x))
x)))
(if (<= x 1.2e-161)
t_0
(if (<= x 5.4e-139)
t_1
(if (<= x 7e-131)
t_0
(if (<= x 9e-74)
t_1
(if (<= x 0.88)
(/ (- x (log x)) n)
(if (<= x 2.1e+151)
(/
(/
(+
1.0
(/
(- (/ (- 0.3333333333333333 (* 0.25 (/ 1.0 x))) x) 0.5)
x))
x)
n)
(/ 0.0 n)))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
double tmp;
if (x <= 1.2e-161) {
tmp = t_0;
} else if (x <= 5.4e-139) {
tmp = t_1;
} else if (x <= 7e-131) {
tmp = t_0;
} else if (x <= 9e-74) {
tmp = t_1;
} else if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else if (x <= 2.1e+151) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log(x) / -n
t_1 = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) + ((-0.5d0) / n)) / x)) / x
if (x <= 1.2d-161) then
tmp = t_0
else if (x <= 5.4d-139) then
tmp = t_1
else if (x <= 7d-131) then
tmp = t_0
else if (x <= 9d-74) then
tmp = t_1
else if (x <= 0.88d0) then
tmp = (x - log(x)) / n
else if (x <= 2.1d+151) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - (0.25d0 * (1.0d0 / x))) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double t_1 = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
double tmp;
if (x <= 1.2e-161) {
tmp = t_0;
} else if (x <= 5.4e-139) {
tmp = t_1;
} else if (x <= 7e-131) {
tmp = t_0;
} else if (x <= 9e-74) {
tmp = t_1;
} else if (x <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.1e+151) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x tmp = 0 if x <= 1.2e-161: tmp = t_0 elif x <= 5.4e-139: tmp = t_1 elif x <= 7e-131: tmp = t_0 elif x <= 9e-74: tmp = t_1 elif x <= 0.88: tmp = (x - math.log(x)) / n elif x <= 2.1e+151: tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x) tmp = 0.0 if (x <= 1.2e-161) tmp = t_0; elseif (x <= 5.4e-139) tmp = t_1; elseif (x <= 7e-131) tmp = t_0; elseif (x <= 9e-74) tmp = t_1; elseif (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.1e+151) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 * Float64(1.0 / x))) / x) - 0.5) / x)) / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x; tmp = 0.0; if (x <= 1.2e-161) tmp = t_0; elseif (x <= 5.4e-139) tmp = t_1; elseif (x <= 7e-131) tmp = t_0; elseif (x <= 9e-74) tmp = t_1; elseif (x <= 0.88) tmp = (x - log(x)) / n; elseif (x <= 2.1e+151) tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[x, 1.2e-161], t$95$0, If[LessEqual[x, 5.4e-139], t$95$1, If[LessEqual[x, 7e-131], t$95$0, If[LessEqual[x, 9e-74], t$95$1, If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.1e+151], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(0.25 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := \frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\
\mathbf{if}\;x \leq 1.2 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{-139}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+151}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.19999999999999999e-161 or 5.3999999999999997e-139 < x < 7.0000000000000004e-131Initial program 39.0%
Taylor expanded in n around inf 63.9%
log1p-define63.9%
Simplified63.9%
Taylor expanded in x around 0 63.9%
neg-mul-163.9%
Simplified63.9%
if 1.19999999999999999e-161 < x < 5.3999999999999997e-139 or 7.0000000000000004e-131 < x < 8.9999999999999998e-74Initial program 55.3%
Taylor expanded in n around inf 30.6%
log1p-define30.6%
Simplified30.6%
div-inv30.6%
Applied egg-rr30.6%
Taylor expanded in x around inf 32.7%
Simplified67.0%
if 8.9999999999999998e-74 < x < 0.880000000000000004Initial program 39.5%
Taylor expanded in n around inf 51.2%
log1p-define51.2%
Simplified51.2%
Taylor expanded in x around 0 51.1%
if 0.880000000000000004 < x < 2.1000000000000001e151Initial program 46.9%
Taylor expanded in n around inf 44.7%
log1p-define44.8%
Simplified44.8%
Taylor expanded in x around -inf 69.6%
if 2.1000000000000001e151 < x Initial program 90.3%
Taylor expanded in n around inf 90.3%
log1p-define90.3%
Simplified90.3%
log1p-undefine90.3%
diff-log90.3%
Applied egg-rr90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in x around inf 90.3%
Final simplification70.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n)))
(t_1
(/
(+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* x n)) (/ -0.5 n)) x))
x)))
(if (<= x 1.15e-161)
t_0
(if (<= x 4.2e-139)
t_1
(if (<= x 3.3e-131)
t_0
(if (<= x 7.5e-74)
t_1
(if (<= x 0.7)
t_0
(if (<= x 3.3e+150)
(/
(/
(+
1.0
(/
(- (/ (- 0.3333333333333333 (* 0.25 (/ 1.0 x))) x) 0.5)
x))
x)
n)
(/ 0.0 n)))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
double tmp;
if (x <= 1.15e-161) {
tmp = t_0;
} else if (x <= 4.2e-139) {
tmp = t_1;
} else if (x <= 3.3e-131) {
tmp = t_0;
} else if (x <= 7.5e-74) {
tmp = t_1;
} else if (x <= 0.7) {
tmp = t_0;
} else if (x <= 3.3e+150) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log(x) / -n
t_1 = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) + ((-0.5d0) / n)) / x)) / x
if (x <= 1.15d-161) then
tmp = t_0
else if (x <= 4.2d-139) then
tmp = t_1
else if (x <= 3.3d-131) then
tmp = t_0
else if (x <= 7.5d-74) then
tmp = t_1
else if (x <= 0.7d0) then
tmp = t_0
else if (x <= 3.3d+150) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - (0.25d0 * (1.0d0 / x))) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double t_1 = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
double tmp;
if (x <= 1.15e-161) {
tmp = t_0;
} else if (x <= 4.2e-139) {
tmp = t_1;
} else if (x <= 3.3e-131) {
tmp = t_0;
} else if (x <= 7.5e-74) {
tmp = t_1;
} else if (x <= 0.7) {
tmp = t_0;
} else if (x <= 3.3e+150) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x tmp = 0 if x <= 1.15e-161: tmp = t_0 elif x <= 4.2e-139: tmp = t_1 elif x <= 3.3e-131: tmp = t_0 elif x <= 7.5e-74: tmp = t_1 elif x <= 0.7: tmp = t_0 elif x <= 3.3e+150: tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x) tmp = 0.0 if (x <= 1.15e-161) tmp = t_0; elseif (x <= 4.2e-139) tmp = t_1; elseif (x <= 3.3e-131) tmp = t_0; elseif (x <= 7.5e-74) tmp = t_1; elseif (x <= 0.7) tmp = t_0; elseif (x <= 3.3e+150) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 * Float64(1.0 / x))) / x) - 0.5) / x)) / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x; tmp = 0.0; if (x <= 1.15e-161) tmp = t_0; elseif (x <= 4.2e-139) tmp = t_1; elseif (x <= 3.3e-131) tmp = t_0; elseif (x <= 7.5e-74) tmp = t_1; elseif (x <= 0.7) tmp = t_0; elseif (x <= 3.3e+150) tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[x, 1.15e-161], t$95$0, If[LessEqual[x, 4.2e-139], t$95$1, If[LessEqual[x, 3.3e-131], t$95$0, If[LessEqual[x, 7.5e-74], t$95$1, If[LessEqual[x, 0.7], t$95$0, If[LessEqual[x, 3.3e+150], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(0.25 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := \frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\
\mathbf{if}\;x \leq 1.15 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-139}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.7:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+150}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.15e-161 or 4.20000000000000016e-139 < x < 3.3000000000000002e-131 or 7.5e-74 < x < 0.69999999999999996Initial program 38.6%
Taylor expanded in n around inf 59.3%
log1p-define59.3%
Simplified59.3%
Taylor expanded in x around 0 59.1%
neg-mul-159.1%
Simplified59.1%
if 1.15e-161 < x < 4.20000000000000016e-139 or 3.3000000000000002e-131 < x < 7.5e-74Initial program 55.3%
Taylor expanded in n around inf 30.6%
log1p-define30.6%
Simplified30.6%
div-inv30.6%
Applied egg-rr30.6%
Taylor expanded in x around inf 32.7%
Simplified67.0%
if 0.69999999999999996 < x < 3.29999999999999981e150Initial program 47.8%
Taylor expanded in n around inf 44.4%
log1p-define44.4%
Simplified44.4%
Taylor expanded in x around -inf 68.8%
if 3.29999999999999981e150 < x Initial program 90.3%
Taylor expanded in n around inf 90.3%
log1p-define90.3%
Simplified90.3%
log1p-undefine90.3%
diff-log90.3%
Applied egg-rr90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in x around inf 90.3%
Final simplification70.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-35)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-10)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+162) (- 1.0 t_0) (/ (/ n x) (pow n 2.0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+162) {
tmp = 1.0 - t_0;
} else {
tmp = (n / x) / pow(n, 2.0);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-35)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-10) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+162) then
tmp = 1.0d0 - t_0
else
tmp = (n / x) / (n ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-35) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-10) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+162) {
tmp = 1.0 - t_0;
} else {
tmp = (n / x) / Math.pow(n, 2.0);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-35: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-10: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+162: tmp = 1.0 - t_0 else: tmp = (n / x) / math.pow(n, 2.0) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-35) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-10) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+162) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(n / x) / (n ^ 2.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-35) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-10) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+162) tmp = 1.0 - t_0; else tmp = (n / x) / (n ^ 2.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-35], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+162], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[Power[n, 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^{-35}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+162}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{{n}^{2}}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000002e-35Initial program 92.3%
Taylor expanded in x around inf 97.6%
associate-/r*97.6%
mul-1-neg97.6%
log-rec97.6%
mul-1-neg97.6%
distribute-neg-frac97.6%
mul-1-neg97.6%
remove-double-neg97.6%
*-rgt-identity97.6%
associate-/l*97.6%
exp-to-pow97.6%
Simplified97.6%
if -2.00000000000000002e-35 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10Initial program 35.0%
Taylor expanded in n around inf 78.1%
log1p-define78.1%
Simplified78.1%
log1p-undefine78.1%
diff-log78.2%
Applied egg-rr78.2%
+-commutative78.2%
Simplified78.2%
if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e162Initial program 69.0%
Taylor expanded in x around 0 65.4%
*-rgt-identity65.4%
associate-*l/65.4%
associate-/l*65.4%
exp-to-pow65.4%
Simplified65.4%
if 1.9999999999999999e162 < (/.f64 #s(literal 1 binary64) n) Initial program 24.7%
Taylor expanded in n around inf 13.0%
log1p-define13.0%
Simplified13.0%
div-inv13.0%
Applied egg-rr13.0%
div-inv13.0%
div-sub13.0%
frac-sub94.6%
pow294.6%
Applied egg-rr94.6%
*-commutative94.6%
distribute-lft-out--94.6%
Simplified94.6%
Taylor expanded in x around inf 94.6%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -2e+98) (/ 0.0 n) (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* x n)) (/ -0.5 n)) x)) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e+98) {
tmp = 0.0 / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-2d+98)) then
tmp = 0.0d0 / n
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) + ((-0.5d0) / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e+98) {
tmp = 0.0 / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e+98: tmp = 0.0 / n else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e+98) tmp = Float64(0.0 / n); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -2e+98) tmp = 0.0 / n; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+98], N[(0.0 / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+98}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e98Initial program 100.0%
Taylor expanded in n around inf 67.5%
log1p-define67.5%
Simplified67.5%
log1p-undefine67.5%
diff-log67.5%
Applied egg-rr67.5%
+-commutative67.5%
Simplified67.5%
Taylor expanded in x around inf 67.8%
if -2e98 < (/.f64 #s(literal 1 binary64) n) Initial program 44.2%
Taylor expanded in n around inf 56.7%
log1p-define56.7%
Simplified56.7%
div-inv56.6%
Applied egg-rr56.6%
Taylor expanded in x around inf 47.0%
Simplified53.4%
Final simplification56.4%
(FPCore (x n) :precision binary64 (if (<= x 7.8e+220) (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* x n)) (/ -0.5 n)) x)) x) (/ (/ -0.5 (* x n)) x)))
double code(double x, double n) {
double tmp;
if (x <= 7.8e+220) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
} else {
tmp = (-0.5 / (x * n)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 7.8d+220) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) + ((-0.5d0) / n)) / x)) / x
else
tmp = ((-0.5d0) / (x * n)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 7.8e+220) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
} else {
tmp = (-0.5 / (x * n)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 7.8e+220: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x else: tmp = (-0.5 / (x * n)) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 7.8e+220) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x); else tmp = Float64(Float64(-0.5 / Float64(x * n)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 7.8e+220) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x; else tmp = (-0.5 / (x * n)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 7.8e+220], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(-0.5 / N[(x * n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.8 \cdot 10^{+220}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-0.5}{x \cdot n}}{x}\\
\end{array}
\end{array}
if x < 7.80000000000000032e220Initial program 48.6%
Taylor expanded in n around inf 52.5%
log1p-define52.5%
Simplified52.5%
div-inv52.4%
Applied egg-rr52.4%
Taylor expanded in x around inf 35.5%
Simplified47.6%
if 7.80000000000000032e220 < x Initial program 92.3%
Taylor expanded in n around inf 92.3%
log1p-define92.3%
Simplified92.3%
Taylor expanded in x around inf 60.2%
associate-*r/60.2%
metadata-eval60.2%
*-commutative60.2%
Simplified60.2%
Taylor expanded in x around 0 78.7%
*-commutative78.7%
Simplified78.7%
(FPCore (x n) :precision binary64 (if (<= x 4.6e+220) (/ (/ 1.0 x) n) (/ (/ -0.5 (* x n)) x)))
double code(double x, double n) {
double tmp;
if (x <= 4.6e+220) {
tmp = (1.0 / x) / n;
} else {
tmp = (-0.5 / (x * n)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 4.6d+220) then
tmp = (1.0d0 / x) / n
else
tmp = ((-0.5d0) / (x * n)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 4.6e+220) {
tmp = (1.0 / x) / n;
} else {
tmp = (-0.5 / (x * n)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.6e+220: tmp = (1.0 / x) / n else: tmp = (-0.5 / (x * n)) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 4.6e+220) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(Float64(-0.5 / Float64(x * n)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.6e+220) tmp = (1.0 / x) / n; else tmp = (-0.5 / (x * n)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.6e+220], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(-0.5 / N[(x * n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+220}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-0.5}{x \cdot n}}{x}\\
\end{array}
\end{array}
if x < 4.59999999999999993e220Initial program 48.6%
Taylor expanded in n around inf 52.5%
log1p-define52.5%
Simplified52.5%
Taylor expanded in x around inf 39.7%
if 4.59999999999999993e220 < x Initial program 92.3%
Taylor expanded in n around inf 92.3%
log1p-define92.3%
Simplified92.3%
Taylor expanded in x around inf 60.2%
associate-*r/60.2%
metadata-eval60.2%
*-commutative60.2%
Simplified60.2%
Taylor expanded in x around 0 78.7%
*-commutative78.7%
Simplified78.7%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 55.6%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 43.0%
(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 55.6%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 42.5%
associate-/r*43.0%
Simplified43.0%
(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 55.6%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 42.5%
Final simplification42.5%
(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 55.6%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 42.5%
inv-pow42.5%
*-commutative42.5%
unpow-prod-down43.0%
inv-pow43.0%
add-exp-log42.0%
rec-exp42.0%
add-sqr-sqrt12.6%
sqrt-unprod14.2%
sqr-neg14.2%
sqrt-unprod1.6%
add-sqr-sqrt4.6%
add-exp-log4.6%
inv-pow4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
Simplified4.6%
herbie shell --seed 2024102
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))