
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2.5e-20)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-51)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5.0)
(/ (pow E (/ (log x) n)) (* 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) <= -2.5e-20) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-51) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5.0) {
tmp = pow(((double) M_E), (log(x) / n)) / (x * n);
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2.5e-20) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-51) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5.0) {
tmp = Math.pow(Math.E, (Math.log(x) / n)) / (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) <= -2.5e-20: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-51: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5.0: tmp = math.pow(math.e, (math.log(x) / n)) / (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) <= -2.5e-20) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-51) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5.0) tmp = Float64((exp(1) ^ Float64(log(x) / n)) / Float64(x * n)); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2.5e-20], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-51], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5.0], N[(N[Power[E, N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2.5 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-51}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5:\\
\;\;\;\;\frac{{e}^{\left(\frac{\log x}{n}\right)}}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.4999999999999999e-20Initial program 92.0%
Taylor expanded in x around inf 96.5%
mul-1-neg96.5%
log-rec96.5%
distribute-frac-neg96.5%
remove-double-neg96.5%
*-rgt-identity96.5%
associate-/l*96.5%
exp-to-pow96.5%
*-commutative96.5%
Simplified96.5%
if -2.4999999999999999e-20 < (/.f64 #s(literal 1 binary64) n) < 2e-51Initial program 27.1%
Taylor expanded in n around inf 82.4%
log1p-define82.4%
Simplified82.4%
if 2e-51 < (/.f64 #s(literal 1 binary64) n) < 5Initial program 4.9%
Taylor expanded in x around inf 76.9%
mul-1-neg76.9%
log-rec76.9%
mul-1-neg76.9%
distribute-neg-frac76.9%
mul-1-neg76.9%
remove-double-neg76.9%
*-commutative76.9%
Simplified76.9%
*-un-lft-identity76.9%
exp-prod77.8%
Applied egg-rr77.8%
if 5 < (/.f64 #s(literal 1 binary64) n) Initial program 62.0%
Taylor expanded in n around 0 62.0%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification89.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 8e-269)
(- 1.0 t_0)
(if (<= x 18.0)
(/
(-
(+
(log1p x)
(/
(+
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0)))
(/
(* 0.16666666666666666 (- (pow (log1p x) 3.0) (pow (log x) 3.0)))
n))
n))
(log x))
n)
(/ (* (/ 1.0 n) t_0) x)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 8e-269) {
tmp = 1.0 - t_0;
} else if (x <= 18.0) {
tmp = ((log1p(x) + (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) + ((0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0))) / n)) / n)) - log(x)) / n;
} else {
tmp = ((1.0 / n) * t_0) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 8e-269) {
tmp = 1.0 - t_0;
} else if (x <= 18.0) {
tmp = ((Math.log1p(x) + (((0.5 * (Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0))) + ((0.16666666666666666 * (Math.pow(Math.log1p(x), 3.0) - Math.pow(Math.log(x), 3.0))) / n)) / n)) - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) * t_0) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 8e-269: tmp = 1.0 - t_0 elif x <= 18.0: tmp = ((math.log1p(x) + (((0.5 * (math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0))) + ((0.16666666666666666 * (math.pow(math.log1p(x), 3.0) - math.pow(math.log(x), 3.0))) / n)) / n)) - math.log(x)) / n else: tmp = ((1.0 / n) * t_0) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 8e-269) tmp = Float64(1.0 - t_0); elseif (x <= 18.0) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) + Float64(Float64(0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / n)) / n)) - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) * t_0) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 8e-269], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 18.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.16666666666666666 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] * t$95$0), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 8 \cdot 10^{-269}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 18:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n}}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} \cdot t\_0}{x}\\
\end{array}
\end{array}
if x < 7.9999999999999997e-269Initial program 67.1%
Taylor expanded in x around 0 67.1%
*-rgt-identity67.1%
associate-/l*67.1%
exp-to-pow67.1%
Simplified67.1%
if 7.9999999999999997e-269 < x < 18Initial program 35.2%
Taylor expanded in n around -inf 84.4%
Simplified84.4%
if 18 < x Initial program 66.2%
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%
*-commutative97.9%
Simplified97.9%
add-cube-cbrt97.4%
pow397.4%
associate-/r*98.6%
div-inv98.6%
pow-to-exp98.6%
pow198.6%
pow-div98.2%
Applied egg-rr98.2%
rem-cube-cbrt98.7%
div-inv98.6%
pow-sub99.0%
pow199.0%
associate-*l/99.0%
Applied egg-rr99.0%
Final simplification88.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 1.02e-268)
(- 1.0 t_0)
(if (<= x 0.68)
(/
(-
(/
(+
(* -0.16666666666666666 (/ (pow (log x) 3.0) n))
(* (pow (log x) 2.0) -0.5))
n)
(log x))
n)
(/ (* (/ 1.0 n) t_0) x)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 1.02e-268) {
tmp = 1.0 - t_0;
} else if (x <= 0.68) {
tmp = ((((-0.16666666666666666 * (pow(log(x), 3.0) / n)) + (pow(log(x), 2.0) * -0.5)) / n) - log(x)) / n;
} else {
tmp = ((1.0 / n) * t_0) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 1.02d-268) then
tmp = 1.0d0 - t_0
else if (x <= 0.68d0) then
tmp = (((((-0.16666666666666666d0) * ((log(x) ** 3.0d0) / n)) + ((log(x) ** 2.0d0) * (-0.5d0))) / n) - log(x)) / n
else
tmp = ((1.0d0 / n) * t_0) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.02e-268) {
tmp = 1.0 - t_0;
} else if (x <= 0.68) {
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 = ((1.0 / n) * t_0) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.02e-268: tmp = 1.0 - t_0 elif x <= 0.68: 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 = ((1.0 / n) * t_0) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1.02e-268) tmp = Float64(1.0 - t_0); elseif (x <= 0.68) 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(Float64(1.0 / n) * t_0) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 1.02e-268) tmp = 1.0 - t_0; elseif (x <= 0.68) tmp = ((((-0.16666666666666666 * ((log(x) ^ 3.0) / n)) + ((log(x) ^ 2.0) * -0.5)) / n) - log(x)) / n; else tmp = ((1.0 / n) * t_0) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.02e-268], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 0.68], 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[(1.0 / n), $MachinePrecision] * t$95$0), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.02 \cdot 10^{-268}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} \cdot t\_0}{x}\\
\end{array}
\end{array}
if x < 1.0200000000000001e-268Initial program 67.1%
Taylor expanded in x around 0 67.1%
*-rgt-identity67.1%
associate-/l*67.1%
exp-to-pow67.1%
Simplified67.1%
if 1.0200000000000001e-268 < x < 0.680000000000000049Initial program 35.5%
Taylor expanded in x around 0 33.0%
*-rgt-identity33.0%
associate-/l*33.0%
exp-to-pow33.0%
Simplified33.0%
Taylor expanded in n around -inf 84.0%
mul-1-neg84.0%
Simplified84.0%
if 0.680000000000000049 < x Initial program 65.7%
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%
*-commutative97.2%
Simplified97.2%
add-cube-cbrt96.8%
pow396.8%
associate-/r*97.9%
div-inv97.9%
pow-to-exp97.9%
pow197.9%
pow-div97.5%
Applied egg-rr97.5%
rem-cube-cbrt98.0%
div-inv98.0%
pow-sub98.3%
pow198.3%
associate-*l/98.4%
Applied egg-rr98.4%
Final simplification88.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2.5e-20)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-51)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5.0)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 2e+187)
(+ (- 1.0 t_0) (/ x n))
(log1p (expm1 (/ x n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2.5e-20) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-51) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 2e+187) {
tmp = (1.0 - t_0) + (x / n);
} else {
tmp = log1p(expm1((x / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2.5e-20) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-51) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 2e+187) {
tmp = (1.0 - t_0) + (x / n);
} else {
tmp = Math.log1p(Math.expm1((x / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2.5e-20: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-51: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5.0: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 2e+187: tmp = (1.0 - t_0) + (x / n) else: tmp = math.log1p(math.expm1((x / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2.5e-20) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-51) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5.0) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 2e+187) tmp = Float64(Float64(1.0 - t_0) + Float64(x / n)); else tmp = log1p(expm1(Float64(x / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2.5e-20], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-51], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+187], N[(N[(1.0 - t$95$0), $MachinePrecision] + N[(x / n), $MachinePrecision]), $MachinePrecision], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2.5 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-51}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+187}:\\
\;\;\;\;\left(1 - t\_0\right) + \frac{x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.4999999999999999e-20Initial program 92.0%
Taylor expanded in x around inf 96.5%
mul-1-neg96.5%
log-rec96.5%
distribute-frac-neg96.5%
remove-double-neg96.5%
*-rgt-identity96.5%
associate-/l*96.5%
exp-to-pow96.5%
*-commutative96.5%
Simplified96.5%
if -2.4999999999999999e-20 < (/.f64 #s(literal 1 binary64) n) < 2e-51Initial program 27.1%
Taylor expanded in n around inf 82.4%
log1p-define82.4%
Simplified82.4%
if 2e-51 < (/.f64 #s(literal 1 binary64) n) < 5Initial program 4.9%
Taylor expanded in x around inf 76.9%
mul-1-neg76.9%
log-rec76.9%
mul-1-neg76.9%
distribute-neg-frac76.9%
mul-1-neg76.9%
remove-double-neg76.9%
*-commutative76.9%
Simplified76.9%
div-inv76.9%
pow-to-exp77.1%
*-un-lft-identity77.1%
times-frac77.1%
Applied egg-rr77.1%
if 5 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999981e187Initial program 84.0%
Taylor expanded in x around 0 84.9%
sub-neg84.9%
+-commutative84.9%
associate-+l+84.9%
sub-neg84.9%
*-rgt-identity84.9%
associate-/l*84.9%
exp-to-pow84.9%
Simplified84.9%
if 1.99999999999999981e187 < (/.f64 #s(literal 1 binary64) n) Initial program 41.0%
Taylor expanded in x around 0 29.6%
sub-neg29.6%
+-commutative29.6%
associate-+l+29.6%
sub-neg29.6%
*-rgt-identity29.6%
associate-/l*29.6%
exp-to-pow29.6%
Simplified29.6%
Taylor expanded in x around inf 5.6%
log1p-expm1-u76.0%
Applied egg-rr76.0%
Final simplification86.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2.5e-20)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-51)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5.0)
(* (/ 1.0 x) (/ t_0 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) <= -2.5e-20) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-51) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5.0) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2.5e-20) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-51) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5.0) {
tmp = (1.0 / x) * (t_0 / 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) <= -2.5e-20: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-51: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5.0: tmp = (1.0 / x) * (t_0 / 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) <= -2.5e-20) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-51) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5.0) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2.5e-20], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-51], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2.5 \cdot 10^{-20}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-51}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.4999999999999999e-20Initial program 92.0%
Taylor expanded in x around inf 96.5%
mul-1-neg96.5%
log-rec96.5%
distribute-frac-neg96.5%
remove-double-neg96.5%
*-rgt-identity96.5%
associate-/l*96.5%
exp-to-pow96.5%
*-commutative96.5%
Simplified96.5%
if -2.4999999999999999e-20 < (/.f64 #s(literal 1 binary64) n) < 2e-51Initial program 27.1%
Taylor expanded in n around inf 82.4%
log1p-define82.4%
Simplified82.4%
if 2e-51 < (/.f64 #s(literal 1 binary64) n) < 5Initial program 4.9%
Taylor expanded in x around inf 76.9%
mul-1-neg76.9%
log-rec76.9%
mul-1-neg76.9%
distribute-neg-frac76.9%
mul-1-neg76.9%
remove-double-neg76.9%
*-commutative76.9%
Simplified76.9%
div-inv76.9%
pow-to-exp77.1%
*-un-lft-identity77.1%
times-frac77.1%
Applied egg-rr77.1%
if 5 < (/.f64 #s(literal 1 binary64) n) Initial program 62.0%
Taylor expanded in n around 0 62.0%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 5.2e-266)
(- 1.0 t_0)
(if (<= x 1.15e-65)
(/ (log x) (- n))
(if (<= x 1.0) (log1p (expm1 (/ x n))) (/ (* (/ 1.0 n) t_0) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 5.2e-266) {
tmp = 1.0 - t_0;
} else if (x <= 1.15e-65) {
tmp = log(x) / -n;
} else if (x <= 1.0) {
tmp = log1p(expm1((x / n)));
} else {
tmp = ((1.0 / n) * t_0) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 5.2e-266) {
tmp = 1.0 - t_0;
} else if (x <= 1.15e-65) {
tmp = Math.log(x) / -n;
} else if (x <= 1.0) {
tmp = Math.log1p(Math.expm1((x / n)));
} else {
tmp = ((1.0 / n) * t_0) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 5.2e-266: tmp = 1.0 - t_0 elif x <= 1.15e-65: tmp = math.log(x) / -n elif x <= 1.0: tmp = math.log1p(math.expm1((x / n))) else: tmp = ((1.0 / n) * t_0) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 5.2e-266) tmp = Float64(1.0 - t_0); elseif (x <= 1.15e-65) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.0) tmp = log1p(expm1(Float64(x / n))); else tmp = Float64(Float64(Float64(1.0 / n) * t_0) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 5.2e-266], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 1.15e-65], 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[(N[(1.0 / n), $MachinePrecision] * t$95$0), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 5.2 \cdot 10^{-266}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-65}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} \cdot t\_0}{x}\\
\end{array}
\end{array}
if x < 5.1999999999999999e-266Initial program 67.1%
Taylor expanded in x around 0 67.1%
*-rgt-identity67.1%
associate-/l*67.1%
exp-to-pow67.1%
Simplified67.1%
if 5.1999999999999999e-266 < x < 1.15e-65Initial program 30.4%
Taylor expanded in x around 0 30.4%
*-rgt-identity30.4%
associate-/l*30.4%
exp-to-pow30.4%
Simplified30.4%
Taylor expanded in n around inf 60.3%
mul-1-neg60.3%
distribute-frac-neg260.3%
Simplified60.3%
if 1.15e-65 < x < 1Initial program 57.6%
Taylor expanded in x around 0 45.3%
sub-neg45.3%
+-commutative45.3%
associate-+l+46.1%
sub-neg46.1%
*-rgt-identity46.1%
associate-/l*46.1%
exp-to-pow46.1%
Simplified46.1%
Taylor expanded in x around inf 6.7%
log1p-expm1-u66.8%
Applied egg-rr66.8%
if 1 < x Initial program 65.7%
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%
*-commutative97.2%
Simplified97.2%
add-cube-cbrt96.8%
pow396.8%
associate-/r*97.9%
div-inv97.9%
pow-to-exp97.9%
pow197.9%
pow-div97.5%
Applied egg-rr97.5%
rem-cube-cbrt98.0%
div-inv98.0%
pow-sub98.3%
pow198.3%
associate-*l/98.4%
Applied egg-rr98.4%
Final simplification78.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 2.7e-266)
(- 1.0 t_0)
(if (<= x 2.8e-40) (/ (log x) (- n)) (/ (* (/ 1.0 n) t_0) x)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 2.7e-266) {
tmp = 1.0 - t_0;
} else if (x <= 2.8e-40) {
tmp = log(x) / -n;
} else {
tmp = ((1.0 / n) * t_0) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 2.7d-266) then
tmp = 1.0d0 - t_0
else if (x <= 2.8d-40) then
tmp = log(x) / -n
else
tmp = ((1.0d0 / n) * t_0) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 2.7e-266) {
tmp = 1.0 - t_0;
} else if (x <= 2.8e-40) {
tmp = Math.log(x) / -n;
} else {
tmp = ((1.0 / n) * t_0) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 2.7e-266: tmp = 1.0 - t_0 elif x <= 2.8e-40: tmp = math.log(x) / -n else: tmp = ((1.0 / n) * t_0) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 2.7e-266) tmp = Float64(1.0 - t_0); elseif (x <= 2.8e-40) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(Float64(1.0 / n) * t_0) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 2.7e-266) tmp = 1.0 - t_0; elseif (x <= 2.8e-40) tmp = log(x) / -n; else tmp = ((1.0 / n) * t_0) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 2.7e-266], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 2.8e-40], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] * t$95$0), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 2.7 \cdot 10^{-266}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-40}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} \cdot t\_0}{x}\\
\end{array}
\end{array}
if x < 2.69999999999999996e-266Initial program 67.1%
Taylor expanded in x around 0 67.1%
*-rgt-identity67.1%
associate-/l*67.1%
exp-to-pow67.1%
Simplified67.1%
if 2.69999999999999996e-266 < x < 2.8e-40Initial program 31.8%
Taylor expanded in x around 0 31.8%
*-rgt-identity31.8%
associate-/l*31.8%
exp-to-pow31.8%
Simplified31.8%
Taylor expanded in n around inf 59.3%
mul-1-neg59.3%
distribute-frac-neg259.3%
Simplified59.3%
if 2.8e-40 < x Initial program 65.6%
Taylor expanded in x around inf 91.3%
mul-1-neg91.3%
log-rec91.3%
mul-1-neg91.3%
distribute-neg-frac91.3%
mul-1-neg91.3%
remove-double-neg91.3%
*-commutative91.3%
Simplified91.3%
add-cube-cbrt90.9%
pow390.9%
associate-/r*91.9%
div-inv91.9%
pow-to-exp91.9%
pow191.9%
pow-div91.6%
Applied egg-rr91.6%
rem-cube-cbrt92.0%
div-inv92.0%
pow-sub92.3%
pow192.3%
associate-*l/92.3%
Applied egg-rr92.3%
Final simplification76.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 2.9e-266)
(- 1.0 t_0)
(if (<= x 2.6e-40) (/ (log x) (- n)) (* (/ 1.0 x) (/ t_0 n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 2.9e-266) {
tmp = 1.0 - t_0;
} else if (x <= 2.6e-40) {
tmp = log(x) / -n;
} else {
tmp = (1.0 / x) * (t_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) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 2.9d-266) then
tmp = 1.0d0 - t_0
else if (x <= 2.6d-40) then
tmp = log(x) / -n
else
tmp = (1.0d0 / x) * (t_0 / 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 <= 2.9e-266) {
tmp = 1.0 - t_0;
} else if (x <= 2.6e-40) {
tmp = Math.log(x) / -n;
} else {
tmp = (1.0 / x) * (t_0 / n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 2.9e-266: tmp = 1.0 - t_0 elif x <= 2.6e-40: tmp = math.log(x) / -n else: tmp = (1.0 / x) * (t_0 / n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 2.9e-266) tmp = Float64(1.0 - t_0); elseif (x <= 2.6e-40) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 2.9e-266) tmp = 1.0 - t_0; elseif (x <= 2.6e-40) tmp = log(x) / -n; else tmp = (1.0 / x) * (t_0 / 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, 2.9e-266], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 2.6e-40], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 2.9 \cdot 10^{-266}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-40}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\end{array}
\end{array}
if x < 2.89999999999999996e-266Initial program 67.1%
Taylor expanded in x around 0 67.1%
*-rgt-identity67.1%
associate-/l*67.1%
exp-to-pow67.1%
Simplified67.1%
if 2.89999999999999996e-266 < x < 2.6000000000000001e-40Initial program 31.8%
Taylor expanded in x around 0 31.8%
*-rgt-identity31.8%
associate-/l*31.8%
exp-to-pow31.8%
Simplified31.8%
Taylor expanded in n around inf 59.3%
mul-1-neg59.3%
distribute-frac-neg259.3%
Simplified59.3%
if 2.6000000000000001e-40 < x Initial program 65.6%
Taylor expanded in x around inf 91.3%
mul-1-neg91.3%
log-rec91.3%
mul-1-neg91.3%
distribute-neg-frac91.3%
mul-1-neg91.3%
remove-double-neg91.3%
*-commutative91.3%
Simplified91.3%
div-inv91.3%
pow-to-exp91.3%
*-un-lft-identity91.3%
times-frac92.3%
Applied egg-rr92.3%
(FPCore (x n) :precision binary64 (if (<= x 1.5e-268) (- 1.0 (pow x (/ 1.0 n))) (if (<= x 1.18e-40) (/ (log x) (- n)) (/ (pow x (+ (/ 1.0 n) -1.0)) n))))
double code(double x, double n) {
double tmp;
if (x <= 1.5e-268) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.18e-40) {
tmp = log(x) / -n;
} else {
tmp = pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.5d-268) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.18d-40) then
tmp = log(x) / -n
else
tmp = (x ** ((1.0d0 / n) + (-1.0d0))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.5e-268) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.18e-40) {
tmp = Math.log(x) / -n;
} else {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.5e-268: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.18e-40: tmp = math.log(x) / -n else: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.5e-268) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.18e-40) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.5e-268) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.18e-40) tmp = log(x) / -n; else tmp = (x ^ ((1.0 / n) + -1.0)) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.5e-268], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.18e-40], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5 \cdot 10^{-268}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1.18 \cdot 10^{-40}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\end{array}
\end{array}
if x < 1.4999999999999999e-268Initial program 67.1%
Taylor expanded in x around 0 67.1%
*-rgt-identity67.1%
associate-/l*67.1%
exp-to-pow67.1%
Simplified67.1%
if 1.4999999999999999e-268 < x < 1.1799999999999999e-40Initial program 31.8%
Taylor expanded in x around 0 31.8%
*-rgt-identity31.8%
associate-/l*31.8%
exp-to-pow31.8%
Simplified31.8%
Taylor expanded in n around inf 59.3%
mul-1-neg59.3%
distribute-frac-neg259.3%
Simplified59.3%
if 1.1799999999999999e-40 < x Initial program 65.6%
Taylor expanded in x around inf 91.3%
mul-1-neg91.3%
log-rec91.3%
mul-1-neg91.3%
distribute-neg-frac91.3%
mul-1-neg91.3%
remove-double-neg91.3%
*-commutative91.3%
Simplified91.3%
*-un-lft-identity91.3%
associate-/r*92.3%
div-inv92.3%
pow-to-exp92.4%
pow192.4%
pow-div92.0%
Applied egg-rr92.0%
*-lft-identity92.0%
sub-neg92.0%
metadata-eval92.0%
Simplified92.0%
(FPCore (x n) :precision binary64 (if (<= x 1.75e-265) (- 1.0 (pow x (/ 1.0 n))) (if (<= x 1.1e-6) (/ (- x (log x)) n) (/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if (x <= 1.75e-265) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.1e-6) {
tmp = (x - log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.75d-265) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.1d-6) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.75e-265) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.1e-6) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.75e-265: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.1e-6: tmp = (x - math.log(x)) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.75e-265) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.1e-6) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.75e-265) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.1e-6) tmp = (x - log(x)) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.75e-265], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.1e-6], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{-265}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1.75000000000000008e-265Initial program 67.1%
Taylor expanded in x around 0 67.1%
*-rgt-identity67.1%
associate-/l*67.1%
exp-to-pow67.1%
Simplified67.1%
if 1.75000000000000008e-265 < x < 1.1000000000000001e-6Initial program 33.2%
Taylor expanded in x around 0 33.5%
sub-neg33.5%
+-commutative33.5%
associate-+l+33.9%
sub-neg33.9%
*-rgt-identity33.9%
associate-/l*33.9%
exp-to-pow33.9%
Simplified33.9%
Taylor expanded in n around inf 57.6%
if 1.1000000000000001e-6 < x Initial program 66.9%
Taylor expanded in x around inf 94.7%
mul-1-neg94.7%
log-rec94.7%
distribute-frac-neg94.7%
remove-double-neg94.7%
*-rgt-identity94.7%
associate-/l*94.7%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in n around inf 53.9%
associate-/l/55.0%
Simplified55.0%
(FPCore (x n) :precision binary64 (if (<= x 1.1e-6) (/ (- x (log x)) n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (x <= 1.1e-6) {
tmp = (x - log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.1d-6) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.1e-6) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.1e-6: tmp = (x - math.log(x)) / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.1e-6) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.1e-6) tmp = (x - log(x)) / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.1e-6], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1.1000000000000001e-6Initial program 40.1%
Taylor expanded in x around 0 40.4%
sub-neg40.4%
+-commutative40.4%
associate-+l+40.6%
sub-neg40.6%
*-rgt-identity40.6%
associate-/l*40.6%
exp-to-pow40.6%
Simplified40.6%
Taylor expanded in n around inf 53.6%
if 1.1000000000000001e-6 < x Initial program 66.9%
Taylor expanded in x around inf 94.7%
mul-1-neg94.7%
log-rec94.7%
distribute-frac-neg94.7%
remove-double-neg94.7%
*-rgt-identity94.7%
associate-/l*94.7%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in n around inf 53.9%
associate-/l/55.0%
Simplified55.0%
(FPCore (x n) :precision binary64 (if (<= x 1.1e-6) (/ (log x) (- n)) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if (x <= 1.1e-6) {
tmp = log(x) / -n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.1d-6) then
tmp = log(x) / -n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.1e-6) {
tmp = Math.log(x) / -n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.1e-6: tmp = math.log(x) / -n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.1e-6) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.1e-6) tmp = log(x) / -n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.1e-6], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if x < 1.1000000000000001e-6Initial program 40.1%
Taylor expanded in x around 0 40.1%
*-rgt-identity40.1%
associate-/l*40.1%
exp-to-pow40.1%
Simplified40.1%
Taylor expanded in n around inf 53.4%
mul-1-neg53.4%
distribute-frac-neg253.4%
Simplified53.4%
if 1.1000000000000001e-6 < x Initial program 66.9%
Taylor expanded in x around inf 94.7%
mul-1-neg94.7%
log-rec94.7%
distribute-frac-neg94.7%
remove-double-neg94.7%
*-rgt-identity94.7%
associate-/l*94.7%
exp-to-pow94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in n around inf 53.9%
associate-/l/55.0%
Simplified55.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 52.0%
Taylor expanded in x around inf 54.3%
mul-1-neg54.3%
log-rec54.3%
distribute-frac-neg54.3%
remove-double-neg54.3%
*-rgt-identity54.3%
associate-/l*54.3%
exp-to-pow54.3%
*-commutative54.3%
Simplified54.3%
Taylor expanded in n around inf 35.7%
associate-/l/36.2%
Simplified36.2%
(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 52.0%
Taylor expanded in x around inf 54.3%
mul-1-neg54.3%
log-rec54.3%
mul-1-neg54.3%
distribute-neg-frac54.3%
mul-1-neg54.3%
remove-double-neg54.3%
*-commutative54.3%
Simplified54.3%
Taylor expanded in n around inf 35.7%
*-commutative35.7%
Simplified35.7%
(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 52.0%
Taylor expanded in x around 0 28.2%
sub-neg28.2%
+-commutative28.2%
associate-+l+24.4%
sub-neg24.4%
*-rgt-identity24.4%
associate-/l*24.4%
exp-to-pow24.4%
Simplified24.4%
Taylor expanded in x around inf 4.4%
herbie shell --seed 2024139
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))