
(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 16 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 (<= x 6.0)
(/
(log
(/
x
(exp
(+
(log1p x)
(/
(fma
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)))))
(- n))
(expm1 (log1p (/ (fma t_0 (/ (/ -0.5 n) x) (/ t_0 n)) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 6.0) {
tmp = log((x / exp((log1p(x) + (fma(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))))) / -n;
} else {
tmp = expm1(log1p((fma(t_0, ((-0.5 / n) / x), (t_0 / n)) / x)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 6.0) tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(0.5, Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n))))) / Float64(-n)); else tmp = expm1(log1p(Float64(fma(t_0, Float64(Float64(-0.5 / n) / x), Float64(t_0 / n)) / x))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 6.0], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $MachinePrecision] + 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] + 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[(Exp[N[Log[1 + N[(N[(t$95$0 * N[(N[(-0.5 / n), $MachinePrecision] / x), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 6:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(0.5, {\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}\right)}{n}}}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(t\_0, \frac{\frac{-0.5}{n}}{x}, \frac{t\_0}{n}\right)}{x}\right)\right)\\
\end{array}
\end{array}
if x < 6Initial program 43.4%
Taylor expanded in n around -inf 79.7%
Simplified79.7%
add-log-exp86.3%
diff-log86.3%
Applied egg-rr86.3%
if 6 < x Initial program 62.2%
Taylor expanded in x around inf 81.9%
Simplified81.9%
Taylor expanded in n around inf 98.2%
*-commutative98.2%
Simplified98.2%
expm1-log1p-u98.2%
expm1-undefine63.0%
Applied egg-rr63.0%
expm1-define98.2%
*-commutative98.2%
associate-/r*98.2%
Simplified98.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 4.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))
(* 2.0 (log (sqrt x))))
n)
(expm1 (log1p (/ (fma t_0 (/ (/ -0.5 n) x) (/ t_0 n)) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 4.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)) - (2.0 * log(sqrt(x)))) / n;
} else {
tmp = expm1(log1p((fma(t_0, ((-0.5 / n) / x), (t_0 / n)) / x)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 4.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)) - Float64(2.0 * log(sqrt(x)))) / n); else tmp = expm1(log1p(Float64(fma(t_0, Float64(Float64(-0.5 / n) / x), Float64(t_0 / n)) / x))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 4.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[(2.0 * N[Log[N[Sqrt[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(Exp[N[Log[1 + N[(N[(t$95$0 * N[(N[(-0.5 / n), $MachinePrecision] / x), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 4:\\
\;\;\;\;\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) - 2 \cdot \log \left(\sqrt{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(t\_0, \frac{\frac{-0.5}{n}}{x}, \frac{t\_0}{n}\right)}{x}\right)\right)\\
\end{array}
\end{array}
if x < 4Initial program 43.4%
Taylor expanded in n around -inf 79.7%
Simplified79.7%
add-sqr-sqrt79.7%
log-prod79.7%
Applied egg-rr79.7%
count-279.7%
Simplified79.7%
if 4 < x Initial program 62.2%
Taylor expanded in x around inf 81.9%
Simplified81.9%
Taylor expanded in n around inf 98.2%
*-commutative98.2%
Simplified98.2%
expm1-log1p-u98.2%
expm1-undefine63.0%
Applied egg-rr63.0%
expm1-define98.2%
*-commutative98.2%
associate-/r*98.2%
Simplified98.2%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 7.2)
(/
(-
(+
(log1p x)
(/
(+
(/
(* 0.16666666666666666 (- (pow (log1p x) 3.0) (pow (log x) 3.0)))
n)
(*
0.5
(-
(pow
(*
x
(+ (* x (- (* x (+ 0.3333333333333333 (* x -0.25))) 0.5)) 1.0))
2.0)
(pow (log x) 2.0))))
n))
(log x))
n)
(expm1 (log1p (/ (fma t_0 (/ (/ -0.5 n) x) (/ t_0 n)) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 7.2) {
tmp = ((log1p(x) + ((((0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0))) / n) + (0.5 * (pow((x * ((x * ((x * (0.3333333333333333 + (x * -0.25))) - 0.5)) + 1.0)), 2.0) - pow(log(x), 2.0)))) / n)) - log(x)) / n;
} else {
tmp = expm1(log1p((fma(t_0, ((-0.5 / n) / x), (t_0 / n)) / x)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 7.2) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(Float64(0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / n) + Float64(0.5 * Float64((Float64(x * Float64(Float64(x * Float64(Float64(x * Float64(0.3333333333333333 + Float64(x * -0.25))) - 0.5)) + 1.0)) ^ 2.0) - (log(x) ^ 2.0)))) / n)) - log(x)) / n); else tmp = expm1(log1p(Float64(fma(t_0, Float64(Float64(-0.5 / n) / x), Float64(t_0 / n)) / x))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 7.2], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(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] + N[(0.5 * N[(N[Power[N[(x * N[(N[(x * N[(N[(x * N[(0.3333333333333333 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(Exp[N[Log[1 + N[(N[(t$95$0 * N[(N[(-0.5 / n), $MachinePrecision] / x), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 7.2:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{\frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n} + 0.5 \cdot \left({\left(x \cdot \left(x \cdot \left(x \cdot \left(0.3333333333333333 + x \cdot -0.25\right) - 0.5\right) + 1\right)\right)}^{2} - {\log x}^{2}\right)}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(t\_0, \frac{\frac{-0.5}{n}}{x}, \frac{t\_0}{n}\right)}{x}\right)\right)\\
\end{array}
\end{array}
if x < 7.20000000000000018Initial program 43.4%
Taylor expanded in n around -inf 79.7%
Simplified79.7%
Taylor expanded in x around 0 79.7%
if 7.20000000000000018 < x Initial program 62.2%
Taylor expanded in x around inf 81.9%
Simplified81.9%
Taylor expanded in n around inf 98.2%
*-commutative98.2%
Simplified98.2%
expm1-log1p-u98.2%
expm1-undefine63.0%
Applied egg-rr63.0%
expm1-define98.2%
*-commutative98.2%
associate-/r*98.2%
Simplified98.2%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 1.0)
(/
(-
(/
(+
(* -0.16666666666666666 (/ (pow (log x) 3.0) n))
(* (pow (log x) 2.0) -0.5))
n)
(log x))
n)
(expm1 (log1p (/ (fma t_0 (/ (/ -0.5 n) x) (/ t_0 n)) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 1.0) {
tmp = ((((-0.16666666666666666 * (pow(log(x), 3.0) / n)) + (pow(log(x), 2.0) * -0.5)) / n) - log(x)) / n;
} else {
tmp = expm1(log1p((fma(t_0, ((-0.5 / n) / x), (t_0 / n)) / x)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1.0) 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 = expm1(log1p(Float64(fma(t_0, Float64(Float64(-0.5 / n) / x), Float64(t_0 / n)) / x))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.0], 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[(Exp[N[Log[1 + N[(N[(t$95$0 * N[(N[(-0.5 / n), $MachinePrecision] / x), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(t\_0, \frac{\frac{-0.5}{n}}{x}, \frac{t\_0}{n}\right)}{x}\right)\right)\\
\end{array}
\end{array}
if x < 1Initial program 43.4%
Taylor expanded in x around 0 41.6%
*-rgt-identity41.6%
associate-*l/41.6%
associate-/l*41.6%
exp-to-pow41.6%
Simplified41.6%
Taylor expanded in n around -inf 79.5%
mul-1-neg79.5%
Simplified79.5%
if 1 < x Initial program 62.2%
Taylor expanded in x around inf 81.9%
Simplified81.9%
Taylor expanded in n around inf 98.2%
*-commutative98.2%
Simplified98.2%
expm1-log1p-u98.2%
expm1-undefine63.0%
Applied egg-rr63.0%
expm1-define98.2%
*-commutative98.2%
associate-/r*98.2%
Simplified98.2%
Final simplification88.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-99)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 10.0)
(/ (- (log (+ x 1.0)) (* 2.0 (log (sqrt 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-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (log((x + 1.0)) - (2.0 * log(sqrt(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-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (Math.log((x + 1.0)) - (2.0 * Math.log(Math.sqrt(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-99: tmp = t_0 / (x * n) elif (1.0 / n) <= 10.0: tmp = (math.log((x + 1.0)) - (2.0 * math.log(math.sqrt(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-99) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(Float64(log(Float64(x + 1.0)) - Float64(2.0 * log(sqrt(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-99], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[(N[Log[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[(2.0 * N[Log[N[Sqrt[x], $MachinePrecision]], $MachinePrecision]), $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^{-99}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\log \left(x + 1\right) - 2 \cdot \log \left(\sqrt{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) < -2e-99Initial program 71.0%
Taylor expanded in x around inf 85.2%
log-rec85.2%
mul-1-neg85.2%
neg-mul-185.2%
mul-1-neg85.2%
distribute-frac-neg85.2%
remove-double-neg85.2%
*-rgt-identity85.2%
associate-/l*85.2%
exp-to-pow85.2%
*-commutative85.2%
Simplified85.2%
if -2e-99 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 33.8%
Taylor expanded in n around -inf 79.9%
Simplified79.9%
add-sqr-sqrt79.9%
log-prod79.9%
Applied egg-rr79.9%
count-279.9%
Simplified79.9%
Taylor expanded in n around inf 79.7%
if 10 < (/.f64 #s(literal 1 binary64) n) Initial program 58.9%
Taylor expanded in n around 0 58.9%
log1p-define100.0%
*-rgt-identity100.0%
associate-*l/100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification84.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-99)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 10.0)
(/ (- (log1p x) (log 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-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (log1p(x) - log(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-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (Math.log1p(x) - Math.log(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-99: tmp = t_0 / (x * n) elif (1.0 / n) <= 10.0: tmp = (math.log1p(x) - math.log(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-99) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(Float64(log1p(x) - log(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-99], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[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^{-99}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-99Initial program 71.0%
Taylor expanded in x around inf 85.2%
log-rec85.2%
mul-1-neg85.2%
neg-mul-185.2%
mul-1-neg85.2%
distribute-frac-neg85.2%
remove-double-neg85.2%
*-rgt-identity85.2%
associate-/l*85.2%
exp-to-pow85.2%
*-commutative85.2%
Simplified85.2%
if -2e-99 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 33.8%
Taylor expanded in n around inf 79.6%
log1p-define79.6%
Simplified79.6%
if 10 < (/.f64 #s(literal 1 binary64) n) Initial program 58.9%
Taylor expanded in n around 0 58.9%
log1p-define100.0%
*-rgt-identity100.0%
associate-*l/100.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) -2e-99)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 10.0)
(/ (- (log1p x) (log x)) n)
(-
(+
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ -1.0 n))))))
1.0)
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = ((x * ((1.0 / n) + (x * ((0.5 * (1.0 / pow(n, 2.0))) + (0.5 * (-1.0 / n)))))) + 1.0) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = ((x * ((1.0 / n) + (x * ((0.5 * (1.0 / Math.pow(n, 2.0))) + (0.5 * (-1.0 / n)))))) + 1.0) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-99: tmp = t_0 / (x * n) elif (1.0 / n) <= 10.0: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = ((x * ((1.0 / n) + (x * ((0.5 * (1.0 / math.pow(n, 2.0))) + (0.5 * (-1.0 / n)))))) + 1.0) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-99) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(Float64(Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) + Float64(0.5 * Float64(-1.0 / n)))))) + 1.0) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-99], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-99}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right) + 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-99Initial program 71.0%
Taylor expanded in x around inf 85.2%
log-rec85.2%
mul-1-neg85.2%
neg-mul-185.2%
mul-1-neg85.2%
distribute-frac-neg85.2%
remove-double-neg85.2%
*-rgt-identity85.2%
associate-/l*85.2%
exp-to-pow85.2%
*-commutative85.2%
Simplified85.2%
if -2e-99 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 33.8%
Taylor expanded in n around inf 79.6%
log1p-define79.6%
Simplified79.6%
if 10 < (/.f64 #s(literal 1 binary64) n) Initial program 58.9%
Taylor expanded in x around 0 82.4%
Final simplification82.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-99)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 10.0)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 2e+145)
(- (+ (/ x n) 1.0) t_0)
(pow (pow (/ (- 1.0 (/ 0.5 x)) (* x n)) 3.0) 0.3333333333333333))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 2e+145) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = pow(pow(((1.0 - (0.5 / x)) / (x * n)), 3.0), 0.3333333333333333);
}
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-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 2e+145) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = Math.pow(Math.pow(((1.0 - (0.5 / x)) / (x * n)), 3.0), 0.3333333333333333);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-99: tmp = t_0 / (x * n) elif (1.0 / n) <= 10.0: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 2e+145: tmp = ((x / n) + 1.0) - t_0 else: tmp = math.pow(math.pow(((1.0 - (0.5 / x)) / (x * n)), 3.0), 0.3333333333333333) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-99) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 2e+145) tmp = Float64(Float64(Float64(x / n) + 1.0) - t_0); else tmp = (Float64(Float64(1.0 - Float64(0.5 / x)) / Float64(x * n)) ^ 3.0) ^ 0.3333333333333333; 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-99], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+145], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[Power[N[Power[N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-99}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+145}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left({\left(\frac{1 - \frac{0.5}{x}}{x \cdot n}\right)}^{3}\right)}^{0.3333333333333333}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-99Initial program 71.0%
Taylor expanded in x around inf 85.2%
log-rec85.2%
mul-1-neg85.2%
neg-mul-185.2%
mul-1-neg85.2%
distribute-frac-neg85.2%
remove-double-neg85.2%
*-rgt-identity85.2%
associate-/l*85.2%
exp-to-pow85.2%
*-commutative85.2%
Simplified85.2%
if -2e-99 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 33.8%
Taylor expanded in n around inf 79.6%
log1p-define79.6%
Simplified79.6%
if 10 < (/.f64 #s(literal 1 binary64) n) < 2e145Initial program 83.6%
Taylor expanded in x around 0 83.8%
if 2e145 < (/.f64 #s(literal 1 binary64) n) Initial program 30.8%
Taylor expanded in x around inf 0.0%
Simplified0.0%
Taylor expanded in n around inf 0.2%
associate-*r/0.2%
metadata-eval0.2%
*-commutative0.2%
Simplified0.2%
add-cbrt-cube0.1%
pow1/380.6%
pow380.6%
Applied egg-rr80.6%
Final simplification82.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-99)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 10.0)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 2e+145)
(- (+ (/ x n) 1.0) t_0)
(log1p (expm1 (/ 1.0 (* x n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 2e+145) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = log1p(expm1((1.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 ((1.0 / n) <= -2e-99) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 10.0) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 2e+145) {
tmp = ((x / n) + 1.0) - t_0;
} else {
tmp = Math.log1p(Math.expm1((1.0 / (x * n))));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-99: tmp = t_0 / (x * n) elif (1.0 / n) <= 10.0: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 2e+145: tmp = ((x / n) + 1.0) - t_0 else: tmp = math.log1p(math.expm1((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) <= -2e-99) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 10.0) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 2e+145) tmp = Float64(Float64(Float64(x / n) + 1.0) - t_0); else tmp = log1p(expm1(Float64(1.0 / Float64(x * n)))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-99], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10.0], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+145], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-99}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+145}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-99Initial program 71.0%
Taylor expanded in x around inf 85.2%
log-rec85.2%
mul-1-neg85.2%
neg-mul-185.2%
mul-1-neg85.2%
distribute-frac-neg85.2%
remove-double-neg85.2%
*-rgt-identity85.2%
associate-/l*85.2%
exp-to-pow85.2%
*-commutative85.2%
Simplified85.2%
if -2e-99 < (/.f64 #s(literal 1 binary64) n) < 10Initial program 33.8%
Taylor expanded in n around inf 79.6%
log1p-define79.6%
Simplified79.6%
if 10 < (/.f64 #s(literal 1 binary64) n) < 2e145Initial program 83.6%
Taylor expanded in x around 0 83.8%
if 2e145 < (/.f64 #s(literal 1 binary64) n) Initial program 30.8%
Taylor expanded in x around inf 0.0%
Simplified0.0%
Taylor expanded in n around inf 0.2%
associate-*r/0.2%
metadata-eval0.2%
*-commutative0.2%
Simplified0.2%
Taylor expanded in x around inf 50.0%
log1p-expm1-u80.6%
Applied egg-rr80.6%
Final simplification82.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log x) (- n))))
(if (<= x 8.2e-291)
t_1
(if (<= x 1.4e-221)
(- (+ (/ x n) 1.0) t_0)
(if (<= x 7e-16) t_1 (/ t_0 (* x n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(x) / -n;
double tmp;
if (x <= 8.2e-291) {
tmp = t_1;
} else if (x <= 1.4e-221) {
tmp = ((x / n) + 1.0) - t_0;
} else if (x <= 7e-16) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(x) / -n
if (x <= 8.2d-291) then
tmp = t_1
else if (x <= 1.4d-221) then
tmp = ((x / n) + 1.0d0) - t_0
else if (x <= 7d-16) then
tmp = t_1
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 t_1 = Math.log(x) / -n;
double tmp;
if (x <= 8.2e-291) {
tmp = t_1;
} else if (x <= 1.4e-221) {
tmp = ((x / n) + 1.0) - t_0;
} else if (x <= 7e-16) {
tmp = t_1;
} else {
tmp = t_0 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(x) / -n tmp = 0 if x <= 8.2e-291: tmp = t_1 elif x <= 1.4e-221: tmp = ((x / n) + 1.0) - t_0 elif x <= 7e-16: tmp = t_1 else: tmp = t_0 / (x * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 8.2e-291) tmp = t_1; elseif (x <= 1.4e-221) tmp = Float64(Float64(Float64(x / n) + 1.0) - t_0); elseif (x <= 7e-16) tmp = t_1; else tmp = Float64(t_0 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(x) / -n; tmp = 0.0; if (x <= 8.2e-291) tmp = t_1; elseif (x <= 1.4e-221) tmp = ((x / n) + 1.0) - t_0; elseif (x <= 7e-16) tmp = t_1; 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]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 8.2e-291], t$95$1, If[LessEqual[x, 1.4e-221], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 7e-16], t$95$1, N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 8.2 \cdot 10^{-291}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-221}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - t\_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\end{array}
\end{array}
if x < 8.200000000000001e-291 or 1.4000000000000001e-221 < x < 7.00000000000000035e-16Initial program 31.4%
Taylor expanded in x around 0 31.4%
*-rgt-identity31.4%
associate-*l/31.4%
associate-/l*31.4%
exp-to-pow31.4%
Simplified31.4%
Taylor expanded in n around inf 62.2%
associate-*r/62.2%
neg-mul-162.2%
Simplified62.2%
if 8.200000000000001e-291 < x < 1.4000000000000001e-221Initial program 75.3%
Taylor expanded in x around 0 76.5%
if 7.00000000000000035e-16 < x Initial program 63.9%
Taylor expanded in x around inf 93.6%
log-rec93.6%
mul-1-neg93.6%
neg-mul-193.6%
mul-1-neg93.6%
distribute-frac-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.7%
*-commutative93.7%
Simplified93.7%
Final simplification79.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (pow x (/ 1.0 n))))
(if (<= x 5.5e-291)
t_0
(if (<= x 2.6e-222)
(- 1.0 t_1)
(if (<= x 1.2e-18) t_0 (/ t_1 (* x n)))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = pow(x, (1.0 / n));
double tmp;
if (x <= 5.5e-291) {
tmp = t_0;
} else if (x <= 2.6e-222) {
tmp = 1.0 - t_1;
} else if (x <= 1.2e-18) {
tmp = t_0;
} else {
tmp = t_1 / (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) :: t_1
real(8) :: tmp
t_0 = log(x) / -n
t_1 = x ** (1.0d0 / n)
if (x <= 5.5d-291) then
tmp = t_0
else if (x <= 2.6d-222) then
tmp = 1.0d0 - t_1
else if (x <= 1.2d-18) then
tmp = t_0
else
tmp = t_1 / (x * 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 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 5.5e-291) {
tmp = t_0;
} else if (x <= 2.6e-222) {
tmp = 1.0 - t_1;
} else if (x <= 1.2e-18) {
tmp = t_0;
} else {
tmp = t_1 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 5.5e-291: tmp = t_0 elif x <= 2.6e-222: tmp = 1.0 - t_1 elif x <= 1.2e-18: tmp = t_0 else: tmp = t_1 / (x * n) return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 5.5e-291) tmp = t_0; elseif (x <= 2.6e-222) tmp = Float64(1.0 - t_1); elseif (x <= 1.2e-18) tmp = t_0; else tmp = Float64(t_1 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = x ^ (1.0 / n); tmp = 0.0; if (x <= 5.5e-291) tmp = t_0; elseif (x <= 2.6e-222) tmp = 1.0 - t_1; elseif (x <= 1.2e-18) tmp = t_0; else tmp = t_1 / (x * 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[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 5.5e-291], t$95$0, If[LessEqual[x, 2.6e-222], N[(1.0 - t$95$1), $MachinePrecision], If[LessEqual[x, 1.2e-18], t$95$0, N[(t$95$1 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-291}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-222}:\\
\;\;\;\;1 - t\_1\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{x \cdot n}\\
\end{array}
\end{array}
if x < 5.5000000000000002e-291 or 2.5999999999999998e-222 < x < 1.19999999999999997e-18Initial program 31.4%
Taylor expanded in x around 0 31.4%
*-rgt-identity31.4%
associate-*l/31.4%
associate-/l*31.4%
exp-to-pow31.4%
Simplified31.4%
Taylor expanded in n around inf 62.2%
associate-*r/62.2%
neg-mul-162.2%
Simplified62.2%
if 5.5000000000000002e-291 < x < 2.5999999999999998e-222Initial program 75.3%
Taylor expanded in x around 0 75.3%
*-rgt-identity75.3%
associate-*l/75.3%
associate-/l*75.3%
exp-to-pow75.3%
Simplified75.3%
if 1.19999999999999997e-18 < x Initial program 63.9%
Taylor expanded in x around inf 93.6%
log-rec93.6%
mul-1-neg93.6%
neg-mul-193.6%
mul-1-neg93.6%
distribute-frac-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.7%
*-commutative93.7%
Simplified93.7%
Final simplification78.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 7e-291)
t_0
(if (<= x 2.6e-222)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.68)
t_0
(if (<= x 2.3e+218)
(/ (/ (+ (/ -0.5 x) 1.0) x) n)
(/ (/ -0.5 n) (* x x))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 7e-291) {
tmp = t_0;
} else if (x <= 2.6e-222) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.68) {
tmp = t_0;
} else if (x <= 2.3e+218) {
tmp = (((-0.5 / x) + 1.0) / x) / n;
} else {
tmp = (-0.5 / n) / (x * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 7d-291) then
tmp = t_0
else if (x <= 2.6d-222) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.68d0) then
tmp = t_0
else if (x <= 2.3d+218) then
tmp = ((((-0.5d0) / x) + 1.0d0) / x) / n
else
tmp = ((-0.5d0) / n) / (x * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 7e-291) {
tmp = t_0;
} else if (x <= 2.6e-222) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.68) {
tmp = t_0;
} else if (x <= 2.3e+218) {
tmp = (((-0.5 / x) + 1.0) / x) / n;
} else {
tmp = (-0.5 / n) / (x * x);
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 7e-291: tmp = t_0 elif x <= 2.6e-222: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.68: tmp = t_0 elif x <= 2.3e+218: tmp = (((-0.5 / x) + 1.0) / x) / n else: tmp = (-0.5 / n) / (x * x) return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 7e-291) tmp = t_0; elseif (x <= 2.6e-222) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.68) tmp = t_0; elseif (x <= 2.3e+218) tmp = Float64(Float64(Float64(Float64(-0.5 / x) + 1.0) / x) / n); else tmp = Float64(Float64(-0.5 / n) / Float64(x * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 7e-291) tmp = t_0; elseif (x <= 2.6e-222) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.68) tmp = t_0; elseif (x <= 2.3e+218) tmp = (((-0.5 / x) + 1.0) / x) / n; else tmp = (-0.5 / n) / (x * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 7e-291], t$95$0, If[LessEqual[x, 2.6e-222], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.68], t$95$0, If[LessEqual[x, 2.3e+218], N[(N[(N[(N[(-0.5 / x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(-0.5 / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 7 \cdot 10^{-291}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-222}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+218}:\\
\;\;\;\;\frac{\frac{\frac{-0.5}{x} + 1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-0.5}{n}}{x \cdot x}\\
\end{array}
\end{array}
if x < 6.99999999999999991e-291 or 2.5999999999999998e-222 < x < 0.680000000000000049Initial program 35.4%
Taylor expanded in x around 0 33.1%
*-rgt-identity33.1%
associate-*l/33.1%
associate-/l*33.1%
exp-to-pow33.1%
Simplified33.1%
Taylor expanded in n around inf 58.9%
associate-*r/58.9%
neg-mul-158.9%
Simplified58.9%
if 6.99999999999999991e-291 < x < 2.5999999999999998e-222Initial program 75.3%
Taylor expanded in x around 0 75.3%
*-rgt-identity75.3%
associate-*l/75.3%
associate-/l*75.3%
exp-to-pow75.3%
Simplified75.3%
if 0.680000000000000049 < x < 2.3000000000000001e218Initial program 46.8%
Taylor expanded in x around inf 80.6%
Simplified80.6%
Taylor expanded in n around inf 67.3%
associate-*r/67.3%
metadata-eval67.3%
*-commutative67.3%
Simplified67.3%
Taylor expanded in x around inf 68.0%
cancel-sign-sub-inv68.0%
metadata-eval68.0%
*-commutative68.0%
associate-*r/68.0%
metadata-eval68.0%
associate-/r*68.0%
metadata-eval68.0%
distribute-neg-frac68.0%
metadata-eval68.0%
associate-*r/68.0%
distribute-frac-neg68.0%
sub-neg68.0%
div-sub68.0%
associate-/r*67.3%
associate-*r/67.3%
metadata-eval67.3%
*-commutative67.3%
associate-/r*68.1%
Simplified68.1%
if 2.3000000000000001e218 < x Initial program 92.6%
Taylor expanded in x around inf 84.6%
Simplified84.6%
Taylor expanded in n around inf 70.8%
associate-*r/70.8%
metadata-eval70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in x around 0 92.6%
associate-/r*92.6%
Simplified92.6%
unpow292.6%
Applied egg-rr92.6%
Final simplification68.6%
(FPCore (x n) :precision binary64 (if (<= x 0.68) (/ (log x) (- n)) (if (<= x 1.9e+218) (/ (/ (+ (/ -0.5 x) 1.0) x) n) (/ (/ -0.5 n) (* x x)))))
double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = log(x) / -n;
} else if (x <= 1.9e+218) {
tmp = (((-0.5 / x) + 1.0) / x) / n;
} else {
tmp = (-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 (x <= 0.68d0) then
tmp = log(x) / -n
else if (x <= 1.9d+218) then
tmp = ((((-0.5d0) / x) + 1.0d0) / x) / n
else
tmp = ((-0.5d0) / n) / (x * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = Math.log(x) / -n;
} else if (x <= 1.9e+218) {
tmp = (((-0.5 / x) + 1.0) / x) / n;
} else {
tmp = (-0.5 / n) / (x * x);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.68: tmp = math.log(x) / -n elif x <= 1.9e+218: tmp = (((-0.5 / x) + 1.0) / x) / n else: tmp = (-0.5 / n) / (x * x) return tmp
function code(x, n) tmp = 0.0 if (x <= 0.68) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.9e+218) tmp = Float64(Float64(Float64(Float64(-0.5 / x) + 1.0) / x) / n); else tmp = Float64(Float64(-0.5 / n) / Float64(x * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.68) tmp = log(x) / -n; elseif (x <= 1.9e+218) tmp = (((-0.5 / x) + 1.0) / x) / n; else tmp = (-0.5 / n) / (x * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.68], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.9e+218], N[(N[(N[(N[(-0.5 / x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(-0.5 / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+218}:\\
\;\;\;\;\frac{\frac{\frac{-0.5}{x} + 1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-0.5}{n}}{x \cdot x}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 43.4%
Taylor expanded in x around 0 41.6%
*-rgt-identity41.6%
associate-*l/41.6%
associate-/l*41.6%
exp-to-pow41.6%
Simplified41.6%
Taylor expanded in n around inf 53.5%
associate-*r/53.5%
neg-mul-153.5%
Simplified53.5%
if 0.680000000000000049 < x < 1.90000000000000006e218Initial program 46.8%
Taylor expanded in x around inf 80.6%
Simplified80.6%
Taylor expanded in n around inf 67.3%
associate-*r/67.3%
metadata-eval67.3%
*-commutative67.3%
Simplified67.3%
Taylor expanded in x around inf 68.0%
cancel-sign-sub-inv68.0%
metadata-eval68.0%
*-commutative68.0%
associate-*r/68.0%
metadata-eval68.0%
associate-/r*68.0%
metadata-eval68.0%
distribute-neg-frac68.0%
metadata-eval68.0%
associate-*r/68.0%
distribute-frac-neg68.0%
sub-neg68.0%
div-sub68.0%
associate-/r*67.3%
associate-*r/67.3%
metadata-eval67.3%
*-commutative67.3%
associate-/r*68.1%
Simplified68.1%
if 1.90000000000000006e218 < x Initial program 92.6%
Taylor expanded in x around inf 84.6%
Simplified84.6%
Taylor expanded in n around inf 70.8%
associate-*r/70.8%
metadata-eval70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in x around 0 92.6%
associate-/r*92.6%
Simplified92.6%
unpow292.6%
Applied egg-rr92.6%
Final simplification63.9%
(FPCore (x n) :precision binary64 (if (<= x 2e+218) (/ (/ 1.0 n) x) (/ (/ -0.5 n) (* x x))))
double code(double x, double n) {
double tmp;
if (x <= 2e+218) {
tmp = (1.0 / n) / x;
} else {
tmp = (-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 (x <= 2d+218) then
tmp = (1.0d0 / n) / x
else
tmp = ((-0.5d0) / n) / (x * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2e+218) {
tmp = (1.0 / n) / x;
} else {
tmp = (-0.5 / n) / (x * x);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2e+218: tmp = (1.0 / n) / x else: tmp = (-0.5 / n) / (x * x) return tmp
function code(x, n) tmp = 0.0 if (x <= 2e+218) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(Float64(-0.5 / n) / Float64(x * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2e+218) tmp = (1.0 / n) / x; else tmp = (-0.5 / n) / (x * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2e+218], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(N[(-0.5 / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{+218}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-0.5}{n}}{x \cdot x}\\
\end{array}
\end{array}
if x < 2.00000000000000017e218Initial program 44.6%
Taylor expanded in x around inf 29.5%
Simplified29.4%
Taylor expanded in n around inf 24.6%
associate-*r/24.6%
metadata-eval24.6%
*-commutative24.6%
Simplified24.6%
Taylor expanded in x around inf 38.6%
associate-/r*38.9%
Simplified38.9%
if 2.00000000000000017e218 < x Initial program 92.6%
Taylor expanded in x around inf 84.6%
Simplified84.6%
Taylor expanded in n around inf 70.8%
associate-*r/70.8%
metadata-eval70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in x around 0 92.6%
associate-/r*92.6%
Simplified92.6%
unpow292.6%
Applied egg-rr92.6%
(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 51.9%
Taylor expanded in x around inf 37.9%
Simplified37.8%
Taylor expanded in n around inf 31.7%
associate-*r/31.7%
metadata-eval31.7%
*-commutative31.7%
Simplified31.7%
Taylor expanded in x around inf 43.5%
associate-/r*43.8%
Simplified43.8%
(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 51.9%
Taylor expanded in x around inf 37.9%
Simplified37.8%
Taylor expanded in n around inf 31.7%
associate-*r/31.7%
metadata-eval31.7%
*-commutative31.7%
Simplified31.7%
Taylor expanded in x around inf 43.5%
herbie shell --seed 2024163
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))