
(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))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -2e-135)
t_1
(if (<= (/ 1.0 n) 1e-118)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 400.0) t_1 (- (exp (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -2e-135) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-118) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 400.0) {
tmp = t_1;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-2d-135)) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-118) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 400.0d0) then
tmp = t_1
else
tmp = exp((x / n)) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -2e-135) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-118) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 400.0) {
tmp = t_1;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -2e-135: tmp = t_1 elif (1.0 / n) <= 1e-118: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 400.0: tmp = t_1 else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -2e-135) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-118) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 400.0) tmp = t_1; else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (t_0 / n) / x; tmp = 0.0; if ((1.0 / n) <= -2e-135) tmp = t_1; elseif ((1.0 / n) <= 1e-118) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 400.0) tmp = t_1; else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-135], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-118], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 400.0], t$95$1, 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)}\\
t_1 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-118}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 400:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-135 or 9.99999999999999985e-119 < (/.f64 #s(literal 1 binary64) n) < 400Initial program 71.0%
Taylor expanded in x around inf 69.8%
associate-/r*70.0%
mul-1-neg70.0%
log-rec70.0%
mul-1-neg70.0%
distribute-neg-frac70.0%
mul-1-neg70.0%
remove-double-neg70.0%
*-rgt-identity70.0%
associate-/l*70.0%
exp-to-pow89.2%
Simplified89.2%
if -2.0000000000000001e-135 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999985e-119Initial program 33.6%
Taylor expanded in n around inf 88.7%
log1p-define88.8%
Simplified88.8%
log1p-undefine88.7%
diff-log88.9%
+-commutative88.9%
Applied egg-rr88.9%
if 400 < (/.f64 #s(literal 1 binary64) n) Initial program 54.6%
Taylor expanded in n around 0 29.4%
log1p-define53.5%
*-rgt-identity53.5%
associate-*l/53.5%
associate-/l*53.5%
exp-to-pow98.6%
Simplified98.6%
Taylor expanded in x around 0 98.6%
Final simplification91.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x -1.25e-150)
0.0
(if (<= x 7.5e-246)
(- (+ 1.0 (/ x n)) t_0)
(if (<= x 1.65e-107)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= x 1.85e-23)
(log1p (expm1 (/ 1.0 (* n x))))
(* (/ t_0 n) (/ 1.0 x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= -1.25e-150) {
tmp = 0.0;
} else if (x <= 7.5e-246) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 1.65e-107) {
tmp = log(((1.0 + x) / x)) / n;
} else if (x <= 1.85e-23) {
tmp = log1p(expm1((1.0 / (n * x))));
} else {
tmp = (t_0 / n) * (1.0 / x);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= -1.25e-150) {
tmp = 0.0;
} else if (x <= 7.5e-246) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 1.65e-107) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if (x <= 1.85e-23) {
tmp = Math.log1p(Math.expm1((1.0 / (n * x))));
} else {
tmp = (t_0 / n) * (1.0 / x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= -1.25e-150: tmp = 0.0 elif x <= 7.5e-246: tmp = (1.0 + (x / n)) - t_0 elif x <= 1.65e-107: tmp = math.log(((1.0 + x) / x)) / n elif x <= 1.85e-23: tmp = math.log1p(math.expm1((1.0 / (n * x)))) else: tmp = (t_0 / n) * (1.0 / x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= -1.25e-150) tmp = 0.0; elseif (x <= 7.5e-246) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif (x <= 1.65e-107) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (x <= 1.85e-23) tmp = log1p(expm1(Float64(1.0 / Float64(n * x)))); else tmp = Float64(Float64(t_0 / n) * Float64(1.0 / x)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.25e-150], 0.0, If[LessEqual[x, 7.5e-246], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 1.65e-107], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.85e-23], N[Log[1 + N[(Exp[N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{-150}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-246}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-107}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n \cdot x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{n} \cdot \frac{1}{x}\\
\end{array}
\end{array}
if x < -1.24999999999999997e-150Initial program 69.3%
add-log-exp69.3%
pow-to-exp10.7%
un-div-inv10.7%
+-commutative10.7%
log1p-define41.5%
Applied egg-rr41.5%
Taylor expanded in x around inf 92.9%
if -1.24999999999999997e-150 < x < 7.50000000000000049e-246Initial program 80.3%
Taylor expanded in x around 0 82.4%
if 7.50000000000000049e-246 < x < 1.65000000000000002e-107Initial program 38.8%
Taylor expanded in n around inf 60.6%
log1p-define60.6%
Simplified60.6%
log1p-undefine60.6%
diff-log60.6%
+-commutative60.6%
Applied egg-rr60.6%
if 1.65000000000000002e-107 < x < 1.8500000000000001e-23Initial program 32.9%
Taylor expanded in n around inf 34.8%
log1p-define34.8%
Simplified34.8%
Taylor expanded in x around inf 22.1%
*-commutative22.1%
Simplified22.1%
log1p-expm1-u65.4%
Applied egg-rr65.4%
if 1.8500000000000001e-23 < x Initial program 62.8%
Taylor expanded in x around inf 93.6%
associate-/r*94.8%
mul-1-neg94.8%
log-rec94.8%
mul-1-neg94.8%
distribute-neg-frac94.8%
mul-1-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
Simplified94.8%
div-inv94.8%
Applied egg-rr94.8%
Final simplification82.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -2e-135)
t_1
(if (<= (/ 1.0 n) 1e-118)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 400.0)
t_1
(if (<= (/ 1.0 n) 1e+275)
(- (+ 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 t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -2e-135) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-118) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 400.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+275) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.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) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-2d-135)) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-118) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 400.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+275) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (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 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -2e-135) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-118) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 400.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+275) {
tmp = (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)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -2e-135: tmp = t_1 elif (1.0 / n) <= 1e-118: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 400.0: tmp = t_1 elif (1.0 / n) <= 1e+275: tmp = (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) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -2e-135) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-118) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 400.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+275) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (t_0 / n) / x; tmp = 0.0; if ((1.0 / n) <= -2e-135) tmp = t_1; elseif ((1.0 / n) <= 1e-118) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 400.0) tmp = t_1; elseif ((1.0 / n) <= 1e+275) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.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[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-135], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-118], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 400.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+275], N[(N[(1.0 + N[(x / n), $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)}\\
t_1 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-118}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 400:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+275}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-135 or 9.99999999999999985e-119 < (/.f64 #s(literal 1 binary64) n) < 400Initial program 71.0%
Taylor expanded in x around inf 69.8%
associate-/r*70.0%
mul-1-neg70.0%
log-rec70.0%
mul-1-neg70.0%
distribute-neg-frac70.0%
mul-1-neg70.0%
remove-double-neg70.0%
*-rgt-identity70.0%
associate-/l*70.0%
exp-to-pow89.2%
Simplified89.2%
if -2.0000000000000001e-135 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999985e-119Initial program 33.6%
Taylor expanded in n around inf 88.7%
log1p-define88.8%
Simplified88.8%
log1p-undefine88.7%
diff-log88.9%
+-commutative88.9%
Applied egg-rr88.9%
if 400 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999996e274Initial program 60.6%
Taylor expanded in x around 0 60.0%
if 9.9999999999999996e274 < (/.f64 #s(literal 1 binary64) n) Initial program 7.7%
Taylor expanded in n around inf 9.4%
log1p-define9.4%
Simplified9.4%
Taylor expanded in x around inf 75.6%
*-commutative75.6%
Simplified75.6%
Final simplification81.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -2e-135)
t_1
(if (<= (/ 1.0 n) 1e-118)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 400.0)
t_1
(if (<= (/ 1.0 n) 1e+275) (- 1.0 t_0) (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -2e-135) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-118) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 400.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+275) {
tmp = 1.0 - t_0;
} else {
tmp = 1.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) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-2d-135)) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-118) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 400.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+275) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (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 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -2e-135) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-118) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 400.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+275) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -2e-135: tmp = t_1 elif (1.0 / n) <= 1e-118: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 400.0: tmp = t_1 elif (1.0 / n) <= 1e+275: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -2e-135) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-118) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 400.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+275) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (t_0 / n) / x; tmp = 0.0; if ((1.0 / n) <= -2e-135) tmp = t_1; elseif ((1.0 / n) <= 1e-118) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 400.0) tmp = t_1; elseif ((1.0 / n) <= 1e+275) tmp = 1.0 - t_0; else tmp = 1.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[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-135], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-118], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 400.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+275], N[(1.0 - 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)}\\
t_1 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-118}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 400:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+275}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-135 or 9.99999999999999985e-119 < (/.f64 #s(literal 1 binary64) n) < 400Initial program 71.0%
Taylor expanded in x around inf 69.8%
associate-/r*70.0%
mul-1-neg70.0%
log-rec70.0%
mul-1-neg70.0%
distribute-neg-frac70.0%
mul-1-neg70.0%
remove-double-neg70.0%
*-rgt-identity70.0%
associate-/l*70.0%
exp-to-pow89.2%
Simplified89.2%
if -2.0000000000000001e-135 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999985e-119Initial program 33.6%
Taylor expanded in n around inf 88.7%
log1p-define88.8%
Simplified88.8%
log1p-undefine88.7%
diff-log88.9%
+-commutative88.9%
Applied egg-rr88.9%
if 400 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999996e274Initial program 60.6%
Taylor expanded in x around 0 32.2%
*-rgt-identity32.2%
associate-*l/32.2%
associate-/l*32.2%
exp-to-pow59.1%
Simplified59.1%
if 9.9999999999999996e274 < (/.f64 #s(literal 1 binary64) n) Initial program 7.7%
Taylor expanded in n around inf 9.4%
log1p-define9.4%
Simplified9.4%
Taylor expanded in x around inf 75.6%
*-commutative75.6%
Simplified75.6%
Final simplification81.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x -2.9e-152)
0.0
(if (<= x 7.5e-246)
(- (+ 1.0 (/ x n)) t_0)
(if (<= x 1e-100)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= x 1.85e-23)
(/ (expm1 (/ (+ 1.0 (/ (+ -1.0 (/ 1.1666666666666667 x)) x)) x)) n)
(* (/ t_0 n) (/ 1.0 x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= -2.9e-152) {
tmp = 0.0;
} else if (x <= 7.5e-246) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 1e-100) {
tmp = log(((1.0 + x) / x)) / n;
} else if (x <= 1.85e-23) {
tmp = expm1(((1.0 + ((-1.0 + (1.1666666666666667 / x)) / x)) / x)) / n;
} else {
tmp = (t_0 / n) * (1.0 / x);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= -2.9e-152) {
tmp = 0.0;
} else if (x <= 7.5e-246) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 1e-100) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if (x <= 1.85e-23) {
tmp = Math.expm1(((1.0 + ((-1.0 + (1.1666666666666667 / x)) / x)) / x)) / n;
} else {
tmp = (t_0 / n) * (1.0 / x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= -2.9e-152: tmp = 0.0 elif x <= 7.5e-246: tmp = (1.0 + (x / n)) - t_0 elif x <= 1e-100: tmp = math.log(((1.0 + x) / x)) / n elif x <= 1.85e-23: tmp = math.expm1(((1.0 + ((-1.0 + (1.1666666666666667 / x)) / x)) / x)) / n else: tmp = (t_0 / n) * (1.0 / x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= -2.9e-152) tmp = 0.0; elseif (x <= 7.5e-246) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif (x <= 1e-100) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (x <= 1.85e-23) tmp = Float64(expm1(Float64(Float64(1.0 + Float64(Float64(-1.0 + Float64(1.1666666666666667 / x)) / x)) / x)) / n); else tmp = Float64(Float64(t_0 / n) * Float64(1.0 / x)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.9e-152], 0.0, If[LessEqual[x, 7.5e-246], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 1e-100], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.85e-23], N[(N[(Exp[N[(N[(1.0 + N[(N[(-1.0 + N[(1.1666666666666667 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]] - 1), $MachinePrecision] / n), $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq -2.9 \cdot 10^{-152}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-246}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{elif}\;x \leq 10^{-100}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 + \frac{1.1666666666666667}{x}}{x}}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{n} \cdot \frac{1}{x}\\
\end{array}
\end{array}
if x < -2.9000000000000001e-152Initial program 69.3%
add-log-exp69.3%
pow-to-exp10.7%
un-div-inv10.7%
+-commutative10.7%
log1p-define41.5%
Applied egg-rr41.5%
Taylor expanded in x around inf 92.9%
if -2.9000000000000001e-152 < x < 7.50000000000000049e-246Initial program 80.3%
Taylor expanded in x around 0 82.4%
if 7.50000000000000049e-246 < x < 1e-100Initial program 37.6%
Taylor expanded in n around inf 60.3%
log1p-define60.3%
Simplified60.3%
log1p-undefine60.3%
diff-log60.3%
+-commutative60.3%
Applied egg-rr60.3%
if 1e-100 < x < 1.8500000000000001e-23Initial program 35.0%
Taylor expanded in n around inf 33.6%
log1p-define33.6%
Simplified33.6%
expm1-log1p-u33.0%
Applied egg-rr33.0%
Taylor expanded in x around inf 65.1%
associate--l+65.1%
unpow265.1%
associate-/r*65.1%
metadata-eval65.1%
associate-*r/65.1%
div-sub65.1%
sub-neg65.1%
metadata-eval65.1%
+-commutative65.1%
associate-*r/65.1%
metadata-eval65.1%
Simplified65.1%
if 1.8500000000000001e-23 < x Initial program 62.8%
Taylor expanded in x around inf 93.6%
associate-/r*94.8%
mul-1-neg94.8%
log-rec94.8%
mul-1-neg94.8%
distribute-neg-frac94.8%
mul-1-neg94.8%
remove-double-neg94.8%
*-rgt-identity94.8%
associate-/l*94.8%
exp-to-pow94.8%
Simplified94.8%
div-inv94.8%
Applied egg-rr94.8%
Final simplification82.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ (+ 1.0 x) x)) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x -2e-158)
0.0
(if (<= x 2.3e-246)
t_1
(if (<= x 3.2e-81)
t_0
(if (<= x 5.5e-40)
t_1
(if (<= x 7.6e+36)
t_0
(if (<= x 1.95e+228) (/ (/ 1.0 x) n) 0.0))))))))
double code(double x, double n) {
double t_0 = log(((1.0 + x) / x)) / n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= -2e-158) {
tmp = 0.0;
} else if (x <= 2.3e-246) {
tmp = t_1;
} else if (x <= 3.2e-81) {
tmp = t_0;
} else if (x <= 5.5e-40) {
tmp = t_1;
} else if (x <= 7.6e+36) {
tmp = t_0;
} else if (x <= 1.95e+228) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log(((1.0d0 + x) / x)) / n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= (-2d-158)) then
tmp = 0.0d0
else if (x <= 2.3d-246) then
tmp = t_1
else if (x <= 3.2d-81) then
tmp = t_0
else if (x <= 5.5d-40) then
tmp = t_1
else if (x <= 7.6d+36) then
tmp = t_0
else if (x <= 1.95d+228) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(((1.0 + x) / x)) / n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= -2e-158) {
tmp = 0.0;
} else if (x <= 2.3e-246) {
tmp = t_1;
} else if (x <= 3.2e-81) {
tmp = t_0;
} else if (x <= 5.5e-40) {
tmp = t_1;
} else if (x <= 7.6e+36) {
tmp = t_0;
} else if (x <= 1.95e+228) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = math.log(((1.0 + x) / x)) / n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= -2e-158: tmp = 0.0 elif x <= 2.3e-246: tmp = t_1 elif x <= 3.2e-81: tmp = t_0 elif x <= 5.5e-40: tmp = t_1 elif x <= 7.6e+36: tmp = t_0 elif x <= 1.95e+228: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= -2e-158) tmp = 0.0; elseif (x <= 2.3e-246) tmp = t_1; elseif (x <= 3.2e-81) tmp = t_0; elseif (x <= 5.5e-40) tmp = t_1; elseif (x <= 7.6e+36) tmp = t_0; elseif (x <= 1.95e+228) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = log(((1.0 + x) / x)) / n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= -2e-158) tmp = 0.0; elseif (x <= 2.3e-246) tmp = t_1; elseif (x <= 3.2e-81) tmp = t_0; elseif (x <= 5.5e-40) tmp = t_1; elseif (x <= 7.6e+36) tmp = t_0; elseif (x <= 1.95e+228) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-158], 0.0, If[LessEqual[x, 2.3e-246], t$95$1, If[LessEqual[x, 3.2e-81], t$95$0, If[LessEqual[x, 5.5e-40], t$95$1, If[LessEqual[x, 7.6e+36], t$95$0, If[LessEqual[x, 1.95e+228], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-158}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-246}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-40}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{+36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{+228}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2.00000000000000013e-158 or 1.94999999999999997e228 < x Initial program 78.9%
add-log-exp78.9%
pow-to-exp41.4%
un-div-inv41.4%
+-commutative41.4%
log1p-define61.1%
Applied egg-rr61.1%
Taylor expanded in x around inf 94.0%
if -2.00000000000000013e-158 < x < 2.2999999999999998e-246 or 3.2e-81 < x < 5.50000000000000002e-40Initial program 77.3%
Taylor expanded in x around 0 48.5%
*-rgt-identity48.5%
associate-*l/48.5%
associate-/l*48.5%
exp-to-pow77.3%
Simplified77.3%
if 2.2999999999999998e-246 < x < 3.2e-81 or 5.50000000000000002e-40 < x < 7.6000000000000005e36Initial program 37.8%
Taylor expanded in n around inf 54.4%
log1p-define54.4%
Simplified54.4%
log1p-undefine54.4%
diff-log54.5%
+-commutative54.5%
Applied egg-rr54.5%
if 7.6000000000000005e36 < x < 1.94999999999999997e228Initial program 49.5%
Taylor expanded in n around inf 49.5%
log1p-define47.6%
Simplified47.6%
Taylor expanded in x around inf 73.3%
Final simplification72.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x -7.5e-153)
0.0
(if (<= x 1.25e-248)
t_0
(if (<= x 6.5e-83)
(/ (log x) (- n))
(if (<= x 1.0)
t_0
(if (<= x 1.95e+228)
(/
(/
(- 1.0 (/ (- 0.5 (/ (+ 0.3333333333333333 (/ -0.25 x)) x)) x))
x)
n)
0.0)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= -7.5e-153) {
tmp = 0.0;
} else if (x <= 1.25e-248) {
tmp = t_0;
} else if (x <= 6.5e-83) {
tmp = log(x) / -n;
} else if (x <= 1.0) {
tmp = t_0;
} else if (x <= 1.95e+228) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= (-7.5d-153)) then
tmp = 0.0d0
else if (x <= 1.25d-248) then
tmp = t_0
else if (x <= 6.5d-83) then
tmp = log(x) / -n
else if (x <= 1.0d0) then
tmp = t_0
else if (x <= 1.95d+228) then
tmp = ((1.0d0 - ((0.5d0 - ((0.3333333333333333d0 + ((-0.25d0) / x)) / x)) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= -7.5e-153) {
tmp = 0.0;
} else if (x <= 1.25e-248) {
tmp = t_0;
} else if (x <= 6.5e-83) {
tmp = Math.log(x) / -n;
} else if (x <= 1.0) {
tmp = t_0;
} else if (x <= 1.95e+228) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= -7.5e-153: tmp = 0.0 elif x <= 1.25e-248: tmp = t_0 elif x <= 6.5e-83: tmp = math.log(x) / -n elif x <= 1.0: tmp = t_0 elif x <= 1.95e+228: tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= -7.5e-153) tmp = 0.0; elseif (x <= 1.25e-248) tmp = t_0; elseif (x <= 6.5e-83) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.0) tmp = t_0; elseif (x <= 1.95e+228) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x)) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= -7.5e-153) tmp = 0.0; elseif (x <= 1.25e-248) tmp = t_0; elseif (x <= 6.5e-83) tmp = log(x) / -n; elseif (x <= 1.0) tmp = t_0; elseif (x <= 1.95e+228) tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.5e-153], 0.0, If[LessEqual[x, 1.25e-248], t$95$0, If[LessEqual[x, 6.5e-83], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.0], t$95$0, If[LessEqual[x, 1.95e+228], N[(N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{-153}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-83}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{+228}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -7.5e-153 or 1.94999999999999997e228 < x Initial program 78.9%
add-log-exp78.9%
pow-to-exp41.4%
un-div-inv41.4%
+-commutative41.4%
log1p-define61.1%
Applied egg-rr61.1%
Taylor expanded in x around inf 94.0%
if -7.5e-153 < x < 1.25e-248 or 6.5e-83 < x < 1Initial program 65.4%
Taylor expanded in x around 0 44.2%
*-rgt-identity44.2%
associate-*l/44.2%
associate-/l*44.2%
exp-to-pow65.4%
Simplified65.4%
if 1.25e-248 < x < 6.5e-83Initial program 35.4%
Taylor expanded in n around inf 58.8%
log1p-define58.8%
Simplified58.8%
Taylor expanded in x around 0 58.8%
neg-mul-158.8%
Simplified58.8%
if 1 < x < 1.94999999999999997e228Initial program 50.8%
Taylor expanded in n around inf 50.3%
log1p-define48.9%
Simplified48.9%
Taylor expanded in x around -inf 65.5%
Taylor expanded in n around 0 63.8%
Simplified65.5%
Final simplification71.0%
(FPCore (x n)
:precision binary64
(if (<= x -4e-310)
0.0
(if (<= x 0.88)
(/ (- x (log x)) n)
(if (<= x 4.8e+229)
(/
(/ (- 1.0 (/ (- 0.5 (/ (+ 0.3333333333333333 (/ -0.25 x)) x)) x)) x)
n)
0.0))))
double code(double x, double n) {
double tmp;
if (x <= -4e-310) {
tmp = 0.0;
} else if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else if (x <= 4.8e+229) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= (-4d-310)) then
tmp = 0.0d0
else if (x <= 0.88d0) then
tmp = (x - log(x)) / n
else if (x <= 4.8d+229) then
tmp = ((1.0d0 - ((0.5d0 - ((0.3333333333333333d0 + ((-0.25d0) / x)) / x)) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= -4e-310) {
tmp = 0.0;
} else if (x <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 4.8e+229) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= -4e-310: tmp = 0.0 elif x <= 0.88: tmp = (x - math.log(x)) / n elif x <= 4.8e+229: tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= -4e-310) tmp = 0.0; elseif (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 4.8e+229) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x)) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= -4e-310) tmp = 0.0; elseif (x <= 0.88) tmp = (x - log(x)) / n; elseif (x <= 4.8e+229) tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, -4e-310], 0.0, If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 4.8e+229], N[(N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+229}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -3.999999999999988e-310 or 4.8000000000000002e229 < x Initial program 80.0%
add-log-exp80.0%
pow-to-exp50.0%
un-div-inv50.0%
+-commutative50.0%
log1p-define67.6%
Applied egg-rr67.6%
Taylor expanded in x around inf 77.1%
if -3.999999999999988e-310 < x < 0.880000000000000004Initial program 45.6%
Taylor expanded in n around inf 45.3%
log1p-define45.3%
Simplified45.3%
Taylor expanded in x around 0 45.3%
if 0.880000000000000004 < x < 4.8000000000000002e229Initial program 50.8%
Taylor expanded in n around inf 50.3%
log1p-define48.9%
Simplified48.9%
Taylor expanded in x around -inf 65.5%
Taylor expanded in n around 0 63.8%
Simplified65.5%
Final simplification60.4%
(FPCore (x n)
:precision binary64
(if (<= x -4e-310)
0.0
(if (<= x 0.71)
(/ (log x) (- n))
(if (<= x 9.6e+228)
(/
(/ (- 1.0 (/ (- 0.5 (/ (+ 0.3333333333333333 (/ -0.25 x)) x)) x)) x)
n)
0.0))))
double code(double x, double n) {
double tmp;
if (x <= -4e-310) {
tmp = 0.0;
} else if (x <= 0.71) {
tmp = log(x) / -n;
} else if (x <= 9.6e+228) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= (-4d-310)) then
tmp = 0.0d0
else if (x <= 0.71d0) then
tmp = log(x) / -n
else if (x <= 9.6d+228) then
tmp = ((1.0d0 - ((0.5d0 - ((0.3333333333333333d0 + ((-0.25d0) / x)) / x)) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= -4e-310) {
tmp = 0.0;
} else if (x <= 0.71) {
tmp = Math.log(x) / -n;
} else if (x <= 9.6e+228) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= -4e-310: tmp = 0.0 elif x <= 0.71: tmp = math.log(x) / -n elif x <= 9.6e+228: tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= -4e-310) tmp = 0.0; elseif (x <= 0.71) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 9.6e+228) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x)) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= -4e-310) tmp = 0.0; elseif (x <= 0.71) tmp = log(x) / -n; elseif (x <= 9.6e+228) tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, -4e-310], 0.0, If[LessEqual[x, 0.71], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 9.6e+228], N[(N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 0.71:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 9.6 \cdot 10^{+228}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -3.999999999999988e-310 or 9.59999999999999954e228 < x Initial program 80.0%
add-log-exp80.0%
pow-to-exp50.0%
un-div-inv50.0%
+-commutative50.0%
log1p-define67.6%
Applied egg-rr67.6%
Taylor expanded in x around inf 77.1%
if -3.999999999999988e-310 < x < 0.70999999999999996Initial program 45.6%
Taylor expanded in n around inf 45.3%
log1p-define45.3%
Simplified45.3%
Taylor expanded in x around 0 45.1%
neg-mul-145.1%
Simplified45.1%
if 0.70999999999999996 < x < 9.59999999999999954e228Initial program 50.8%
Taylor expanded in n around inf 50.3%
log1p-define48.9%
Simplified48.9%
Taylor expanded in x around -inf 65.5%
Taylor expanded in n around 0 63.8%
Simplified65.5%
Final simplification60.3%
(FPCore (x n)
:precision binary64
(if (<= x 8.5e-293)
0.0
(if (<= x 1.95e+228)
(* (/ 1.0 x) (+ (/ 1.0 n) (/ (/ (- (/ 0.3333333333333333 x) 0.5) n) x)))
0.0)))
double code(double x, double n) {
double tmp;
if (x <= 8.5e-293) {
tmp = 0.0;
} else if (x <= 1.95e+228) {
tmp = (1.0 / x) * ((1.0 / n) + ((((0.3333333333333333 / x) - 0.5) / n) / x));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 8.5d-293) then
tmp = 0.0d0
else if (x <= 1.95d+228) then
tmp = (1.0d0 / x) * ((1.0d0 / n) + ((((0.3333333333333333d0 / x) - 0.5d0) / n) / x))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 8.5e-293) {
tmp = 0.0;
} else if (x <= 1.95e+228) {
tmp = (1.0 / x) * ((1.0 / n) + ((((0.3333333333333333 / x) - 0.5) / n) / x));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 8.5e-293: tmp = 0.0 elif x <= 1.95e+228: tmp = (1.0 / x) * ((1.0 / n) + ((((0.3333333333333333 / x) - 0.5) / n) / x)) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 8.5e-293) tmp = 0.0; elseif (x <= 1.95e+228) tmp = Float64(Float64(1.0 / x) * Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / n) / x))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 8.5e-293) tmp = 0.0; elseif (x <= 1.95e+228) tmp = (1.0 / x) * ((1.0 / n) + ((((0.3333333333333333 / x) - 0.5) / n) / x)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 8.5e-293], 0.0, If[LessEqual[x, 1.95e+228], N[(N[(1.0 / x), $MachinePrecision] * N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{-293}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{+228}:\\
\;\;\;\;\frac{1}{x} \cdot \left(\frac{1}{n} + \frac{\frac{\frac{0.3333333333333333}{x} - 0.5}{n}}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.50000000000000044e-293 or 1.94999999999999997e228 < x Initial program 79.6%
add-log-exp79.6%
pow-to-exp51.7%
un-div-inv51.7%
+-commutative51.7%
log1p-define68.8%
Applied egg-rr68.8%
Taylor expanded in x around inf 71.9%
if 8.50000000000000044e-293 < x < 1.94999999999999997e228Initial program 46.6%
Taylor expanded in n around inf 48.0%
log1p-define47.5%
Simplified47.5%
Taylor expanded in x around -inf 44.7%
mul-1-neg44.7%
mul-1-neg44.7%
associate-*r/44.7%
metadata-eval44.7%
*-commutative44.7%
associate-*r/44.7%
metadata-eval44.7%
Simplified44.7%
frac-2neg44.7%
div-inv44.8%
Applied egg-rr44.8%
Final simplification53.9%
(FPCore (x n) :precision binary64 (* (/ 1.0 x) (+ (/ 1.0 n) (/ (/ (- (/ 0.3333333333333333 x) 0.5) n) x))))
double code(double x, double n) {
return (1.0 / x) * ((1.0 / n) + ((((0.3333333333333333 / x) - 0.5) / n) / x));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) * ((1.0d0 / n) + ((((0.3333333333333333d0 / x) - 0.5d0) / n) / x))
end function
public static double code(double x, double n) {
return (1.0 / x) * ((1.0 / n) + ((((0.3333333333333333 / x) - 0.5) / n) / x));
}
def code(x, n): return (1.0 / x) * ((1.0 / n) + ((((0.3333333333333333 / x) - 0.5) / n) / x))
function code(x, n) return Float64(Float64(1.0 / x) * Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / n) / x))) end
function tmp = code(x, n) tmp = (1.0 / x) * ((1.0 / n) + ((((0.3333333333333333 / x) - 0.5) / n) / x)); end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] * N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x} \cdot \left(\frac{1}{n} + \frac{\frac{\frac{0.3333333333333333}{x} - 0.5}{n}}{x}\right)
\end{array}
Initial program 57.7%
Taylor expanded in n around inf 41.0%
log1p-define40.7%
Simplified40.7%
Taylor expanded in x around -inf 35.1%
mul-1-neg35.1%
mul-1-neg35.1%
associate-*r/35.1%
metadata-eval35.1%
*-commutative35.1%
associate-*r/35.1%
metadata-eval35.1%
Simplified35.1%
frac-2neg35.1%
div-inv35.1%
Applied egg-rr35.1%
Final simplification35.1%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 x) -0.5) (* n x))) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / x) + -0.5) / (n * x))) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((0.3333333333333333d0 / x) + (-0.5d0)) / (n * x))) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / x) + -0.5) / (n * x))) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 / x) + -0.5) / (n * x))) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / x) + -0.5) / Float64(n * x))) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 / x) + -0.5) / (n * x))) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + -0.5), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x} + -0.5}{n \cdot x}}{x}
\end{array}
Initial program 57.7%
Taylor expanded in n around inf 41.0%
log1p-define40.7%
Simplified40.7%
expm1-log1p-u40.4%
Applied egg-rr40.4%
Taylor expanded in x around inf 27.6%
Simplified35.1%
Final simplification35.1%
(FPCore (x n) :precision binary64 (/ (/ (+ 1.0 (/ (+ (/ 0.3333333333333333 x) -0.5) x)) n) x))
double code(double x, double n) {
return ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 + (((0.3333333333333333d0 / x) + (-0.5d0)) / x)) / n) / x
end function
public static double code(double x, double n) {
return ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / n) / x;
}
def code(x, n): return ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / n) / x
function code(x, n) return Float64(Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) + -0.5) / x)) / n) / x) end
function tmp = code(x, n) tmp = ((1.0 + (((0.3333333333333333 / x) + -0.5) / x)) / n) / x; end
code[x_, n_] := N[(N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + -0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 + \frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{n}}{x}
\end{array}
Initial program 57.7%
Taylor expanded in n around inf 41.0%
log1p-define40.7%
Simplified40.7%
Taylor expanded in x around inf 27.6%
Taylor expanded in n around 0 35.1%
associate--l+35.1%
unpow235.1%
associate-/r*35.1%
associate-/l*35.1%
associate-*r/35.1%
metadata-eval35.1%
div-sub35.1%
sub-neg35.1%
metadata-eval35.1%
+-commutative35.1%
associate-*r/35.1%
metadata-eval35.1%
Simplified35.1%
Final simplification35.1%
(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 57.7%
Taylor expanded in n around inf 41.0%
log1p-define40.7%
Simplified40.7%
Taylor expanded in x around inf 30.6%
*-commutative30.6%
Simplified30.6%
Final simplification30.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 57.7%
Taylor expanded in x around inf 44.4%
associate-/r*44.9%
mul-1-neg44.9%
log-rec44.9%
mul-1-neg44.9%
distribute-neg-frac44.9%
mul-1-neg44.9%
remove-double-neg44.9%
*-rgt-identity44.9%
associate-/l*44.9%
exp-to-pow60.4%
Simplified60.4%
Taylor expanded in n around inf 31.0%
Final simplification31.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 57.7%
Taylor expanded in n around inf 41.0%
log1p-define40.7%
Simplified40.7%
Taylor expanded in x around inf 31.0%
Final simplification31.0%
herbie shell --seed 2024059
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))