
(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 17 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 (- (exp (/ (log1p x) n)) t_0))
(t_2 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_2 -5e-6)
(* 2.0 (log (sqrt (exp t_1))))
(if (<= t_2 0.0) (/ (- (log (/ x (+ x 1.0)))) n) t_1))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = exp((log1p(x) / n)) - t_0;
double t_2 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_2 <= -5e-6) {
tmp = 2.0 * log(sqrt(exp(t_1)));
} else if (t_2 <= 0.0) {
tmp = -log((x / (x + 1.0))) / n;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.exp((Math.log1p(x) / n)) - t_0;
double t_2 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_2 <= -5e-6) {
tmp = 2.0 * Math.log(Math.sqrt(Math.exp(t_1)));
} else if (t_2 <= 0.0) {
tmp = -Math.log((x / (x + 1.0))) / n;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.exp((math.log1p(x) / n)) - t_0 t_2 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_2 <= -5e-6: tmp = 2.0 * math.log(math.sqrt(math.exp(t_1))) elif t_2 <= 0.0: tmp = -math.log((x / (x + 1.0))) / n else: tmp = t_1 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(exp(Float64(log1p(x) / n)) - t_0) t_2 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_2 <= -5e-6) tmp = Float64(2.0 * log(sqrt(exp(t_1)))); elseif (t_2 <= 0.0) tmp = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n); else tmp = t_1; 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[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-6], N[(2.0 * N[Log[N[Sqrt[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[((-N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
t_2 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{if}\;t_2 \leq -5 \cdot 10^{-6}:\\
\;\;\;\;2 \cdot \log \left(\sqrt{e^{t_1}}\right)\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -5.00000000000000041e-6Initial program 99.1%
add-log-exp99.0%
add-sqr-sqrt99.0%
log-prod99.1%
add-exp-log99.1%
log-pow99.1%
+-commutative99.1%
log1p-udef99.1%
*-commutative99.1%
un-div-inv99.1%
Applied egg-rr99.1%
count-299.1%
Simplified99.1%
if -5.00000000000000041e-6 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 0.0Initial program 43.2%
Taylor expanded in n around inf 80.7%
+-rgt-identity80.7%
+-rgt-identity80.7%
log1p-def80.7%
Simplified80.7%
log1p-udef80.7%
+-commutative80.7%
diff-log80.8%
Applied egg-rr80.8%
clear-num80.8%
log-rec80.8%
Applied egg-rr80.8%
if 0.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 54.7%
Taylor expanded in n around 0 54.7%
log1p-def100.0%
Simplified100.0%
Final simplification85.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -5e-6)
(- 1.0 (cbrt (pow x (/ 3.0 n))))
(if (<= t_1 0.0)
(/ (- (log (/ x (+ x 1.0)))) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-6) {
tmp = 1.0 - cbrt(pow(x, (3.0 / n)));
} else if (t_1 <= 0.0) {
tmp = -log((x / (x + 1.0))) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -5e-6) {
tmp = 1.0 - Math.cbrt(Math.pow(x, (3.0 / n)));
} else if (t_1 <= 0.0) {
tmp = -Math.log((x / (x + 1.0))) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -5e-6) tmp = Float64(1.0 - cbrt((x ^ Float64(3.0 / n)))); elseif (t_1 <= 0.0) tmp = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-6], N[(1.0 - N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[((-N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_0\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-6}:\\
\;\;\;\;1 - \sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -5.00000000000000041e-6Initial program 99.1%
Taylor expanded in x around 0 99.1%
add-cbrt-cube99.1%
pow399.1%
pow-pow99.1%
Applied egg-rr99.1%
associate-*l/99.1%
metadata-eval99.1%
Simplified99.1%
if -5.00000000000000041e-6 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 0.0Initial program 43.2%
Taylor expanded in n around inf 80.7%
+-rgt-identity80.7%
+-rgt-identity80.7%
log1p-def80.7%
Simplified80.7%
log1p-udef80.7%
+-commutative80.7%
diff-log80.8%
Applied egg-rr80.8%
clear-num80.8%
log-rec80.8%
Applied egg-rr80.8%
if 0.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 54.7%
Taylor expanded in n around 0 54.7%
log1p-def100.0%
Simplified100.0%
Final simplification85.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log (/ x (+ x 1.0)))) n)))
(if (<= (/ 1.0 n) -5e-35)
(/ (exp (/ (log x) n)) (* x n))
(if (<= (/ 1.0 n) 4e-177)
t_0
(if (<= (/ 1.0 n) 4e-132)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 2e-5)
t_0
(if (<= (/ 1.0 n) 2e+137)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(sqrt (pow (* x n) -2.0)))))))))
double code(double x, double n) {
double t_0 = -log((x / (x + 1.0))) / n;
double tmp;
if ((1.0 / n) <= -5e-35) {
tmp = exp((log(x) / n)) / (x * n);
} else if ((1.0 / n) <= 4e-177) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 2e+137) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else {
tmp = sqrt(pow((x * n), -2.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 = -log((x / (x + 1.0d0))) / n
if ((1.0d0 / n) <= (-5d-35)) then
tmp = exp((log(x) / n)) / (x * n)
else if ((1.0d0 / n) <= 4d-177) then
tmp = t_0
else if ((1.0d0 / n) <= 4d-132) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 2d-5) then
tmp = t_0
else if ((1.0d0 / n) <= 2d+137) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else
tmp = sqrt(((x * n) ** (-2.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log((x / (x + 1.0))) / n;
double tmp;
if ((1.0 / n) <= -5e-35) {
tmp = Math.exp((Math.log(x) / n)) / (x * n);
} else if ((1.0 / n) <= 4e-177) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 2e+137) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = Math.sqrt(Math.pow((x * n), -2.0));
}
return tmp;
}
def code(x, n): t_0 = -math.log((x / (x + 1.0))) / n tmp = 0 if (1.0 / n) <= -5e-35: tmp = math.exp((math.log(x) / n)) / (x * n) elif (1.0 / n) <= 4e-177: tmp = t_0 elif (1.0 / n) <= 4e-132: tmp = (1.0 / n) / x elif (1.0 / n) <= 2e-5: tmp = t_0 elif (1.0 / n) <= 2e+137: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) else: tmp = math.sqrt(math.pow((x * n), -2.0)) return tmp
function code(x, n) t_0 = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-35) tmp = Float64(exp(Float64(log(x) / n)) / Float64(x * n)); elseif (Float64(1.0 / n) <= 4e-177) tmp = t_0; elseif (Float64(1.0 / n) <= 4e-132) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 2e-5) tmp = t_0; elseif (Float64(1.0 / n) <= 2e+137) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = sqrt((Float64(x * n) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = -log((x / (x + 1.0))) / n; tmp = 0.0; if ((1.0 / n) <= -5e-35) tmp = exp((log(x) / n)) / (x * n); elseif ((1.0 / n) <= 4e-177) tmp = t_0; elseif ((1.0 / n) <= 4e-132) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 2e-5) tmp = t_0; elseif ((1.0 / n) <= 2e+137) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); else tmp = sqrt(((x * n) ^ -2.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-35], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-177], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-132], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-5], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+137], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[Power[N[(x * n), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-35}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-177}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+137}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(x \cdot n\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999964e-35Initial program 94.1%
Taylor expanded in x around inf 92.9%
mul-1-neg92.9%
log-rec92.9%
mul-1-neg92.9%
distribute-neg-frac92.9%
mul-1-neg92.9%
remove-double-neg92.9%
*-commutative92.9%
Simplified92.9%
if -4.99999999999999964e-35 < (/.f64 1 n) < 3.99999999999999981e-177 or 3.9999999999999999e-132 < (/.f64 1 n) < 2.00000000000000016e-5Initial program 29.7%
Taylor expanded in n around inf 81.2%
+-rgt-identity81.2%
+-rgt-identity81.2%
log1p-def81.2%
Simplified81.2%
log1p-udef81.2%
+-commutative81.2%
diff-log81.3%
Applied egg-rr81.3%
clear-num81.3%
log-rec81.3%
Applied egg-rr81.3%
if 3.99999999999999981e-177 < (/.f64 1 n) < 3.9999999999999999e-132Initial program 29.6%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-def45.4%
Simplified45.4%
log1p-udef45.4%
+-commutative45.4%
diff-log45.4%
Applied egg-rr45.4%
Taylor expanded in x around inf 84.0%
associate-/r*84.1%
Simplified84.1%
if 2.00000000000000016e-5 < (/.f64 1 n) < 2.0000000000000001e137Initial program 76.1%
Taylor expanded in x around 0 77.7%
if 2.0000000000000001e137 < (/.f64 1 n) Initial program 21.3%
Taylor expanded in n around inf 5.7%
+-rgt-identity5.7%
+-rgt-identity5.7%
log1p-def5.7%
Simplified5.7%
Taylor expanded in x around inf 48.8%
*-commutative48.8%
Simplified48.8%
add-sqr-sqrt48.8%
sqrt-unprod77.6%
inv-pow77.6%
inv-pow77.6%
pow-prod-up77.6%
metadata-eval77.6%
Applied egg-rr77.6%
Final simplification84.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log (/ x (+ x 1.0)))) n)) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e-13)
(- (pow (+ x 1.0) (/ 1.0 n)) t_1)
(if (<= (/ 1.0 n) 4e-177)
t_0
(if (<= (/ 1.0 n) 4e-132)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 2e-5)
t_0
(if (<= (/ 1.0 n) 2e+137)
(- (+ 1.0 (/ x n)) t_1)
(sqrt (pow (* x n) -2.0)))))))))
double code(double x, double n) {
double t_0 = -log((x / (x + 1.0))) / n;
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-13) {
tmp = pow((x + 1.0), (1.0 / n)) - t_1;
} else if ((1.0 / n) <= 4e-177) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 2e+137) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = sqrt(pow((x * n), -2.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((x / (x + 1.0d0))) / n
t_1 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-1d-13)) then
tmp = ((x + 1.0d0) ** (1.0d0 / n)) - t_1
else if ((1.0d0 / n) <= 4d-177) then
tmp = t_0
else if ((1.0d0 / n) <= 4d-132) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 2d-5) then
tmp = t_0
else if ((1.0d0 / n) <= 2d+137) then
tmp = (1.0d0 + (x / n)) - t_1
else
tmp = sqrt(((x * n) ** (-2.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log((x / (x + 1.0))) / n;
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e-13) {
tmp = Math.pow((x + 1.0), (1.0 / n)) - t_1;
} else if ((1.0 / n) <= 4e-177) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 2e+137) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = Math.sqrt(Math.pow((x * n), -2.0));
}
return tmp;
}
def code(x, n): t_0 = -math.log((x / (x + 1.0))) / n t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e-13: tmp = math.pow((x + 1.0), (1.0 / n)) - t_1 elif (1.0 / n) <= 4e-177: tmp = t_0 elif (1.0 / n) <= 4e-132: tmp = (1.0 / n) / x elif (1.0 / n) <= 2e-5: tmp = t_0 elif (1.0 / n) <= 2e+137: tmp = (1.0 + (x / n)) - t_1 else: tmp = math.sqrt(math.pow((x * n), -2.0)) return tmp
function code(x, n) t_0 = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-13) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_1); elseif (Float64(1.0 / n) <= 4e-177) tmp = t_0; elseif (Float64(1.0 / n) <= 4e-132) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 2e-5) tmp = t_0; elseif (Float64(1.0 / n) <= 2e+137) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); else tmp = sqrt((Float64(x * n) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = -log((x / (x + 1.0))) / n; t_1 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -1e-13) tmp = ((x + 1.0) ^ (1.0 / n)) - t_1; elseif ((1.0 / n) <= 4e-177) tmp = t_0; elseif ((1.0 / n) <= 4e-132) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 2e-5) tmp = t_0; elseif ((1.0 / n) <= 2e+137) tmp = (1.0 + (x / n)) - t_1; else tmp = sqrt(((x * n) ^ -2.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-13], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-177], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-132], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-5], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+137], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[Sqrt[N[Power[N[(x * n), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-13}:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-177}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+137}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(x \cdot n\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e-13Initial program 98.3%
if -1e-13 < (/.f64 1 n) < 3.99999999999999981e-177 or 3.9999999999999999e-132 < (/.f64 1 n) < 2.00000000000000016e-5Initial program 29.2%
Taylor expanded in n around inf 80.3%
+-rgt-identity80.3%
+-rgt-identity80.3%
log1p-def80.3%
Simplified80.3%
log1p-udef80.3%
+-commutative80.3%
diff-log80.4%
Applied egg-rr80.4%
clear-num80.4%
log-rec80.4%
Applied egg-rr80.4%
if 3.99999999999999981e-177 < (/.f64 1 n) < 3.9999999999999999e-132Initial program 29.6%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-def45.4%
Simplified45.4%
log1p-udef45.4%
+-commutative45.4%
diff-log45.4%
Applied egg-rr45.4%
Taylor expanded in x around inf 84.0%
associate-/r*84.1%
Simplified84.1%
if 2.00000000000000016e-5 < (/.f64 1 n) < 2.0000000000000001e137Initial program 76.1%
Taylor expanded in x around 0 77.7%
if 2.0000000000000001e137 < (/.f64 1 n) Initial program 21.3%
Taylor expanded in n around inf 5.7%
+-rgt-identity5.7%
+-rgt-identity5.7%
log1p-def5.7%
Simplified5.7%
Taylor expanded in x around inf 48.8%
*-commutative48.8%
Simplified48.8%
add-sqr-sqrt48.8%
sqrt-unprod77.6%
inv-pow77.6%
inv-pow77.6%
pow-prod-up77.6%
metadata-eval77.6%
Applied egg-rr77.6%
Final simplification85.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))))
(if (<= n -1.02)
(/ (- (log t_0)) n)
(if (<= n 5.1e-141)
(/ (- (log1p (+ t_0 -1.0))) n)
(if (<= n 90000.0)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= n 4.5e+131)
(/ (- (log1p x) (log x)) n)
(if (<= n 2.1e+168)
(/ (/ 1.0 n) x)
(- (/ (log1p x) n) (/ (log x) n)))))))))
double code(double x, double n) {
double t_0 = x / (x + 1.0);
double tmp;
if (n <= -1.02) {
tmp = -log(t_0) / n;
} else if (n <= 5.1e-141) {
tmp = -log1p((t_0 + -1.0)) / n;
} else if (n <= 90000.0) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (n <= 4.5e+131) {
tmp = (log1p(x) - log(x)) / n;
} else if (n <= 2.1e+168) {
tmp = (1.0 / n) / x;
} else {
tmp = (log1p(x) / n) - (log(x) / n);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = x / (x + 1.0);
double tmp;
if (n <= -1.02) {
tmp = -Math.log(t_0) / n;
} else if (n <= 5.1e-141) {
tmp = -Math.log1p((t_0 + -1.0)) / n;
} else if (n <= 90000.0) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (n <= 4.5e+131) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if (n <= 2.1e+168) {
tmp = (1.0 / n) / x;
} else {
tmp = (Math.log1p(x) / n) - (Math.log(x) / n);
}
return tmp;
}
def code(x, n): t_0 = x / (x + 1.0) tmp = 0 if n <= -1.02: tmp = -math.log(t_0) / n elif n <= 5.1e-141: tmp = -math.log1p((t_0 + -1.0)) / n elif n <= 90000.0: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif n <= 4.5e+131: tmp = (math.log1p(x) - math.log(x)) / n elif n <= 2.1e+168: tmp = (1.0 / n) / x else: tmp = (math.log1p(x) / n) - (math.log(x) / n) return tmp
function code(x, n) t_0 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (n <= -1.02) tmp = Float64(Float64(-log(t_0)) / n); elseif (n <= 5.1e-141) tmp = Float64(Float64(-log1p(Float64(t_0 + -1.0))) / n); elseif (n <= 90000.0) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (n <= 4.5e+131) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (n <= 2.1e+168) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(Float64(log1p(x) / n) - Float64(log(x) / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.02], N[((-N[Log[t$95$0], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[n, 5.1e-141], N[((-N[Log[1 + N[(t$95$0 + -1.0), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[n, 90000.0], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.5e+131], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 2.1e+168], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;n \leq -1.02:\\
\;\;\;\;\frac{-\log t_0}{n}\\
\mathbf{elif}\;n \leq 5.1 \cdot 10^{-141}:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(t_0 + -1\right)}{n}\\
\mathbf{elif}\;n \leq 90000:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 4.5 \cdot 10^{+131}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;n \leq 2.1 \cdot 10^{+168}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right)}{n} - \frac{\log x}{n}\\
\end{array}
\end{array}
if n < -1.02Initial program 32.2%
Taylor expanded in n around inf 71.1%
+-rgt-identity71.1%
+-rgt-identity71.1%
log1p-def71.1%
Simplified71.1%
log1p-udef71.1%
+-commutative71.1%
diff-log71.2%
Applied egg-rr71.2%
clear-num71.2%
log-rec71.3%
Applied egg-rr71.3%
if -1.02 < n < 5.09999999999999977e-141Initial program 87.8%
Taylor expanded in n around inf 48.2%
+-rgt-identity48.2%
+-rgt-identity48.2%
log1p-def48.2%
Simplified48.2%
log1p-udef48.2%
+-commutative48.2%
diff-log48.2%
Applied egg-rr48.2%
clear-num48.2%
log-rec48.2%
Applied egg-rr48.2%
add-sqr-sqrt44.0%
sqrt-unprod44.3%
sqr-neg44.3%
sqrt-unprod44.3%
add-sqr-sqrt44.3%
neg-log44.3%
clear-num44.3%
diff-log44.3%
+-commutative44.3%
log1p-udef44.3%
add-sqr-sqrt44.3%
unpow244.3%
log1p-expm1-u44.3%
unpow244.3%
add-sqr-sqrt44.3%
Applied egg-rr95.4%
if 5.09999999999999977e-141 < n < 9e4Initial program 76.1%
Taylor expanded in x around 0 77.7%
if 9e4 < n < 4.5000000000000002e131Initial program 15.2%
Taylor expanded in n around inf 71.8%
+-rgt-identity71.8%
+-rgt-identity71.8%
log1p-def71.8%
Simplified71.8%
if 4.5000000000000002e131 < n < 2.10000000000000003e168Initial program 29.6%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-def45.4%
Simplified45.4%
log1p-udef45.4%
+-commutative45.4%
diff-log45.4%
Applied egg-rr45.4%
Taylor expanded in x around inf 84.0%
associate-/r*84.1%
Simplified84.1%
if 2.10000000000000003e168 < n Initial program 36.2%
Taylor expanded in n around inf 93.4%
+-rgt-identity93.4%
+-rgt-identity93.4%
log1p-def93.4%
Simplified93.4%
div-sub93.5%
Applied egg-rr93.5%
Final simplification84.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (- (log t_0)) n)))
(if (<= n -0.98)
t_1
(if (<= n 2.3e-139)
(/ (- (log1p (+ t_0 -1.0))) n)
(if (<= n 90000.0)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= n 4.5e+131)
(/ (- (log1p x) (log x)) n)
(if (<= n 2.1e+168) (/ (/ 1.0 n) x) t_1)))))))
double code(double x, double n) {
double t_0 = x / (x + 1.0);
double t_1 = -log(t_0) / n;
double tmp;
if (n <= -0.98) {
tmp = t_1;
} else if (n <= 2.3e-139) {
tmp = -log1p((t_0 + -1.0)) / n;
} else if (n <= 90000.0) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (n <= 4.5e+131) {
tmp = (log1p(x) - log(x)) / n;
} else if (n <= 2.1e+168) {
tmp = (1.0 / n) / x;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = x / (x + 1.0);
double t_1 = -Math.log(t_0) / n;
double tmp;
if (n <= -0.98) {
tmp = t_1;
} else if (n <= 2.3e-139) {
tmp = -Math.log1p((t_0 + -1.0)) / n;
} else if (n <= 90000.0) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (n <= 4.5e+131) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if (n <= 2.1e+168) {
tmp = (1.0 / n) / x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = x / (x + 1.0) t_1 = -math.log(t_0) / n tmp = 0 if n <= -0.98: tmp = t_1 elif n <= 2.3e-139: tmp = -math.log1p((t_0 + -1.0)) / n elif n <= 90000.0: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif n <= 4.5e+131: tmp = (math.log1p(x) - math.log(x)) / n elif n <= 2.1e+168: tmp = (1.0 / n) / x else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(-log(t_0)) / n) tmp = 0.0 if (n <= -0.98) tmp = t_1; elseif (n <= 2.3e-139) tmp = Float64(Float64(-log1p(Float64(t_0 + -1.0))) / n); elseif (n <= 90000.0) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (n <= 4.5e+131) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (n <= 2.1e+168) tmp = Float64(Float64(1.0 / n) / x); else tmp = t_1; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[t$95$0], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[n, -0.98], t$95$1, If[LessEqual[n, 2.3e-139], N[((-N[Log[1 + N[(t$95$0 + -1.0), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[n, 90000.0], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.5e+131], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 2.1e+168], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{-\log t_0}{n}\\
\mathbf{if}\;n \leq -0.98:\\
\;\;\;\;t_1\\
\mathbf{elif}\;n \leq 2.3 \cdot 10^{-139}:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(t_0 + -1\right)}{n}\\
\mathbf{elif}\;n \leq 90000:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 4.5 \cdot 10^{+131}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;n \leq 2.1 \cdot 10^{+168}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if n < -0.97999999999999998 or 2.10000000000000003e168 < n Initial program 33.7%
Taylor expanded in n around inf 79.5%
+-rgt-identity79.5%
+-rgt-identity79.5%
log1p-def79.5%
Simplified79.5%
log1p-udef79.5%
+-commutative79.5%
diff-log79.5%
Applied egg-rr79.5%
clear-num79.5%
log-rec79.6%
Applied egg-rr79.6%
if -0.97999999999999998 < n < 2.30000000000000012e-139Initial program 87.8%
Taylor expanded in n around inf 48.2%
+-rgt-identity48.2%
+-rgt-identity48.2%
log1p-def48.2%
Simplified48.2%
log1p-udef48.2%
+-commutative48.2%
diff-log48.2%
Applied egg-rr48.2%
clear-num48.2%
log-rec48.2%
Applied egg-rr48.2%
add-sqr-sqrt44.0%
sqrt-unprod44.3%
sqr-neg44.3%
sqrt-unprod44.3%
add-sqr-sqrt44.3%
neg-log44.3%
clear-num44.3%
diff-log44.3%
+-commutative44.3%
log1p-udef44.3%
add-sqr-sqrt44.3%
unpow244.3%
log1p-expm1-u44.3%
unpow244.3%
add-sqr-sqrt44.3%
Applied egg-rr95.4%
if 2.30000000000000012e-139 < n < 9e4Initial program 76.1%
Taylor expanded in x around 0 77.7%
if 9e4 < n < 4.5000000000000002e131Initial program 15.2%
Taylor expanded in n around inf 71.8%
+-rgt-identity71.8%
+-rgt-identity71.8%
log1p-def71.8%
Simplified71.8%
if 4.5000000000000002e131 < n < 2.10000000000000003e168Initial program 29.6%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-def45.4%
Simplified45.4%
log1p-udef45.4%
+-commutative45.4%
diff-log45.4%
Applied egg-rr45.4%
Taylor expanded in x around inf 84.0%
associate-/r*84.1%
Simplified84.1%
Final simplification84.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (- (log (/ x (+ x 1.0)))) n)))
(if (<= (/ 1.0 n) -2e+25)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) -1e-8)
(- 1.0 t_0)
(if (<= (/ 1.0 n) 4e-177)
t_1
(if (<= (/ 1.0 n) 4e-132)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 2e-5)
t_1
(if (<= (/ 1.0 n) 5e+218)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* x n))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = -log((x / (x + 1.0))) / n;
double tmp;
if ((1.0 / n) <= -2e+25) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= -1e-8) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= 4e-177) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+218) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = -log((x / (x + 1.0d0))) / n
if ((1.0d0 / n) <= (-2d+25)) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= (-1d-8)) then
tmp = 1.0d0 - t_0
else if ((1.0d0 / n) <= 4d-177) then
tmp = t_1
else if ((1.0d0 / n) <= 4d-132) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 2d-5) then
tmp = t_1
else if ((1.0d0 / n) <= 5d+218) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = -Math.log((x / (x + 1.0))) / n;
double tmp;
if ((1.0 / n) <= -2e+25) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= -1e-8) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= 4e-177) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+218) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = -math.log((x / (x + 1.0))) / n tmp = 0 if (1.0 / n) <= -2e+25: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= -1e-8: tmp = 1.0 - t_0 elif (1.0 / n) <= 4e-177: tmp = t_1 elif (1.0 / n) <= 4e-132: tmp = (1.0 / n) / x elif (1.0 / n) <= 2e-5: tmp = t_1 elif (1.0 / n) <= 5e+218: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (x * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e+25) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= -1e-8) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= 4e-177) tmp = t_1; elseif (Float64(1.0 / n) <= 4e-132) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 2e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+218) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = -log((x / (x + 1.0))) / n; tmp = 0.0; if ((1.0 / n) <= -2e+25) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= -1e-8) tmp = 1.0 - t_0; elseif ((1.0 / n) <= 4e-177) tmp = t_1; elseif ((1.0 / n) <= 4e-132) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 2e-5) tmp = t_1; elseif ((1.0 / n) <= 5e+218) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+25], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-177], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-132], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+218], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;1 - t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-177}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+218}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.00000000000000018e25Initial program 100.0%
Taylor expanded in n around inf 61.1%
+-rgt-identity61.1%
+-rgt-identity61.1%
log1p-def61.1%
Simplified61.1%
log1p-udef61.1%
+-commutative61.1%
diff-log61.1%
Applied egg-rr61.1%
if -2.00000000000000018e25 < (/.f64 1 n) < -1e-8Initial program 97.1%
Taylor expanded in x around 0 81.0%
if -1e-8 < (/.f64 1 n) < 3.99999999999999981e-177 or 3.9999999999999999e-132 < (/.f64 1 n) < 2.00000000000000016e-5Initial program 29.1%
Taylor expanded in n around inf 79.8%
+-rgt-identity79.8%
+-rgt-identity79.8%
log1p-def79.8%
Simplified79.8%
log1p-udef79.8%
+-commutative79.8%
diff-log79.8%
Applied egg-rr79.8%
clear-num79.8%
log-rec79.9%
Applied egg-rr79.9%
if 3.99999999999999981e-177 < (/.f64 1 n) < 3.9999999999999999e-132Initial program 29.6%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-def45.4%
Simplified45.4%
log1p-udef45.4%
+-commutative45.4%
diff-log45.4%
Applied egg-rr45.4%
Taylor expanded in x around inf 84.0%
associate-/r*84.1%
Simplified84.1%
if 2.00000000000000016e-5 < (/.f64 1 n) < 4.99999999999999983e218Initial program 64.4%
Taylor expanded in x around 0 65.9%
if 4.99999999999999983e218 < (/.f64 1 n) Initial program 20.5%
Taylor expanded in n around inf 6.4%
+-rgt-identity6.4%
+-rgt-identity6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 75.8%
*-commutative75.8%
Simplified75.8%
Final simplification74.1%
(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) -2e+25)
t_1
(if (<= (/ 1.0 n) -1e-8)
t_0
(if (<= (/ 1.0 n) 4e-177)
t_1
(if (<= (/ 1.0 n) 4e-132)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 5e-5)
t_1
(if (<= (/ 1.0 n) 5e+218) t_0 (/ 1.0 (* x 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) <= -2e+25) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-177) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 5e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+218) {
tmp = t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: 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) <= (-2d+25)) then
tmp = t_1
else if ((1.0d0 / n) <= (-1d-8)) then
tmp = t_0
else if ((1.0d0 / n) <= 4d-177) then
tmp = t_1
else if ((1.0d0 / n) <= 4d-132) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 5d-5) then
tmp = t_1
else if ((1.0d0 / n) <= 5d+218) then
tmp = t_0
else
tmp = 1.0d0 / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -2e+25) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-177) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 5e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+218) {
tmp = t_0;
} else {
tmp = 1.0 / (x * 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) <= -2e+25: tmp = t_1 elif (1.0 / n) <= -1e-8: tmp = t_0 elif (1.0 / n) <= 4e-177: tmp = t_1 elif (1.0 / n) <= 4e-132: tmp = (1.0 / n) / x elif (1.0 / n) <= 5e-5: tmp = t_1 elif (1.0 / n) <= 5e+218: tmp = t_0 else: tmp = 1.0 / (x * 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) <= -2e+25) tmp = t_1; elseif (Float64(1.0 / n) <= -1e-8) tmp = t_0; elseif (Float64(1.0 / n) <= 4e-177) tmp = t_1; elseif (Float64(1.0 / n) <= 4e-132) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 5e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+218) tmp = t_0; else tmp = Float64(1.0 / Float64(x * n)); 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) <= -2e+25) tmp = t_1; elseif ((1.0 / n) <= -1e-8) tmp = t_0; elseif ((1.0 / n) <= 4e-177) tmp = t_1; elseif ((1.0 / n) <= 4e-132) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 5e-5) tmp = t_1; elseif ((1.0 / n) <= 5e+218) tmp = t_0; else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, 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], -2e+25], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-177], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-132], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+218], t$95$0, N[(1.0 / N[(x * n), $MachinePrecision]), $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 -2 \cdot 10^{+25}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-177}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+218}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.00000000000000018e25 or -1e-8 < (/.f64 1 n) < 3.99999999999999981e-177 or 3.9999999999999999e-132 < (/.f64 1 n) < 5.00000000000000024e-5Initial program 51.1%
Taylor expanded in n around inf 73.6%
+-rgt-identity73.6%
+-rgt-identity73.6%
log1p-def73.6%
Simplified73.6%
log1p-udef73.6%
+-commutative73.6%
diff-log73.6%
Applied egg-rr73.6%
if -2.00000000000000018e25 < (/.f64 1 n) < -1e-8 or 5.00000000000000024e-5 < (/.f64 1 n) < 4.99999999999999983e218Initial program 77.8%
Taylor expanded in x around 0 72.1%
if 3.99999999999999981e-177 < (/.f64 1 n) < 3.9999999999999999e-132Initial program 29.6%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-def45.4%
Simplified45.4%
log1p-udef45.4%
+-commutative45.4%
diff-log45.4%
Applied egg-rr45.4%
Taylor expanded in x around inf 84.0%
associate-/r*84.1%
Simplified84.1%
if 4.99999999999999983e218 < (/.f64 1 n) Initial program 20.5%
Taylor expanded in n around inf 6.4%
+-rgt-identity6.4%
+-rgt-identity6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 75.8%
*-commutative75.8%
Simplified75.8%
Final simplification74.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (- (log (/ x (+ x 1.0)))) n)))
(if (<= (/ 1.0 n) -2e+25)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) -1e-8)
t_0
(if (<= (/ 1.0 n) 4e-177)
t_1
(if (<= (/ 1.0 n) 4e-132)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 5e-5)
t_1
(if (<= (/ 1.0 n) 5e+218) t_0 (/ 1.0 (* x n))))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = -log((x / (x + 1.0))) / n;
double tmp;
if ((1.0 / n) <= -2e+25) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-177) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 5e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+218) {
tmp = t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = -log((x / (x + 1.0d0))) / n
if ((1.0d0 / n) <= (-2d+25)) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= (-1d-8)) then
tmp = t_0
else if ((1.0d0 / n) <= 4d-177) then
tmp = t_1
else if ((1.0d0 / n) <= 4d-132) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 5d-5) then
tmp = t_1
else if ((1.0d0 / n) <= 5d+218) then
tmp = t_0
else
tmp = 1.0d0 / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = -Math.log((x / (x + 1.0))) / n;
double tmp;
if ((1.0 / n) <= -2e+25) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= -1e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-177) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-132) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 5e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+218) {
tmp = t_0;
} else {
tmp = 1.0 / (x * n);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = -math.log((x / (x + 1.0))) / n tmp = 0 if (1.0 / n) <= -2e+25: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= -1e-8: tmp = t_0 elif (1.0 / n) <= 4e-177: tmp = t_1 elif (1.0 / n) <= 4e-132: tmp = (1.0 / n) / x elif (1.0 / n) <= 5e-5: tmp = t_1 elif (1.0 / n) <= 5e+218: tmp = t_0 else: tmp = 1.0 / (x * n) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e+25) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= -1e-8) tmp = t_0; elseif (Float64(1.0 / n) <= 4e-177) tmp = t_1; elseif (Float64(1.0 / n) <= 4e-132) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 5e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+218) tmp = t_0; else tmp = Float64(1.0 / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = -log((x / (x + 1.0))) / n; tmp = 0.0; if ((1.0 / n) <= -2e+25) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= -1e-8) tmp = t_0; elseif ((1.0 / n) <= 4e-177) tmp = t_1; elseif ((1.0 / n) <= 4e-132) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 5e-5) tmp = t_1; elseif ((1.0 / n) <= 5e+218) tmp = t_0; else tmp = 1.0 / (x * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+25], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-8], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-177], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-132], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+218], t$95$0, N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-177}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+218}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.00000000000000018e25Initial program 100.0%
Taylor expanded in n around inf 61.1%
+-rgt-identity61.1%
+-rgt-identity61.1%
log1p-def61.1%
Simplified61.1%
log1p-udef61.1%
+-commutative61.1%
diff-log61.1%
Applied egg-rr61.1%
if -2.00000000000000018e25 < (/.f64 1 n) < -1e-8 or 5.00000000000000024e-5 < (/.f64 1 n) < 4.99999999999999983e218Initial program 77.8%
Taylor expanded in x around 0 72.1%
if -1e-8 < (/.f64 1 n) < 3.99999999999999981e-177 or 3.9999999999999999e-132 < (/.f64 1 n) < 5.00000000000000024e-5Initial program 28.9%
Taylor expanded in n around inf 79.2%
+-rgt-identity79.2%
+-rgt-identity79.2%
log1p-def79.2%
Simplified79.2%
log1p-udef79.2%
+-commutative79.2%
diff-log79.3%
Applied egg-rr79.3%
clear-num79.3%
log-rec79.3%
Applied egg-rr79.3%
if 3.99999999999999981e-177 < (/.f64 1 n) < 3.9999999999999999e-132Initial program 29.6%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-def45.4%
Simplified45.4%
log1p-udef45.4%
+-commutative45.4%
diff-log45.4%
Applied egg-rr45.4%
Taylor expanded in x around inf 84.0%
associate-/r*84.1%
Simplified84.1%
if 4.99999999999999983e218 < (/.f64 1 n) Initial program 20.5%
Taylor expanded in n around inf 6.4%
+-rgt-identity6.4%
+-rgt-identity6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 75.8%
*-commutative75.8%
Simplified75.8%
Final simplification74.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (- (log t_0)) n)))
(if (<= n -1.28)
t_1
(if (<= n 1.55e-140)
(/ (- (log1p (+ t_0 -1.0))) n)
(if (<= n 90000.0)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= n 3.9e+131)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= n 2.1e+168) (/ (/ 1.0 n) x) t_1)))))))
double code(double x, double n) {
double t_0 = x / (x + 1.0);
double t_1 = -log(t_0) / n;
double tmp;
if (n <= -1.28) {
tmp = t_1;
} else if (n <= 1.55e-140) {
tmp = -log1p((t_0 + -1.0)) / n;
} else if (n <= 90000.0) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (n <= 3.9e+131) {
tmp = log(((x + 1.0) / x)) / n;
} else if (n <= 2.1e+168) {
tmp = (1.0 / n) / x;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = x / (x + 1.0);
double t_1 = -Math.log(t_0) / n;
double tmp;
if (n <= -1.28) {
tmp = t_1;
} else if (n <= 1.55e-140) {
tmp = -Math.log1p((t_0 + -1.0)) / n;
} else if (n <= 90000.0) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (n <= 3.9e+131) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if (n <= 2.1e+168) {
tmp = (1.0 / n) / x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = x / (x + 1.0) t_1 = -math.log(t_0) / n tmp = 0 if n <= -1.28: tmp = t_1 elif n <= 1.55e-140: tmp = -math.log1p((t_0 + -1.0)) / n elif n <= 90000.0: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif n <= 3.9e+131: tmp = math.log(((x + 1.0) / x)) / n elif n <= 2.1e+168: tmp = (1.0 / n) / x else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(-log(t_0)) / n) tmp = 0.0 if (n <= -1.28) tmp = t_1; elseif (n <= 1.55e-140) tmp = Float64(Float64(-log1p(Float64(t_0 + -1.0))) / n); elseif (n <= 90000.0) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (n <= 3.9e+131) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (n <= 2.1e+168) tmp = Float64(Float64(1.0 / n) / x); else tmp = t_1; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[t$95$0], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[n, -1.28], t$95$1, If[LessEqual[n, 1.55e-140], N[((-N[Log[1 + N[(t$95$0 + -1.0), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[n, 90000.0], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.9e+131], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 2.1e+168], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{-\log t_0}{n}\\
\mathbf{if}\;n \leq -1.28:\\
\;\;\;\;t_1\\
\mathbf{elif}\;n \leq 1.55 \cdot 10^{-140}:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(t_0 + -1\right)}{n}\\
\mathbf{elif}\;n \leq 90000:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 3.9 \cdot 10^{+131}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;n \leq 2.1 \cdot 10^{+168}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if n < -1.28000000000000003 or 2.10000000000000003e168 < n Initial program 33.7%
Taylor expanded in n around inf 79.5%
+-rgt-identity79.5%
+-rgt-identity79.5%
log1p-def79.5%
Simplified79.5%
log1p-udef79.5%
+-commutative79.5%
diff-log79.5%
Applied egg-rr79.5%
clear-num79.5%
log-rec79.6%
Applied egg-rr79.6%
if -1.28000000000000003 < n < 1.55e-140Initial program 87.8%
Taylor expanded in n around inf 48.2%
+-rgt-identity48.2%
+-rgt-identity48.2%
log1p-def48.2%
Simplified48.2%
log1p-udef48.2%
+-commutative48.2%
diff-log48.2%
Applied egg-rr48.2%
clear-num48.2%
log-rec48.2%
Applied egg-rr48.2%
add-sqr-sqrt44.0%
sqrt-unprod44.3%
sqr-neg44.3%
sqrt-unprod44.3%
add-sqr-sqrt44.3%
neg-log44.3%
clear-num44.3%
diff-log44.3%
+-commutative44.3%
log1p-udef44.3%
add-sqr-sqrt44.3%
unpow244.3%
log1p-expm1-u44.3%
unpow244.3%
add-sqr-sqrt44.3%
Applied egg-rr95.4%
if 1.55e-140 < n < 9e4Initial program 76.1%
Taylor expanded in x around 0 77.7%
if 9e4 < n < 3.9e131Initial program 15.2%
Taylor expanded in n around inf 71.8%
+-rgt-identity71.8%
+-rgt-identity71.8%
log1p-def71.8%
Simplified71.8%
log1p-udef71.8%
+-commutative71.8%
diff-log71.8%
Applied egg-rr71.8%
if 3.9e131 < n < 2.10000000000000003e168Initial program 29.6%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-def45.4%
Simplified45.4%
log1p-udef45.4%
+-commutative45.4%
diff-log45.4%
Applied egg-rr45.4%
Taylor expanded in x around inf 84.0%
associate-/r*84.1%
Simplified84.1%
Final simplification84.2%
(FPCore (x n)
:precision binary64
(if (<= x 1.55e-268)
(/ (- (log x)) n)
(if (<= x 2.45e-200)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (<= x 4.7e+120)
(/ (/ 1.0 x) n)
(* 0.3333333333333333 (/ 0.0 n)))))))
double code(double x, double n) {
double tmp;
if (x <= 1.55e-268) {
tmp = -log(x) / n;
} else if (x <= 2.45e-200) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 4.7e+120) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.3333333333333333 * (0.0 / n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.55d-268) then
tmp = -log(x) / n
else if (x <= 2.45d-200) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 4.7d+120) then
tmp = (1.0d0 / x) / n
else
tmp = 0.3333333333333333d0 * (0.0d0 / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.55e-268) {
tmp = -Math.log(x) / n;
} else if (x <= 2.45e-200) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 4.7e+120) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.3333333333333333 * (0.0 / n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.55e-268: tmp = -math.log(x) / n elif x <= 2.45e-200: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 4.7e+120: tmp = (1.0 / x) / n else: tmp = 0.3333333333333333 * (0.0 / n) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.55e-268) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.45e-200) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 4.7e+120) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.3333333333333333 * Float64(0.0 / n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.55e-268) tmp = -log(x) / n; elseif (x <= 2.45e-200) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 4.7e+120) tmp = (1.0 / x) / n; else tmp = 0.3333333333333333 * (0.0 / n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.55e-268], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.45e-200], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 4.7e+120], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.3333333333333333 * N[(0.0 / n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55 \cdot 10^{-268}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.45 \cdot 10^{-200}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{+120}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{0}{n}\\
\end{array}
\end{array}
if x < 1.5499999999999999e-268Initial program 19.0%
Taylor expanded in n around inf 87.1%
+-rgt-identity87.1%
+-rgt-identity87.1%
log1p-def87.1%
Simplified87.1%
Taylor expanded in x around 0 87.1%
neg-mul-187.1%
Simplified87.1%
if 1.5499999999999999e-268 < x < 2.45e-200Initial program 60.4%
Taylor expanded in x around 0 60.4%
if 2.45e-200 < x < 1Initial program 37.7%
Taylor expanded in n around inf 57.6%
+-rgt-identity57.6%
+-rgt-identity57.6%
log1p-def57.6%
Simplified57.6%
log1p-udef57.6%
+-commutative57.6%
diff-log57.6%
Applied egg-rr57.6%
Taylor expanded in x around 0 57.3%
neg-mul-157.3%
unsub-neg57.3%
Simplified57.3%
if 1 < x < 4.69999999999999993e120Initial program 35.7%
Taylor expanded in n around inf 41.1%
+-rgt-identity41.1%
+-rgt-identity41.1%
log1p-def41.1%
Simplified41.1%
Taylor expanded in x around inf 62.5%
if 4.69999999999999993e120 < x Initial program 82.9%
flip3--47.4%
div-inv47.4%
add-exp-log47.4%
log-pow47.4%
+-commutative47.4%
log1p-udef47.4%
*-commutative47.4%
un-div-inv47.4%
pow-pow47.2%
Applied egg-rr47.3%
associate-*l/47.3%
metadata-eval47.3%
+-commutative47.3%
pow-sqr47.3%
sqr-neg47.3%
+-commutative47.3%
associate-+r+47.3%
Simplified47.3%
Taylor expanded in n around inf 82.9%
cancel-sign-sub-inv82.9%
log1p-def82.9%
log1p-def82.9%
distribute-rgt1-in82.9%
metadata-eval82.9%
metadata-eval82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in x around inf 82.9%
log-rec82.9%
log-rec82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
mul0-rgt82.9%
Simplified82.9%
Final simplification67.8%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- x (log x)) n) (if (<= x 3.55e+120) (/ (/ 1.0 x) n) (* 0.3333333333333333 (/ 0.0 n)))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 3.55e+120) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.3333333333333333 * (0.0 / n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 3.55d+120) then
tmp = (1.0d0 / x) / n
else
tmp = 0.3333333333333333d0 * (0.0d0 / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 3.55e+120) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.3333333333333333 * (0.0 / n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 3.55e+120: tmp = (1.0 / x) / n else: tmp = 0.3333333333333333 * (0.0 / n) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 3.55e+120) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.3333333333333333 * Float64(0.0 / n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 3.55e+120) tmp = (1.0 / x) / n; else tmp = 0.3333333333333333 * (0.0 / n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3.55e+120], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.3333333333333333 * N[(0.0 / n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3.55 \cdot 10^{+120}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{0}{n}\\
\end{array}
\end{array}
if x < 1Initial program 41.0%
Taylor expanded in n around inf 56.2%
+-rgt-identity56.2%
+-rgt-identity56.2%
log1p-def56.2%
Simplified56.2%
log1p-udef56.2%
+-commutative56.2%
diff-log56.2%
Applied egg-rr56.2%
Taylor expanded in x around 0 56.0%
neg-mul-156.0%
unsub-neg56.0%
Simplified56.0%
if 1 < x < 3.5500000000000001e120Initial program 35.7%
Taylor expanded in n around inf 41.1%
+-rgt-identity41.1%
+-rgt-identity41.1%
log1p-def41.1%
Simplified41.1%
Taylor expanded in x around inf 62.5%
if 3.5500000000000001e120 < x Initial program 82.9%
flip3--47.4%
div-inv47.4%
add-exp-log47.4%
log-pow47.4%
+-commutative47.4%
log1p-udef47.4%
*-commutative47.4%
un-div-inv47.4%
pow-pow47.2%
Applied egg-rr47.3%
associate-*l/47.3%
metadata-eval47.3%
+-commutative47.3%
pow-sqr47.3%
sqr-neg47.3%
+-commutative47.3%
associate-+r+47.3%
Simplified47.3%
Taylor expanded in n around inf 82.9%
cancel-sign-sub-inv82.9%
log1p-def82.9%
log1p-def82.9%
distribute-rgt1-in82.9%
metadata-eval82.9%
metadata-eval82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in x around inf 82.9%
log-rec82.9%
log-rec82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
mul0-rgt82.9%
Simplified82.9%
Final simplification65.0%
(FPCore (x n) :precision binary64 (if (<= x 0.55) (/ (- (log x)) n) (if (<= x 6.8e+120) (/ (/ 1.0 x) n) (* 0.3333333333333333 (/ 0.0 n)))))
double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -log(x) / n;
} else if (x <= 6.8e+120) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.3333333333333333 * (0.0 / n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.55d0) then
tmp = -log(x) / n
else if (x <= 6.8d+120) then
tmp = (1.0d0 / x) / n
else
tmp = 0.3333333333333333d0 * (0.0d0 / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -Math.log(x) / n;
} else if (x <= 6.8e+120) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.3333333333333333 * (0.0 / n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.55: tmp = -math.log(x) / n elif x <= 6.8e+120: tmp = (1.0 / x) / n else: tmp = 0.3333333333333333 * (0.0 / n) return tmp
function code(x, n) tmp = 0.0 if (x <= 0.55) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 6.8e+120) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.3333333333333333 * Float64(0.0 / n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.55) tmp = -log(x) / n; elseif (x <= 6.8e+120) tmp = (1.0 / x) / n; else tmp = 0.3333333333333333 * (0.0 / n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.55], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 6.8e+120], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.3333333333333333 * N[(0.0 / n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.55:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+120}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{0}{n}\\
\end{array}
\end{array}
if x < 0.55000000000000004Initial program 41.0%
Taylor expanded in n around inf 56.2%
+-rgt-identity56.2%
+-rgt-identity56.2%
log1p-def56.2%
Simplified56.2%
Taylor expanded in x around 0 55.6%
neg-mul-155.6%
Simplified55.6%
if 0.55000000000000004 < x < 6.79999999999999998e120Initial program 35.7%
Taylor expanded in n around inf 41.1%
+-rgt-identity41.1%
+-rgt-identity41.1%
log1p-def41.1%
Simplified41.1%
Taylor expanded in x around inf 62.5%
if 6.79999999999999998e120 < x Initial program 82.9%
flip3--47.4%
div-inv47.4%
add-exp-log47.4%
log-pow47.4%
+-commutative47.4%
log1p-udef47.4%
*-commutative47.4%
un-div-inv47.4%
pow-pow47.2%
Applied egg-rr47.3%
associate-*l/47.3%
metadata-eval47.3%
+-commutative47.3%
pow-sqr47.3%
sqr-neg47.3%
+-commutative47.3%
associate-+r+47.3%
Simplified47.3%
Taylor expanded in n around inf 82.9%
cancel-sign-sub-inv82.9%
log1p-def82.9%
log1p-def82.9%
distribute-rgt1-in82.9%
metadata-eval82.9%
metadata-eval82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in x around inf 82.9%
log-rec82.9%
log-rec82.9%
distribute-rgt-out82.9%
metadata-eval82.9%
mul0-rgt82.9%
Simplified82.9%
Final simplification64.7%
(FPCore (x n) :precision binary64 (if (or (<= n -6.4) (not (<= n -3.2e-265))) (/ 1.0 (* x n)) (* 0.3333333333333333 (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if ((n <= -6.4) || !(n <= -3.2e-265)) {
tmp = 1.0 / (x * n);
} else {
tmp = 0.3333333333333333 * (0.0 / n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-6.4d0)) .or. (.not. (n <= (-3.2d-265)))) then
tmp = 1.0d0 / (x * n)
else
tmp = 0.3333333333333333d0 * (0.0d0 / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -6.4) || !(n <= -3.2e-265)) {
tmp = 1.0 / (x * n);
} else {
tmp = 0.3333333333333333 * (0.0 / n);
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -6.4) or not (n <= -3.2e-265): tmp = 1.0 / (x * n) else: tmp = 0.3333333333333333 * (0.0 / n) return tmp
function code(x, n) tmp = 0.0 if ((n <= -6.4) || !(n <= -3.2e-265)) tmp = Float64(1.0 / Float64(x * n)); else tmp = Float64(0.3333333333333333 * Float64(0.0 / n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -6.4) || ~((n <= -3.2e-265))) tmp = 1.0 / (x * n); else tmp = 0.3333333333333333 * (0.0 / n); end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -6.4], N[Not[LessEqual[n, -3.2e-265]], $MachinePrecision]], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(0.0 / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.4 \lor \neg \left(n \leq -3.2 \cdot 10^{-265}\right):\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{0}{n}\\
\end{array}
\end{array}
if n < -6.4000000000000004 or -3.2e-265 < n Initial program 36.9%
Taylor expanded in n around inf 63.5%
+-rgt-identity63.5%
+-rgt-identity63.5%
log1p-def63.5%
Simplified63.5%
Taylor expanded in x around inf 45.4%
*-commutative45.4%
Simplified45.4%
if -6.4000000000000004 < n < -3.2e-265Initial program 100.0%
flip3--0.0%
div-inv0.0%
add-exp-log0.0%
log-pow0.0%
+-commutative0.0%
log1p-udef0.0%
*-commutative0.0%
un-div-inv0.0%
pow-pow0.0%
Applied egg-rr0.0%
associate-*l/0.0%
metadata-eval0.0%
+-commutative0.0%
pow-sqr0.0%
sqr-neg0.0%
+-commutative0.0%
associate-+r+0.0%
Simplified0.0%
Taylor expanded in n around inf 56.7%
cancel-sign-sub-inv56.7%
log1p-def56.7%
log1p-def56.7%
distribute-rgt1-in56.7%
metadata-eval56.7%
metadata-eval56.7%
*-commutative56.7%
Simplified56.7%
Taylor expanded in x around inf 56.9%
log-rec56.9%
log-rec56.9%
distribute-rgt-out56.9%
metadata-eval56.9%
mul0-rgt56.9%
Simplified56.9%
Final simplification48.3%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -40.0) (* 0.3333333333333333 (/ 0.0 n)) (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = 0.3333333333333333 * (0.0 / n);
} 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) :: tmp
if ((1.0d0 / n) <= (-40.0d0)) then
tmp = 0.3333333333333333d0 * (0.0d0 / n)
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = 0.3333333333333333 * (0.0 / n);
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -40.0: tmp = 0.3333333333333333 * (0.0 / n) else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -40.0) tmp = Float64(0.3333333333333333 * Float64(0.0 / n)); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -40.0) tmp = 0.3333333333333333 * (0.0 / n); else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -40.0], N[(0.3333333333333333 * N[(0.0 / n), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -40:\\
\;\;\;\;0.3333333333333333 \cdot \frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -40Initial program 100.0%
flip3--0.0%
div-inv0.0%
add-exp-log0.0%
log-pow0.0%
+-commutative0.0%
log1p-udef0.0%
*-commutative0.0%
un-div-inv0.0%
pow-pow0.0%
Applied egg-rr0.0%
associate-*l/0.0%
metadata-eval0.0%
+-commutative0.0%
pow-sqr0.0%
sqr-neg0.0%
+-commutative0.0%
associate-+r+0.0%
Simplified0.0%
Taylor expanded in n around inf 55.9%
cancel-sign-sub-inv55.9%
log1p-def55.9%
log1p-def55.9%
distribute-rgt1-in55.9%
metadata-eval55.9%
metadata-eval55.9%
*-commutative55.9%
Simplified55.9%
Taylor expanded in x around inf 54.2%
log-rec54.2%
log-rec54.2%
distribute-rgt-out54.2%
metadata-eval54.2%
mul0-rgt54.2%
Simplified54.2%
if -40 < (/.f64 1 n) Initial program 34.5%
Taylor expanded in n around inf 64.1%
+-rgt-identity64.1%
+-rgt-identity64.1%
log1p-def64.1%
Simplified64.1%
log1p-udef64.1%
+-commutative64.1%
diff-log64.1%
Applied egg-rr64.1%
Taylor expanded in x around inf 44.4%
associate-/r*45.4%
Simplified45.4%
Final simplification47.8%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -40.0) (* 0.3333333333333333 (/ 0.0 n)) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = 0.3333333333333333 * (0.0 / n);
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-40.0d0)) then
tmp = 0.3333333333333333d0 * (0.0d0 / n)
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = 0.3333333333333333 * (0.0 / n);
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -40.0: tmp = 0.3333333333333333 * (0.0 / n) else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -40.0) tmp = Float64(0.3333333333333333 * Float64(0.0 / n)); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -40.0) tmp = 0.3333333333333333 * (0.0 / n); else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -40.0], N[(0.3333333333333333 * N[(0.0 / n), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -40:\\
\;\;\;\;0.3333333333333333 \cdot \frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -40Initial program 100.0%
flip3--0.0%
div-inv0.0%
add-exp-log0.0%
log-pow0.0%
+-commutative0.0%
log1p-udef0.0%
*-commutative0.0%
un-div-inv0.0%
pow-pow0.0%
Applied egg-rr0.0%
associate-*l/0.0%
metadata-eval0.0%
+-commutative0.0%
pow-sqr0.0%
sqr-neg0.0%
+-commutative0.0%
associate-+r+0.0%
Simplified0.0%
Taylor expanded in n around inf 55.9%
cancel-sign-sub-inv55.9%
log1p-def55.9%
log1p-def55.9%
distribute-rgt1-in55.9%
metadata-eval55.9%
metadata-eval55.9%
*-commutative55.9%
Simplified55.9%
Taylor expanded in x around inf 54.2%
log-rec54.2%
log-rec54.2%
distribute-rgt-out54.2%
metadata-eval54.2%
mul0-rgt54.2%
Simplified54.2%
if -40 < (/.f64 1 n) Initial program 34.5%
Taylor expanded in n around inf 64.1%
+-rgt-identity64.1%
+-rgt-identity64.1%
log1p-def64.1%
Simplified64.1%
Taylor expanded in x around inf 45.4%
Final simplification47.9%
(FPCore (x n) :precision binary64 (* 0.3333333333333333 (/ 0.0 n)))
double code(double x, double n) {
return 0.3333333333333333 * (0.0 / n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.3333333333333333d0 * (0.0d0 / n)
end function
public static double code(double x, double n) {
return 0.3333333333333333 * (0.0 / n);
}
def code(x, n): return 0.3333333333333333 * (0.0 / n)
function code(x, n) return Float64(0.3333333333333333 * Float64(0.0 / n)) end
function tmp = code(x, n) tmp = 0.3333333333333333 * (0.0 / n); end
code[x_, n_] := N[(0.3333333333333333 * N[(0.0 / n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.3333333333333333 \cdot \frac{0}{n}
\end{array}
Initial program 52.6%
flip3--24.9%
div-inv24.9%
add-exp-log24.9%
log-pow24.9%
+-commutative24.9%
log1p-udef29.4%
*-commutative29.4%
un-div-inv29.4%
pow-pow29.5%
Applied egg-rr25.6%
associate-*l/25.6%
metadata-eval25.6%
+-commutative25.6%
pow-sqr25.6%
sqr-neg25.6%
+-commutative25.6%
associate-+r+25.6%
Simplified25.6%
Taylor expanded in n around inf 61.7%
cancel-sign-sub-inv61.7%
log1p-def61.7%
log1p-def61.7%
distribute-rgt1-in61.7%
metadata-eval61.7%
metadata-eval61.7%
*-commutative61.7%
Simplified61.7%
Taylor expanded in x around inf 32.3%
log-rec32.3%
log-rec32.3%
distribute-rgt-out32.3%
metadata-eval32.3%
mul0-rgt32.3%
Simplified32.3%
Final simplification32.3%
herbie shell --seed 2023298
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))