
(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 13 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 (* x n)))
(t_2 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -5e-16)
t_1
(if (<= (/ 1.0 n) -4e-127)
t_2
(if (<= (/ 1.0 n) -1e-143)
(/ (/ (- 1.0 (/ 0.5 x)) n) x)
(if (<= (/ 1.0 n) 5e-35)
t_2
(if (<= (/ 1.0 n) 1000.0)
t_1
(if (<= (/ 1.0 n) 2e+185)
(- (+ 1.0 (/ x n)) t_0)
(/
(+
(/ 1.0 n)
(/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (x * n);
double t_2 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e-16) {
tmp = t_1;
} else if ((1.0 / n) <= -4e-127) {
tmp = t_2;
} else if ((1.0 / n) <= -1e-143) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else if ((1.0 / n) <= 5e-35) {
tmp = t_2;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+185) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (x * n)
t_2 = log(((x + 1.0d0) / x)) / n
if ((1.0d0 / n) <= (-5d-16)) then
tmp = t_1
else if ((1.0d0 / n) <= (-4d-127)) then
tmp = t_2
else if ((1.0d0 / n) <= (-1d-143)) then
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
else if ((1.0d0 / n) <= 5d-35) then
tmp = t_2
else if ((1.0d0 / n) <= 1000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 2d+185) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / 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 / (x * n);
double t_2 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e-16) {
tmp = t_1;
} else if ((1.0 / n) <= -4e-127) {
tmp = t_2;
} else if ((1.0 / n) <= -1e-143) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else if ((1.0 / n) <= 5e-35) {
tmp = t_2;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+185) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (x * n) t_2 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -5e-16: tmp = t_1 elif (1.0 / n) <= -4e-127: tmp = t_2 elif (1.0 / n) <= -1e-143: tmp = ((1.0 - (0.5 / x)) / n) / x elif (1.0 / n) <= 5e-35: tmp = t_2 elif (1.0 / n) <= 1000.0: tmp = t_1 elif (1.0 / n) <= 2e+185: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(x * n)) t_2 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-16) tmp = t_1; elseif (Float64(1.0 / n) <= -4e-127) tmp = t_2; elseif (Float64(1.0 / n) <= -1e-143) tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); elseif (Float64(1.0 / n) <= 5e-35) tmp = t_2; elseif (Float64(1.0 / n) <= 1000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+185) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (x * n); t_2 = log(((x + 1.0) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -5e-16) tmp = t_1; elseif ((1.0 / n) <= -4e-127) tmp = t_2; elseif ((1.0 / n) <= -1e-143) tmp = ((1.0 - (0.5 / x)) / n) / x; elseif ((1.0 / n) <= 5e-35) tmp = t_2; elseif ((1.0 / n) <= 1000.0) tmp = t_1; elseif ((1.0 / n) <= 2e+185) tmp = (1.0 + (x / n)) - t_0; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / 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[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-16], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-127], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-143], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-35], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+185], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{x \cdot n}\\
t_2 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -4 \cdot 10^{-127}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-143}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-35}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 1000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+185}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.0000000000000004e-16 or 4.99999999999999964e-35 < (/.f64 #s(literal 1 binary64) n) < 1e3Initial program 87.9%
Taylor expanded in x around inf 96.0%
mul-1-neg96.0%
log-rec96.0%
mul-1-neg96.0%
distribute-neg-frac96.0%
mul-1-neg96.0%
remove-double-neg96.0%
*-rgt-identity96.0%
associate-/l*95.9%
exp-to-pow96.0%
*-commutative96.0%
Simplified96.0%
if -5.0000000000000004e-16 < (/.f64 #s(literal 1 binary64) n) < -4.0000000000000001e-127 or -9.9999999999999995e-144 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999964e-35Initial program 27.7%
Taylor expanded in n around inf 80.7%
log1p-define80.7%
Simplified80.7%
log1p-undefine80.7%
diff-log80.9%
Applied egg-rr80.9%
+-commutative80.9%
Simplified80.9%
if -4.0000000000000001e-127 < (/.f64 #s(literal 1 binary64) n) < -9.9999999999999995e-144Initial program 7.1%
Taylor expanded in n around 0 7.1%
log1p-define7.1%
*-rgt-identity7.1%
associate-/l*7.1%
exp-to-pow7.1%
Simplified7.1%
Taylor expanded in x around inf 99.4%
Simplified99.4%
Taylor expanded in n around inf 99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
if 1e3 < (/.f64 #s(literal 1 binary64) n) < 2e185Initial program 80.6%
Taylor expanded in x around 0 72.5%
if 2e185 < (/.f64 #s(literal 1 binary64) n) Initial program 8.2%
Taylor expanded in n around inf 7.1%
log1p-define7.1%
Simplified7.1%
Taylor expanded in x around -inf 94.9%
mul-1-neg94.9%
mul-1-neg94.9%
associate-*r/94.9%
metadata-eval94.9%
*-commutative94.9%
associate-*r/94.9%
metadata-eval94.9%
Simplified94.9%
Final simplification86.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n)))
(t_1 (/ t_0 (* x n)))
(t_2 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -5e-16)
t_1
(if (<= (/ 1.0 n) -4e-127)
t_2
(if (<= (/ 1.0 n) -1e-143)
(/ (/ (- 1.0 (/ 0.5 x)) n) x)
(if (<= (/ 1.0 n) 5e-35)
t_2
(if (<= (/ 1.0 n) 1000.0)
t_1
(if (<= (/ 1.0 n) 1e+104)
(- 1.0 t_0)
(/ (- x (log1p (+ x -1.0))) n)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (x * n);
double t_2 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e-16) {
tmp = t_1;
} else if ((1.0 / n) <= -4e-127) {
tmp = t_2;
} else if ((1.0 / n) <= -1e-143) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else if ((1.0 / n) <= 5e-35) {
tmp = t_2;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+104) {
tmp = 1.0 - t_0;
} else {
tmp = (x - log1p((x + -1.0))) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (x * n);
double t_2 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e-16) {
tmp = t_1;
} else if ((1.0 / n) <= -4e-127) {
tmp = t_2;
} else if ((1.0 / n) <= -1e-143) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else if ((1.0 / n) <= 5e-35) {
tmp = t_2;
} else if ((1.0 / n) <= 1000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+104) {
tmp = 1.0 - t_0;
} else {
tmp = (x - Math.log1p((x + -1.0))) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (x * n) t_2 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -5e-16: tmp = t_1 elif (1.0 / n) <= -4e-127: tmp = t_2 elif (1.0 / n) <= -1e-143: tmp = ((1.0 - (0.5 / x)) / n) / x elif (1.0 / n) <= 5e-35: tmp = t_2 elif (1.0 / n) <= 1000.0: tmp = t_1 elif (1.0 / n) <= 1e+104: tmp = 1.0 - t_0 else: tmp = (x - math.log1p((x + -1.0))) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(x * n)) t_2 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-16) tmp = t_1; elseif (Float64(1.0 / n) <= -4e-127) tmp = t_2; elseif (Float64(1.0 / n) <= -1e-143) tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); elseif (Float64(1.0 / n) <= 5e-35) tmp = t_2; elseif (Float64(1.0 / n) <= 1000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+104) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(x - log1p(Float64(x + -1.0))) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-16], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-127], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-143], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-35], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+104], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(x - N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{x \cdot n}\\
t_2 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -4 \cdot 10^{-127}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-143}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-35}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 1000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+104}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \mathsf{log1p}\left(x + -1\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.0000000000000004e-16 or 4.99999999999999964e-35 < (/.f64 #s(literal 1 binary64) n) < 1e3Initial program 87.9%
Taylor expanded in x around inf 96.0%
mul-1-neg96.0%
log-rec96.0%
mul-1-neg96.0%
distribute-neg-frac96.0%
mul-1-neg96.0%
remove-double-neg96.0%
*-rgt-identity96.0%
associate-/l*95.9%
exp-to-pow96.0%
*-commutative96.0%
Simplified96.0%
if -5.0000000000000004e-16 < (/.f64 #s(literal 1 binary64) n) < -4.0000000000000001e-127 or -9.9999999999999995e-144 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999964e-35Initial program 27.7%
Taylor expanded in n around inf 80.7%
log1p-define80.7%
Simplified80.7%
log1p-undefine80.7%
diff-log80.9%
Applied egg-rr80.9%
+-commutative80.9%
Simplified80.9%
if -4.0000000000000001e-127 < (/.f64 #s(literal 1 binary64) n) < -9.9999999999999995e-144Initial program 7.1%
Taylor expanded in n around 0 7.1%
log1p-define7.1%
*-rgt-identity7.1%
associate-/l*7.1%
exp-to-pow7.1%
Simplified7.1%
Taylor expanded in x around inf 99.4%
Simplified99.4%
Taylor expanded in n around inf 99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
if 1e3 < (/.f64 #s(literal 1 binary64) n) < 1e104Initial program 98.3%
Taylor expanded in x around 0 90.2%
*-rgt-identity90.2%
associate-/l*90.2%
exp-to-pow90.2%
Simplified90.2%
if 1e104 < (/.f64 #s(literal 1 binary64) n) Initial program 23.9%
Taylor expanded in x around 0 21.2%
Taylor expanded in n around inf 6.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
add-exp-log79.3%
Applied egg-rr79.3%
Final simplification86.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -5e+105)
t_1
(if (<= (/ 1.0 n) -2e+20)
t_0
(if (<= (/ 1.0 n) 0.0002)
t_1
(if (<= (/ 1.0 n) 1e+104) t_0 (/ (- x (log1p (+ x -1.0))) n)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+105) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+20) {
tmp = t_0;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+104) {
tmp = t_0;
} else {
tmp = (x - log1p((x + -1.0))) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+105) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+20) {
tmp = t_0;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+104) {
tmp = t_0;
} else {
tmp = (x - Math.log1p((x + -1.0))) / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -5e+105: tmp = t_1 elif (1.0 / n) <= -2e+20: tmp = t_0 elif (1.0 / n) <= 0.0002: tmp = t_1 elif (1.0 / n) <= 1e+104: tmp = t_0 else: tmp = (x - math.log1p((x + -1.0))) / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+105) tmp = t_1; elseif (Float64(1.0 / n) <= -2e+20) tmp = t_0; elseif (Float64(1.0 / n) <= 0.0002) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+104) tmp = t_0; else tmp = Float64(Float64(x - log1p(Float64(x + -1.0))) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+105], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+20], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+104], t$95$0, N[(N[(x - N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+105}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \mathsf{log1p}\left(x + -1\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000046e105 or -2e20 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-4Initial program 45.5%
Taylor expanded in n around inf 72.5%
log1p-define72.5%
Simplified72.5%
log1p-undefine72.5%
diff-log72.3%
Applied egg-rr72.3%
+-commutative72.3%
Simplified72.3%
if -5.00000000000000046e105 < (/.f64 #s(literal 1 binary64) n) < -2e20 or 2.0000000000000001e-4 < (/.f64 #s(literal 1 binary64) n) < 1e104Initial program 93.4%
Taylor expanded in x around 0 66.5%
*-rgt-identity66.5%
associate-/l*66.5%
exp-to-pow66.5%
Simplified66.5%
if 1e104 < (/.f64 #s(literal 1 binary64) n) Initial program 23.9%
Taylor expanded in x around 0 21.2%
Taylor expanded in n around inf 6.3%
log1p-expm1-u79.3%
expm1-undefine79.3%
add-exp-log79.3%
Applied egg-rr79.3%
Final simplification72.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -5e+105)
t_1
(if (<= (/ 1.0 n) -2e+20)
t_0
(if (<= (/ 1.0 n) 0.0002)
t_1
(if (<= (/ 1.0 n) 2e+185)
t_0
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
x)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+105) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+20) {
tmp = t_0;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+185) {
tmp = t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((x + 1.0d0) / x)) / n
if ((1.0d0 / n) <= (-5d+105)) then
tmp = t_1
else if ((1.0d0 / n) <= (-2d+20)) then
tmp = t_0
else if ((1.0d0 / n) <= 0.0002d0) then
tmp = t_1
else if ((1.0d0 / n) <= 2d+185) then
tmp = t_0
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -5e+105) {
tmp = t_1;
} else if ((1.0 / n) <= -2e+20) {
tmp = t_0;
} else if ((1.0 / n) <= 0.0002) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+185) {
tmp = t_0;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -5e+105: tmp = t_1 elif (1.0 / n) <= -2e+20: tmp = t_0 elif (1.0 / n) <= 0.0002: tmp = t_1 elif (1.0 / n) <= 2e+185: tmp = t_0 else: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+105) tmp = t_1; elseif (Float64(1.0 / n) <= -2e+20) tmp = t_0; elseif (Float64(1.0 / n) <= 0.0002) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+185) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(((x + 1.0) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -5e+105) tmp = t_1; elseif ((1.0 / n) <= -2e+20) tmp = t_0; elseif ((1.0 / n) <= 0.0002) tmp = t_1; elseif ((1.0 / n) <= 2e+185) tmp = t_0; else tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+105], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+20], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0002], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+185], t$95$0, N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+105}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 0.0002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+185}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000046e105 or -2e20 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-4Initial program 45.5%
Taylor expanded in n around inf 72.5%
log1p-define72.5%
Simplified72.5%
log1p-undefine72.5%
diff-log72.3%
Applied egg-rr72.3%
+-commutative72.3%
Simplified72.3%
if -5.00000000000000046e105 < (/.f64 #s(literal 1 binary64) n) < -2e20 or 2.0000000000000001e-4 < (/.f64 #s(literal 1 binary64) n) < 2e185Initial program 86.6%
Taylor expanded in x around 0 62.7%
*-rgt-identity62.7%
associate-/l*62.7%
exp-to-pow62.7%
Simplified62.7%
if 2e185 < (/.f64 #s(literal 1 binary64) n) Initial program 8.2%
Taylor expanded in n around inf 7.1%
log1p-define7.1%
Simplified7.1%
Taylor expanded in x around -inf 94.9%
mul-1-neg94.9%
mul-1-neg94.9%
associate-*r/94.9%
metadata-eval94.9%
*-commutative94.9%
associate-*r/94.9%
metadata-eval94.9%
Simplified94.9%
Final simplification72.2%
(FPCore (x n)
:precision binary64
(if (<= x 1.65e-290)
(/ (log x) (- n))
(if (<= x 2.3e-249)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.215)
(/ (- x (log x)) n)
(/ (/ (+ 1.0 (/ (- (* 0.3333333333333333 (/ 1.0 x)) 0.5) x)) x) n)))))
double code(double x, double n) {
double tmp;
if (x <= 1.65e-290) {
tmp = log(x) / -n;
} else if (x <= 2.3e-249) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.215) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + (((0.3333333333333333 * (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 <= 1.65d-290) then
tmp = log(x) / -n
else if (x <= 2.3d-249) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.215d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + (((0.3333333333333333d0 * (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 <= 1.65e-290) {
tmp = Math.log(x) / -n;
} else if (x <= 2.3e-249) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.215) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + (((0.3333333333333333 * (1.0 / x)) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.65e-290: tmp = math.log(x) / -n elif x <= 2.3e-249: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.215: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + (((0.3333333333333333 * (1.0 / x)) - 0.5) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.65e-290) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 2.3e-249) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.215) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 * Float64(1.0 / x)) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.65e-290) tmp = log(x) / -n; elseif (x <= 2.3e-249) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.215) tmp = (x - log(x)) / n; else tmp = ((1.0 + (((0.3333333333333333 * (1.0 / x)) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.65e-290], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.3e-249], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.215], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(0.3333333333333333 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.65 \cdot 10^{-290}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-249}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.215:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 1.64999999999999993e-290Initial program 16.7%
Taylor expanded in x around 0 16.7%
*-rgt-identity16.7%
associate-/l*16.7%
exp-to-pow16.7%
Simplified16.7%
Taylor expanded in n around inf 87.5%
associate-*r/87.5%
neg-mul-187.5%
Simplified87.5%
if 1.64999999999999993e-290 < x < 2.2999999999999998e-249Initial program 73.6%
Taylor expanded in x around 0 73.6%
*-rgt-identity73.6%
associate-/l*73.6%
exp-to-pow73.6%
Simplified73.6%
if 2.2999999999999998e-249 < x < 0.214999999999999997Initial program 35.2%
Taylor expanded in x around 0 34.0%
Taylor expanded in n around inf 53.0%
if 0.214999999999999997 < x Initial program 66.2%
Taylor expanded in n around inf 64.1%
log1p-define64.1%
Simplified64.1%
Taylor expanded in x around -inf 58.8%
Final simplification57.8%
(FPCore (x n)
:precision binary64
(if (<= x 5.5e-193)
(/ (log x) (- n))
(if (<= x 6.4e-172)
(/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x)) x)
(if (<= x 0.215)
(/ (- x (log x)) n)
(/ (/ (+ 1.0 (/ (- (* 0.3333333333333333 (/ 1.0 x)) 0.5) x)) x) n)))))
double code(double x, double n) {
double tmp;
if (x <= 5.5e-193) {
tmp = log(x) / -n;
} else if (x <= 6.4e-172) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else if (x <= 0.215) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + (((0.3333333333333333 * (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.5d-193) then
tmp = log(x) / -n
else if (x <= 6.4d-172) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
else if (x <= 0.215d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + (((0.3333333333333333d0 * (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.5e-193) {
tmp = Math.log(x) / -n;
} else if (x <= 6.4e-172) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else if (x <= 0.215) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + (((0.3333333333333333 * (1.0 / x)) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5.5e-193: tmp = math.log(x) / -n elif x <= 6.4e-172: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x elif x <= 0.215: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + (((0.3333333333333333 * (1.0 / x)) - 0.5) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 5.5e-193) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 6.4e-172) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); elseif (x <= 0.215) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 * Float64(1.0 / x)) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5.5e-193) tmp = log(x) / -n; elseif (x <= 6.4e-172) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; elseif (x <= 0.215) tmp = (x - log(x)) / n; else tmp = ((1.0 + (((0.3333333333333333 * (1.0 / x)) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5.5e-193], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 6.4e-172], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.215], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(0.3333333333333333 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{-193}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-172}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.215:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 5.50000000000000014e-193Initial program 41.0%
Taylor expanded in x around 0 41.0%
*-rgt-identity41.0%
associate-/l*41.0%
exp-to-pow41.0%
Simplified41.0%
Taylor expanded in n around inf 55.6%
associate-*r/55.6%
neg-mul-155.6%
Simplified55.6%
if 5.50000000000000014e-193 < x < 6.4000000000000003e-172Initial program 43.7%
Taylor expanded in n around inf 21.4%
log1p-define21.4%
Simplified21.4%
Taylor expanded in x around -inf 67.6%
mul-1-neg67.6%
mul-1-neg67.6%
associate-*r/67.6%
metadata-eval67.6%
*-commutative67.6%
associate-*r/67.6%
metadata-eval67.6%
Simplified67.6%
if 6.4000000000000003e-172 < x < 0.214999999999999997Initial program 35.0%
Taylor expanded in x around 0 33.0%
Taylor expanded in n around inf 54.8%
if 0.214999999999999997 < x Initial program 66.2%
Taylor expanded in n around inf 64.1%
log1p-define64.1%
Simplified64.1%
Taylor expanded in x around -inf 58.8%
Final simplification57.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 6.2e-193)
t_0
(if (<= x 8.8e-172)
(/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x)) x)
(if (<= x 0.215)
t_0
(/
(/ (+ 1.0 (/ (- (* 0.3333333333333333 (/ 1.0 x)) 0.5) x)) x)
n))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 6.2e-193) {
tmp = t_0;
} else if (x <= 8.8e-172) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else if (x <= 0.215) {
tmp = t_0;
} else {
tmp = ((1.0 + (((0.3333333333333333 * (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 <= 6.2d-193) then
tmp = t_0
else if (x <= 8.8d-172) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
else if (x <= 0.215d0) then
tmp = t_0
else
tmp = ((1.0d0 + (((0.3333333333333333d0 * (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 <= 6.2e-193) {
tmp = t_0;
} else if (x <= 8.8e-172) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
} else if (x <= 0.215) {
tmp = t_0;
} else {
tmp = ((1.0 + (((0.3333333333333333 * (1.0 / x)) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 6.2e-193: tmp = t_0 elif x <= 8.8e-172: tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x elif x <= 0.215: tmp = t_0 else: tmp = ((1.0 + (((0.3333333333333333 * (1.0 / x)) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 6.2e-193) tmp = t_0; elseif (x <= 8.8e-172) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x); elseif (x <= 0.215) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 * Float64(1.0 / x)) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 6.2e-193) tmp = t_0; elseif (x <= 8.8e-172) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; elseif (x <= 0.215) tmp = t_0; else tmp = ((1.0 + (((0.3333333333333333 * (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, 6.2e-193], t$95$0, If[LessEqual[x, 8.8e-172], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.215], t$95$0, N[(N[(N[(1.0 + N[(N[(N[(0.3333333333333333 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 6.2 \cdot 10^{-193}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-172}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.215:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 6.2000000000000004e-193 or 8.80000000000000036e-172 < x < 0.214999999999999997Initial program 37.4%
Taylor expanded in x around 0 35.8%
*-rgt-identity35.8%
associate-/l*35.8%
exp-to-pow35.8%
Simplified35.8%
Taylor expanded in n around inf 54.7%
associate-*r/54.7%
neg-mul-154.7%
Simplified54.7%
if 6.2000000000000004e-193 < x < 8.80000000000000036e-172Initial program 43.7%
Taylor expanded in n around inf 21.4%
log1p-define21.4%
Simplified21.4%
Taylor expanded in x around -inf 67.6%
mul-1-neg67.6%
mul-1-neg67.6%
associate-*r/67.6%
metadata-eval67.6%
*-commutative67.6%
associate-*r/67.6%
metadata-eval67.6%
Simplified67.6%
if 0.214999999999999997 < x Initial program 66.2%
Taylor expanded in n around inf 64.1%
log1p-define64.1%
Simplified64.1%
Taylor expanded in x around -inf 58.8%
Final simplification57.1%
(FPCore (x n) :precision binary64 (if (<= x 3.2e-13) (* x (- (/ 1.0 n) (/ (log x) (* x n)))) (* (/ 1.0 n) (pow x (+ (/ 1.0 n) -1.0)))))
double code(double x, double n) {
double tmp;
if (x <= 3.2e-13) {
tmp = x * ((1.0 / n) - (log(x) / (x * n)));
} else {
tmp = (1.0 / n) * pow(x, ((1.0 / n) + -1.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.2d-13) then
tmp = x * ((1.0d0 / n) - (log(x) / (x * n)))
else
tmp = (1.0d0 / n) * (x ** ((1.0d0 / n) + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.2e-13) {
tmp = x * ((1.0 / n) - (Math.log(x) / (x * n)));
} else {
tmp = (1.0 / n) * Math.pow(x, ((1.0 / n) + -1.0));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.2e-13: tmp = x * ((1.0 / n) - (math.log(x) / (x * n))) else: tmp = (1.0 / n) * math.pow(x, ((1.0 / n) + -1.0)) return tmp
function code(x, n) tmp = 0.0 if (x <= 3.2e-13) tmp = Float64(x * Float64(Float64(1.0 / n) - Float64(log(x) / Float64(x * n)))); else tmp = Float64(Float64(1.0 / n) * (x ^ Float64(Float64(1.0 / n) + -1.0))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.2e-13) tmp = x * ((1.0 / n) - (log(x) / (x * n))); else tmp = (1.0 / n) * (x ^ ((1.0 / n) + -1.0)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.2e-13], N[(x * N[(N[(1.0 / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] * N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{-13}:\\
\;\;\;\;x \cdot \left(\frac{1}{n} - \frac{\log x}{x \cdot n}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n} \cdot {x}^{\left(\frac{1}{n} + -1\right)}\\
\end{array}
\end{array}
if x < 3.2e-13Initial program 36.8%
Taylor expanded in x around 0 37.1%
Taylor expanded in n around inf 53.6%
Taylor expanded in x around inf 75.2%
log-rec75.2%
*-commutative75.2%
Simplified75.2%
if 3.2e-13 < x Initial program 65.8%
Taylor expanded in x around inf 94.5%
mul-1-neg94.5%
log-rec94.5%
mul-1-neg94.5%
distribute-neg-frac94.5%
mul-1-neg94.5%
remove-double-neg94.5%
*-commutative94.5%
Simplified94.5%
associate-/r*95.6%
div-inv95.6%
div-inv95.6%
pow-to-exp95.6%
pow195.6%
pow-div95.3%
Applied egg-rr95.3%
Final simplification84.6%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (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 * n)) - (0.5d0 / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}
\end{array}
Initial program 50.4%
Taylor expanded in n around inf 58.0%
log1p-define58.0%
Simplified58.0%
Taylor expanded in x around -inf 44.9%
mul-1-neg44.9%
mul-1-neg44.9%
associate-*r/44.9%
metadata-eval44.9%
*-commutative44.9%
associate-*r/44.9%
metadata-eval44.9%
Simplified44.9%
Final simplification44.9%
(FPCore (x n) :precision binary64 (* (/ 1.0 n) (/ 1.0 x)))
double code(double x, double n) {
return (1.0 / n) * (1.0 / x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) * (1.0d0 / x)
end function
public static double code(double x, double n) {
return (1.0 / n) * (1.0 / x);
}
def code(x, n): return (1.0 / n) * (1.0 / x)
function code(x, n) return Float64(Float64(1.0 / n) * Float64(1.0 / x)) end
function tmp = code(x, n) tmp = (1.0 / n) * (1.0 / x); end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n} \cdot \frac{1}{x}
\end{array}
Initial program 50.4%
Taylor expanded in x around inf 56.4%
mul-1-neg56.4%
log-rec56.4%
mul-1-neg56.4%
distribute-neg-frac56.4%
mul-1-neg56.4%
remove-double-neg56.4%
*-commutative56.4%
Simplified56.4%
associate-/r*57.1%
div-inv57.1%
div-inv57.1%
pow-to-exp57.1%
pow157.1%
pow-div57.0%
Applied egg-rr57.0%
Taylor expanded in n around inf 40.8%
Final simplification40.8%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(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 50.4%
Taylor expanded in x around inf 56.4%
mul-1-neg56.4%
log-rec56.4%
mul-1-neg56.4%
distribute-neg-frac56.4%
mul-1-neg56.4%
remove-double-neg56.4%
*-commutative56.4%
Simplified56.4%
Taylor expanded in n around inf 40.2%
*-commutative40.2%
associate-/r*40.8%
Simplified40.8%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 50.4%
Taylor expanded in x around inf 56.4%
mul-1-neg56.4%
log-rec56.4%
mul-1-neg56.4%
distribute-neg-frac56.4%
mul-1-neg56.4%
remove-double-neg56.4%
*-commutative56.4%
Simplified56.4%
Taylor expanded in n around inf 40.2%
Final simplification40.2%
(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 50.4%
Taylor expanded in x around 0 27.8%
Taylor expanded in x around inf 4.6%
herbie shell --seed 2024110
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))