
(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 14 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 350000.0)
(/
(log
(/
x
(exp
(+
(log1p x)
(/
(fma
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)))))
(- n))
(/ (/ (pow x (/ 1.0 n)) x) n)))
double code(double x, double n) {
double tmp;
if (x <= 350000.0) {
tmp = log((x / exp((log1p(x) + (fma(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))))) / -n;
} else {
tmp = (pow(x, (1.0 / n)) / x) / n;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 350000.0) tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(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))))) / Float64(-n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / x) / n); end return tmp end
code[x_, n_] := If[LessEqual[x, 350000.0], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $MachinePrecision] + 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] + 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]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 350000:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(0.16666666666666666, \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\right)}{n}}}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{x}}{n}\\
\end{array}
\end{array}
if x < 3.5e5Initial program 44.5%
Taylor expanded in n around -inf 83.3%
Simplified83.3%
add-log-exp91.4%
diff-log91.4%
Applied egg-rr91.4%
if 3.5e5 < x Initial program 70.3%
Taylor expanded in x around inf 98.7%
mul-1-neg98.7%
log-rec98.7%
mul-1-neg98.7%
distribute-neg-frac98.7%
mul-1-neg98.7%
remove-double-neg98.7%
*-rgt-identity98.7%
associate-/l*98.7%
exp-to-pow98.7%
*-commutative98.7%
Simplified98.7%
*-un-lft-identity98.7%
associate-/r*99.5%
pow199.5%
pow-div99.3%
Applied egg-rr99.3%
*-lft-identity99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
unpow-prod-up99.6%
unpow-199.6%
Applied egg-rr99.6%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
(FPCore (x n)
:precision binary64
(if (<= x 350000.0)
(/
(-
(+
(log1p x)
(/
(+
(* (- (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))
(log x))
n)
(/ (/ (pow x (/ 1.0 n)) x) n)))
double code(double x, double n) {
double tmp;
if (x <= 350000.0) {
tmp = ((log1p(x) + ((((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)) - log(x)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / x) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 350000.0) {
tmp = ((Math.log1p(x) + ((((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) * 0.5) + (0.16666666666666666 * ((Math.pow(Math.log1p(x), 3.0) - Math.pow(Math.log(x), 3.0)) / n))) / n)) - Math.log(x)) / n;
} else {
tmp = (Math.pow(x, (1.0 / n)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 350000.0: tmp = ((math.log1p(x) + ((((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) * 0.5) + (0.16666666666666666 * ((math.pow(math.log1p(x), 3.0) - math.pow(math.log(x), 3.0)) / n))) / n)) - math.log(x)) / n else: tmp = (math.pow(x, (1.0 / n)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 350000.0) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(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)) - log(x)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / x) / n); end return tmp end
code[x_, n_] := If[LessEqual[x, 350000.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(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), $MachinePrecision] + 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] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 350000:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) \cdot 0.5 + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{x}}{n}\\
\end{array}
\end{array}
if x < 3.5e5Initial program 44.5%
Taylor expanded in n around -inf 83.3%
Simplified83.3%
if 3.5e5 < x Initial program 70.3%
Taylor expanded in x around inf 98.7%
mul-1-neg98.7%
log-rec98.7%
mul-1-neg98.7%
distribute-neg-frac98.7%
mul-1-neg98.7%
remove-double-neg98.7%
*-rgt-identity98.7%
associate-/l*98.7%
exp-to-pow98.7%
*-commutative98.7%
Simplified98.7%
*-un-lft-identity98.7%
associate-/r*99.5%
pow199.5%
pow-div99.3%
Applied egg-rr99.3%
*-lft-identity99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
unpow-prod-up99.6%
unpow-199.6%
Applied egg-rr99.6%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification90.1%
(FPCore (x n)
:precision binary64
(if (<= x 0.32)
(/
(-
(/
(+
(* -0.16666666666666666 (/ (pow (log x) 3.0) n))
(* (pow (log x) 2.0) -0.5))
n)
(log x))
n)
(/ (/ (pow x (/ 1.0 n)) x) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.32) {
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)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.32d0) 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)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.32) {
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)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.32: 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)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.32) 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)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.32) tmp = ((((-0.16666666666666666 * ((log(x) ^ 3.0) / n)) + ((log(x) ^ 2.0) * -0.5)) / n) - log(x)) / n; else tmp = ((x ^ (1.0 / n)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.32], 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] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.32:\\
\;\;\;\;\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)}}{x}}{n}\\
\end{array}
\end{array}
if x < 0.320000000000000007Initial program 45.3%
Taylor expanded in x around 0 44.0%
*-rgt-identity44.0%
associate-/l*44.0%
exp-to-pow44.0%
Simplified44.0%
Taylor expanded in n around -inf 83.0%
mul-1-neg83.0%
Simplified83.0%
if 0.320000000000000007 < x Initial program 68.5%
Taylor expanded in x around inf 97.2%
mul-1-neg97.2%
log-rec97.2%
mul-1-neg97.2%
distribute-neg-frac97.2%
mul-1-neg97.2%
remove-double-neg97.2%
*-rgt-identity97.2%
associate-/l*97.2%
exp-to-pow97.2%
*-commutative97.2%
Simplified97.2%
*-un-lft-identity97.2%
associate-/r*98.0%
pow198.0%
pow-div97.8%
Applied egg-rr97.8%
*-lft-identity97.8%
sub-neg97.8%
metadata-eval97.8%
Simplified97.8%
unpow-prod-up98.1%
unpow-198.1%
Applied egg-rr98.1%
associate-*r/98.0%
*-rgt-identity98.0%
Simplified98.0%
Final simplification89.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-53)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-23)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 50.0)
(/ 1.0 (/ (* x n) t_0))
(- (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) <= -5e-53) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-23) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 50.0) {
tmp = 1.0 / ((x * n) / t_0);
} 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) <= -5e-53) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-23) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 50.0) {
tmp = 1.0 / ((x * n) / t_0);
} 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) <= -5e-53: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-23: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 50.0: tmp = 1.0 / ((x * n) / t_0) 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) <= -5e-53) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-23) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 50.0) tmp = Float64(1.0 / Float64(Float64(x * n) / t_0)); 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], -5e-53], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-23], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], N[(1.0 / N[(N[(x * n), $MachinePrecision] / t$95$0), $MachinePrecision]), $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 -5 \cdot 10^{-53}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\frac{1}{\frac{x \cdot n}{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e-53Initial program 92.9%
Taylor expanded in x around inf 97.9%
mul-1-neg97.9%
log-rec97.9%
mul-1-neg97.9%
distribute-neg-frac97.9%
mul-1-neg97.9%
remove-double-neg97.9%
*-rgt-identity97.9%
associate-/l*97.9%
exp-to-pow97.9%
*-commutative97.9%
Simplified97.9%
if -5e-53 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999992e-23Initial program 33.1%
Taylor expanded in n around inf 83.8%
log1p-define83.8%
Simplified83.8%
if 1.99999999999999992e-23 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 19.6%
Taylor expanded in x around inf 67.6%
mul-1-neg67.6%
log-rec67.6%
mul-1-neg67.6%
distribute-neg-frac67.6%
mul-1-neg67.6%
remove-double-neg67.6%
*-rgt-identity67.6%
associate-/l*67.6%
exp-to-pow67.8%
*-commutative67.8%
Simplified67.8%
clear-num68.0%
inv-pow68.0%
Applied egg-rr68.0%
unpow-168.0%
Simplified68.0%
if 50 < (/.f64 #s(literal 1 binary64) n) Initial program 48.2%
Taylor expanded in n around 0 48.2%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-53)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-23)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 50.0)
(/ 1.0 (/ (* x n) t_0))
(-
(+ (* x (+ (/ 1.0 n) (* x (/ (+ -0.5 (/ 0.5 n)) 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) <= -5e-53) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-23) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 50.0) {
tmp = 1.0 / ((x * n) / t_0);
} else {
tmp = ((x * ((1.0 / n) + (x * ((-0.5 + (0.5 / n)) / n)))) + 1.0) - 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) <= -5e-53) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-23) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 50.0) {
tmp = 1.0 / ((x * n) / t_0);
} else {
tmp = ((x * ((1.0 / n) + (x * ((-0.5 + (0.5 / n)) / 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) <= -5e-53: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-23: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 50.0: tmp = 1.0 / ((x * n) / t_0) else: tmp = ((x * ((1.0 / n) + (x * ((-0.5 + (0.5 / n)) / 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) <= -5e-53) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-23) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 50.0) tmp = Float64(1.0 / Float64(Float64(x * n) / t_0)); else tmp = Float64(Float64(Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(-0.5 + Float64(0.5 / n)) / n)))) + 1.0) - 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], -5e-53], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-23], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], N[(1.0 / N[(N[(x * n), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $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 -5 \cdot 10^{-53}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\frac{1}{\frac{x \cdot n}{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(\frac{1}{n} + x \cdot \frac{-0.5 + \frac{0.5}{n}}{n}\right) + 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e-53Initial program 92.9%
Taylor expanded in x around inf 97.9%
mul-1-neg97.9%
log-rec97.9%
mul-1-neg97.9%
distribute-neg-frac97.9%
mul-1-neg97.9%
remove-double-neg97.9%
*-rgt-identity97.9%
associate-/l*97.9%
exp-to-pow97.9%
*-commutative97.9%
Simplified97.9%
if -5e-53 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999992e-23Initial program 33.1%
Taylor expanded in n around inf 83.8%
log1p-define83.8%
Simplified83.8%
if 1.99999999999999992e-23 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 19.6%
Taylor expanded in x around inf 67.6%
mul-1-neg67.6%
log-rec67.6%
mul-1-neg67.6%
distribute-neg-frac67.6%
mul-1-neg67.6%
remove-double-neg67.6%
*-rgt-identity67.6%
associate-/l*67.6%
exp-to-pow67.8%
*-commutative67.8%
Simplified67.8%
clear-num68.0%
inv-pow68.0%
Applied egg-rr68.0%
unpow-168.0%
Simplified68.0%
if 50 < (/.f64 #s(literal 1 binary64) n) Initial program 48.2%
Taylor expanded in x around 0 81.0%
Taylor expanded in n around inf 81.0%
sub-neg81.0%
associate-*r/81.0%
metadata-eval81.0%
metadata-eval81.0%
Simplified81.0%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 6e-285)
(- 1.0 t_0)
(if (<= x 2e-100)
(/ (log x) (- n))
(if (<= x 1.0) (log1p (expm1 (/ x n))) (/ (/ t_0 x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 6e-285) {
tmp = 1.0 - t_0;
} else if (x <= 2e-100) {
tmp = log(x) / -n;
} else if (x <= 1.0) {
tmp = log1p(expm1((x / n)));
} else {
tmp = (t_0 / x) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 6e-285) {
tmp = 1.0 - t_0;
} else if (x <= 2e-100) {
tmp = Math.log(x) / -n;
} else if (x <= 1.0) {
tmp = Math.log1p(Math.expm1((x / n)));
} else {
tmp = (t_0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 6e-285: tmp = 1.0 - t_0 elif x <= 2e-100: tmp = math.log(x) / -n elif x <= 1.0: tmp = math.log1p(math.expm1((x / n))) else: tmp = (t_0 / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 6e-285) tmp = Float64(1.0 - t_0); elseif (x <= 2e-100) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.0) tmp = log1p(expm1(Float64(x / n))); else tmp = Float64(Float64(t_0 / x) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 6e-285], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 2e-100], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.0], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 6 \cdot 10^{-285}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-100}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{x}}{n}\\
\end{array}
\end{array}
if x < 6.00000000000000007e-285Initial program 77.8%
Taylor expanded in x around 0 77.8%
*-rgt-identity77.8%
associate-/l*77.8%
exp-to-pow77.8%
Simplified77.8%
if 6.00000000000000007e-285 < x < 2e-100Initial program 38.3%
Taylor expanded in x around 0 38.3%
*-rgt-identity38.3%
associate-/l*38.3%
exp-to-pow38.3%
Simplified38.3%
Taylor expanded in n around inf 60.3%
mul-1-neg60.3%
Simplified60.3%
if 2e-100 < x < 1Initial program 50.7%
Taylor expanded in x around 0 46.1%
Taylor expanded in x around inf 5.7%
log1p-expm1-u68.5%
Applied egg-rr68.5%
if 1 < x Initial program 68.5%
Taylor expanded in x around inf 97.2%
mul-1-neg97.2%
log-rec97.2%
mul-1-neg97.2%
distribute-neg-frac97.2%
mul-1-neg97.2%
remove-double-neg97.2%
*-rgt-identity97.2%
associate-/l*97.2%
exp-to-pow97.2%
*-commutative97.2%
Simplified97.2%
*-un-lft-identity97.2%
associate-/r*98.0%
pow198.0%
pow-div97.8%
Applied egg-rr97.8%
*-lft-identity97.8%
sub-neg97.8%
metadata-eval97.8%
Simplified97.8%
unpow-prod-up98.1%
unpow-198.1%
Applied egg-rr98.1%
associate-*r/98.0%
*-rgt-identity98.0%
Simplified98.0%
Final simplification78.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2000000000.0)
(/ t_0 n)
(if (<= (/ 1.0 n) 4e-282)
(/ (/ (- 1.0 (/ 0.5 x)) n) x)
(if (<= (/ 1.0 n) 1.5e-9)
(/ (log x) (- n))
(if (<= (/ 1.0 n) 5e+175) (- 1.0 t_0) (/ 1.0 (* x n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2000000000.0) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 4e-282) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else if ((1.0 / n) <= 1.5e-9) {
tmp = log(x) / -n;
} else if ((1.0 / n) <= 5e+175) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2000000000.0d0)) then
tmp = t_0 / n
else if ((1.0d0 / n) <= 4d-282) then
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
else if ((1.0d0 / n) <= 1.5d-9) then
tmp = log(x) / -n
else if ((1.0d0 / n) <= 5d+175) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (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) <= -2000000000.0) {
tmp = t_0 / n;
} else if ((1.0 / n) <= 4e-282) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else if ((1.0 / n) <= 1.5e-9) {
tmp = Math.log(x) / -n;
} else if ((1.0 / n) <= 5e+175) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2000000000.0: tmp = t_0 / n elif (1.0 / n) <= 4e-282: tmp = ((1.0 - (0.5 / x)) / n) / x elif (1.0 / n) <= 1.5e-9: tmp = math.log(x) / -n elif (1.0 / n) <= 5e+175: tmp = 1.0 - t_0 else: tmp = 1.0 / (x * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2000000000.0) tmp = Float64(t_0 / n); elseif (Float64(1.0 / n) <= 4e-282) tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); elseif (Float64(1.0 / n) <= 1.5e-9) tmp = Float64(log(x) / Float64(-n)); elseif (Float64(1.0 / n) <= 5e+175) tmp = Float64(1.0 - t_0); else tmp = Float64(1.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) <= -2000000000.0) tmp = t_0 / n; elseif ((1.0 / n) <= 4e-282) tmp = ((1.0 - (0.5 / x)) / n) / x; elseif ((1.0 / n) <= 1.5e-9) tmp = log(x) / -n; elseif ((1.0 / n) <= 5e+175) tmp = 1.0 - t_0; else tmp = 1.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], -2000000000.0], N[(t$95$0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-282], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.5e-9], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+175], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2000000000:\\
\;\;\;\;\frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-282}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+175}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e9Initial program 100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
associate-/r*100.0%
pow1100.0%
pow-div100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in n around 0 100.0%
if -2e9 < (/.f64 #s(literal 1 binary64) n) < 4.0000000000000001e-282Initial program 39.2%
Taylor expanded in x around inf 59.9%
Simplified59.9%
Taylor expanded in n around inf 59.3%
associate-*r/59.3%
metadata-eval59.3%
Simplified59.3%
if 4.0000000000000001e-282 < (/.f64 #s(literal 1 binary64) n) < 1.49999999999999999e-9Initial program 23.8%
Taylor expanded in x around 0 23.7%
*-rgt-identity23.7%
associate-/l*23.7%
exp-to-pow23.7%
Simplified23.7%
Taylor expanded in n around inf 59.3%
mul-1-neg59.3%
Simplified59.3%
if 1.49999999999999999e-9 < (/.f64 #s(literal 1 binary64) n) < 5e175Initial program 69.4%
Taylor expanded in x around 0 59.4%
*-rgt-identity59.4%
associate-/l*59.4%
exp-to-pow59.4%
Simplified59.4%
if 5e175 < (/.f64 #s(literal 1 binary64) n) Initial program 10.0%
Taylor expanded in x around inf 0.3%
mul-1-neg0.3%
log-rec0.3%
mul-1-neg0.3%
distribute-neg-frac0.3%
mul-1-neg0.3%
remove-double-neg0.3%
*-rgt-identity0.3%
associate-/l*0.3%
exp-to-pow0.3%
*-commutative0.3%
Simplified0.3%
Taylor expanded in n around inf 86.5%
*-commutative86.5%
Simplified86.5%
Final simplification74.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 3.15e-285)
t_0
(if (<= x 2.2e-121)
(/ (log x) (- n))
(if (<= x 1.0) t_0 (/ (/ (- 1.0 (/ 0.5 x)) n) x))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 3.15e-285) {
tmp = t_0;
} else if (x <= 2.2e-121) {
tmp = log(x) / -n;
} else if (x <= 1.0) {
tmp = t_0;
} else {
tmp = ((1.0 - (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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 3.15d-285) then
tmp = t_0
else if (x <= 2.2d-121) then
tmp = log(x) / -n
else if (x <= 1.0d0) then
tmp = t_0
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 3.15e-285) {
tmp = t_0;
} else if (x <= 2.2e-121) {
tmp = Math.log(x) / -n;
} else if (x <= 1.0) {
tmp = t_0;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 3.15e-285: tmp = t_0 elif x <= 2.2e-121: tmp = math.log(x) / -n elif x <= 1.0: tmp = t_0 else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 3.15e-285) tmp = t_0; elseif (x <= 2.2e-121) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.0) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 3.15e-285) tmp = t_0; elseif (x <= 2.2e-121) tmp = log(x) / -n; elseif (x <= 1.0) tmp = t_0; else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3.15e-285], t$95$0, If[LessEqual[x, 2.2e-121], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.0], t$95$0, N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 3.15 \cdot 10^{-285}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-121}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 3.14999999999999994e-285 or 2.20000000000000021e-121 < x < 1Initial program 58.6%
Taylor expanded in x around 0 55.5%
*-rgt-identity55.5%
associate-/l*55.5%
exp-to-pow55.5%
Simplified55.5%
if 3.14999999999999994e-285 < x < 2.20000000000000021e-121Initial program 35.5%
Taylor expanded in x around 0 35.5%
*-rgt-identity35.5%
associate-/l*35.5%
exp-to-pow35.5%
Simplified35.5%
Taylor expanded in n around inf 62.3%
mul-1-neg62.3%
Simplified62.3%
if 1 < x Initial program 68.5%
Taylor expanded in x around inf 89.0%
Simplified89.0%
Taylor expanded in n around inf 63.6%
associate-*r/63.6%
metadata-eval63.6%
Simplified63.6%
Final simplification61.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 8e-286)
(- 1.0 t_0)
(if (<= x 4.2e-122) (/ (log x) (- n)) (/ (/ t_0 x) n)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 8e-286) {
tmp = 1.0 - t_0;
} else if (x <= 4.2e-122) {
tmp = log(x) / -n;
} else {
tmp = (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 (x <= 8d-286) then
tmp = 1.0d0 - t_0
else if (x <= 4.2d-122) then
tmp = log(x) / -n
else
tmp = (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 (x <= 8e-286) {
tmp = 1.0 - t_0;
} else if (x <= 4.2e-122) {
tmp = Math.log(x) / -n;
} else {
tmp = (t_0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 8e-286: tmp = 1.0 - t_0 elif x <= 4.2e-122: tmp = math.log(x) / -n else: tmp = (t_0 / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 8e-286) tmp = Float64(1.0 - t_0); elseif (x <= 4.2e-122) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(t_0 / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 8e-286) tmp = 1.0 - t_0; elseif (x <= 4.2e-122) tmp = log(x) / -n; else tmp = (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[x, 8e-286], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 4.2e-122], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 8 \cdot 10^{-286}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-122}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{x}}{n}\\
\end{array}
\end{array}
if x < 8.0000000000000004e-286Initial program 77.8%
Taylor expanded in x around 0 77.8%
*-rgt-identity77.8%
associate-/l*77.8%
exp-to-pow77.8%
Simplified77.8%
if 8.0000000000000004e-286 < x < 4.19999999999999985e-122Initial program 35.5%
Taylor expanded in x around 0 35.5%
*-rgt-identity35.5%
associate-/l*35.5%
exp-to-pow35.5%
Simplified35.5%
Taylor expanded in n around inf 62.3%
mul-1-neg62.3%
Simplified62.3%
if 4.19999999999999985e-122 < x Initial program 63.8%
Taylor expanded in x around inf 81.8%
mul-1-neg81.8%
log-rec81.8%
mul-1-neg81.8%
distribute-neg-frac81.8%
mul-1-neg81.8%
remove-double-neg81.8%
*-rgt-identity81.8%
associate-/l*81.8%
exp-to-pow81.9%
*-commutative81.9%
Simplified81.9%
*-un-lft-identity81.9%
associate-/r*82.5%
pow182.5%
pow-div82.3%
Applied egg-rr82.3%
*-lft-identity82.3%
sub-neg82.3%
metadata-eval82.3%
Simplified82.3%
unpow-prod-up82.5%
unpow-182.5%
Applied egg-rr82.5%
associate-*r/82.5%
*-rgt-identity82.5%
Simplified82.5%
Final simplification75.6%
(FPCore (x n) :precision binary64 (if (<= x 0.98) (/ (- x (log x)) n) (/ (/ (- 1.0 (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.98) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 - (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 <= 0.98d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.98) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.98: tmp = (x - math.log(x)) / n else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.98) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.98) tmp = (x - log(x)) / n; else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.98], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.98:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 0.97999999999999998Initial program 45.3%
Taylor expanded in x around 0 44.2%
Taylor expanded in n around inf 50.6%
if 0.97999999999999998 < x Initial program 68.5%
Taylor expanded in x around inf 89.0%
Simplified89.0%
Taylor expanded in n around inf 63.6%
associate-*r/63.6%
metadata-eval63.6%
Simplified63.6%
(FPCore (x n) :precision binary64 (if (<= x 0.66) (/ (log x) (- n)) (/ (/ (- 1.0 (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.66) {
tmp = log(x) / -n;
} else {
tmp = ((1.0 - (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 <= 0.66d0) then
tmp = log(x) / -n
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.66) {
tmp = Math.log(x) / -n;
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.66: tmp = math.log(x) / -n else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.66) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.66) tmp = log(x) / -n; else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.66], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.66:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 0.660000000000000031Initial program 45.3%
Taylor expanded in x around 0 44.0%
*-rgt-identity44.0%
associate-/l*44.0%
exp-to-pow44.0%
Simplified44.0%
Taylor expanded in n around inf 50.2%
mul-1-neg50.2%
Simplified50.2%
if 0.660000000000000031 < x Initial program 68.5%
Taylor expanded in x around inf 89.0%
Simplified89.0%
Taylor expanded in n around inf 63.6%
associate-*r/63.6%
metadata-eval63.6%
Simplified63.6%
Final simplification56.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(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.3%
Taylor expanded in x around inf 61.2%
mul-1-neg61.2%
log-rec61.2%
mul-1-neg61.2%
distribute-neg-frac61.2%
mul-1-neg61.2%
remove-double-neg61.2%
*-rgt-identity61.2%
associate-/l*61.2%
exp-to-pow61.2%
*-commutative61.2%
Simplified61.2%
*-un-lft-identity61.2%
associate-/r*61.7%
pow161.7%
pow-div61.6%
Applied egg-rr61.6%
*-lft-identity61.6%
sub-neg61.6%
metadata-eval61.6%
Simplified61.6%
Taylor expanded in n around inf 42.9%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 55.3%
Taylor expanded in x around inf 61.2%
mul-1-neg61.2%
log-rec61.2%
mul-1-neg61.2%
distribute-neg-frac61.2%
mul-1-neg61.2%
remove-double-neg61.2%
*-rgt-identity61.2%
associate-/l*61.2%
exp-to-pow61.2%
*-commutative61.2%
Simplified61.2%
Taylor expanded in n around inf 42.5%
*-commutative42.5%
Simplified42.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.3%
Taylor expanded in x around 0 32.9%
Taylor expanded in x around inf 4.3%
herbie shell --seed 2024116
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))