
(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 (log (+ 1.0 x)))
(t_1 (exp (/ (log x) n)))
(t_2 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-98)
(/ (/ t_2 n) x)
(if (<= (/ 1.0 n) 5e-46)
(-
(+
(* 0.5 (/ (pow t_0 2.0) (pow n 2.0)))
(+
(* 0.041666666666666664 (/ (pow t_0 4.0) (pow n 4.0)))
(-
(/ (- t_0 (log x)) n)
(/
(-
(* -0.16666666666666666 (pow t_0 3.0))
(* -0.16666666666666666 (pow (log x) 3.0)))
(pow n 3.0)))))
(+
(* 0.5 (/ (pow (log x) 2.0) (pow n 2.0)))
(* 0.041666666666666664 (/ (pow (log x) 4.0) (pow n 4.0)))))
(if (<= (/ 1.0 n) 0.5)
(+
(/ (* t_1 (+ (/ 0.5 (* n n)) (/ -0.5 n))) (* x x))
(+
(+
(/ t_1 (* n x))
(/
t_1
(/
(pow x 3.0)
(+
(/ 0.3333333333333333 n)
(+ (/ 0.16666666666666666 (pow n 3.0)) (/ (/ -0.5 n) n))))))
(/
(-
(+
(/ 0.041666666666666664 (pow n 4.0))
(/ 0.4583333333333333 (* n n)))
(+ (/ 0.25 (pow n 3.0)) (/ 0.25 n)))
(/ (pow x 4.0) t_1))))
(- (exp (/ x n)) t_2))))))
double code(double x, double n) {
double t_0 = log((1.0 + x));
double t_1 = exp((log(x) / n));
double t_2 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-98) {
tmp = (t_2 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = ((0.5 * (pow(t_0, 2.0) / pow(n, 2.0))) + ((0.041666666666666664 * (pow(t_0, 4.0) / pow(n, 4.0))) + (((t_0 - log(x)) / n) - (((-0.16666666666666666 * pow(t_0, 3.0)) - (-0.16666666666666666 * pow(log(x), 3.0))) / pow(n, 3.0))))) - ((0.5 * (pow(log(x), 2.0) / pow(n, 2.0))) + (0.041666666666666664 * (pow(log(x), 4.0) / pow(n, 4.0))));
} else if ((1.0 / n) <= 0.5) {
tmp = ((t_1 * ((0.5 / (n * n)) + (-0.5 / n))) / (x * x)) + (((t_1 / (n * x)) + (t_1 / (pow(x, 3.0) / ((0.3333333333333333 / n) + ((0.16666666666666666 / pow(n, 3.0)) + ((-0.5 / n) / n)))))) + ((((0.041666666666666664 / pow(n, 4.0)) + (0.4583333333333333 / (n * n))) - ((0.25 / pow(n, 3.0)) + (0.25 / n))) / (pow(x, 4.0) / t_1)));
} else {
tmp = exp((x / n)) - t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = log((1.0d0 + x))
t_1 = exp((log(x) / n))
t_2 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-98)) then
tmp = (t_2 / n) / x
else if ((1.0d0 / n) <= 5d-46) then
tmp = ((0.5d0 * ((t_0 ** 2.0d0) / (n ** 2.0d0))) + ((0.041666666666666664d0 * ((t_0 ** 4.0d0) / (n ** 4.0d0))) + (((t_0 - log(x)) / n) - ((((-0.16666666666666666d0) * (t_0 ** 3.0d0)) - ((-0.16666666666666666d0) * (log(x) ** 3.0d0))) / (n ** 3.0d0))))) - ((0.5d0 * ((log(x) ** 2.0d0) / (n ** 2.0d0))) + (0.041666666666666664d0 * ((log(x) ** 4.0d0) / (n ** 4.0d0))))
else if ((1.0d0 / n) <= 0.5d0) then
tmp = ((t_1 * ((0.5d0 / (n * n)) + ((-0.5d0) / n))) / (x * x)) + (((t_1 / (n * x)) + (t_1 / ((x ** 3.0d0) / ((0.3333333333333333d0 / n) + ((0.16666666666666666d0 / (n ** 3.0d0)) + (((-0.5d0) / n) / n)))))) + ((((0.041666666666666664d0 / (n ** 4.0d0)) + (0.4583333333333333d0 / (n * n))) - ((0.25d0 / (n ** 3.0d0)) + (0.25d0 / n))) / ((x ** 4.0d0) / t_1)))
else
tmp = exp((x / n)) - t_2
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log((1.0 + x));
double t_1 = Math.exp((Math.log(x) / n));
double t_2 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-98) {
tmp = (t_2 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = ((0.5 * (Math.pow(t_0, 2.0) / Math.pow(n, 2.0))) + ((0.041666666666666664 * (Math.pow(t_0, 4.0) / Math.pow(n, 4.0))) + (((t_0 - Math.log(x)) / n) - (((-0.16666666666666666 * Math.pow(t_0, 3.0)) - (-0.16666666666666666 * Math.pow(Math.log(x), 3.0))) / Math.pow(n, 3.0))))) - ((0.5 * (Math.pow(Math.log(x), 2.0) / Math.pow(n, 2.0))) + (0.041666666666666664 * (Math.pow(Math.log(x), 4.0) / Math.pow(n, 4.0))));
} else if ((1.0 / n) <= 0.5) {
tmp = ((t_1 * ((0.5 / (n * n)) + (-0.5 / n))) / (x * x)) + (((t_1 / (n * x)) + (t_1 / (Math.pow(x, 3.0) / ((0.3333333333333333 / n) + ((0.16666666666666666 / Math.pow(n, 3.0)) + ((-0.5 / n) / n)))))) + ((((0.041666666666666664 / Math.pow(n, 4.0)) + (0.4583333333333333 / (n * n))) - ((0.25 / Math.pow(n, 3.0)) + (0.25 / n))) / (Math.pow(x, 4.0) / t_1)));
} else {
tmp = Math.exp((x / n)) - t_2;
}
return tmp;
}
def code(x, n): t_0 = math.log((1.0 + x)) t_1 = math.exp((math.log(x) / n)) t_2 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-98: tmp = (t_2 / n) / x elif (1.0 / n) <= 5e-46: tmp = ((0.5 * (math.pow(t_0, 2.0) / math.pow(n, 2.0))) + ((0.041666666666666664 * (math.pow(t_0, 4.0) / math.pow(n, 4.0))) + (((t_0 - math.log(x)) / n) - (((-0.16666666666666666 * math.pow(t_0, 3.0)) - (-0.16666666666666666 * math.pow(math.log(x), 3.0))) / math.pow(n, 3.0))))) - ((0.5 * (math.pow(math.log(x), 2.0) / math.pow(n, 2.0))) + (0.041666666666666664 * (math.pow(math.log(x), 4.0) / math.pow(n, 4.0)))) elif (1.0 / n) <= 0.5: tmp = ((t_1 * ((0.5 / (n * n)) + (-0.5 / n))) / (x * x)) + (((t_1 / (n * x)) + (t_1 / (math.pow(x, 3.0) / ((0.3333333333333333 / n) + ((0.16666666666666666 / math.pow(n, 3.0)) + ((-0.5 / n) / n)))))) + ((((0.041666666666666664 / math.pow(n, 4.0)) + (0.4583333333333333 / (n * n))) - ((0.25 / math.pow(n, 3.0)) + (0.25 / n))) / (math.pow(x, 4.0) / t_1))) else: tmp = math.exp((x / n)) - t_2 return tmp
function code(x, n) t_0 = log(Float64(1.0 + x)) t_1 = exp(Float64(log(x) / n)) t_2 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-98) tmp = Float64(Float64(t_2 / n) / x); elseif (Float64(1.0 / n) <= 5e-46) tmp = Float64(Float64(Float64(0.5 * Float64((t_0 ^ 2.0) / (n ^ 2.0))) + Float64(Float64(0.041666666666666664 * Float64((t_0 ^ 4.0) / (n ^ 4.0))) + Float64(Float64(Float64(t_0 - log(x)) / n) - Float64(Float64(Float64(-0.16666666666666666 * (t_0 ^ 3.0)) - Float64(-0.16666666666666666 * (log(x) ^ 3.0))) / (n ^ 3.0))))) - Float64(Float64(0.5 * Float64((log(x) ^ 2.0) / (n ^ 2.0))) + Float64(0.041666666666666664 * Float64((log(x) ^ 4.0) / (n ^ 4.0))))); elseif (Float64(1.0 / n) <= 0.5) tmp = Float64(Float64(Float64(t_1 * Float64(Float64(0.5 / Float64(n * n)) + Float64(-0.5 / n))) / Float64(x * x)) + Float64(Float64(Float64(t_1 / Float64(n * x)) + Float64(t_1 / Float64((x ^ 3.0) / Float64(Float64(0.3333333333333333 / n) + Float64(Float64(0.16666666666666666 / (n ^ 3.0)) + Float64(Float64(-0.5 / n) / n)))))) + Float64(Float64(Float64(Float64(0.041666666666666664 / (n ^ 4.0)) + Float64(0.4583333333333333 / Float64(n * n))) - Float64(Float64(0.25 / (n ^ 3.0)) + Float64(0.25 / n))) / Float64((x ^ 4.0) / t_1)))); else tmp = Float64(exp(Float64(x / n)) - t_2); end return tmp end
function tmp_2 = code(x, n) t_0 = log((1.0 + x)); t_1 = exp((log(x) / n)); t_2 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-98) tmp = (t_2 / n) / x; elseif ((1.0 / n) <= 5e-46) tmp = ((0.5 * ((t_0 ^ 2.0) / (n ^ 2.0))) + ((0.041666666666666664 * ((t_0 ^ 4.0) / (n ^ 4.0))) + (((t_0 - log(x)) / n) - (((-0.16666666666666666 * (t_0 ^ 3.0)) - (-0.16666666666666666 * (log(x) ^ 3.0))) / (n ^ 3.0))))) - ((0.5 * ((log(x) ^ 2.0) / (n ^ 2.0))) + (0.041666666666666664 * ((log(x) ^ 4.0) / (n ^ 4.0)))); elseif ((1.0 / n) <= 0.5) tmp = ((t_1 * ((0.5 / (n * n)) + (-0.5 / n))) / (x * x)) + (((t_1 / (n * x)) + (t_1 / ((x ^ 3.0) / ((0.3333333333333333 / n) + ((0.16666666666666666 / (n ^ 3.0)) + ((-0.5 / n) / n)))))) + ((((0.041666666666666664 / (n ^ 4.0)) + (0.4583333333333333 / (n * n))) - ((0.25 / (n ^ 3.0)) + (0.25 / n))) / ((x ^ 4.0) / t_1))); else tmp = exp((x / n)) - t_2; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-98], N[(N[(t$95$2 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-46], N[(N[(N[(0.5 * N[(N[Power[t$95$0, 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.041666666666666664 * N[(N[Power[t$95$0, 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t$95$0 - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(N[(-0.16666666666666666 * N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision] - N[(-0.16666666666666666 * N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.5], N[(N[(N[(t$95$1 * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t$95$1 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 / N[(N[Power[x, 3.0], $MachinePrecision] / N[(N[(0.3333333333333333 / n), $MachinePrecision] + N[(N[(0.16666666666666666 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 / n), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(0.041666666666666664 / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.4583333333333333 / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.25 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] + N[(0.25 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 4.0], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$2), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(1 + x\right)\\
t_1 := e^{\frac{\log x}{n}}\\
t_2 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-98}:\\
\;\;\;\;\frac{\frac{t_2}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\left(0.5 \cdot \frac{{t_0}^{2}}{{n}^{2}} + \left(0.041666666666666664 \cdot \frac{{t_0}^{4}}{{n}^{4}} + \left(\frac{t_0 - \log x}{n} - \frac{-0.16666666666666666 \cdot {t_0}^{3} - -0.16666666666666666 \cdot {\log x}^{3}}{{n}^{3}}\right)\right)\right) - \left(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + 0.041666666666666664 \cdot \frac{{\log x}^{4}}{{n}^{4}}\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 0.5:\\
\;\;\;\;\frac{t_1 \cdot \left(\frac{0.5}{n \cdot n} + \frac{-0.5}{n}\right)}{x \cdot x} + \left(\left(\frac{t_1}{n \cdot x} + \frac{t_1}{\frac{{x}^{3}}{\frac{0.3333333333333333}{n} + \left(\frac{0.16666666666666666}{{n}^{3}} + \frac{\frac{-0.5}{n}}{n}\right)}}\right) + \frac{\left(\frac{0.041666666666666664}{{n}^{4}} + \frac{0.4583333333333333}{n \cdot n}\right) - \left(\frac{0.25}{{n}^{3}} + \frac{0.25}{n}\right)}{\frac{{x}^{4}}{t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_2\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.99999999999999988e-98Initial program 77.4%
Taylor expanded in n around 0 77.4%
log1p-def77.4%
*-rgt-identity77.4%
associate-*r/77.4%
unpow-177.4%
exp-to-pow77.4%
/-rgt-identity77.4%
metadata-eval77.4%
associate-/l*77.4%
*-commutative77.4%
*-commutative77.4%
associate-/l*77.4%
metadata-eval77.4%
/-rgt-identity77.4%
unpow-177.4%
Simplified77.4%
Taylor expanded in x around inf 90.0%
mul-1-neg90.0%
log-rec90.0%
distribute-frac-neg90.0%
remove-double-neg90.0%
*-commutative90.0%
Simplified90.0%
add-exp-log35.4%
div-inv35.4%
pow-to-exp35.4%
Applied egg-rr35.4%
add-exp-log90.0%
*-commutative90.0%
associate-/r*90.0%
Applied egg-rr90.0%
if -1.99999999999999988e-98 < (/.f64 1 n) < 4.99999999999999992e-46Initial program 33.0%
Taylor expanded in n around -inf 81.6%
if 4.99999999999999992e-46 < (/.f64 1 n) < 0.5Initial program 11.9%
Taylor expanded in n around 0 11.9%
log1p-def11.9%
*-rgt-identity11.9%
associate-*r/11.0%
unpow-111.0%
exp-to-pow11.4%
/-rgt-identity11.4%
metadata-eval11.4%
associate-/l*11.4%
*-commutative11.4%
*-commutative11.4%
associate-/l*11.4%
metadata-eval11.4%
/-rgt-identity11.4%
unpow-111.4%
Simplified11.4%
Taylor expanded in x around inf 78.6%
Simplified78.6%
if 0.5 < (/.f64 1 n) Initial program 47.3%
Taylor expanded in n around 0 47.3%
log1p-def100.0%
*-rgt-identity100.0%
associate-*r/100.0%
unpow-1100.0%
exp-to-pow100.0%
/-rgt-identity100.0%
metadata-eval100.0%
associate-/l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (exp (/ (log x) n))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-98)
(/ (/ t_1 n) x)
(if (<= (/ 1.0 n) 5e-46)
(+
(fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) (/ (- (log1p x) (log x)) n))
(* -0.5 (/ (pow (log x) 2.0) (* n n))))
(if (<= (/ 1.0 n) 0.5)
(+
(/ (* t_0 (+ (/ 0.5 (* n n)) (/ -0.5 n))) (* x x))
(+
(+
(/ t_0 (* n x))
(/
t_0
(/
(pow x 3.0)
(+
(/ 0.3333333333333333 n)
(+ (/ 0.16666666666666666 (pow n 3.0)) (/ (/ -0.5 n) n))))))
(/
(-
(+
(/ 0.041666666666666664 (pow n 4.0))
(/ 0.4583333333333333 (* n n)))
(+ (/ 0.25 (pow n 3.0)) (/ 0.25 n)))
(/ (pow x 4.0) t_0))))
(- (exp (/ x n)) t_1))))))
double code(double x, double n) {
double t_0 = exp((log(x) / n));
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-98) {
tmp = (t_1 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), ((log1p(x) - log(x)) / n)) + (-0.5 * (pow(log(x), 2.0) / (n * n)));
} else if ((1.0 / n) <= 0.5) {
tmp = ((t_0 * ((0.5 / (n * n)) + (-0.5 / n))) / (x * x)) + (((t_0 / (n * x)) + (t_0 / (pow(x, 3.0) / ((0.3333333333333333 / n) + ((0.16666666666666666 / pow(n, 3.0)) + ((-0.5 / n) / n)))))) + ((((0.041666666666666664 / pow(n, 4.0)) + (0.4583333333333333 / (n * n))) - ((0.25 / pow(n, 3.0)) + (0.25 / n))) / (pow(x, 4.0) / t_0)));
} else {
tmp = exp((x / n)) - t_1;
}
return tmp;
}
function code(x, n) t_0 = exp(Float64(log(x) / n)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-98) tmp = Float64(Float64(t_1 / n) / x); elseif (Float64(1.0 / n) <= 5e-46) tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), Float64(Float64(log1p(x) - log(x)) / n)) + Float64(-0.5 * Float64((log(x) ^ 2.0) / Float64(n * n)))); elseif (Float64(1.0 / n) <= 0.5) tmp = Float64(Float64(Float64(t_0 * Float64(Float64(0.5 / Float64(n * n)) + Float64(-0.5 / n))) / Float64(x * x)) + Float64(Float64(Float64(t_0 / Float64(n * x)) + Float64(t_0 / Float64((x ^ 3.0) / Float64(Float64(0.3333333333333333 / n) + Float64(Float64(0.16666666666666666 / (n ^ 3.0)) + Float64(Float64(-0.5 / n) / n)))))) + Float64(Float64(Float64(Float64(0.041666666666666664 / (n ^ 4.0)) + Float64(0.4583333333333333 / Float64(n * n))) - Float64(Float64(0.25 / (n ^ 3.0)) + Float64(0.25 / n))) / Float64((x ^ 4.0) / t_0)))); else tmp = Float64(exp(Float64(x / n)) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-98], N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-46], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.5], N[(N[(N[(t$95$0 * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / N[(N[Power[x, 3.0], $MachinePrecision] / N[(N[(0.3333333333333333 / n), $MachinePrecision] + N[(N[(0.16666666666666666 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 / n), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(0.041666666666666664 / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.4583333333333333 / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.25 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] + N[(0.25 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 4.0], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\log x}{n}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-98}:\\
\;\;\;\;\frac{\frac{t_1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + -0.5 \cdot \frac{{\log x}^{2}}{n \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.5:\\
\;\;\;\;\frac{t_0 \cdot \left(\frac{0.5}{n \cdot n} + \frac{-0.5}{n}\right)}{x \cdot x} + \left(\left(\frac{t_0}{n \cdot x} + \frac{t_0}{\frac{{x}^{3}}{\frac{0.3333333333333333}{n} + \left(\frac{0.16666666666666666}{{n}^{3}} + \frac{\frac{-0.5}{n}}{n}\right)}}\right) + \frac{\left(\frac{0.041666666666666664}{{n}^{4}} + \frac{0.4583333333333333}{n \cdot n}\right) - \left(\frac{0.25}{{n}^{3}} + \frac{0.25}{n}\right)}{\frac{{x}^{4}}{t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.99999999999999988e-98Initial program 77.4%
Taylor expanded in n around 0 77.4%
log1p-def77.4%
*-rgt-identity77.4%
associate-*r/77.4%
unpow-177.4%
exp-to-pow77.4%
/-rgt-identity77.4%
metadata-eval77.4%
associate-/l*77.4%
*-commutative77.4%
*-commutative77.4%
associate-/l*77.4%
metadata-eval77.4%
/-rgt-identity77.4%
unpow-177.4%
Simplified77.4%
Taylor expanded in x around inf 90.0%
mul-1-neg90.0%
log-rec90.0%
distribute-frac-neg90.0%
remove-double-neg90.0%
*-commutative90.0%
Simplified90.0%
add-exp-log35.4%
div-inv35.4%
pow-to-exp35.4%
Applied egg-rr35.4%
add-exp-log90.0%
*-commutative90.0%
associate-/r*90.0%
Applied egg-rr90.0%
if -1.99999999999999988e-98 < (/.f64 1 n) < 4.99999999999999992e-46Initial program 33.0%
Taylor expanded in n around inf 81.6%
associate--r+76.7%
sub-neg76.7%
Simplified81.6%
if 4.99999999999999992e-46 < (/.f64 1 n) < 0.5Initial program 11.9%
Taylor expanded in n around 0 11.9%
log1p-def11.9%
*-rgt-identity11.9%
associate-*r/11.0%
unpow-111.0%
exp-to-pow11.4%
/-rgt-identity11.4%
metadata-eval11.4%
associate-/l*11.4%
*-commutative11.4%
*-commutative11.4%
associate-/l*11.4%
metadata-eval11.4%
/-rgt-identity11.4%
unpow-111.4%
Simplified11.4%
Taylor expanded in x around inf 78.6%
Simplified78.6%
if 0.5 < (/.f64 1 n) Initial program 47.3%
Taylor expanded in n around 0 47.3%
log1p-def100.0%
*-rgt-identity100.0%
associate-*r/100.0%
unpow-1100.0%
exp-to-pow100.0%
/-rgt-identity100.0%
metadata-eval100.0%
associate-/l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-98)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-46)
(+
(fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) (/ (- (log1p x) (log x)) n))
(* -0.5 (/ (pow (log x) 2.0) (* n n))))
(if (<= (/ 1.0 n) 0.5)
(+
(/ t_0 (* n x))
(/ (- (/ 0.3333333333333333 (pow x 3.0)) (/ 0.5 (* x x))) n))
(- (exp (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-98) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), ((log1p(x) - log(x)) / n)) + (-0.5 * (pow(log(x), 2.0) / (n * n)));
} else if ((1.0 / n) <= 0.5) {
tmp = (t_0 / (n * x)) + (((0.3333333333333333 / pow(x, 3.0)) - (0.5 / (x * x))) / n);
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-98) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-46) tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), Float64(Float64(log1p(x) - log(x)) / n)) + Float64(-0.5 * Float64((log(x) ^ 2.0) / Float64(n * n)))); elseif (Float64(1.0 / n) <= 0.5) tmp = Float64(Float64(t_0 / Float64(n * x)) + Float64(Float64(Float64(0.3333333333333333 / (x ^ 3.0)) - Float64(0.5 / Float64(x * 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], -2e-98], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-46], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.5], N[(N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 \cdot 10^{-98}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + -0.5 \cdot \frac{{\log x}^{2}}{n \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.5:\\
\;\;\;\;\frac{t_0}{n \cdot x} + \frac{\frac{0.3333333333333333}{{x}^{3}} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.99999999999999988e-98Initial program 77.4%
Taylor expanded in n around 0 77.4%
log1p-def77.4%
*-rgt-identity77.4%
associate-*r/77.4%
unpow-177.4%
exp-to-pow77.4%
/-rgt-identity77.4%
metadata-eval77.4%
associate-/l*77.4%
*-commutative77.4%
*-commutative77.4%
associate-/l*77.4%
metadata-eval77.4%
/-rgt-identity77.4%
unpow-177.4%
Simplified77.4%
Taylor expanded in x around inf 90.0%
mul-1-neg90.0%
log-rec90.0%
distribute-frac-neg90.0%
remove-double-neg90.0%
*-commutative90.0%
Simplified90.0%
add-exp-log35.4%
div-inv35.4%
pow-to-exp35.4%
Applied egg-rr35.4%
add-exp-log90.0%
*-commutative90.0%
associate-/r*90.0%
Applied egg-rr90.0%
if -1.99999999999999988e-98 < (/.f64 1 n) < 4.99999999999999992e-46Initial program 33.0%
Taylor expanded in n around inf 81.6%
associate--r+76.7%
sub-neg76.7%
Simplified81.6%
if 4.99999999999999992e-46 < (/.f64 1 n) < 0.5Initial program 11.9%
Taylor expanded in x around inf 77.8%
Simplified77.7%
Taylor expanded in n around inf 77.7%
associate-*r/77.7%
metadata-eval77.7%
associate-*r/77.7%
metadata-eval77.7%
unpow277.7%
Simplified77.7%
if 0.5 < (/.f64 1 n) Initial program 47.3%
Taylor expanded in n around 0 47.3%
log1p-def100.0%
*-rgt-identity100.0%
associate-*r/100.0%
unpow-1100.0%
exp-to-pow100.0%
/-rgt-identity100.0%
metadata-eval100.0%
associate-/l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-98)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-46)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 0.5)
(+
(/ t_0 (* n x))
(/ (- (/ 0.3333333333333333 (pow x 3.0)) (/ 0.5 (* x x))) n))
(- (exp (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-98) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 0.5) {
tmp = (t_0 / (n * x)) + (((0.3333333333333333 / pow(x, 3.0)) - (0.5 / (x * 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) <= -2e-98) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 0.5) {
tmp = (t_0 / (n * x)) + (((0.3333333333333333 / Math.pow(x, 3.0)) - (0.5 / (x * x))) / n);
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-98: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-46: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 0.5: tmp = (t_0 / (n * x)) + (((0.3333333333333333 / math.pow(x, 3.0)) - (0.5 / (x * x))) / n) else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-98) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-46) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 0.5) tmp = Float64(Float64(t_0 / Float64(n * x)) + Float64(Float64(Float64(0.3333333333333333 / (x ^ 3.0)) - Float64(0.5 / Float64(x * 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], -2e-98], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-46], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.5], N[(N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 \cdot 10^{-98}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.5:\\
\;\;\;\;\frac{t_0}{n \cdot x} + \frac{\frac{0.3333333333333333}{{x}^{3}} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.99999999999999988e-98Initial program 77.4%
Taylor expanded in n around 0 77.4%
log1p-def77.4%
*-rgt-identity77.4%
associate-*r/77.4%
unpow-177.4%
exp-to-pow77.4%
/-rgt-identity77.4%
metadata-eval77.4%
associate-/l*77.4%
*-commutative77.4%
*-commutative77.4%
associate-/l*77.4%
metadata-eval77.4%
/-rgt-identity77.4%
unpow-177.4%
Simplified77.4%
Taylor expanded in x around inf 90.0%
mul-1-neg90.0%
log-rec90.0%
distribute-frac-neg90.0%
remove-double-neg90.0%
*-commutative90.0%
Simplified90.0%
add-exp-log35.4%
div-inv35.4%
pow-to-exp35.4%
Applied egg-rr35.4%
add-exp-log90.0%
*-commutative90.0%
associate-/r*90.0%
Applied egg-rr90.0%
if -1.99999999999999988e-98 < (/.f64 1 n) < 4.99999999999999992e-46Initial program 33.0%
Taylor expanded in n around inf 81.6%
log1p-def81.6%
Simplified81.6%
if 4.99999999999999992e-46 < (/.f64 1 n) < 0.5Initial program 11.9%
Taylor expanded in x around inf 77.8%
Simplified77.7%
Taylor expanded in n around inf 77.7%
associate-*r/77.7%
metadata-eval77.7%
associate-*r/77.7%
metadata-eval77.7%
unpow277.7%
Simplified77.7%
if 0.5 < (/.f64 1 n) Initial program 47.3%
Taylor expanded in n around 0 47.3%
log1p-def100.0%
*-rgt-identity100.0%
associate-*r/100.0%
unpow-1100.0%
exp-to-pow100.0%
/-rgt-identity100.0%
metadata-eval100.0%
associate-/l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-98)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-46)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 0.5)
(+ (/ t_0 (* n x)) (/ (/ -0.5 n) (* x x)))
(- (exp (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-98) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 0.5) {
tmp = (t_0 / (n * x)) + ((-0.5 / n) / (x * x));
} 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) <= -2e-98) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 0.5) {
tmp = (t_0 / (n * x)) + ((-0.5 / n) / (x * x));
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-98: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-46: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 0.5: tmp = (t_0 / (n * x)) + ((-0.5 / n) / (x * x)) else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-98) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-46) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 0.5) tmp = Float64(Float64(t_0 / Float64(n * x)) + Float64(Float64(-0.5 / n) / Float64(x * x))); 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], -2e-98], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-46], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.5], N[(N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $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 \cdot 10^{-98}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.5:\\
\;\;\;\;\frac{t_0}{n \cdot x} + \frac{\frac{-0.5}{n}}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.99999999999999988e-98Initial program 77.4%
Taylor expanded in n around 0 77.4%
log1p-def77.4%
*-rgt-identity77.4%
associate-*r/77.4%
unpow-177.4%
exp-to-pow77.4%
/-rgt-identity77.4%
metadata-eval77.4%
associate-/l*77.4%
*-commutative77.4%
*-commutative77.4%
associate-/l*77.4%
metadata-eval77.4%
/-rgt-identity77.4%
unpow-177.4%
Simplified77.4%
Taylor expanded in x around inf 90.0%
mul-1-neg90.0%
log-rec90.0%
distribute-frac-neg90.0%
remove-double-neg90.0%
*-commutative90.0%
Simplified90.0%
add-exp-log35.4%
div-inv35.4%
pow-to-exp35.4%
Applied egg-rr35.4%
add-exp-log90.0%
*-commutative90.0%
associate-/r*90.0%
Applied egg-rr90.0%
if -1.99999999999999988e-98 < (/.f64 1 n) < 4.99999999999999992e-46Initial program 33.0%
Taylor expanded in n around inf 81.6%
log1p-def81.6%
Simplified81.6%
if 4.99999999999999992e-46 < (/.f64 1 n) < 0.5Initial program 11.9%
Taylor expanded in x around inf 75.0%
Simplified75.0%
Taylor expanded in n around inf 75.0%
if 0.5 < (/.f64 1 n) Initial program 47.3%
Taylor expanded in n around 0 47.3%
log1p-def100.0%
*-rgt-identity100.0%
associate-*r/100.0%
unpow-1100.0%
exp-to-pow100.0%
/-rgt-identity100.0%
metadata-eval100.0%
associate-/l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification87.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-98)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-46)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 0.5)
(+ (/ t_0 (* n x)) (/ (/ -0.5 n) (* x x)))
(if (<= (/ 1.0 n) 5e+215)
(-
(+ (* (* x x) (- (/ 0.5 (* n n)) (/ 0.5 n))) (+ 1.0 (/ x n)))
t_0)
(/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-98) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 0.5) {
tmp = (t_0 / (n * x)) + ((-0.5 / n) / (x * x));
} else if ((1.0 / n) <= 5e+215) {
tmp = (((x * x) * ((0.5 / (n * n)) - (0.5 / n))) + (1.0 + (x / n))) - t_0;
} else {
tmp = 1.0 / (n * x);
}
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-98) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-46) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 0.5) {
tmp = (t_0 / (n * x)) + ((-0.5 / n) / (x * x));
} else if ((1.0 / n) <= 5e+215) {
tmp = (((x * x) * ((0.5 / (n * n)) - (0.5 / n))) + (1.0 + (x / n))) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-98: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-46: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 0.5: tmp = (t_0 / (n * x)) + ((-0.5 / n) / (x * x)) elif (1.0 / n) <= 5e+215: tmp = (((x * x) * ((0.5 / (n * n)) - (0.5 / n))) + (1.0 + (x / n))) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-98) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-46) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 0.5) tmp = Float64(Float64(t_0 / Float64(n * x)) + Float64(Float64(-0.5 / n) / Float64(x * x))); elseif (Float64(1.0 / n) <= 5e+215) tmp = Float64(Float64(Float64(Float64(x * x) * Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n))) + Float64(1.0 + Float64(x / n))) - t_0); else tmp = Float64(1.0 / Float64(n * x)); 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-98], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-46], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.5], N[(N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+215], N[(N[(N[(N[(x * x), $MachinePrecision] * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $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^{-98}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.5:\\
\;\;\;\;\frac{t_0}{n \cdot x} + \frac{\frac{-0.5}{n}}{x \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+215}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) + \left(1 + \frac{x}{n}\right)\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.99999999999999988e-98Initial program 77.4%
Taylor expanded in n around 0 77.4%
log1p-def77.4%
*-rgt-identity77.4%
associate-*r/77.4%
unpow-177.4%
exp-to-pow77.4%
/-rgt-identity77.4%
metadata-eval77.4%
associate-/l*77.4%
*-commutative77.4%
*-commutative77.4%
associate-/l*77.4%
metadata-eval77.4%
/-rgt-identity77.4%
unpow-177.4%
Simplified77.4%
Taylor expanded in x around inf 90.0%
mul-1-neg90.0%
log-rec90.0%
distribute-frac-neg90.0%
remove-double-neg90.0%
*-commutative90.0%
Simplified90.0%
add-exp-log35.4%
div-inv35.4%
pow-to-exp35.4%
Applied egg-rr35.4%
add-exp-log90.0%
*-commutative90.0%
associate-/r*90.0%
Applied egg-rr90.0%
if -1.99999999999999988e-98 < (/.f64 1 n) < 4.99999999999999992e-46Initial program 33.0%
Taylor expanded in n around inf 81.6%
log1p-def81.6%
Simplified81.6%
if 4.99999999999999992e-46 < (/.f64 1 n) < 0.5Initial program 11.9%
Taylor expanded in x around inf 75.0%
Simplified75.0%
Taylor expanded in n around inf 75.0%
if 0.5 < (/.f64 1 n) < 5.0000000000000001e215Initial program 63.4%
Taylor expanded in x around 0 78.2%
associate-+r+78.2%
+-commutative78.2%
associate-*r/78.2%
metadata-eval78.2%
unpow278.2%
associate-*r/78.2%
metadata-eval78.2%
unpow278.2%
Simplified78.2%
if 5.0000000000000001e215 < (/.f64 1 n) Initial program 27.0%
Taylor expanded in n around 0 27.0%
log1p-def100.0%
*-rgt-identity100.0%
associate-*r/100.0%
unpow-1100.0%
exp-to-pow100.0%
/-rgt-identity100.0%
metadata-eval100.0%
associate-/l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in x around inf 0.2%
mul-1-neg0.2%
log-rec0.2%
distribute-frac-neg0.2%
remove-double-neg0.2%
*-commutative0.2%
Simplified0.2%
Taylor expanded in n around inf 65.3%
*-commutative65.3%
Simplified65.3%
Final simplification83.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- 1.0 t_0)) (t_2 (/ (- (log x)) n)))
(if (<= x 1.6e-241)
t_1
(if (<= x 4.4e-132)
t_2
(if (<= x 4.4e-91) t_1 (if (<= x 5.5e-16) t_2 (/ (/ t_0 n) x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double t_2 = -log(x) / n;
double tmp;
if (x <= 1.6e-241) {
tmp = t_1;
} else if (x <= 4.4e-132) {
tmp = t_2;
} else if (x <= 4.4e-91) {
tmp = t_1;
} else if (x <= 5.5e-16) {
tmp = t_2;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = 1.0d0 - t_0
t_2 = -log(x) / n
if (x <= 1.6d-241) then
tmp = t_1
else if (x <= 4.4d-132) then
tmp = t_2
else if (x <= 4.4d-91) then
tmp = t_1
else if (x <= 5.5d-16) then
tmp = t_2
else
tmp = (t_0 / n) / 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 t_1 = 1.0 - t_0;
double t_2 = -Math.log(x) / n;
double tmp;
if (x <= 1.6e-241) {
tmp = t_1;
} else if (x <= 4.4e-132) {
tmp = t_2;
} else if (x <= 4.4e-91) {
tmp = t_1;
} else if (x <= 5.5e-16) {
tmp = t_2;
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 - t_0 t_2 = -math.log(x) / n tmp = 0 if x <= 1.6e-241: tmp = t_1 elif x <= 4.4e-132: tmp = t_2 elif x <= 4.4e-91: tmp = t_1 elif x <= 5.5e-16: tmp = t_2 else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 - t_0) t_2 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 1.6e-241) tmp = t_1; elseif (x <= 4.4e-132) tmp = t_2; elseif (x <= 4.4e-91) tmp = t_1; elseif (x <= 5.5e-16) tmp = t_2; else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = 1.0 - t_0; t_2 = -log(x) / n; tmp = 0.0; if (x <= 1.6e-241) tmp = t_1; elseif (x <= 4.4e-132) tmp = t_2; elseif (x <= 4.4e-91) tmp = t_1; elseif (x <= 5.5e-16) tmp = t_2; else tmp = (t_0 / n) / x; 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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 1.6e-241], t$95$1, If[LessEqual[x, 4.4e-132], t$95$2, If[LessEqual[x, 4.4e-91], t$95$1, If[LessEqual[x, 5.5e-16], t$95$2, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := 1 - t_0\\
t_2 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 1.6 \cdot 10^{-241}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-132}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-91}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-16}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.6e-241 or 4.39999999999999981e-132 < x < 4.4000000000000002e-91Initial program 59.0%
Taylor expanded in x around 0 59.0%
*-rgt-identity59.0%
associate-*r/59.0%
unpow-159.0%
exp-to-pow59.0%
unpow-159.0%
Simplified59.0%
if 1.6e-241 < x < 4.39999999999999981e-132 or 4.4000000000000002e-91 < x < 5.49999999999999964e-16Initial program 30.5%
Taylor expanded in x around 0 30.5%
*-rgt-identity30.5%
associate-*r/30.5%
unpow-130.5%
exp-to-pow30.5%
unpow-130.5%
Simplified30.5%
Taylor expanded in n around inf 55.8%
associate-*r/55.8%
mul-1-neg55.8%
Simplified55.8%
if 5.49999999999999964e-16 < x Initial program 62.3%
Taylor expanded in n around 0 62.3%
log1p-def62.3%
*-rgt-identity62.3%
associate-*r/62.2%
unpow-162.2%
exp-to-pow62.2%
/-rgt-identity62.2%
metadata-eval62.2%
associate-/l*62.2%
*-commutative62.2%
*-commutative62.2%
associate-/l*62.2%
metadata-eval62.2%
/-rgt-identity62.2%
unpow-162.2%
Simplified62.2%
Taylor expanded in x around inf 94.9%
mul-1-neg94.9%
log-rec94.9%
distribute-frac-neg94.9%
remove-double-neg94.9%
*-commutative94.9%
Simplified94.9%
add-exp-log71.6%
div-inv71.6%
pow-to-exp71.6%
Applied egg-rr71.6%
add-exp-log94.9%
*-commutative94.9%
associate-/r*96.1%
Applied egg-rr96.1%
Final simplification74.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n))
(t_1 (pow x (/ 1.0 n)))
(t_2 (- (+ 1.0 (/ x n)) t_1)))
(if (<= x 2.6e-241)
t_2
(if (<= x 4e-130)
t_0
(if (<= x 2.7e-91) t_2 (if (<= x 4.4e-16) t_0 (/ (/ t_1 n) x)))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double t_1 = pow(x, (1.0 / n));
double t_2 = (1.0 + (x / n)) - t_1;
double tmp;
if (x <= 2.6e-241) {
tmp = t_2;
} else if (x <= 4e-130) {
tmp = t_0;
} else if (x <= 2.7e-91) {
tmp = t_2;
} else if (x <= 4.4e-16) {
tmp = t_0;
} else {
tmp = (t_1 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = -log(x) / n
t_1 = x ** (1.0d0 / n)
t_2 = (1.0d0 + (x / n)) - t_1
if (x <= 2.6d-241) then
tmp = t_2
else if (x <= 4d-130) then
tmp = t_0
else if (x <= 2.7d-91) then
tmp = t_2
else if (x <= 4.4d-16) then
tmp = t_0
else
tmp = (t_1 / n) / x
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 t_2 = (1.0 + (x / n)) - t_1;
double tmp;
if (x <= 2.6e-241) {
tmp = t_2;
} else if (x <= 4e-130) {
tmp = t_0;
} else if (x <= 2.7e-91) {
tmp = t_2;
} else if (x <= 4.4e-16) {
tmp = t_0;
} else {
tmp = (t_1 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n t_1 = math.pow(x, (1.0 / n)) t_2 = (1.0 + (x / n)) - t_1 tmp = 0 if x <= 2.6e-241: tmp = t_2 elif x <= 4e-130: tmp = t_0 elif x <= 2.7e-91: tmp = t_2 elif x <= 4.4e-16: tmp = t_0 else: tmp = (t_1 / n) / x return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(Float64(1.0 + Float64(x / n)) - t_1) tmp = 0.0 if (x <= 2.6e-241) tmp = t_2; elseif (x <= 4e-130) tmp = t_0; elseif (x <= 2.7e-91) tmp = t_2; elseif (x <= 4.4e-16) tmp = t_0; else tmp = Float64(Float64(t_1 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; t_1 = x ^ (1.0 / n); t_2 = (1.0 + (x / n)) - t_1; tmp = 0.0; if (x <= 2.6e-241) tmp = t_2; elseif (x <= 4e-130) tmp = t_0; elseif (x <= 2.7e-91) tmp = t_2; elseif (x <= 4.4e-16) tmp = t_0; else tmp = (t_1 / n) / x; 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]}, Block[{t$95$2 = N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[x, 2.6e-241], t$95$2, If[LessEqual[x, 4e-130], t$95$0, If[LessEqual[x, 2.7e-91], t$95$2, If[LessEqual[x, 4.4e-16], t$95$0, N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \left(1 + \frac{x}{n}\right) - t_1\\
\mathbf{if}\;x \leq 2.6 \cdot 10^{-241}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-130}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-91}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-16}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_1}{n}}{x}\\
\end{array}
\end{array}
if x < 2.5999999999999999e-241 or 4.0000000000000003e-130 < x < 2.6999999999999997e-91Initial program 59.0%
Taylor expanded in x around 0 60.1%
if 2.5999999999999999e-241 < x < 4.0000000000000003e-130 or 2.6999999999999997e-91 < x < 4.40000000000000001e-16Initial program 30.5%
Taylor expanded in x around 0 30.5%
*-rgt-identity30.5%
associate-*r/30.5%
unpow-130.5%
exp-to-pow30.5%
unpow-130.5%
Simplified30.5%
Taylor expanded in n around inf 55.8%
associate-*r/55.8%
mul-1-neg55.8%
Simplified55.8%
if 4.40000000000000001e-16 < x Initial program 62.3%
Taylor expanded in n around 0 62.3%
log1p-def62.3%
*-rgt-identity62.3%
associate-*r/62.2%
unpow-162.2%
exp-to-pow62.2%
/-rgt-identity62.2%
metadata-eval62.2%
associate-/l*62.2%
*-commutative62.2%
*-commutative62.2%
associate-/l*62.2%
metadata-eval62.2%
/-rgt-identity62.2%
unpow-162.2%
Simplified62.2%
Taylor expanded in x around inf 94.9%
mul-1-neg94.9%
log-rec94.9%
distribute-frac-neg94.9%
remove-double-neg94.9%
*-commutative94.9%
Simplified94.9%
add-exp-log71.6%
div-inv71.6%
pow-to-exp71.6%
Applied egg-rr71.6%
add-exp-log94.9%
*-commutative94.9%
associate-/r*96.1%
Applied egg-rr96.1%
Final simplification74.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 2e-242)
t_0
(if (<= x 1.45e-131)
(/ (- (log x)) n)
(if (<= x 5.5e-92)
t_0
(if (<= x 0.98)
(/ (- x (log x)) n)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 2e-242) {
tmp = t_0;
} else if (x <= 1.45e-131) {
tmp = -log(x) / n;
} else if (x <= 5.5e-92) {
tmp = t_0;
} else if (x <= 0.98) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 2d-242) then
tmp = t_0
else if (x <= 1.45d-131) then
tmp = -log(x) / n
else if (x <= 5.5d-92) then
tmp = t_0
else if (x <= 0.98d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 2e-242) {
tmp = t_0;
} else if (x <= 1.45e-131) {
tmp = -Math.log(x) / n;
} else if (x <= 5.5e-92) {
tmp = t_0;
} else if (x <= 0.98) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 2e-242: tmp = t_0 elif x <= 1.45e-131: tmp = -math.log(x) / n elif x <= 5.5e-92: tmp = t_0 elif x <= 0.98: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / x) - (0.5 / (x * x))) / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 2e-242) tmp = t_0; elseif (x <= 1.45e-131) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 5.5e-92) tmp = t_0; elseif (x <= 0.98) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 2e-242) tmp = t_0; elseif (x <= 1.45e-131) tmp = -log(x) / n; elseif (x <= 5.5e-92) tmp = t_0; elseif (x <= 0.98) tmp = (x - log(x)) / n; else tmp = ((1.0 / x) - (0.5 / (x * x))) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2e-242], t$95$0, If[LessEqual[x, 1.45e-131], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 5.5e-92], t$95$0, If[LessEqual[x, 0.98], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 2 \cdot 10^{-242}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-131}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-92}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.98:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\end{array}
\end{array}
if x < 2e-242 or 1.4500000000000001e-131 < x < 5.5000000000000002e-92Initial program 59.0%
Taylor expanded in x around 0 59.0%
*-rgt-identity59.0%
associate-*r/59.0%
unpow-159.0%
exp-to-pow59.0%
unpow-159.0%
Simplified59.0%
if 2e-242 < x < 1.4500000000000001e-131Initial program 33.0%
Taylor expanded in x around 0 33.0%
*-rgt-identity33.0%
associate-*r/33.0%
unpow-133.0%
exp-to-pow33.0%
unpow-133.0%
Simplified33.0%
Taylor expanded in n around inf 59.2%
associate-*r/59.2%
mul-1-neg59.2%
Simplified59.2%
if 5.5000000000000002e-92 < x < 0.97999999999999998Initial program 33.1%
Taylor expanded in x around 0 31.7%
Taylor expanded in n around inf 49.2%
if 0.97999999999999998 < x Initial program 61.9%
Taylor expanded in x around inf 85.7%
Simplified85.7%
Taylor expanded in n around inf 64.7%
associate-*r/64.7%
metadata-eval64.7%
unpow264.7%
Simplified64.7%
Final simplification59.4%
(FPCore (x n)
:precision binary64
(if (<= x 5.4e-264)
(/ (- (log x)) n)
(if (<= x 6.4e-245)
(/ 1.0 (* n x))
(if (<= x 1.0) (/ (- x (log x)) n) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)))))
double code(double x, double n) {
double tmp;
if (x <= 5.4e-264) {
tmp = -log(x) / n;
} else if (x <= 6.4e-245) {
tmp = 1.0 / (n * x);
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / x) - (0.5 / (x * 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 <= 5.4d-264) then
tmp = -log(x) / n
else if (x <= 6.4d-245) then
tmp = 1.0d0 / (n * x)
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 5.4e-264) {
tmp = -Math.log(x) / n;
} else if (x <= 6.4e-245) {
tmp = 1.0 / (n * x);
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5.4e-264: tmp = -math.log(x) / n elif x <= 6.4e-245: tmp = 1.0 / (n * x) elif x <= 1.0: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / x) - (0.5 / (x * x))) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 5.4e-264) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 6.4e-245) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5.4e-264) tmp = -log(x) / n; elseif (x <= 6.4e-245) tmp = 1.0 / (n * x); elseif (x <= 1.0) tmp = (x - log(x)) / n; else tmp = ((1.0 / x) - (0.5 / (x * x))) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5.4e-264], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 6.4e-245], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.4 \cdot 10^{-264}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-245}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\end{array}
\end{array}
if x < 5.39999999999999989e-264Initial program 46.7%
Taylor expanded in x around 0 46.7%
*-rgt-identity46.7%
associate-*r/46.7%
unpow-146.7%
exp-to-pow46.7%
unpow-146.7%
Simplified46.7%
Taylor expanded in n around inf 51.0%
associate-*r/51.0%
mul-1-neg51.0%
Simplified51.0%
if 5.39999999999999989e-264 < x < 6.39999999999999972e-245Initial program 67.8%
Taylor expanded in n around 0 67.8%
log1p-def89.3%
*-rgt-identity89.3%
associate-*r/89.3%
unpow-189.3%
exp-to-pow89.3%
/-rgt-identity89.3%
metadata-eval89.3%
associate-/l*89.3%
*-commutative89.3%
*-commutative89.3%
associate-/l*89.3%
metadata-eval89.3%
/-rgt-identity89.3%
unpow-189.3%
Simplified89.3%
Taylor expanded in x around inf 44.8%
mul-1-neg44.8%
log-rec44.8%
distribute-frac-neg44.8%
remove-double-neg44.8%
*-commutative44.8%
Simplified44.8%
Taylor expanded in n around inf 67.8%
*-commutative67.8%
Simplified67.8%
if 6.39999999999999972e-245 < x < 1Initial program 40.5%
Taylor expanded in x around 0 40.4%
Taylor expanded in n around inf 48.0%
if 1 < x Initial program 61.9%
Taylor expanded in x around inf 85.7%
Simplified85.7%
Taylor expanded in n around inf 64.7%
associate-*r/64.7%
metadata-eval64.7%
unpow264.7%
Simplified64.7%
Final simplification56.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 5.4e-264)
t_0
(if (<= x 6.4e-245)
(/ 1.0 (* n x))
(if (<= x 0.68) t_0 (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 5.4e-264) {
tmp = t_0;
} else if (x <= 6.4e-245) {
tmp = 1.0 / (n * x);
} else if (x <= 0.68) {
tmp = t_0;
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = -log(x) / n
if (x <= 5.4d-264) then
tmp = t_0
else if (x <= 6.4d-245) then
tmp = 1.0d0 / (n * x)
else if (x <= 0.68d0) then
tmp = t_0
else
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
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 <= 5.4e-264) {
tmp = t_0;
} else if (x <= 6.4e-245) {
tmp = 1.0 / (n * x);
} else if (x <= 0.68) {
tmp = t_0;
} else {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 5.4e-264: tmp = t_0 elif x <= 6.4e-245: tmp = 1.0 / (n * x) elif x <= 0.68: tmp = t_0 else: tmp = ((1.0 / x) - (0.5 / (x * x))) / n return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 5.4e-264) tmp = t_0; elseif (x <= 6.4e-245) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 0.68) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (x <= 5.4e-264) tmp = t_0; elseif (x <= 6.4e-245) tmp = 1.0 / (n * x); elseif (x <= 0.68) tmp = t_0; else tmp = ((1.0 / x) - (0.5 / (x * x))) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 5.4e-264], t$95$0, If[LessEqual[x, 6.4e-245], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.68], t$95$0, N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 5.4 \cdot 10^{-264}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-245}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\end{array}
\end{array}
if x < 5.39999999999999989e-264 or 6.39999999999999972e-245 < x < 0.680000000000000049Initial program 41.7%
Taylor expanded in x around 0 41.0%
*-rgt-identity41.0%
associate-*r/41.0%
unpow-141.0%
exp-to-pow41.0%
unpow-141.0%
Simplified41.0%
Taylor expanded in n around inf 48.4%
associate-*r/48.4%
mul-1-neg48.4%
Simplified48.4%
if 5.39999999999999989e-264 < x < 6.39999999999999972e-245Initial program 67.8%
Taylor expanded in n around 0 67.8%
log1p-def89.3%
*-rgt-identity89.3%
associate-*r/89.3%
unpow-189.3%
exp-to-pow89.3%
/-rgt-identity89.3%
metadata-eval89.3%
associate-/l*89.3%
*-commutative89.3%
*-commutative89.3%
associate-/l*89.3%
metadata-eval89.3%
/-rgt-identity89.3%
unpow-189.3%
Simplified89.3%
Taylor expanded in x around inf 44.8%
mul-1-neg44.8%
log-rec44.8%
distribute-frac-neg44.8%
remove-double-neg44.8%
*-commutative44.8%
Simplified44.8%
Taylor expanded in n around inf 67.8%
*-commutative67.8%
Simplified67.8%
if 0.680000000000000049 < x Initial program 61.9%
Taylor expanded in x around inf 85.7%
Simplified85.7%
Taylor expanded in n around inf 64.7%
associate-*r/64.7%
metadata-eval64.7%
unpow264.7%
Simplified64.7%
Final simplification56.0%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 51.2%
Taylor expanded in n around 0 51.2%
log1p-def60.1%
*-rgt-identity60.1%
associate-*r/60.0%
unpow-160.0%
exp-to-pow60.0%
/-rgt-identity60.0%
metadata-eval60.0%
associate-/l*60.0%
*-commutative60.0%
*-commutative60.0%
associate-/l*60.0%
metadata-eval60.0%
/-rgt-identity60.0%
unpow-160.0%
Simplified60.0%
Taylor expanded in x around inf 57.8%
mul-1-neg57.8%
log-rec57.8%
distribute-frac-neg57.8%
remove-double-neg57.8%
*-commutative57.8%
Simplified57.8%
Taylor expanded in n around inf 42.5%
*-commutative42.5%
Simplified42.5%
Final simplification42.5%
(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.2%
Taylor expanded in n around 0 51.2%
log1p-def60.1%
*-rgt-identity60.1%
associate-*r/60.0%
unpow-160.0%
exp-to-pow60.0%
/-rgt-identity60.0%
metadata-eval60.0%
associate-/l*60.0%
*-commutative60.0%
*-commutative60.0%
associate-/l*60.0%
metadata-eval60.0%
/-rgt-identity60.0%
unpow-160.0%
Simplified60.0%
Taylor expanded in x around inf 57.8%
mul-1-neg57.8%
log-rec57.8%
distribute-frac-neg57.8%
remove-double-neg57.8%
*-commutative57.8%
Simplified57.8%
Taylor expanded in n around inf 42.5%
associate-/r*43.0%
Simplified43.0%
Final simplification43.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 51.2%
Taylor expanded in n around 0 51.2%
log1p-def60.1%
*-rgt-identity60.1%
associate-*r/60.0%
unpow-160.0%
exp-to-pow60.0%
/-rgt-identity60.0%
metadata-eval60.0%
associate-/l*60.0%
*-commutative60.0%
*-commutative60.0%
associate-/l*60.0%
metadata-eval60.0%
/-rgt-identity60.0%
unpow-160.0%
Simplified60.0%
Taylor expanded in x around inf 57.8%
mul-1-neg57.8%
log-rec57.8%
distribute-frac-neg57.8%
remove-double-neg57.8%
*-commutative57.8%
Simplified57.8%
add-exp-log32.9%
div-inv32.9%
pow-to-exp32.9%
Applied egg-rr32.9%
Taylor expanded in n around inf 42.5%
associate-/l/43.0%
Simplified43.0%
Final simplification43.0%
(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 51.2%
Taylor expanded in x around 0 32.9%
Taylor expanded in x around inf 4.6%
Final simplification4.6%
herbie shell --seed 2023242
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))