
(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))))
(if (<= (/ 1.0 n) -5e-42)
(/ (pow E (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 1e-43)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e-5)
(/ t_0 (* n x))
(log (exp (- (exp (/ (log1p x) n)) t_0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = pow(((double) M_E), (log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 1e-43) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else {
tmp = log(exp((exp((log1p(x) / n)) - t_0)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = Math.pow(Math.E, (Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 1e-43) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else {
tmp = Math.log(Math.exp((Math.exp((Math.log1p(x) / n)) - t_0)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = math.pow(math.e, (math.log(x) / n)) / (n * x) elif (1.0 / n) <= 1e-43: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e-5: tmp = t_0 / (n * x) else: tmp = math.log(math.exp((math.exp((math.log1p(x) / n)) - t_0))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64((exp(1) ^ Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 1e-43) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(t_0 / Float64(n * x)); else tmp = log(exp(Float64(exp(Float64(log1p(x) / n)) - t_0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[Power[E, N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-43], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[Log[N[Exp[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{{e}^{\left(\frac{\log x}{n}\right)}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-43}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0}\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 89.7%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
mul-1-neg97.3%
distribute-neg-frac97.3%
mul-1-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
*-un-lft-identity97.3%
exp-prod97.3%
Applied egg-rr97.3%
if -5.00000000000000003e-42 < (/.f64 1 n) < 1.00000000000000008e-43Initial program 33.1%
Taylor expanded in n around inf 86.7%
log1p-def86.7%
Simplified86.7%
log1p-udef86.7%
diff-log86.7%
+-commutative86.7%
Applied egg-rr86.7%
clear-num86.7%
log-rec86.7%
Applied egg-rr86.7%
if 1.00000000000000008e-43 < (/.f64 1 n) < 1.00000000000000008e-5Initial program 5.1%
Taylor expanded in x around inf 79.7%
mul-1-neg79.7%
log-rec79.7%
mul-1-neg79.7%
distribute-neg-frac79.7%
mul-1-neg79.7%
remove-double-neg79.7%
*-commutative79.7%
Simplified79.7%
Taylor expanded in x around 0 79.7%
*-rgt-identity79.7%
associate-*l/79.7%
associate-*r/79.7%
exp-to-pow79.7%
*-commutative79.7%
Simplified79.7%
if 1.00000000000000008e-5 < (/.f64 1 n) Initial program 60.4%
add-log-exp60.4%
add-exp-log60.4%
log-pow60.4%
+-commutative60.4%
log1p-udef100.0%
*-commutative100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Final simplification91.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-43)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e-5)
(/ t_0 (* n x))
(- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-43: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e-5: tmp = t_0 / (n * x) else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-43) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(t_0 / Float64(n * x)); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-43], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-43}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 89.7%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
mul-1-neg97.3%
distribute-neg-frac97.3%
mul-1-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
div-inv97.3%
pow-to-exp97.3%
*-un-lft-identity97.3%
times-frac97.3%
Applied egg-rr97.3%
if -5.00000000000000003e-42 < (/.f64 1 n) < 1.00000000000000008e-43Initial program 33.1%
Taylor expanded in n around inf 86.7%
log1p-def86.7%
Simplified86.7%
log1p-udef86.7%
diff-log86.7%
+-commutative86.7%
Applied egg-rr86.7%
clear-num86.7%
log-rec86.7%
Applied egg-rr86.7%
if 1.00000000000000008e-43 < (/.f64 1 n) < 1.00000000000000008e-5Initial program 5.1%
Taylor expanded in x around inf 79.7%
mul-1-neg79.7%
log-rec79.7%
mul-1-neg79.7%
distribute-neg-frac79.7%
mul-1-neg79.7%
remove-double-neg79.7%
*-commutative79.7%
Simplified79.7%
Taylor expanded in x around 0 79.7%
*-rgt-identity79.7%
associate-*l/79.7%
associate-*r/79.7%
exp-to-pow79.7%
*-commutative79.7%
Simplified79.7%
if 1.00000000000000008e-5 < (/.f64 1 n) Initial program 60.4%
Taylor expanded in n around 0 60.4%
log1p-def99.9%
Simplified99.9%
Final simplification91.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ (pow E (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 1e-43)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e-5)
(/ t_0 (* n x))
(- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = pow(((double) M_E), (log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 1e-43) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = Math.pow(Math.E, (Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 1e-43) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = math.pow(math.e, (math.log(x) / n)) / (n * x) elif (1.0 / n) <= 1e-43: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e-5: tmp = t_0 / (n * x) else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64((exp(1) ^ Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 1e-43) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(t_0 / Float64(n * x)); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[Power[E, N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-43], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{{e}^{\left(\frac{\log x}{n}\right)}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-43}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 89.7%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
mul-1-neg97.3%
distribute-neg-frac97.3%
mul-1-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
*-un-lft-identity97.3%
exp-prod97.3%
Applied egg-rr97.3%
if -5.00000000000000003e-42 < (/.f64 1 n) < 1.00000000000000008e-43Initial program 33.1%
Taylor expanded in n around inf 86.7%
log1p-def86.7%
Simplified86.7%
log1p-udef86.7%
diff-log86.7%
+-commutative86.7%
Applied egg-rr86.7%
clear-num86.7%
log-rec86.7%
Applied egg-rr86.7%
if 1.00000000000000008e-43 < (/.f64 1 n) < 1.00000000000000008e-5Initial program 5.1%
Taylor expanded in x around inf 79.7%
mul-1-neg79.7%
log-rec79.7%
mul-1-neg79.7%
distribute-neg-frac79.7%
mul-1-neg79.7%
remove-double-neg79.7%
*-commutative79.7%
Simplified79.7%
Taylor expanded in x around 0 79.7%
*-rgt-identity79.7%
associate-*l/79.7%
associate-*r/79.7%
exp-to-pow79.7%
*-commutative79.7%
Simplified79.7%
if 1.00000000000000008e-5 < (/.f64 1 n) Initial program 60.4%
Taylor expanded in n around 0 60.4%
log1p-def99.9%
Simplified99.9%
Final simplification91.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-43)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e-5)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 4e+166)
(- (pow (+ 1.0 x) (/ 1.0 n)) t_0)
(sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e+166) {
tmp = pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -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 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-42)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-43) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d-5) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 4d+166) then
tmp = ((1.0d0 + x) ** (1.0d0 / n)) - t_0
else
tmp = sqrt(((n * x) ** (-2.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e+166) {
tmp = Math.pow((1.0 + x), (1.0 / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-43: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e-5: tmp = t_0 / (n * x) elif (1.0 / n) <= 4e+166: tmp = math.pow((1.0 + x), (1.0 / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-43) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e+166) tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-43) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e-5) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 4e+166) tmp = ((1.0 + x) ^ (1.0 / n)) - t_0; else tmp = sqrt(((n * x) ^ -2.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-43], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+166], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-43}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+166}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 89.7%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
mul-1-neg97.3%
distribute-neg-frac97.3%
mul-1-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
div-inv97.3%
pow-to-exp97.3%
*-un-lft-identity97.3%
times-frac97.3%
Applied egg-rr97.3%
if -5.00000000000000003e-42 < (/.f64 1 n) < 1.00000000000000008e-43Initial program 33.1%
Taylor expanded in n around inf 86.7%
log1p-def86.7%
Simplified86.7%
log1p-udef86.7%
diff-log86.7%
+-commutative86.7%
Applied egg-rr86.7%
clear-num86.7%
log-rec86.7%
Applied egg-rr86.7%
if 1.00000000000000008e-43 < (/.f64 1 n) < 1.00000000000000008e-5Initial program 5.1%
Taylor expanded in x around inf 79.7%
mul-1-neg79.7%
log-rec79.7%
mul-1-neg79.7%
distribute-neg-frac79.7%
mul-1-neg79.7%
remove-double-neg79.7%
*-commutative79.7%
Simplified79.7%
Taylor expanded in x around 0 79.7%
*-rgt-identity79.7%
associate-*l/79.7%
associate-*r/79.7%
exp-to-pow79.7%
*-commutative79.7%
Simplified79.7%
if 1.00000000000000008e-5 < (/.f64 1 n) < 3.99999999999999976e166Initial program 91.7%
if 3.99999999999999976e166 < (/.f64 1 n) Initial program 30.8%
Taylor expanded in n around inf 5.9%
log1p-def5.9%
Simplified5.9%
Taylor expanded in x around inf 57.4%
*-commutative57.4%
Simplified57.4%
add-sqr-sqrt57.4%
sqrt-unprod67.7%
inv-pow67.7%
inv-pow67.7%
pow-prod-up67.7%
metadata-eval67.7%
Applied egg-rr67.7%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-43)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e-5)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 4e+166)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e+166) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -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 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-42)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-43) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d-5) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 4d+166) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = sqrt(((n * x) ** (-2.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e+166) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-43: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e-5: tmp = t_0 / (n * x) elif (1.0 / n) <= 4e+166: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-43) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e+166) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-43) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e-5) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 4e+166) tmp = (1.0 + (x / n)) - t_0; else tmp = sqrt(((n * x) ^ -2.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-43], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+166], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-43}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+166}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 89.7%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
mul-1-neg97.3%
distribute-neg-frac97.3%
mul-1-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
div-inv97.3%
pow-to-exp97.3%
*-un-lft-identity97.3%
times-frac97.3%
Applied egg-rr97.3%
if -5.00000000000000003e-42 < (/.f64 1 n) < 1.00000000000000008e-43Initial program 33.1%
Taylor expanded in n around inf 86.7%
log1p-def86.7%
Simplified86.7%
log1p-udef86.7%
diff-log86.7%
+-commutative86.7%
Applied egg-rr86.7%
clear-num86.7%
log-rec86.7%
Applied egg-rr86.7%
if 1.00000000000000008e-43 < (/.f64 1 n) < 1.00000000000000008e-5Initial program 5.1%
Taylor expanded in x around inf 79.7%
mul-1-neg79.7%
log-rec79.7%
mul-1-neg79.7%
distribute-neg-frac79.7%
mul-1-neg79.7%
remove-double-neg79.7%
*-commutative79.7%
Simplified79.7%
Taylor expanded in x around 0 79.7%
*-rgt-identity79.7%
associate-*l/79.7%
associate-*r/79.7%
exp-to-pow79.7%
*-commutative79.7%
Simplified79.7%
if 1.00000000000000008e-5 < (/.f64 1 n) < 3.99999999999999976e166Initial program 91.7%
Taylor expanded in x around 0 88.4%
if 3.99999999999999976e166 < (/.f64 1 n) Initial program 30.8%
Taylor expanded in n around inf 5.9%
log1p-def5.9%
Simplified5.9%
Taylor expanded in x around inf 57.4%
*-commutative57.4%
Simplified57.4%
add-sqr-sqrt57.4%
sqrt-unprod67.7%
inv-pow67.7%
inv-pow67.7%
pow-prod-up67.7%
metadata-eval67.7%
Applied egg-rr67.7%
Final simplification88.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-43)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e-5)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e+215)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+215) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-42)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-43) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d-5) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d+215) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+215) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-43: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e-5: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e+215: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-43) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e+215) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-43) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e-5) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e+215) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-43], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+215], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-43}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+215}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 89.7%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
mul-1-neg97.3%
distribute-neg-frac97.3%
mul-1-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
div-inv97.3%
pow-to-exp97.3%
*-un-lft-identity97.3%
times-frac97.3%
Applied egg-rr97.3%
if -5.00000000000000003e-42 < (/.f64 1 n) < 1.00000000000000008e-43Initial program 33.1%
Taylor expanded in n around inf 86.7%
log1p-def86.7%
Simplified86.7%
log1p-udef86.7%
diff-log86.7%
+-commutative86.7%
Applied egg-rr86.7%
clear-num86.7%
log-rec86.7%
Applied egg-rr86.7%
if 1.00000000000000008e-43 < (/.f64 1 n) < 1.00000000000000008e-5Initial program 5.1%
Taylor expanded in x around inf 79.7%
mul-1-neg79.7%
log-rec79.7%
mul-1-neg79.7%
distribute-neg-frac79.7%
mul-1-neg79.7%
remove-double-neg79.7%
*-commutative79.7%
Simplified79.7%
Taylor expanded in x around 0 79.7%
*-rgt-identity79.7%
associate-*l/79.7%
associate-*r/79.7%
exp-to-pow79.7%
*-commutative79.7%
Simplified79.7%
if 1.00000000000000008e-5 < (/.f64 1 n) < 1.99999999999999981e215Initial program 80.3%
Taylor expanded in x around 0 78.0%
if 1.99999999999999981e215 < (/.f64 1 n) Initial program 26.6%
Taylor expanded in n around inf 6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 70.2%
*-commutative70.2%
Simplified70.2%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -5e-42)
t_1
(if (<= (/ 1.0 n) 1e-43)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e-5)
t_1
(if (<= (/ 1.0 n) 2e+215) (- 1.0 t_0) (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-43) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+215) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-5d-42)) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-43) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d-5) then
tmp = t_1
else if ((1.0d0 / n) <= 2d+215) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-43) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+215) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -5e-42: tmp = t_1 elif (1.0 / n) <= 1e-43: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e-5: tmp = t_1 elif (1.0 / n) <= 2e+215: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-43) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+215) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = t_1; elseif ((1.0 / n) <= 1e-43) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e-5) tmp = t_1; elseif ((1.0 / n) <= 2e+215) tmp = 1.0 - t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-43], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+215], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-43}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+215}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42 or 1.00000000000000008e-43 < (/.f64 1 n) < 1.00000000000000008e-5Initial program 80.5%
Taylor expanded in x around inf 95.3%
mul-1-neg95.3%
log-rec95.3%
mul-1-neg95.3%
distribute-neg-frac95.3%
mul-1-neg95.3%
remove-double-neg95.3%
*-commutative95.3%
Simplified95.3%
Taylor expanded in x around 0 95.3%
*-rgt-identity95.3%
associate-*l/95.3%
associate-*r/95.3%
exp-to-pow95.4%
*-commutative95.4%
Simplified95.4%
if -5.00000000000000003e-42 < (/.f64 1 n) < 1.00000000000000008e-43Initial program 33.1%
Taylor expanded in n around inf 86.7%
log1p-def86.7%
Simplified86.7%
log1p-udef86.7%
diff-log86.7%
+-commutative86.7%
Applied egg-rr86.7%
clear-num86.7%
log-rec86.7%
Applied egg-rr86.7%
if 1.00000000000000008e-5 < (/.f64 1 n) < 1.99999999999999981e215Initial program 80.3%
Taylor expanded in x around 0 75.9%
if 1.99999999999999981e215 < (/.f64 1 n) Initial program 26.6%
Taylor expanded in n around inf 6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 70.2%
*-commutative70.2%
Simplified70.2%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-43)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e-5)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e+215) (- 1.0 t_0) (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+215) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-42)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-43) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d-5) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d+215) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-43) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e+215) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-43: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e-5: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e+215: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-43) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e+215) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-43) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e-5) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e+215) tmp = 1.0 - t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-43], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+215], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-43}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+215}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 89.7%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
mul-1-neg97.3%
distribute-neg-frac97.3%
mul-1-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
div-inv97.3%
pow-to-exp97.3%
*-un-lft-identity97.3%
times-frac97.3%
Applied egg-rr97.3%
if -5.00000000000000003e-42 < (/.f64 1 n) < 1.00000000000000008e-43Initial program 33.1%
Taylor expanded in n around inf 86.7%
log1p-def86.7%
Simplified86.7%
log1p-udef86.7%
diff-log86.7%
+-commutative86.7%
Applied egg-rr86.7%
clear-num86.7%
log-rec86.7%
Applied egg-rr86.7%
if 1.00000000000000008e-43 < (/.f64 1 n) < 1.00000000000000008e-5Initial program 5.1%
Taylor expanded in x around inf 79.7%
mul-1-neg79.7%
log-rec79.7%
mul-1-neg79.7%
distribute-neg-frac79.7%
mul-1-neg79.7%
remove-double-neg79.7%
*-commutative79.7%
Simplified79.7%
Taylor expanded in x around 0 79.7%
*-rgt-identity79.7%
associate-*l/79.7%
associate-*r/79.7%
exp-to-pow79.7%
*-commutative79.7%
Simplified79.7%
if 1.00000000000000008e-5 < (/.f64 1 n) < 1.99999999999999981e215Initial program 80.3%
Taylor expanded in x around 0 75.9%
if 1.99999999999999981e215 < (/.f64 1 n) Initial program 26.6%
Taylor expanded in n around inf 6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 70.2%
*-commutative70.2%
Simplified70.2%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 4.5e-264)
(* (log x) (/ 1.0 (- n)))
(if (<= x 3.6e-248)
t_0
(if (<= x 2.5e-234)
(/ (- (log x)) n)
(if (<= x 2.2e-213)
t_0
(if (<= x 2.55e-8)
(/ (- x (log x)) n)
(if (<= x 7.5e+94) (/ (/ 1.0 n) x) (/ 0.0 n)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 4.5e-264) {
tmp = log(x) * (1.0 / -n);
} else if (x <= 3.6e-248) {
tmp = t_0;
} else if (x <= 2.5e-234) {
tmp = -log(x) / n;
} else if (x <= 2.2e-213) {
tmp = t_0;
} else if (x <= 2.55e-8) {
tmp = (x - log(x)) / n;
} else if (x <= 7.5e+94) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 4.5d-264) then
tmp = log(x) * (1.0d0 / -n)
else if (x <= 3.6d-248) then
tmp = t_0
else if (x <= 2.5d-234) then
tmp = -log(x) / n
else if (x <= 2.2d-213) then
tmp = t_0
else if (x <= 2.55d-8) then
tmp = (x - log(x)) / n
else if (x <= 7.5d+94) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 4.5e-264) {
tmp = Math.log(x) * (1.0 / -n);
} else if (x <= 3.6e-248) {
tmp = t_0;
} else if (x <= 2.5e-234) {
tmp = -Math.log(x) / n;
} else if (x <= 2.2e-213) {
tmp = t_0;
} else if (x <= 2.55e-8) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 7.5e+94) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 4.5e-264: tmp = math.log(x) * (1.0 / -n) elif x <= 3.6e-248: tmp = t_0 elif x <= 2.5e-234: tmp = -math.log(x) / n elif x <= 2.2e-213: tmp = t_0 elif x <= 2.55e-8: tmp = (x - math.log(x)) / n elif x <= 7.5e+94: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 4.5e-264) tmp = Float64(log(x) * Float64(1.0 / Float64(-n))); elseif (x <= 3.6e-248) tmp = t_0; elseif (x <= 2.5e-234) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.2e-213) tmp = t_0; elseif (x <= 2.55e-8) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 7.5e+94) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 4.5e-264) tmp = log(x) * (1.0 / -n); elseif (x <= 3.6e-248) tmp = t_0; elseif (x <= 2.5e-234) tmp = -log(x) / n; elseif (x <= 2.2e-213) tmp = t_0; elseif (x <= 2.55e-8) tmp = (x - log(x)) / n; elseif (x <= 7.5e+94) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4.5e-264], N[(N[Log[x], $MachinePrecision] * N[(1.0 / (-n)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.6e-248], t$95$0, If[LessEqual[x, 2.5e-234], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.2e-213], t$95$0, If[LessEqual[x, 2.55e-8], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 7.5e+94], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 4.5 \cdot 10^{-264}:\\
\;\;\;\;\log x \cdot \frac{1}{-n}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-234}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-213}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-8}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 4.5000000000000001e-264Initial program 41.3%
Taylor expanded in n around inf 59.4%
log1p-def59.4%
Simplified59.4%
log1p-udef59.4%
diff-log59.4%
+-commutative59.4%
Applied egg-rr59.4%
frac-2neg59.4%
log-div59.4%
+-commutative59.4%
log1p-udef59.4%
div-inv59.5%
log1p-udef59.5%
+-commutative59.5%
log-div59.4%
neg-log59.4%
clear-num59.5%
Applied egg-rr59.5%
Taylor expanded in x around 0 59.5%
if 4.5000000000000001e-264 < x < 3.59999999999999985e-248 or 2.49999999999999989e-234 < x < 2.2000000000000001e-213Initial program 78.2%
Taylor expanded in x around 0 78.2%
if 3.59999999999999985e-248 < x < 2.49999999999999989e-234Initial program 17.3%
Taylor expanded in n around inf 75.9%
log1p-def75.9%
Simplified75.9%
Taylor expanded in x around 0 75.9%
neg-mul-175.9%
Simplified75.9%
if 2.2000000000000001e-213 < x < 2.55e-8Initial program 28.7%
Taylor expanded in n around inf 66.8%
log1p-def66.8%
Simplified66.8%
Taylor expanded in x around 0 66.8%
neg-mul-166.8%
unsub-neg66.8%
Simplified66.8%
if 2.55e-8 < x < 7.49999999999999978e94Initial program 43.3%
Taylor expanded in n around inf 33.9%
log1p-def33.9%
Simplified33.9%
log1p-udef33.9%
diff-log34.1%
+-commutative34.1%
Applied egg-rr34.1%
clear-num34.1%
log-rec34.1%
Applied egg-rr34.1%
Taylor expanded in x around inf 60.5%
associate-/r*60.6%
Simplified60.6%
if 7.49999999999999978e94 < x Initial program 84.8%
Taylor expanded in n around inf 84.8%
log1p-def84.8%
Simplified84.8%
log1p-udef84.8%
diff-log84.8%
+-commutative84.8%
Applied egg-rr84.8%
Taylor expanded in x around inf 84.8%
Final simplification71.8%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) 1e-5) (/ (log (/ (+ 1.0 x) x)) n) (if (<= (/ 1.0 n) 2e+215) (- 1.0 (pow x (/ 1.0 n))) (/ 1.0 (* n x)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 1e-5) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+215) {
tmp = 1.0 - pow(x, (1.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) <= 1d-5) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2d+215) then
tmp = 1.0d0 - (x ** (1.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) <= 1e-5) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+215) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 1e-5: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+215: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 1e-5) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+215) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= 1e-5) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2e+215) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+215], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+215}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < 1.00000000000000008e-5Initial program 50.9%
Taylor expanded in n around inf 73.3%
log1p-def73.3%
Simplified73.3%
log1p-udef73.3%
diff-log73.3%
+-commutative73.3%
Applied egg-rr73.3%
if 1.00000000000000008e-5 < (/.f64 1 n) < 1.99999999999999981e215Initial program 80.3%
Taylor expanded in x around 0 75.9%
if 1.99999999999999981e215 < (/.f64 1 n) Initial program 26.6%
Taylor expanded in n around inf 6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 70.2%
*-commutative70.2%
Simplified70.2%
Final simplification73.4%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) 1e-5) (/ (- (log (/ x (+ 1.0 x)))) n) (if (<= (/ 1.0 n) 2e+215) (- 1.0 (pow x (/ 1.0 n))) (/ 1.0 (* n x)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 1e-5) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 2e+215) {
tmp = 1.0 - pow(x, (1.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) <= 1d-5) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 2d+215) then
tmp = 1.0d0 - (x ** (1.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) <= 1e-5) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 2e+215) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 1e-5: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 2e+215: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 1e-5) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 2e+215) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= 1e-5) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 2e+215) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+215], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+215}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < 1.00000000000000008e-5Initial program 50.9%
Taylor expanded in n around inf 73.3%
log1p-def73.3%
Simplified73.3%
log1p-udef73.3%
diff-log73.3%
+-commutative73.3%
Applied egg-rr73.3%
clear-num73.3%
log-rec73.3%
Applied egg-rr73.3%
if 1.00000000000000008e-5 < (/.f64 1 n) < 1.99999999999999981e215Initial program 80.3%
Taylor expanded in x around 0 75.9%
if 1.99999999999999981e215 < (/.f64 1 n) Initial program 26.6%
Taylor expanded in n around inf 6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 70.2%
*-commutative70.2%
Simplified70.2%
Final simplification73.4%
(FPCore (x n) :precision binary64 (if (<= x 2.55e-8) (/ (- x (log x)) n) (if (<= x 5.9e+97) (/ (/ 1.0 n) x) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 2.55e-8) {
tmp = (x - log(x)) / n;
} else if (x <= 5.9e+97) {
tmp = (1.0 / n) / x;
} else {
tmp = 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 <= 2.55d-8) then
tmp = (x - log(x)) / n
else if (x <= 5.9d+97) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.55e-8) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 5.9e+97) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.55e-8: tmp = (x - math.log(x)) / n elif x <= 5.9e+97: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 2.55e-8) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 5.9e+97) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.55e-8) tmp = (x - log(x)) / n; elseif (x <= 5.9e+97) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.55e-8], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 5.9e+97], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.55 \cdot 10^{-8}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{+97}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.55e-8Initial program 36.3%
Taylor expanded in n around inf 60.2%
log1p-def60.2%
Simplified60.2%
Taylor expanded in x around 0 60.2%
neg-mul-160.2%
unsub-neg60.2%
Simplified60.2%
if 2.55e-8 < x < 5.90000000000000009e97Initial program 43.3%
Taylor expanded in n around inf 33.9%
log1p-def33.9%
Simplified33.9%
log1p-udef33.9%
diff-log34.1%
+-commutative34.1%
Applied egg-rr34.1%
clear-num34.1%
log-rec34.1%
Applied egg-rr34.1%
Taylor expanded in x around inf 60.5%
associate-/r*60.6%
Simplified60.6%
if 5.90000000000000009e97 < x Initial program 84.8%
Taylor expanded in n around inf 84.8%
log1p-def84.8%
Simplified84.8%
log1p-udef84.8%
diff-log84.8%
+-commutative84.8%
Applied egg-rr84.8%
Taylor expanded in x around inf 84.8%
Final simplification67.8%
(FPCore (x n) :precision binary64 (if (<= x 2.55e-8) (/ (- (log x)) n) (if (<= x 5.9e+97) (/ (/ 1.0 n) x) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 2.55e-8) {
tmp = -log(x) / n;
} else if (x <= 5.9e+97) {
tmp = (1.0 / n) / x;
} else {
tmp = 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 <= 2.55d-8) then
tmp = -log(x) / n
else if (x <= 5.9d+97) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.55e-8) {
tmp = -Math.log(x) / n;
} else if (x <= 5.9e+97) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.55e-8: tmp = -math.log(x) / n elif x <= 5.9e+97: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 2.55e-8) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 5.9e+97) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.55e-8) tmp = -log(x) / n; elseif (x <= 5.9e+97) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.55e-8], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 5.9e+97], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.55 \cdot 10^{-8}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{+97}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.55e-8Initial program 36.3%
Taylor expanded in n around inf 60.2%
log1p-def60.2%
Simplified60.2%
Taylor expanded in x around 0 60.0%
neg-mul-160.0%
Simplified60.0%
if 2.55e-8 < x < 5.90000000000000009e97Initial program 43.3%
Taylor expanded in n around inf 33.9%
log1p-def33.9%
Simplified33.9%
log1p-udef33.9%
diff-log34.1%
+-commutative34.1%
Applied egg-rr34.1%
clear-num34.1%
log-rec34.1%
Applied egg-rr34.1%
Taylor expanded in x around inf 60.5%
associate-/r*60.6%
Simplified60.6%
if 5.90000000000000009e97 < x Initial program 84.8%
Taylor expanded in n around inf 84.8%
log1p-def84.8%
Simplified84.8%
log1p-udef84.8%
diff-log84.8%
+-commutative84.8%
Applied egg-rr84.8%
Taylor expanded in x around inf 84.8%
Final simplification67.7%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -2.0) (/ 0.0 n) (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2.0) {
tmp = 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) <= (-2.0d0)) then
tmp = 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) <= -2.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2.0: tmp = 0.0 / n else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2.0) tmp = 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) <= -2.0) tmp = 0.0 / n; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2.0], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2Initial program 98.6%
Taylor expanded in n around inf 58.3%
log1p-def58.3%
Simplified58.3%
log1p-udef58.3%
diff-log58.3%
+-commutative58.3%
Applied egg-rr58.3%
Taylor expanded in x around inf 58.3%
if -2 < (/.f64 1 n) Initial program 36.1%
Taylor expanded in n around inf 66.2%
log1p-def66.2%
Simplified66.2%
log1p-udef66.2%
diff-log66.3%
+-commutative66.3%
Applied egg-rr66.3%
clear-num66.3%
log-rec66.3%
Applied egg-rr66.3%
Taylor expanded in x around inf 44.3%
associate-/r*44.3%
Simplified44.3%
Final simplification47.9%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 52.2%
Taylor expanded in n around inf 64.2%
log1p-def64.2%
Simplified64.2%
Taylor expanded in x around inf 37.8%
*-commutative37.8%
Simplified37.8%
Final simplification37.8%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 52.2%
Taylor expanded in n around inf 64.2%
log1p-def64.2%
Simplified64.2%
log1p-udef64.2%
diff-log64.2%
+-commutative64.2%
Applied egg-rr64.2%
clear-num64.2%
log-rec64.2%
Applied egg-rr64.2%
Taylor expanded in x around inf 37.8%
associate-/r*37.8%
Simplified37.8%
Final simplification37.8%
(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 52.2%
Taylor expanded in x around 0 28.1%
Taylor expanded in x around inf 4.5%
Final simplification4.5%
herbie shell --seed 2024031
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))