
(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 18 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
(if (<= x 15.6)
(/
(log
(/
x
(exp
(+
(log1p x)
(/
(fma
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
0.5
(/
(* 0.16666666666666666 (- (pow (log1p x) 3.0) (pow (log x) 3.0)))
n))
n)))))
(- n))
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 15.6) {
tmp = log((x / exp((log1p(x) + (fma((pow(log1p(x), 2.0) - pow(log(x), 2.0)), 0.5, ((0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0))) / n)) / n))))) / -n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 15.6) tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), 0.5, Float64(Float64(0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / n)) / n))))) / Float64(-n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 15.6], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(0.16666666666666666 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 15.6:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n}\right)}{n}}}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 15.5999999999999996Initial program 41.5%
Taylor expanded in n around -inf 79.9%
Simplified79.9%
add-log-exp86.8%
diff-log86.8%
Applied egg-rr86.8%
if 15.5999999999999996 < x Initial program 71.7%
Taylor expanded in x around inf 97.4%
associate-/r*98.7%
mul-1-neg98.7%
log-rec98.7%
mul-1-neg98.7%
distribute-neg-frac98.7%
mul-1-neg98.7%
remove-double-neg98.7%
*-rgt-identity98.7%
associate-/l*98.7%
exp-to-pow98.7%
Simplified98.7%
Final simplification91.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -1.115e-74)
t_1
(if (<= (/ 1.0 n) 1e-45)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 50000.0) t_1 (- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1.115e-74) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-45) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 50000.0) {
tmp = t_1;
} 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 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1.115e-74) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-45) {
tmp = Math.log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 50000.0) {
tmp = t_1;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -1.115e-74: tmp = t_1 elif (1.0 / n) <= 1e-45: tmp = math.log((x / (x + 1.0))) / -n elif (1.0 / n) <= 50000.0: tmp = t_1 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(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1.115e-74) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-45) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 50000.0) tmp = t_1; 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[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.115e-74], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-45], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50000.0], t$95$1, 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 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1.115 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-45}:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.115e-74 or 9.99999999999999984e-46 < (/.f64 #s(literal 1 binary64) n) < 5e4Initial program 77.7%
Taylor expanded in x around inf 89.5%
associate-/r*90.3%
mul-1-neg90.3%
log-rec90.3%
mul-1-neg90.3%
distribute-neg-frac90.3%
mul-1-neg90.3%
remove-double-neg90.3%
*-rgt-identity90.3%
associate-/l*90.3%
exp-to-pow90.3%
Simplified90.3%
if -1.115e-74 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999984e-46Initial program 38.5%
Taylor expanded in n around inf 88.8%
log1p-define88.8%
Simplified88.8%
log1p-undefine88.8%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
if 5e4 < (/.f64 #s(literal 1 binary64) n) Initial program 57.3%
Taylor expanded in n around 0 57.3%
log1p-define100.0%
*-rgt-identity100.0%
associate-*l/100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification90.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -1.115e-74)
t_1
(if (<= (/ 1.0 n) 1e-45)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 50000.0)
t_1
(-
(+ 1.0 (* x (+ (/ 1.0 n) (/ (+ (* x -0.5) (* 0.5 (/ x n))) n))))
t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1.115e-74) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-45) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 50000.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (((x * -0.5) + (0.5 * (x / n))) / n)))) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-1.115d-74)) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-45) then
tmp = log((x / (x + 1.0d0))) / -n
else if ((1.0d0 / n) <= 50000.0d0) then
tmp = t_1
else
tmp = (1.0d0 + (x * ((1.0d0 / n) + (((x * (-0.5d0)) + (0.5d0 * (x / n))) / n)))) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1.115e-74) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-45) {
tmp = Math.log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 50000.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (((x * -0.5) + (0.5 * (x / n))) / n)))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -1.115e-74: tmp = t_1 elif (1.0 / n) <= 1e-45: tmp = math.log((x / (x + 1.0))) / -n elif (1.0 / n) <= 50000.0: tmp = t_1 else: tmp = (1.0 + (x * ((1.0 / n) + (((x * -0.5) + (0.5 * (x / n))) / n)))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1.115e-74) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-45) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 50000.0) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(Float64(Float64(x * -0.5) + Float64(0.5 * Float64(x / n))) / n)))) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (t_0 / n) / x; tmp = 0.0; if ((1.0 / n) <= -1.115e-74) tmp = t_1; elseif ((1.0 / n) <= 1e-45) tmp = log((x / (x + 1.0))) / -n; elseif ((1.0 / n) <= 50000.0) tmp = t_1; else tmp = (1.0 + (x * ((1.0 / n) + (((x * -0.5) + (0.5 * (x / n))) / n)))) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.115e-74], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-45], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50000.0], t$95$1, N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(x * -0.5), $MachinePrecision] + N[(0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1.115 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-45}:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + \frac{x \cdot -0.5 + 0.5 \cdot \frac{x}{n}}{n}\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.115e-74 or 9.99999999999999984e-46 < (/.f64 #s(literal 1 binary64) n) < 5e4Initial program 77.7%
Taylor expanded in x around inf 89.5%
associate-/r*90.3%
mul-1-neg90.3%
log-rec90.3%
mul-1-neg90.3%
distribute-neg-frac90.3%
mul-1-neg90.3%
remove-double-neg90.3%
*-rgt-identity90.3%
associate-/l*90.3%
exp-to-pow90.3%
Simplified90.3%
if -1.115e-74 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999984e-46Initial program 38.5%
Taylor expanded in n around inf 88.8%
log1p-define88.8%
Simplified88.8%
log1p-undefine88.8%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
if 5e4 < (/.f64 #s(literal 1 binary64) n) Initial program 57.3%
Taylor expanded in x around 0 85.5%
Taylor expanded in n around inf 85.6%
Final simplification89.0%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e+47)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= (/ 1.0 n) -1e-40)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) -1.115e-74)
(/ 1.0 (* x n))
(if (<= (/ 1.0 n) 0.002)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 4e+150)
(+ 1.0 (pow x (/ 1.0 n)))
(/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) (* x n))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e+47) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if ((1.0 / n) <= -1e-40) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= -1.115e-74) {
tmp = 1.0 / (x * n);
} else if ((1.0 / n) <= 0.002) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 4e+150) {
tmp = 1.0 + pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-5d+47)) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if ((1.0d0 / n) <= (-1d-40)) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= (-1.115d-74)) then
tmp = 1.0d0 / (x * n)
else if ((1.0d0 / n) <= 0.002d0) then
tmp = log((x / (x + 1.0d0))) / -n
else if ((1.0d0 / n) <= 4d+150) then
tmp = 1.0d0 + (x ** (1.0d0 / n))
else
tmp = (1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / (x * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e+47) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if ((1.0 / n) <= -1e-40) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= -1.115e-74) {
tmp = 1.0 / (x * n);
} else if ((1.0 / n) <= 0.002) {
tmp = Math.log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 4e+150) {
tmp = 1.0 + Math.pow(x, (1.0 / n));
} else {
tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5e+47: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif (1.0 / n) <= -1e-40: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= -1.115e-74: tmp = 1.0 / (x * n) elif (1.0 / n) <= 0.002: tmp = math.log((x / (x + 1.0))) / -n elif (1.0 / n) <= 4e+150: tmp = 1.0 + math.pow(x, (1.0 / n)) else: tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+47) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (Float64(1.0 / n) <= -1e-40) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= -1.115e-74) tmp = Float64(1.0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 0.002) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e+150) tmp = Float64(1.0 + (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / Float64(x * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -5e+47) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif ((1.0 / n) <= -1e-40) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= -1.115e-74) tmp = 1.0 / (x * n); elseif ((1.0 / n) <= 0.002) tmp = log((x / (x + 1.0))) / -n; elseif ((1.0 / n) <= 4e+150) tmp = 1.0 + (x ^ (1.0 / n)); else tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+47], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-40], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.115e-74], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.002], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+150], N[(1.0 + N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+47}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-40}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1.115 \cdot 10^{-74}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.002:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+150}:\\
\;\;\;\;1 + {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000022e47Initial program 100.0%
Taylor expanded in n around inf 38.5%
log1p-define38.5%
Simplified38.5%
Taylor expanded in x around -inf 48.6%
Taylor expanded in x around 0 77.2%
*-commutative77.2%
Simplified77.2%
if -5.00000000000000022e47 < (/.f64 #s(literal 1 binary64) n) < -9.9999999999999993e-41Initial program 69.9%
Taylor expanded in n around inf 80.8%
log1p-define80.8%
Simplified80.8%
log1p-undefine80.8%
diff-log80.8%
Applied egg-rr80.8%
+-commutative80.8%
Simplified80.8%
if -9.9999999999999993e-41 < (/.f64 #s(literal 1 binary64) n) < -1.115e-74Initial program 6.9%
Taylor expanded in n around inf 18.9%
log1p-define18.9%
Simplified18.9%
Taylor expanded in x around inf 87.9%
if -1.115e-74 < (/.f64 #s(literal 1 binary64) n) < 2e-3Initial program 38.3%
Taylor expanded in n around inf 85.7%
log1p-define85.7%
Simplified85.7%
log1p-undefine85.7%
diff-log85.8%
Applied egg-rr85.8%
+-commutative85.8%
Simplified85.8%
clear-num85.8%
log-div85.8%
metadata-eval85.8%
Applied egg-rr85.8%
neg-sub085.8%
Simplified85.8%
if 2e-3 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999992e150Initial program 81.9%
Taylor expanded in x around 0 77.5%
*-rgt-identity77.5%
associate-*l/77.5%
associate-/l*77.5%
exp-to-pow77.5%
Simplified77.5%
add-exp-log77.5%
sub-neg77.5%
log1p-define77.5%
Applied egg-rr77.5%
log1p-undefine77.5%
rem-exp-log77.5%
add-sqr-sqrt72.9%
sqrt-unprod91.1%
sqr-neg91.1%
sqrt-unprod91.1%
add-sqr-sqrt91.1%
Applied egg-rr91.1%
if 3.99999999999999992e150 < (/.f64 #s(literal 1 binary64) n) Initial program 12.7%
Taylor expanded in n around inf 7.2%
log1p-define7.2%
Simplified7.2%
Taylor expanded in x around -inf 87.1%
Taylor expanded in n around 0 87.1%
Simplified87.1%
Final simplification84.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (pow x (/ 1.0 n))) (t_2 (/ (/ t_1 n) x)))
(if (<= (/ 1.0 n) -1.115e-74)
t_2
(if (<= (/ 1.0 n) 1e-45)
(/ (log t_0) (- n))
(if (<= (/ 1.0 n) 0.002)
t_2
(if (<= (/ 1.0 n) 5e+112)
(+ 1.0 t_1)
(/ (log1p (+ t_0 -1.0)) (- n))))))))
double code(double x, double n) {
double t_0 = x / (x + 1.0);
double t_1 = pow(x, (1.0 / n));
double t_2 = (t_1 / n) / x;
double tmp;
if ((1.0 / n) <= -1.115e-74) {
tmp = t_2;
} else if ((1.0 / n) <= 1e-45) {
tmp = log(t_0) / -n;
} else if ((1.0 / n) <= 0.002) {
tmp = t_2;
} else if ((1.0 / n) <= 5e+112) {
tmp = 1.0 + t_1;
} else {
tmp = log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = x / (x + 1.0);
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = (t_1 / n) / x;
double tmp;
if ((1.0 / n) <= -1.115e-74) {
tmp = t_2;
} else if ((1.0 / n) <= 1e-45) {
tmp = Math.log(t_0) / -n;
} else if ((1.0 / n) <= 0.002) {
tmp = t_2;
} else if ((1.0 / n) <= 5e+112) {
tmp = 1.0 + t_1;
} else {
tmp = Math.log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = x / (x + 1.0) t_1 = math.pow(x, (1.0 / n)) t_2 = (t_1 / n) / x tmp = 0 if (1.0 / n) <= -1.115e-74: tmp = t_2 elif (1.0 / n) <= 1e-45: tmp = math.log(t_0) / -n elif (1.0 / n) <= 0.002: tmp = t_2 elif (1.0 / n) <= 5e+112: tmp = 1.0 + t_1 else: tmp = math.log1p((t_0 + -1.0)) / -n return tmp
function code(x, n) t_0 = Float64(x / Float64(x + 1.0)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(Float64(t_1 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1.115e-74) tmp = t_2; elseif (Float64(1.0 / n) <= 1e-45) tmp = Float64(log(t_0) / Float64(-n)); elseif (Float64(1.0 / n) <= 0.002) tmp = t_2; elseif (Float64(1.0 / n) <= 5e+112) tmp = Float64(1.0 + t_1); else tmp = Float64(log1p(Float64(t_0 + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.115e-74], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-45], N[(N[Log[t$95$0], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.002], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+112], N[(1.0 + t$95$1), $MachinePrecision], N[(N[Log[1 + N[(t$95$0 + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{\frac{t\_1}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1.115 \cdot 10^{-74}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-45}:\\
\;\;\;\;\frac{\log t\_0}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.002:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+112}:\\
\;\;\;\;1 + t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(t\_0 + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.115e-74 or 9.99999999999999984e-46 < (/.f64 #s(literal 1 binary64) n) < 2e-3Initial program 80.2%
Taylor expanded in x around inf 90.1%
associate-/r*91.0%
mul-1-neg91.0%
log-rec91.0%
mul-1-neg91.0%
distribute-neg-frac91.0%
mul-1-neg91.0%
remove-double-neg91.0%
*-rgt-identity91.0%
associate-/l*91.0%
exp-to-pow91.0%
Simplified91.0%
if -1.115e-74 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999984e-46Initial program 38.5%
Taylor expanded in n around inf 88.8%
log1p-define88.8%
Simplified88.8%
log1p-undefine88.8%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
if 2e-3 < (/.f64 #s(literal 1 binary64) n) < 5e112Initial program 84.9%
Taylor expanded in x around 0 80.1%
*-rgt-identity80.1%
associate-*l/80.1%
associate-/l*80.1%
exp-to-pow80.1%
Simplified80.1%
add-exp-log80.1%
sub-neg80.1%
log1p-define80.1%
Applied egg-rr80.1%
log1p-undefine80.1%
rem-exp-log80.1%
add-sqr-sqrt75.1%
sqrt-unprod95.1%
sqr-neg95.1%
sqrt-unprod95.1%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
if 5e112 < (/.f64 #s(literal 1 binary64) n) Initial program 17.3%
Taylor expanded in n around inf 6.9%
log1p-define6.9%
Simplified6.9%
log1p-undefine6.9%
diff-log6.9%
Applied egg-rr6.9%
+-commutative6.9%
Simplified6.9%
clear-num6.9%
log-div6.9%
metadata-eval6.9%
Applied egg-rr6.9%
neg-sub06.9%
Simplified6.9%
log1p-expm1-u82.9%
expm1-undefine82.9%
add-exp-log82.9%
Applied egg-rr82.9%
Final simplification89.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -1.115e-74)
t_1
(if (<= (/ 1.0 n) 1e-45)
(/ (log (/ x (+ x 1.0))) (- n))
(if (<= (/ 1.0 n) 0.002)
t_1
(if (<= (/ 1.0 n) 4e+150)
(+ 1.0 t_0)
(/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) (* x n))))))))
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) <= -1.115e-74) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-45) {
tmp = log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 0.002) {
tmp = t_1;
} else if ((1.0 / n) <= 4e+150) {
tmp = 1.0 + t_0;
} else {
tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-1.115d-74)) then
tmp = t_1
else if ((1.0d0 / n) <= 1d-45) then
tmp = log((x / (x + 1.0d0))) / -n
else if ((1.0d0 / n) <= 0.002d0) then
tmp = t_1
else if ((1.0d0 / n) <= 4d+150) then
tmp = 1.0d0 + t_0
else
tmp = (1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / (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 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -1.115e-74) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-45) {
tmp = Math.log((x / (x + 1.0))) / -n;
} else if ((1.0 / n) <= 0.002) {
tmp = t_1;
} else if ((1.0 / n) <= 4e+150) {
tmp = 1.0 + t_0;
} else {
tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n);
}
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) <= -1.115e-74: tmp = t_1 elif (1.0 / n) <= 1e-45: tmp = math.log((x / (x + 1.0))) / -n elif (1.0 / n) <= 0.002: tmp = t_1 elif (1.0 / n) <= 4e+150: tmp = 1.0 + t_0 else: tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -1.115e-74) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-45) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); elseif (Float64(1.0 / n) <= 0.002) tmp = t_1; elseif (Float64(1.0 / n) <= 4e+150) tmp = Float64(1.0 + t_0); else tmp = Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / Float64(x * n)); 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) <= -1.115e-74) tmp = t_1; elseif ((1.0 / n) <= 1e-45) tmp = log((x / (x + 1.0))) / -n; elseif ((1.0 / n) <= 0.002) tmp = t_1; elseif ((1.0 / n) <= 4e+150) tmp = 1.0 + t_0; else tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (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[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1.115e-74], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-45], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.002], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+150], N[(1.0 + t$95$0), $MachinePrecision], N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -1.115 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-45}:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+150}:\\
\;\;\;\;1 + t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.115e-74 or 9.99999999999999984e-46 < (/.f64 #s(literal 1 binary64) n) < 2e-3Initial program 80.2%
Taylor expanded in x around inf 90.1%
associate-/r*91.0%
mul-1-neg91.0%
log-rec91.0%
mul-1-neg91.0%
distribute-neg-frac91.0%
mul-1-neg91.0%
remove-double-neg91.0%
*-rgt-identity91.0%
associate-/l*91.0%
exp-to-pow91.0%
Simplified91.0%
if -1.115e-74 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999984e-46Initial program 38.5%
Taylor expanded in n around inf 88.8%
log1p-define88.8%
Simplified88.8%
log1p-undefine88.8%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
if 2e-3 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999992e150Initial program 81.9%
Taylor expanded in x around 0 77.5%
*-rgt-identity77.5%
associate-*l/77.5%
associate-/l*77.5%
exp-to-pow77.5%
Simplified77.5%
add-exp-log77.5%
sub-neg77.5%
log1p-define77.5%
Applied egg-rr77.5%
log1p-undefine77.5%
rem-exp-log77.5%
add-sqr-sqrt72.9%
sqrt-unprod91.1%
sqr-neg91.1%
sqrt-unprod91.1%
add-sqr-sqrt91.1%
Applied egg-rr91.1%
if 3.99999999999999992e150 < (/.f64 #s(literal 1 binary64) n) Initial program 12.7%
Taylor expanded in n around inf 7.2%
log1p-define7.2%
Simplified7.2%
Taylor expanded in x around -inf 87.1%
Taylor expanded in n around 0 87.1%
Simplified87.1%
Final simplification89.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 2.05e-234)
t_0
(if (<= x 5.8e-200)
t_1
(if (<= x 1.15e-150)
t_0
(if (<= x 6e-123)
t_1
(if (<= x 0.86)
(- (/ x n) (/ (log x) n))
(if (<= x 9.5e+153)
(/
(/
(- 1.0 (/ (- 0.5 (/ (+ 0.3333333333333333 (/ -0.25 x)) x)) x))
x)
n)
(/ 0.0 n)))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 2.05e-234) {
tmp = t_0;
} else if (x <= 5.8e-200) {
tmp = t_1;
} else if (x <= 1.15e-150) {
tmp = t_0;
} else if (x <= 6e-123) {
tmp = t_1;
} else if (x <= 0.86) {
tmp = (x / n) - (log(x) / n);
} else if (x <= 9.5e+153) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} 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) :: t_1
real(8) :: tmp
t_0 = log(x) / -n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 2.05d-234) then
tmp = t_0
else if (x <= 5.8d-200) then
tmp = t_1
else if (x <= 1.15d-150) then
tmp = t_0
else if (x <= 6d-123) then
tmp = t_1
else if (x <= 0.86d0) then
tmp = (x / n) - (log(x) / n)
else if (x <= 9.5d+153) then
tmp = ((1.0d0 - ((0.5d0 - ((0.3333333333333333d0 + ((-0.25d0) / x)) / x)) / x)) / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 2.05e-234) {
tmp = t_0;
} else if (x <= 5.8e-200) {
tmp = t_1;
} else if (x <= 1.15e-150) {
tmp = t_0;
} else if (x <= 6e-123) {
tmp = t_1;
} else if (x <= 0.86) {
tmp = (x / n) - (Math.log(x) / n);
} else if (x <= 9.5e+153) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 2.05e-234: tmp = t_0 elif x <= 5.8e-200: tmp = t_1 elif x <= 1.15e-150: tmp = t_0 elif x <= 6e-123: tmp = t_1 elif x <= 0.86: tmp = (x / n) - (math.log(x) / n) elif x <= 9.5e+153: tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 2.05e-234) tmp = t_0; elseif (x <= 5.8e-200) tmp = t_1; elseif (x <= 1.15e-150) tmp = t_0; elseif (x <= 6e-123) tmp = t_1; elseif (x <= 0.86) tmp = Float64(Float64(x / n) - Float64(log(x) / n)); elseif (x <= 9.5e+153) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x)) / x)) / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 2.05e-234) tmp = t_0; elseif (x <= 5.8e-200) tmp = t_1; elseif (x <= 1.15e-150) tmp = t_0; elseif (x <= 6e-123) tmp = t_1; elseif (x <= 0.86) tmp = (x / n) - (log(x) / n); elseif (x <= 9.5e+153) tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.05e-234], t$95$0, If[LessEqual[x, 5.8e-200], t$95$1, If[LessEqual[x, 1.15e-150], t$95$0, If[LessEqual[x, 6e-123], t$95$1, If[LessEqual[x, 0.86], N[(N[(x / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e+153], N[(N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 2.05 \cdot 10^{-234}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-200}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-150}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.86:\\
\;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.05000000000000005e-234 or 5.8e-200 < x < 1.15000000000000001e-150Initial program 33.6%
Taylor expanded in n around inf 65.4%
log1p-define65.4%
Simplified65.4%
Taylor expanded in x around 0 65.4%
neg-mul-165.4%
Simplified65.4%
if 2.05000000000000005e-234 < x < 5.8e-200 or 1.15000000000000001e-150 < x < 5.99999999999999968e-123Initial program 69.7%
Taylor expanded in x around 0 69.7%
*-rgt-identity69.7%
associate-*l/69.7%
associate-/l*69.7%
exp-to-pow69.7%
Simplified69.7%
if 5.99999999999999968e-123 < x < 0.859999999999999987Initial program 34.0%
Taylor expanded in n around inf 57.9%
log1p-define57.8%
Simplified57.8%
Taylor expanded in x around 0 56.3%
neg-mul-156.3%
distribute-neg-frac56.3%
log-rec56.3%
+-commutative56.3%
log-rec56.3%
distribute-neg-frac56.3%
unsub-neg56.3%
Simplified56.3%
if 0.859999999999999987 < x < 9.4999999999999995e153Initial program 52.7%
Taylor expanded in n around inf 50.5%
log1p-define50.5%
Simplified50.5%
log1p-undefine50.5%
diff-log50.8%
Applied egg-rr50.8%
+-commutative50.8%
Simplified50.8%
clear-num50.8%
log-div50.9%
metadata-eval50.9%
Applied egg-rr50.9%
neg-sub050.9%
Simplified50.9%
Taylor expanded in x around -inf 76.4%
mul-1-neg76.4%
distribute-neg-frac276.4%
Simplified76.4%
if 9.4999999999999995e153 < x Initial program 89.0%
Taylor expanded in n around inf 89.0%
log1p-define89.0%
Simplified89.0%
log1p-undefine89.0%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
Taylor expanded in x around inf 89.0%
Final simplification71.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= n -8.95e+73)
t_0
(if (<= n -1.35e+44)
(/ 1.0 (* x n))
(if (<= n -1.65e-37)
t_0
(if (<= n 3.05e-152)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= n 175.0) (+ 1.0 (pow x (/ 1.0 n))) t_0)))))))
double code(double x, double n) {
double t_0 = log(((x + 1.0) / x)) / n;
double tmp;
if (n <= -8.95e+73) {
tmp = t_0;
} else if (n <= -1.35e+44) {
tmp = 1.0 / (x * n);
} else if (n <= -1.65e-37) {
tmp = t_0;
} else if (n <= 3.05e-152) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if (n <= 175.0) {
tmp = 1.0 + pow(x, (1.0 / n));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(((x + 1.0d0) / x)) / n
if (n <= (-8.95d+73)) then
tmp = t_0
else if (n <= (-1.35d+44)) then
tmp = 1.0d0 / (x * n)
else if (n <= (-1.65d-37)) then
tmp = t_0
else if (n <= 3.05d-152) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if (n <= 175.0d0) then
tmp = 1.0d0 + (x ** (1.0d0 / n))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if (n <= -8.95e+73) {
tmp = t_0;
} else if (n <= -1.35e+44) {
tmp = 1.0 / (x * n);
} else if (n <= -1.65e-37) {
tmp = t_0;
} else if (n <= 3.05e-152) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if (n <= 175.0) {
tmp = 1.0 + Math.pow(x, (1.0 / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.log(((x + 1.0) / x)) / n tmp = 0 if n <= -8.95e+73: tmp = t_0 elif n <= -1.35e+44: tmp = 1.0 / (x * n) elif n <= -1.65e-37: tmp = t_0 elif n <= 3.05e-152: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif n <= 175.0: tmp = 1.0 + math.pow(x, (1.0 / n)) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (n <= -8.95e+73) tmp = t_0; elseif (n <= -1.35e+44) tmp = Float64(1.0 / Float64(x * n)); elseif (n <= -1.65e-37) tmp = t_0; elseif (n <= 3.05e-152) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (n <= 175.0) tmp = Float64(1.0 + (x ^ Float64(1.0 / n))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = log(((x + 1.0) / x)) / n; tmp = 0.0; if (n <= -8.95e+73) tmp = t_0; elseif (n <= -1.35e+44) tmp = 1.0 / (x * n); elseif (n <= -1.65e-37) tmp = t_0; elseif (n <= 3.05e-152) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif (n <= 175.0) tmp = 1.0 + (x ^ (1.0 / n)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -8.95e+73], t$95$0, If[LessEqual[n, -1.35e+44], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -1.65e-37], t$95$0, If[LessEqual[n, 3.05e-152], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 175.0], N[(1.0 + N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;n \leq -8.95 \cdot 10^{+73}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -1.35 \cdot 10^{+44}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;n \leq -1.65 \cdot 10^{-37}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 3.05 \cdot 10^{-152}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;n \leq 175:\\
\;\;\;\;1 + {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -8.9500000000000001e73 or -1.35e44 < n < -1.64999999999999991e-37 or 175 < n Initial program 41.2%
Taylor expanded in n around inf 85.1%
log1p-define85.1%
Simplified85.1%
log1p-undefine85.1%
diff-log85.2%
Applied egg-rr85.2%
+-commutative85.2%
Simplified85.2%
if -8.9500000000000001e73 < n < -1.35e44Initial program 6.9%
Taylor expanded in n around inf 18.9%
log1p-define18.9%
Simplified18.9%
Taylor expanded in x around inf 87.9%
if -1.64999999999999991e-37 < n < 3.04999999999999991e-152Initial program 81.3%
Taylor expanded in n around inf 32.7%
log1p-define32.7%
Simplified32.7%
Taylor expanded in x around -inf 56.2%
Taylor expanded in x around 0 79.7%
*-commutative79.7%
Simplified79.7%
if 3.04999999999999991e-152 < n < 175Initial program 81.9%
Taylor expanded in x around 0 77.5%
*-rgt-identity77.5%
associate-*l/77.5%
associate-/l*77.5%
exp-to-pow77.5%
Simplified77.5%
add-exp-log77.5%
sub-neg77.5%
log1p-define77.5%
Applied egg-rr77.5%
log1p-undefine77.5%
rem-exp-log77.5%
add-sqr-sqrt72.9%
sqrt-unprod91.1%
sqr-neg91.1%
sqrt-unprod91.1%
add-sqr-sqrt91.1%
Applied egg-rr91.1%
Final simplification84.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 2.3e-234)
t_0
(if (<= x 5.8e-200)
t_1
(if (<= x 1.12e-150)
t_0
(if (<= x 5.7e-123)
t_1
(if (<= x 0.9)
(/ (- x (log x)) n)
(if (<= x 1e+154)
(/
(/
(- 1.0 (/ (- 0.5 (/ (+ 0.3333333333333333 (/ -0.25 x)) x)) x))
x)
n)
(/ 0.0 n)))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 2.3e-234) {
tmp = t_0;
} else if (x <= 5.8e-200) {
tmp = t_1;
} else if (x <= 1.12e-150) {
tmp = t_0;
} else if (x <= 5.7e-123) {
tmp = t_1;
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else if (x <= 1e+154) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} 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) :: t_1
real(8) :: tmp
t_0 = log(x) / -n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 2.3d-234) then
tmp = t_0
else if (x <= 5.8d-200) then
tmp = t_1
else if (x <= 1.12d-150) then
tmp = t_0
else if (x <= 5.7d-123) then
tmp = t_1
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else if (x <= 1d+154) then
tmp = ((1.0d0 - ((0.5d0 - ((0.3333333333333333d0 + ((-0.25d0) / x)) / x)) / x)) / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 2.3e-234) {
tmp = t_0;
} else if (x <= 5.8e-200) {
tmp = t_1;
} else if (x <= 1.12e-150) {
tmp = t_0;
} else if (x <= 5.7e-123) {
tmp = t_1;
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1e+154) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 2.3e-234: tmp = t_0 elif x <= 5.8e-200: tmp = t_1 elif x <= 1.12e-150: tmp = t_0 elif x <= 5.7e-123: tmp = t_1 elif x <= 0.9: tmp = (x - math.log(x)) / n elif x <= 1e+154: tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 2.3e-234) tmp = t_0; elseif (x <= 5.8e-200) tmp = t_1; elseif (x <= 1.12e-150) tmp = t_0; elseif (x <= 5.7e-123) tmp = t_1; elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1e+154) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x)) / x)) / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 2.3e-234) tmp = t_0; elseif (x <= 5.8e-200) tmp = t_1; elseif (x <= 1.12e-150) tmp = t_0; elseif (x <= 5.7e-123) tmp = t_1; elseif (x <= 0.9) tmp = (x - log(x)) / n; elseif (x <= 1e+154) tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.3e-234], t$95$0, If[LessEqual[x, 5.8e-200], t$95$1, If[LessEqual[x, 1.12e-150], t$95$0, If[LessEqual[x, 5.7e-123], t$95$1, If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1e+154], N[(N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 2.3 \cdot 10^{-234}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-200}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-150}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 10^{+154}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.2999999999999999e-234 or 5.8e-200 < x < 1.12e-150Initial program 33.6%
Taylor expanded in n around inf 65.4%
log1p-define65.4%
Simplified65.4%
Taylor expanded in x around 0 65.4%
neg-mul-165.4%
Simplified65.4%
if 2.2999999999999999e-234 < x < 5.8e-200 or 1.12e-150 < x < 5.70000000000000027e-123Initial program 69.7%
Taylor expanded in x around 0 69.7%
*-rgt-identity69.7%
associate-*l/69.7%
associate-/l*69.7%
exp-to-pow69.7%
Simplified69.7%
if 5.70000000000000027e-123 < x < 0.900000000000000022Initial program 34.0%
Taylor expanded in n around inf 57.9%
log1p-define57.8%
Simplified57.8%
Taylor expanded in x around 0 56.3%
if 0.900000000000000022 < x < 1.00000000000000004e154Initial program 52.7%
Taylor expanded in n around inf 50.5%
log1p-define50.5%
Simplified50.5%
log1p-undefine50.5%
diff-log50.8%
Applied egg-rr50.8%
+-commutative50.8%
Simplified50.8%
clear-num50.8%
log-div50.9%
metadata-eval50.9%
Applied egg-rr50.9%
neg-sub050.9%
Simplified50.9%
Taylor expanded in x around -inf 76.4%
mul-1-neg76.4%
distribute-neg-frac276.4%
Simplified76.4%
if 1.00000000000000004e154 < x Initial program 89.0%
Taylor expanded in n around inf 89.0%
log1p-define89.0%
Simplified89.0%
log1p-undefine89.0%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
Taylor expanded in x around inf 89.0%
Final simplification71.6%
(FPCore (x n)
:precision binary64
(if (<= x 1.8e-234)
(/ (log x) (- n))
(if (<= x 3.5e-196)
(/ 1.0 (* x n))
(if (<= x 0.9)
(/ (- x (log x)) n)
(if (<= x 2.1e+154)
(/
(/ (- 1.0 (/ (- 0.5 (/ (+ 0.3333333333333333 (/ -0.25 x)) x)) x)) x)
n)
(/ 0.0 n))))))
double code(double x, double n) {
double tmp;
if (x <= 1.8e-234) {
tmp = log(x) / -n;
} else if (x <= 3.5e-196) {
tmp = 1.0 / (x * n);
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else if (x <= 2.1e+154) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} 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 <= 1.8d-234) then
tmp = log(x) / -n
else if (x <= 3.5d-196) then
tmp = 1.0d0 / (x * n)
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else if (x <= 2.1d+154) then
tmp = ((1.0d0 - ((0.5d0 - ((0.3333333333333333d0 + ((-0.25d0) / x)) / x)) / x)) / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.8e-234) {
tmp = Math.log(x) / -n;
} else if (x <= 3.5e-196) {
tmp = 1.0 / (x * n);
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.1e+154) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.8e-234: tmp = math.log(x) / -n elif x <= 3.5e-196: tmp = 1.0 / (x * n) elif x <= 0.9: tmp = (x - math.log(x)) / n elif x <= 2.1e+154: tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.8e-234) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 3.5e-196) tmp = Float64(1.0 / Float64(x * n)); elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.1e+154) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x)) / x)) / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.8e-234) tmp = log(x) / -n; elseif (x <= 3.5e-196) tmp = 1.0 / (x * n); elseif (x <= 0.9) tmp = (x - log(x)) / n; elseif (x <= 2.1e+154) tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.8e-234], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 3.5e-196], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.1e+154], N[(N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{-234}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-196}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+154}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.7999999999999999e-234Initial program 37.1%
Taylor expanded in n around inf 65.1%
log1p-define65.1%
Simplified65.1%
Taylor expanded in x around 0 65.1%
neg-mul-165.1%
Simplified65.1%
if 1.7999999999999999e-234 < x < 3.50000000000000004e-196Initial program 56.1%
Taylor expanded in n around inf 33.3%
log1p-define33.3%
Simplified33.3%
Taylor expanded in x around inf 54.2%
if 3.50000000000000004e-196 < x < 0.900000000000000022Initial program 39.7%
Taylor expanded in n around inf 56.5%
log1p-define56.4%
Simplified56.4%
Taylor expanded in x around 0 55.4%
if 0.900000000000000022 < x < 2.09999999999999994e154Initial program 52.7%
Taylor expanded in n around inf 50.5%
log1p-define50.5%
Simplified50.5%
log1p-undefine50.5%
diff-log50.8%
Applied egg-rr50.8%
+-commutative50.8%
Simplified50.8%
clear-num50.8%
log-div50.9%
metadata-eval50.9%
Applied egg-rr50.9%
neg-sub050.9%
Simplified50.9%
Taylor expanded in x around -inf 76.4%
mul-1-neg76.4%
distribute-neg-frac276.4%
Simplified76.4%
if 2.09999999999999994e154 < x Initial program 89.0%
Taylor expanded in n around inf 89.0%
log1p-define89.0%
Simplified89.0%
log1p-undefine89.0%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
Taylor expanded in x around inf 89.0%
Final simplification68.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.8e-234)
t_0
(if (<= x 8e-197)
(/ 1.0 (* x n))
(if (<= x 0.7)
t_0
(if (<= x 9e+153)
(/
(/
(- 1.0 (/ (- 0.5 (/ (+ 0.3333333333333333 (/ -0.25 x)) x)) x))
x)
n)
(/ 0.0 n)))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.8e-234) {
tmp = t_0;
} else if (x <= 8e-197) {
tmp = 1.0 / (x * n);
} else if (x <= 0.7) {
tmp = t_0;
} else if (x <= 9e+153) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} 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 = log(x) / -n
if (x <= 1.8d-234) then
tmp = t_0
else if (x <= 8d-197) then
tmp = 1.0d0 / (x * n)
else if (x <= 0.7d0) then
tmp = t_0
else if (x <= 9d+153) then
tmp = ((1.0d0 - ((0.5d0 - ((0.3333333333333333d0 + ((-0.25d0) / x)) / x)) / x)) / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 1.8e-234) {
tmp = t_0;
} else if (x <= 8e-197) {
tmp = 1.0 / (x * n);
} else if (x <= 0.7) {
tmp = t_0;
} else if (x <= 9e+153) {
tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.8e-234: tmp = t_0 elif x <= 8e-197: tmp = 1.0 / (x * n) elif x <= 0.7: tmp = t_0 elif x <= 9e+153: tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.8e-234) tmp = t_0; elseif (x <= 8e-197) tmp = Float64(1.0 / Float64(x * n)); elseif (x <= 0.7) tmp = t_0; elseif (x <= 9e+153) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x)) / x)) / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.8e-234) tmp = t_0; elseif (x <= 8e-197) tmp = 1.0 / (x * n); elseif (x <= 0.7) tmp = t_0; elseif (x <= 9e+153) tmp = ((1.0 - ((0.5 - ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.8e-234], t$95$0, If[LessEqual[x, 8e-197], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.7], t$95$0, If[LessEqual[x, 9e+153], N[(N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.8 \cdot 10^{-234}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-197}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;x \leq 0.7:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.7999999999999999e-234 or 7.9999999999999999e-197 < x < 0.69999999999999996Initial program 39.0%
Taylor expanded in n around inf 59.0%
log1p-define59.0%
Simplified59.0%
Taylor expanded in x around 0 57.6%
neg-mul-157.6%
Simplified57.6%
if 1.7999999999999999e-234 < x < 7.9999999999999999e-197Initial program 56.1%
Taylor expanded in n around inf 33.3%
log1p-define33.3%
Simplified33.3%
Taylor expanded in x around inf 54.2%
if 0.69999999999999996 < x < 9.0000000000000002e153Initial program 52.7%
Taylor expanded in n around inf 50.5%
log1p-define50.5%
Simplified50.5%
log1p-undefine50.5%
diff-log50.8%
Applied egg-rr50.8%
+-commutative50.8%
Simplified50.8%
clear-num50.8%
log-div50.9%
metadata-eval50.9%
Applied egg-rr50.9%
neg-sub050.9%
Simplified50.9%
Taylor expanded in x around -inf 76.4%
mul-1-neg76.4%
distribute-neg-frac276.4%
Simplified76.4%
if 9.0000000000000002e153 < x Initial program 89.0%
Taylor expanded in n around inf 89.0%
log1p-define89.0%
Simplified89.0%
log1p-undefine89.0%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
Taylor expanded in x around inf 89.0%
Final simplification68.3%
(FPCore (x n) :precision binary64 (if (<= x 1.5e+154) (/ (+ (/ 1.0 n) (/ (/ (+ -0.5 (/ 0.3333333333333333 x)) n) x)) x) (/ 0.0 n)))
double code(double x, double n) {
double tmp;
if (x <= 1.5e+154) {
tmp = ((1.0 / n) + (((-0.5 + (0.3333333333333333 / x)) / n) / x)) / 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 <= 1.5d+154) then
tmp = ((1.0d0 / n) + ((((-0.5d0) + (0.3333333333333333d0 / x)) / n) / x)) / x
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.5e+154) {
tmp = ((1.0 / n) + (((-0.5 + (0.3333333333333333 / x)) / n) / x)) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.5e+154: tmp = ((1.0 / n) + (((-0.5 + (0.3333333333333333 / x)) / n) / x)) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.5e+154) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / n) / x)) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.5e+154) tmp = ((1.0 / n) + (((-0.5 + (0.3333333333333333 / x)) / n) / x)) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.5e+154], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5 \cdot 10^{+154}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.50000000000000013e154Initial program 44.5%
Taylor expanded in n around inf 54.0%
log1p-define54.0%
Simplified54.0%
log1p-undefine54.0%
diff-log54.1%
Applied egg-rr54.1%
+-commutative54.1%
Simplified54.1%
Taylor expanded in x around inf 25.9%
Simplified41.6%
Taylor expanded in x around inf 41.6%
associate-*r/41.6%
metadata-eval41.6%
associate-/l/41.6%
metadata-eval41.6%
associate-*r/41.6%
associate-*r/41.6%
metadata-eval41.6%
div-sub41.6%
sub-neg41.6%
associate-*r/41.6%
metadata-eval41.6%
metadata-eval41.6%
Simplified41.6%
if 1.50000000000000013e154 < x Initial program 89.0%
Taylor expanded in n around inf 89.0%
log1p-define89.0%
Simplified89.0%
log1p-undefine89.0%
diff-log89.0%
Applied egg-rr89.0%
+-commutative89.0%
Simplified89.0%
clear-num89.0%
log-div89.0%
metadata-eval89.0%
Applied egg-rr89.0%
neg-sub089.0%
Simplified89.0%
Taylor expanded in x around inf 89.0%
Final simplification52.3%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (/ (+ -0.5 (/ 0.3333333333333333 x)) n) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((-0.5 + (0.3333333333333333 / x)) / n) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + ((((-0.5d0) + (0.3333333333333333d0 / x)) / n) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((-0.5 + (0.3333333333333333 / x)) / n) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((-0.5 + (0.3333333333333333 / x)) / n) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / n) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((-0.5 + (0.3333333333333333 / x)) / n) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{n}}{x}}{x}
\end{array}
Initial program 54.6%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
log1p-undefine61.9%
diff-log62.0%
Applied egg-rr62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in x around inf 34.5%
Simplified46.7%
Taylor expanded in x around inf 46.7%
associate-*r/46.7%
metadata-eval46.7%
associate-/l/46.7%
metadata-eval46.7%
associate-*r/46.7%
associate-*r/46.7%
metadata-eval46.7%
div-sub46.7%
sub-neg46.7%
associate-*r/46.7%
metadata-eval46.7%
metadata-eval46.7%
Simplified46.7%
Final simplification46.7%
(FPCore (x n) :precision binary64 (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) (* x n)))
double code(double x, double n) {
return (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / (x * n)
end function
public static double code(double x, double n) {
return (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n);
}
def code(x, n): return (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n)
function code(x, n) return Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / Float64(x * n)) end
function tmp = code(x, n) tmp = (1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (x * n); end
code[x_, n_] := N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}
\end{array}
Initial program 54.6%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
Taylor expanded in x around -inf 46.6%
Taylor expanded in n around 0 46.4%
Simplified46.4%
Final simplification46.4%
(FPCore (x n) :precision binary64 (/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n))
double code(double x, double n) {
return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
def code(x, n): return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Initial program 54.6%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
log1p-undefine61.9%
diff-log62.0%
Applied egg-rr62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in x around inf 46.6%
Simplified46.6%
Final simplification46.6%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 54.6%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
Taylor expanded in x around inf 44.1%
Final simplification44.1%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(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 54.6%
Taylor expanded in n around inf 61.9%
log1p-define61.9%
Simplified61.9%
Taylor expanded in x around inf 44.1%
associate-/r*44.3%
Simplified44.3%
Final simplification44.3%
(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 54.6%
Taylor expanded in x around 0 32.4%
Taylor expanded in x around inf 4.7%
Final simplification4.7%
herbie shell --seed 2024085
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))