
(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
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2000000.0)
(/ (log1p (/ 1.0 x)) n)
(pow (cbrt (- (exp (/ (log1p x) n)) t_0)) 3.0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = pow(cbrt((exp((log1p(x) / n)) - t_0)), 3.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-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.pow(Math.cbrt((Math.exp((Math.log1p(x) / n)) - t_0)), 3.0);
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2000000.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = cbrt(Float64(exp(Float64(log1p(x) / n)) - t_0)) ^ 3.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-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000000.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], 1/3], $MachinePrecision], 3.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^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000000:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0}\right)}^{3}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
mul-1-neg98.3%
distribute-neg-frac98.3%
mul-1-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 2e6Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-define80.0%
Simplified80.0%
log1p-expm1-u80.0%
expm1-undefine80.0%
exp-diff80.0%
add-exp-log59.1%
log1p-undefine59.1%
rem-exp-log80.2%
Applied egg-rr80.2%
Taylor expanded in x around 0 97.8%
if 2e6 < (/.f64 #s(literal 1 binary64) n) Initial program 59.8%
add-cube-cbrt59.8%
pow359.8%
pow-to-exp59.8%
un-div-inv59.8%
+-commutative59.8%
log1p-define99.8%
Applied egg-rr99.8%
Final simplification98.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2000000.0)
(/ (log1p (/ 1.0 x)) n)
(- (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-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = Math.log1p((1.0 / x)) / n;
} 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-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 2000000.0: tmp = math.log1p((1.0 / x)) / n 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-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2000000.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000000.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000000:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
mul-1-neg98.3%
distribute-neg-frac98.3%
mul-1-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 2e6Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-define80.0%
Simplified80.0%
log1p-expm1-u80.0%
expm1-undefine80.0%
exp-diff80.0%
add-exp-log59.1%
log1p-undefine59.1%
rem-exp-log80.2%
Applied egg-rr80.2%
Taylor expanded in x around 0 97.8%
if 2e6 < (/.f64 #s(literal 1 binary64) n) Initial program 59.8%
Taylor expanded in n around 0 59.8%
log1p-define99.8%
*-rgt-identity99.8%
associate-/l*99.8%
exp-to-pow99.8%
Simplified99.8%
Final simplification98.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2000000.0)
(/ (log1p (/ 1.0 x)) n)
(- (+ 1.0 (* x (/ (+ 1.0 (+ (* 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 tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / 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-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 2000000.0: tmp = math.log1p((1.0 / x)) / n else: tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / 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-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2000000.0) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 + Float64(Float64(x * -0.5) + Float64(0.5 * Float64(x / n)))) / 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-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000000.0], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 + N[(N[(x * -0.5), $MachinePrecision] + N[(0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $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^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000000:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \frac{1 + \left(x \cdot -0.5 + 0.5 \cdot \frac{x}{n}\right)}{n}\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
mul-1-neg98.3%
distribute-neg-frac98.3%
mul-1-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 2e6Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-define80.0%
Simplified80.0%
log1p-expm1-u80.0%
expm1-undefine80.0%
exp-diff80.0%
add-exp-log59.1%
log1p-undefine59.1%
rem-exp-log80.2%
Applied egg-rr80.2%
Taylor expanded in x around 0 97.8%
if 2e6 < (/.f64 #s(literal 1 binary64) n) Initial program 59.8%
Taylor expanded in x around 0 71.4%
Taylor expanded in n around inf 79.4%
Final simplification95.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -2e+227)
t_0
(if (<= (/ 1.0 n) -0.4)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+17)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+178)
t_0
(/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+227) {
tmp = t_0;
} else if ((1.0 / n) <= -0.4) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+17) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = t_0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+227) {
tmp = t_0;
} else if ((1.0 / n) <= -0.4) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+17) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = t_0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e+227: tmp = t_0 elif (1.0 / n) <= -0.4: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+17: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+178: tmp = t_0 else: tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -2e+227) tmp = t_0; elseif (Float64(1.0 / n) <= -0.4) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+17) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+178) tmp = t_0; else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+227], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.4], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+17], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+178], t$95$0, N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+227}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -0.4:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000002e227 or 5e17 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e178Initial program 90.4%
Taylor expanded in x around 0 76.2%
*-rgt-identity76.2%
associate-/l*76.2%
exp-to-pow76.2%
Simplified76.2%
if -2.0000000000000002e227 < (/.f64 #s(literal 1 binary64) n) < -0.40000000000000002Initial program 98.0%
Taylor expanded in n around inf 63.9%
log1p-define63.9%
Simplified63.9%
log1p-undefine63.9%
diff-log63.9%
Applied egg-rr63.9%
+-commutative63.9%
Simplified63.9%
if -0.40000000000000002 < (/.f64 #s(literal 1 binary64) n) < 5e17Initial program 28.9%
Taylor expanded in n around inf 77.8%
log1p-define77.8%
Simplified77.8%
log1p-expm1-u77.8%
expm1-undefine77.8%
exp-diff77.8%
add-exp-log57.5%
log1p-undefine57.5%
rem-exp-log77.9%
Applied egg-rr77.9%
Taylor expanded in x around 0 95.5%
if 2.0000000000000001e178 < (/.f64 #s(literal 1 binary64) n) Initial program 35.4%
Taylor expanded in n around inf 6.6%
log1p-define6.6%
Simplified6.6%
log1p-expm1-u6.6%
expm1-undefine6.6%
exp-diff6.6%
add-exp-log6.6%
log1p-undefine6.6%
rem-exp-log6.6%
Applied egg-rr6.6%
Taylor expanded in x around inf 11.5%
Simplified68.0%
Final simplification85.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -2e+227)
t_0
(if (<= (/ 1.0 n) -0.4)
0.0
(if (<= (/ 1.0 n) 5e+17)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+178)
t_0
(/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+227) {
tmp = t_0;
} else if ((1.0 / n) <= -0.4) {
tmp = 0.0;
} else if ((1.0 / n) <= 5e+17) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = t_0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+227) {
tmp = t_0;
} else if ((1.0 / n) <= -0.4) {
tmp = 0.0;
} else if ((1.0 / n) <= 5e+17) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = t_0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e+227: tmp = t_0 elif (1.0 / n) <= -0.4: tmp = 0.0 elif (1.0 / n) <= 5e+17: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+178: tmp = t_0 else: tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -2e+227) tmp = t_0; elseif (Float64(1.0 / n) <= -0.4) tmp = 0.0; elseif (Float64(1.0 / n) <= 5e+17) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+178) tmp = t_0; else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+227], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.4], 0.0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+17], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+178], t$95$0, N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+227}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -0.4:\\
\;\;\;\;0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000002e227 or 5e17 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e178Initial program 90.4%
Taylor expanded in x around 0 76.2%
*-rgt-identity76.2%
associate-/l*76.2%
exp-to-pow76.2%
Simplified76.2%
if -2.0000000000000002e227 < (/.f64 #s(literal 1 binary64) n) < -0.40000000000000002Initial program 98.0%
Taylor expanded in x around 0 37.6%
Taylor expanded in n around inf 63.0%
metadata-eval63.0%
Applied egg-rr63.0%
if -0.40000000000000002 < (/.f64 #s(literal 1 binary64) n) < 5e17Initial program 28.9%
Taylor expanded in n around inf 77.8%
log1p-define77.8%
Simplified77.8%
log1p-expm1-u77.8%
expm1-undefine77.8%
exp-diff77.8%
add-exp-log57.5%
log1p-undefine57.5%
rem-exp-log77.9%
Applied egg-rr77.9%
Taylor expanded in x around 0 95.5%
if 2.0000000000000001e178 < (/.f64 #s(literal 1 binary64) n) Initial program 35.4%
Taylor expanded in n around inf 6.6%
log1p-define6.6%
Simplified6.6%
log1p-expm1-u6.6%
expm1-undefine6.6%
exp-diff6.6%
add-exp-log6.6%
log1p-undefine6.6%
rem-exp-log6.6%
Applied egg-rr6.6%
Taylor expanded in x around inf 11.5%
Simplified68.0%
Final simplification85.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e+17)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+195)
(- (+ 1.0 (/ x n)) t_0)
(/
(expm1 (/ (+ 1.0 (/ (- -1.0 (/ -1.1666666666666667 x)) x)) x))
n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+195) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = expm1(((1.0 + ((-1.0 - (-1.1666666666666667 / x)) / x)) / x)) / n;
}
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-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+195) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.expm1(((1.0 + ((-1.0 - (-1.1666666666666667 / x)) / x)) / x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e+17: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+195: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.expm1(((1.0 + ((-1.0 - (-1.1666666666666667 / x)) / x)) / x)) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e+17) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+195) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(expm1(Float64(Float64(1.0 + Float64(Float64(-1.0 - Float64(-1.1666666666666667 / x)) / x)) / x)) / n); 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-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+17], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(Exp[N[(N[(1.0 + N[(N[(-1.0 - N[(-1.1666666666666667 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]] - 1), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 - \frac{-1.1666666666666667}{x}}{x}}{x}\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
mul-1-neg98.3%
distribute-neg-frac98.3%
mul-1-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 5e17Initial program 28.9%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
log1p-expm1-u79.5%
expm1-undefine79.5%
exp-diff79.5%
add-exp-log58.8%
log1p-undefine58.8%
rem-exp-log79.7%
Applied egg-rr79.7%
Taylor expanded in x around 0 97.2%
if 5e17 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e195Initial program 78.9%
Taylor expanded in x around 0 80.9%
if 4.9999999999999998e195 < (/.f64 #s(literal 1 binary64) n) Initial program 33.4%
Taylor expanded in n around inf 6.8%
log1p-define6.8%
Simplified6.8%
expm1-log1p-u6.8%
Applied egg-rr6.8%
Taylor expanded in x around -inf 75.8%
Taylor expanded in x around 0 75.8%
Simplified75.8%
Final simplification94.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e+17)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+195)
(- (+ 1.0 (/ x n)) t_0)
(/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+195) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
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-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+195) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e+17: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+195: tmp = (1.0 + (x / n)) - t_0 else: tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e+17) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+195) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x)); 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-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+17], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / 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^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
mul-1-neg98.3%
distribute-neg-frac98.3%
mul-1-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 5e17Initial program 28.9%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
log1p-expm1-u79.5%
expm1-undefine79.5%
exp-diff79.5%
add-exp-log58.8%
log1p-undefine58.8%
rem-exp-log79.7%
Applied egg-rr79.7%
Taylor expanded in x around 0 97.2%
if 5e17 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e195Initial program 78.9%
Taylor expanded in x around 0 80.9%
if 4.9999999999999998e195 < (/.f64 #s(literal 1 binary64) n) Initial program 33.4%
Taylor expanded in n around inf 6.8%
log1p-define6.8%
Simplified6.8%
log1p-expm1-u6.8%
expm1-undefine6.8%
exp-diff6.8%
add-exp-log6.8%
log1p-undefine6.8%
rem-exp-log6.8%
Applied egg-rr6.8%
Taylor expanded in x around inf 6.7%
Simplified70.0%
Final simplification94.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e+17)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 2e+178)
(- 1.0 t_0)
(/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = 1.0 - t_0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
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-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = 1.0 - t_0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e+17: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 2e+178: tmp = 1.0 - t_0 else: tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e+17) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 2e+178) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x)); 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-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+17], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+178], 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[(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^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
mul-1-neg98.3%
distribute-neg-frac98.3%
mul-1-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 5e17Initial program 28.9%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
log1p-expm1-u79.5%
expm1-undefine79.5%
exp-diff79.5%
add-exp-log58.8%
log1p-undefine58.8%
rem-exp-log79.7%
Applied egg-rr79.7%
Taylor expanded in x around 0 97.2%
if 5e17 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e178Initial program 81.9%
Taylor expanded in x around 0 81.9%
*-rgt-identity81.9%
associate-/l*81.9%
exp-to-pow81.9%
Simplified81.9%
if 2.0000000000000001e178 < (/.f64 #s(literal 1 binary64) n) Initial program 35.4%
Taylor expanded in n around inf 6.6%
log1p-define6.6%
Simplified6.6%
log1p-expm1-u6.6%
expm1-undefine6.6%
exp-diff6.6%
add-exp-log6.6%
log1p-undefine6.6%
rem-exp-log6.6%
Applied egg-rr6.6%
Taylor expanded in x around inf 11.5%
Simplified68.0%
Final simplification94.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x))))
(if (<= (/ 1.0 n) -2e+227)
t_0
(if (<= (/ 1.0 n) -0.4)
0.0
(if (<= (/ 1.0 n) 2e+178) (/ (log1p (/ 1.0 x)) n) t_0)))))
double code(double x, double n) {
double t_0 = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
double tmp;
if ((1.0 / n) <= -2e+227) {
tmp = t_0;
} else if ((1.0 / n) <= -0.4) {
tmp = 0.0;
} else if ((1.0 / n) <= 2e+178) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
double tmp;
if ((1.0 / n) <= -2e+227) {
tmp = t_0;
} else if ((1.0 / n) <= -0.4) {
tmp = 0.0;
} else if ((1.0 / n) <= 2e+178) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x) tmp = 0 if (1.0 / n) <= -2e+227: tmp = t_0 elif (1.0 / n) <= -0.4: tmp = 0.0 elif (1.0 / n) <= 2e+178: tmp = math.log1p((1.0 / x)) / n else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e+227) tmp = t_0; elseif (Float64(1.0 / n) <= -0.4) tmp = 0.0; elseif (Float64(1.0 / n) <= 2e+178) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = t_0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+227], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.4], 0.0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+178], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+227}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -0.4:\\
\;\;\;\;0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000002e227 or 2.0000000000000001e178 < (/.f64 #s(literal 1 binary64) n) Initial program 65.8%
Taylor expanded in n around inf 20.8%
log1p-define20.8%
Simplified20.8%
log1p-expm1-u20.8%
expm1-undefine20.8%
exp-diff20.8%
add-exp-log6.3%
log1p-undefine6.3%
rem-exp-log20.8%
Applied egg-rr20.8%
Taylor expanded in x around inf 9.7%
Simplified66.0%
if -2.0000000000000002e227 < (/.f64 #s(literal 1 binary64) n) < -0.40000000000000002Initial program 98.0%
Taylor expanded in x around 0 37.6%
Taylor expanded in n around inf 63.0%
metadata-eval63.0%
Applied egg-rr63.0%
if -0.40000000000000002 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e178Initial program 34.3%
Taylor expanded in n around inf 70.5%
log1p-define70.5%
Simplified70.5%
log1p-expm1-u70.5%
expm1-undefine70.5%
exp-diff70.5%
add-exp-log52.3%
log1p-undefine52.3%
rem-exp-log70.7%
Applied egg-rr70.7%
Taylor expanded in x around 0 86.5%
Final simplification79.6%
(FPCore (x n)
:precision binary64
(if (<= x 0.7)
(/ (log x) (- n))
(if (<= x 2.5e+132)
(/
(/
(+ 1.0 (/ (- (/ (+ 0.3333333333333333 (* 0.25 (/ -1.0 x))) x) 0.5) x))
x)
n)
0.0)))
double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = log(x) / -n;
} else if (x <= 2.5e+132) {
tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.7d0) then
tmp = log(x) / -n
else if (x <= 2.5d+132) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 + (0.25d0 * ((-1.0d0) / x))) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = Math.log(x) / -n;
} else if (x <= 2.5e+132) {
tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.7: tmp = math.log(x) / -n elif x <= 2.5e+132: tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.7) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 2.5e+132) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(0.25 * Float64(-1.0 / x))) / x) - 0.5) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.7) tmp = log(x) / -n; elseif (x <= 2.5e+132) tmp = ((1.0 + ((((0.3333333333333333 + (0.25 * (-1.0 / x))) / x) - 0.5) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.7], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.5e+132], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 + N[(0.25 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+132}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + 0.25 \cdot \frac{-1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial program 37.4%
Taylor expanded in x around 0 36.1%
*-rgt-identity36.1%
associate-/l*36.1%
exp-to-pow36.1%
Simplified36.1%
Taylor expanded in n around inf 58.1%
associate-*r/58.1%
neg-mul-158.1%
Simplified58.1%
if 0.69999999999999996 < x < 2.5000000000000001e132Initial program 44.1%
Taylor expanded in n around inf 48.6%
log1p-define48.6%
Simplified48.6%
Taylor expanded in x around -inf 63.3%
if 2.5000000000000001e132 < x Initial program 79.8%
Taylor expanded in x around 0 47.3%
Taylor expanded in n around inf 79.8%
metadata-eval79.8%
Applied egg-rr79.8%
Final simplification64.7%
(FPCore (x n) :precision binary64 (if (or (<= n -0.000116) (not (<= n -6.5e-227))) (/ (- (/ 1.0 n) (/ (+ 0.5 (/ -0.3333333333333333 x)) (* n x))) x) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -0.000116) || !(n <= -6.5e-227)) {
tmp = ((1.0 / n) - ((0.5 + (-0.3333333333333333 / x)) / (n * x))) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-0.000116d0)) .or. (.not. (n <= (-6.5d-227)))) then
tmp = ((1.0d0 / n) - ((0.5d0 + ((-0.3333333333333333d0) / x)) / (n * x))) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -0.000116) || !(n <= -6.5e-227)) {
tmp = ((1.0 / n) - ((0.5 + (-0.3333333333333333 / x)) / (n * x))) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -0.000116) or not (n <= -6.5e-227): tmp = ((1.0 / n) - ((0.5 + (-0.3333333333333333 / x)) / (n * x))) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -0.000116) || !(n <= -6.5e-227)) tmp = Float64(Float64(Float64(1.0 / n) - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / Float64(n * x))) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -0.000116) || ~((n <= -6.5e-227))) tmp = ((1.0 / n) - ((0.5 + (-0.3333333333333333 / x)) / (n * x))) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -0.000116], N[Not[LessEqual[n, -6.5e-227]], $MachinePrecision]], N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.000116 \lor \neg \left(n \leq -6.5 \cdot 10^{-227}\right):\\
\;\;\;\;\frac{\frac{1}{n} - \frac{0.5 + \frac{-0.3333333333333333}{x}}{n \cdot x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.16e-4 or -6.4999999999999996e-227 < n Initial program 39.5%
Taylor expanded in n around inf 62.0%
log1p-define62.0%
Simplified62.0%
Taylor expanded in x around -inf 44.1%
Taylor expanded in n around 0 44.1%
associate-*r/44.1%
sub-neg44.1%
metadata-eval44.1%
distribute-lft-in44.1%
neg-mul-144.1%
metadata-eval44.1%
+-commutative44.1%
sub-neg44.1%
*-commutative44.1%
sub-neg44.1%
associate-*r/44.1%
metadata-eval44.1%
distribute-neg-frac44.1%
metadata-eval44.1%
Simplified44.1%
if -1.16e-4 < n < -6.4999999999999996e-227Initial program 100.0%
Taylor expanded in x around 0 36.9%
Taylor expanded in n around inf 65.7%
metadata-eval65.7%
Applied egg-rr65.7%
Final simplification47.7%
(FPCore (x n) :precision binary64 (if (or (<= n -6e-6) (not (<= n -5.5e-226))) (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) n) x) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -6e-6) || !(n <= -5.5e-226)) {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-6d-6)) .or. (.not. (n <= (-5.5d-226)))) then
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -6e-6) || !(n <= -5.5e-226)) {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -6e-6) or not (n <= -5.5e-226): tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -6e-6) || !(n <= -5.5e-226)) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -6e-6) || ~((n <= -5.5e-226))) tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -6e-6], N[Not[LessEqual[n, -5.5e-226]], $MachinePrecision]], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6 \cdot 10^{-6} \lor \neg \left(n \leq -5.5 \cdot 10^{-226}\right):\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -6.0000000000000002e-6 or -5.5e-226 < n Initial program 39.5%
Taylor expanded in n around inf 62.0%
log1p-define62.0%
Simplified62.0%
Taylor expanded in x around -inf 44.1%
Taylor expanded in n around 0 44.1%
sub-neg44.1%
metadata-eval44.1%
+-commutative44.1%
associate-*r/44.1%
sub-neg44.1%
metadata-eval44.1%
distribute-lft-in44.1%
neg-mul-144.1%
metadata-eval44.1%
+-commutative44.1%
associate-*r/44.1%
metadata-eval44.1%
distribute-neg-frac44.1%
metadata-eval44.1%
Simplified44.1%
if -6.0000000000000002e-6 < n < -5.5e-226Initial program 100.0%
Taylor expanded in x around 0 36.9%
Taylor expanded in n around inf 65.7%
metadata-eval65.7%
Applied egg-rr65.7%
Final simplification47.7%
(FPCore (x n) :precision binary64 (if (or (<= n -9.6e-6) (not (<= n -4.6e-226))) (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -9.6e-6) || !(n <= -4.6e-226)) {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-9.6d-6)) .or. (.not. (n <= (-4.6d-226)))) then
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -9.6e-6) || !(n <= -4.6e-226)) {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -9.6e-6) or not (n <= -4.6e-226): tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -9.6e-6) || !(n <= -4.6e-226)) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -9.6e-6) || ~((n <= -4.6e-226))) tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -9.6e-6], N[Not[LessEqual[n, -4.6e-226]], $MachinePrecision]], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.6 \cdot 10^{-6} \lor \neg \left(n \leq -4.6 \cdot 10^{-226}\right):\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -9.5999999999999996e-6 or -4.6000000000000001e-226 < n Initial program 39.5%
Taylor expanded in n around inf 62.0%
log1p-define62.0%
Simplified62.0%
log1p-expm1-u62.0%
expm1-undefine62.0%
exp-diff62.0%
add-exp-log44.5%
log1p-undefine44.5%
rem-exp-log62.1%
Applied egg-rr62.1%
Taylor expanded in x around -inf 44.0%
associate-*r/44.0%
sub-neg44.0%
metadata-eval44.0%
distribute-lft-in44.0%
associate-*r/44.0%
sub-neg44.0%
metadata-eval44.0%
distribute-lft-in44.0%
neg-mul-144.0%
metadata-eval44.0%
+-commutative44.0%
sub-neg44.0%
metadata-eval44.0%
+-commutative44.0%
Simplified44.0%
if -9.5999999999999996e-6 < n < -4.6000000000000001e-226Initial program 100.0%
Taylor expanded in x around 0 36.9%
Taylor expanded in n around inf 65.7%
metadata-eval65.7%
Applied egg-rr65.7%
Final simplification47.7%
(FPCore (x n)
:precision binary64
(if (<= n -0.048)
(/ (/ 1.0 x) n)
(if (<= n -5.5e-226)
0.0
(/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x)))))
double code(double x, double n) {
double tmp;
if (n <= -0.048) {
tmp = (1.0 / x) / n;
} else if (n <= -5.5e-226) {
tmp = 0.0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-0.048d0)) then
tmp = (1.0d0 / x) / n
else if (n <= (-5.5d-226)) then
tmp = 0.0d0
else
tmp = (1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -0.048) {
tmp = (1.0 / x) / n;
} else if (n <= -5.5e-226) {
tmp = 0.0;
} else {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -0.048: tmp = (1.0 / x) / n elif n <= -5.5e-226: tmp = 0.0 else: tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x) return tmp
function code(x, n) tmp = 0.0 if (n <= -0.048) tmp = Float64(Float64(1.0 / x) / n); elseif (n <= -5.5e-226) tmp = 0.0; else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -0.048) tmp = (1.0 / x) / n; elseif (n <= -5.5e-226) tmp = 0.0; else tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -0.048], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, -5.5e-226], 0.0, N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.048:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;n \leq -5.5 \cdot 10^{-226}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\
\end{array}
\end{array}
if n < -0.048000000000000001Initial program 24.9%
Taylor expanded in n around inf 78.2%
log1p-define78.2%
Simplified78.2%
Taylor expanded in x around inf 35.8%
if -0.048000000000000001 < n < -5.5e-226Initial program 100.0%
Taylor expanded in x around 0 36.9%
Taylor expanded in n around inf 65.7%
metadata-eval65.7%
Applied egg-rr65.7%
if -5.5e-226 < n Initial program 46.5%
Taylor expanded in n around inf 54.2%
log1p-define54.2%
Simplified54.2%
log1p-expm1-u54.2%
expm1-undefine54.2%
exp-diff54.2%
add-exp-log36.0%
log1p-undefine36.0%
rem-exp-log54.3%
Applied egg-rr54.3%
Taylor expanded in x around inf 34.4%
Simplified47.2%
Final simplification47.2%
(FPCore (x n) :precision binary64 (if (or (<= n -0.048) (not (<= n -5.1e-226))) (/ (/ 1.0 x) n) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -0.048) || !(n <= -5.1e-226)) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-0.048d0)) .or. (.not. (n <= (-5.1d-226)))) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -0.048) || !(n <= -5.1e-226)) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -0.048) or not (n <= -5.1e-226): tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -0.048) || !(n <= -5.1e-226)) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -0.048) || ~((n <= -5.1e-226))) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -0.048], N[Not[LessEqual[n, -5.1e-226]], $MachinePrecision]], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.048 \lor \neg \left(n \leq -5.1 \cdot 10^{-226}\right):\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -0.048000000000000001 or -5.09999999999999973e-226 < n Initial program 39.5%
Taylor expanded in n around inf 62.0%
log1p-define62.0%
Simplified62.0%
Taylor expanded in x around inf 43.0%
if -0.048000000000000001 < n < -5.09999999999999973e-226Initial program 100.0%
Taylor expanded in x around 0 36.9%
Taylor expanded in n around inf 65.7%
metadata-eval65.7%
Applied egg-rr65.7%
Final simplification46.8%
(FPCore (x n) :precision binary64 (if (or (<= n -0.048) (not (<= n -9.8e-226))) (/ 1.0 (* n x)) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -0.048) || !(n <= -9.8e-226)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-0.048d0)) .or. (.not. (n <= (-9.8d-226)))) then
tmp = 1.0d0 / (n * x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -0.048) || !(n <= -9.8e-226)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -0.048) or not (n <= -9.8e-226): tmp = 1.0 / (n * x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -0.048) || !(n <= -9.8e-226)) tmp = Float64(1.0 / Float64(n * x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -0.048) || ~((n <= -9.8e-226))) tmp = 1.0 / (n * x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -0.048], N[Not[LessEqual[n, -9.8e-226]], $MachinePrecision]], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.048 \lor \neg \left(n \leq -9.8 \cdot 10^{-226}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -0.048000000000000001 or -9.79999999999999972e-226 < n Initial program 39.5%
Taylor expanded in n around inf 62.0%
log1p-define62.0%
Simplified62.0%
Taylor expanded in x around inf 42.4%
*-commutative42.4%
Simplified42.4%
if -0.048000000000000001 < n < -9.79999999999999972e-226Initial program 100.0%
Taylor expanded in x around 0 36.9%
Taylor expanded in n around inf 65.7%
metadata-eval65.7%
Applied egg-rr65.7%
Final simplification46.3%
(FPCore (x n) :precision binary64 (if (<= n -0.048) (/ (/ 1.0 x) n) (if (<= n -4.3e-228) 0.0 (/ (/ 1.0 n) x))))
double code(double x, double n) {
double tmp;
if (n <= -0.048) {
tmp = (1.0 / x) / n;
} else if (n <= -4.3e-228) {
tmp = 0.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) :: tmp
if (n <= (-0.048d0)) then
tmp = (1.0d0 / x) / n
else if (n <= (-4.3d-228)) then
tmp = 0.0d0
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -0.048) {
tmp = (1.0 / x) / n;
} else if (n <= -4.3e-228) {
tmp = 0.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -0.048: tmp = (1.0 / x) / n elif n <= -4.3e-228: tmp = 0.0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (n <= -0.048) tmp = Float64(Float64(1.0 / x) / n); elseif (n <= -4.3e-228) tmp = 0.0; else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -0.048) tmp = (1.0 / x) / n; elseif (n <= -4.3e-228) tmp = 0.0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -0.048], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, -4.3e-228], 0.0, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.048:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;n \leq -4.3 \cdot 10^{-228}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if n < -0.048000000000000001Initial program 24.9%
Taylor expanded in n around inf 78.2%
log1p-define78.2%
Simplified78.2%
Taylor expanded in x around inf 35.8%
if -0.048000000000000001 < n < -4.3e-228Initial program 100.0%
Taylor expanded in x around 0 36.9%
Taylor expanded in n around inf 65.7%
metadata-eval65.7%
Applied egg-rr65.7%
if -4.3e-228 < n Initial program 46.5%
Taylor expanded in n around inf 54.2%
log1p-define54.2%
Simplified54.2%
Taylor expanded in x around -inf 47.8%
Taylor expanded in x around inf 46.0%
associate-/r*46.5%
Simplified46.5%
Final simplification46.8%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 49.7%
Taylor expanded in x around 0 36.1%
Taylor expanded in n around inf 30.0%
metadata-eval30.0%
Applied egg-rr30.0%
herbie shell --seed 2024117
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))