
(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-42)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-17)
(/ (log (/ (+ 1.0 x) 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-42) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-17) {
tmp = log(((1.0 + x) / 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-42) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-17) {
tmp = Math.log(((1.0 + x) / 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-42: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-17: tmp = math.log(((1.0 + x) / 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-42) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-17) tmp = Float64(log(Float64(Float64(1.0 + x) / 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-42], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-17], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / 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^{-42}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-17}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{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.00000000000000003e-42Initial program 88.8%
Taylor expanded in x around inf 28.7%
Simplified28.7%
Taylor expanded in x around inf 96.1%
log-rec96.1%
neg-mul-196.1%
associate-*r/96.1%
distribute-lft-neg-in96.1%
metadata-eval96.1%
*-commutative96.1%
*-rgt-identity96.1%
associate-*r/96.1%
*-rgt-identity96.1%
exp-to-pow96.1%
Simplified96.1%
if -5.00000000000000003e-42 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000014e-17Initial program 35.2%
Taylor expanded in n around inf 83.0%
log1p-define83.0%
Simplified83.0%
log1p-undefine83.0%
diff-log83.1%
Applied egg-rr83.1%
if 2.00000000000000014e-17 < (/.f64 #s(literal 1 binary64) n) Initial program 54.4%
Taylor expanded in n around 0 54.4%
log1p-define94.0%
Simplified94.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) 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-42) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 + ((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) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-42)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-9) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = (1.0d0 + (x * ((1.0d0 + ((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 tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / 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-42: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / 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-42) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / 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
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-9) tmp = log(((1.0 + x) / x)) / n; else tmp = (1.0 + (x * ((1.0 + ((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]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / 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^{-42}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{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.00000000000000003e-42Initial program 88.8%
Taylor expanded in x around inf 28.7%
Simplified28.7%
Taylor expanded in x around inf 96.1%
log-rec96.1%
neg-mul-196.1%
associate-*r/96.1%
distribute-lft-neg-in96.1%
metadata-eval96.1%
*-commutative96.1%
*-rgt-identity96.1%
associate-*r/96.1%
*-rgt-identity96.1%
exp-to-pow96.1%
Simplified96.1%
if -5.00000000000000003e-42 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000001e-9Initial program 34.7%
Taylor expanded in n around inf 81.8%
log1p-define81.8%
Simplified81.8%
log1p-undefine81.8%
diff-log81.9%
Applied egg-rr81.9%
if 5.0000000000000001e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 56.5%
Taylor expanded in x around 0 79.0%
Taylor expanded in n around inf 79.0%
Final simplification85.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+151)
(- (+ 1.0 (/ x n)) t_0)
(/ (- x (log1p (+ x -1.0))) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+151) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (x - log1p((x + -1.0))) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+151) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (x - Math.log1p((x + -1.0))) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+151: tmp = (1.0 + (x / n)) - t_0 else: tmp = (x - math.log1p((x + -1.0))) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+151) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(x - log1p(Float64(x + -1.0))) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+151], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(x - N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+151}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \mathsf{log1p}\left(x + -1\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000003e-42Initial program 88.8%
Taylor expanded in x around inf 28.7%
Simplified28.7%
Taylor expanded in x around inf 96.1%
log-rec96.1%
neg-mul-196.1%
associate-*r/96.1%
distribute-lft-neg-in96.1%
metadata-eval96.1%
*-commutative96.1%
*-rgt-identity96.1%
associate-*r/96.1%
*-rgt-identity96.1%
exp-to-pow96.1%
Simplified96.1%
if -5.00000000000000003e-42 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000001e-9Initial program 34.7%
Taylor expanded in n around inf 81.8%
log1p-define81.8%
Simplified81.8%
log1p-undefine81.8%
diff-log81.9%
Applied egg-rr81.9%
if 5.0000000000000001e-9 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e151Initial program 76.1%
Taylor expanded in x around 0 78.4%
if 1.00000000000000002e151 < (/.f64 #s(literal 1 binary64) n) Initial program 28.6%
Taylor expanded in n around inf 7.4%
log1p-define7.4%
Simplified7.4%
Taylor expanded in x around 0 7.4%
log1p-expm1-u74.7%
expm1-undefine74.7%
add-exp-log74.7%
Applied egg-rr74.7%
Final simplification85.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+151)
(- 1.0 t_0)
(/ (- x (log1p (+ x -1.0))) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+151) {
tmp = 1.0 - t_0;
} else {
tmp = (x - log1p((x + -1.0))) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+151) {
tmp = 1.0 - t_0;
} else {
tmp = (x - Math.log1p((x + -1.0))) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+151: tmp = 1.0 - t_0 else: tmp = (x - math.log1p((x + -1.0))) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+151) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(x - log1p(Float64(x + -1.0))) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+151], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(x - N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+151}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \mathsf{log1p}\left(x + -1\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000003e-42Initial program 88.8%
Taylor expanded in x around inf 28.7%
Simplified28.7%
Taylor expanded in x around inf 96.1%
log-rec96.1%
neg-mul-196.1%
associate-*r/96.1%
distribute-lft-neg-in96.1%
metadata-eval96.1%
*-commutative96.1%
*-rgt-identity96.1%
associate-*r/96.1%
*-rgt-identity96.1%
exp-to-pow96.1%
Simplified96.1%
if -5.00000000000000003e-42 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000001e-9Initial program 34.7%
Taylor expanded in n around inf 81.8%
log1p-define81.8%
Simplified81.8%
log1p-undefine81.8%
diff-log81.9%
Applied egg-rr81.9%
if 5.0000000000000001e-9 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e151Initial program 76.1%
Taylor expanded in x around 0 76.1%
if 1.00000000000000002e151 < (/.f64 #s(literal 1 binary64) n) Initial program 28.6%
Taylor expanded in n around inf 7.4%
log1p-define7.4%
Simplified7.4%
Taylor expanded in x around 0 7.4%
log1p-expm1-u74.7%
expm1-undefine74.7%
add-exp-log74.7%
Applied egg-rr74.7%
Final simplification85.2%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-10)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+151)
(- 1.0 (pow x (/ 1.0 n)))
(/ (- x (log1p (+ x -1.0))) n)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+151) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = (x - log1p((x + -1.0))) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+151) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = (x - Math.log1p((x + -1.0))) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5e-10: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+151: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = (x - math.log1p((x + -1.0))) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+151) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(x - log1p(Float64(x + -1.0))) / n); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-10], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+151], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(x - N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+151}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \mathsf{log1p}\left(x + -1\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 98.6%
Taylor expanded in n around inf 46.5%
log1p-define46.5%
Simplified46.5%
Taylor expanded in x around -inf 42.4%
Taylor expanded in x around 0 75.2%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000001e-9Initial program 34.1%
Taylor expanded in n around inf 79.1%
log1p-define79.1%
Simplified79.1%
log1p-undefine79.1%
diff-log79.3%
Applied egg-rr79.3%
if 5.0000000000000001e-9 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e151Initial program 76.1%
Taylor expanded in x around 0 76.1%
if 1.00000000000000002e151 < (/.f64 #s(literal 1 binary64) n) Initial program 28.6%
Taylor expanded in n around inf 7.4%
log1p-define7.4%
Simplified7.4%
Taylor expanded in x around 0 7.4%
log1p-expm1-u74.7%
expm1-undefine74.7%
add-exp-log74.7%
Applied egg-rr74.7%
Final simplification77.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ 0.3333333333333333 (* n (pow x 3.0)))))
(if (<= (/ 1.0 n) -5e-10)
t_0
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 4e+224) (- 1.0 (pow x (/ 1.0 n))) t_0)))))
double code(double x, double n) {
double t_0 = 0.3333333333333333 / (n * pow(x, 3.0));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 4e+224) {
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 = 0.3333333333333333d0 / (n * (x ** 3.0d0))
if ((1.0d0 / n) <= (-5d-10)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d-9) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 4d+224) 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 = 0.3333333333333333 / (n * Math.pow(x, 3.0));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 4e+224) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = 0.3333333333333333 / (n * math.pow(x, 3.0)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 4e+224: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 4e+224) 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 = 0.3333333333333333 / (n * (x ^ 3.0)); tmp = 0.0; if ((1.0 / n) <= -5e-10) tmp = t_0; elseif ((1.0 / n) <= 5e-9) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 4e+224) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-10], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e+224], 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{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{+224}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10 or 3.99999999999999988e224 < (/.f64 #s(literal 1 binary64) n) Initial program 87.7%
Taylor expanded in n around inf 41.8%
log1p-define41.8%
Simplified41.8%
Taylor expanded in x around -inf 48.5%
Taylor expanded in x around 0 77.2%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000001e-9Initial program 34.1%
Taylor expanded in n around inf 79.1%
log1p-define79.1%
Simplified79.1%
log1p-undefine79.1%
diff-log79.3%
Applied egg-rr79.3%
if 5.0000000000000001e-9 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999988e224Initial program 68.6%
Taylor expanded in x around 0 68.6%
(FPCore (x n)
:precision binary64
(if (<= x 5e-277)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (<= x 2.8e+114) (* (/ 1.0 n) (/ (- 1.0 (/ 0.5 x)) x)) 0.0))))
double code(double x, double n) {
double tmp;
if (x <= 5e-277) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 2.8e+114) {
tmp = (1.0 / n) * ((1.0 - (0.5 / 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 (x <= 5d-277) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 2.8d+114) then
tmp = (1.0d0 / n) * ((1.0d0 - (0.5d0 / x)) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 5e-277) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.8e+114) {
tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5e-277: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 2.8e+114: tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 5e-277) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.8e+114) tmp = Float64(Float64(1.0 / n) * Float64(Float64(1.0 - Float64(0.5 / x)) / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5e-277) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 2.8e+114) tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5e-277], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.8e+114], N[(N[(1.0 / n), $MachinePrecision] * N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-277}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+114}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1 - \frac{0.5}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 5e-277Initial program 80.5%
Taylor expanded in x around 0 80.5%
if 5e-277 < x < 1Initial program 40.0%
Taylor expanded in n around inf 51.7%
log1p-define51.7%
Simplified51.7%
Taylor expanded in x around 0 51.7%
if 1 < x < 2.8e114Initial program 44.1%
Taylor expanded in n around inf 36.2%
log1p-define36.2%
Simplified36.2%
div-inv36.2%
Applied egg-rr36.2%
Taylor expanded in x around inf 74.2%
associate-*r/74.2%
metadata-eval74.2%
Simplified74.2%
if 2.8e114 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification66.3%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- x (log x)) n) (if (<= x 1.1e+113) (* (/ 1.0 n) (/ (- 1.0 (/ 0.5 x)) x)) 0.0)))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 1.1e+113) {
tmp = (1.0 / n) * ((1.0 - (0.5 / 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 (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 1.1d+113) then
tmp = (1.0d0 / n) * ((1.0d0 - (0.5d0 / x)) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.1e+113) {
tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 1.1e+113: tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.1e+113) tmp = Float64(Float64(1.0 / n) * Float64(Float64(1.0 - Float64(0.5 / x)) / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 1.1e+113) tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.1e+113], N[(N[(1.0 / n), $MachinePrecision] * N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+113}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1 - \frac{0.5}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 43.9%
Taylor expanded in n around inf 49.2%
log1p-define49.2%
Simplified49.2%
Taylor expanded in x around 0 49.2%
if 1 < x < 1.10000000000000005e113Initial program 44.1%
Taylor expanded in n around inf 36.2%
log1p-define36.2%
Simplified36.2%
div-inv36.2%
Applied egg-rr36.2%
Taylor expanded in x around inf 74.2%
associate-*r/74.2%
metadata-eval74.2%
Simplified74.2%
if 1.10000000000000005e113 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification63.3%
(FPCore (x n) :precision binary64 (if (<= x 0.68) (/ (log x) (- n)) (if (<= x 6.5e+113) (* (/ 1.0 n) (/ (- 1.0 (/ 0.5 x)) x)) 0.0)))
double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = log(x) / -n;
} else if (x <= 6.5e+113) {
tmp = (1.0 / n) * ((1.0 - (0.5 / 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 (x <= 0.68d0) then
tmp = log(x) / -n
else if (x <= 6.5d+113) then
tmp = (1.0d0 / n) * ((1.0d0 - (0.5d0 / x)) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = Math.log(x) / -n;
} else if (x <= 6.5e+113) {
tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.68: tmp = math.log(x) / -n elif x <= 6.5e+113: tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.68) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 6.5e+113) tmp = Float64(Float64(1.0 / n) * Float64(Float64(1.0 - Float64(0.5 / x)) / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.68) tmp = log(x) / -n; elseif (x <= 6.5e+113) tmp = (1.0 / n) * ((1.0 - (0.5 / x)) / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.68], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 6.5e+113], N[(N[(1.0 / n), $MachinePrecision] * N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+113}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1 - \frac{0.5}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 43.9%
Taylor expanded in x around 0 43.2%
Taylor expanded in n around inf 48.9%
associate-*r/48.9%
neg-mul-148.9%
Simplified48.9%
if 0.680000000000000049 < x < 6.5000000000000001e113Initial program 44.1%
Taylor expanded in n around inf 36.2%
log1p-define36.2%
Simplified36.2%
div-inv36.2%
Applied egg-rr36.2%
Taylor expanded in x around inf 74.2%
associate-*r/74.2%
metadata-eval74.2%
Simplified74.2%
if 6.5000000000000001e113 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification63.1%
(FPCore (x n) :precision binary64 (if (<= x 5e+113) (* (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) n) (/ -1.0 x)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 5e+113) {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / n) * (-1.0 / 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 (x <= 5d+113) then
tmp = (((-1.0d0) + ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / n) * ((-1.0d0) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 5e+113) {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / n) * (-1.0 / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5e+113: tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / n) * (-1.0 / x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 5e+113) tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / n) * Float64(-1.0 / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5e+113) tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / n) * (-1.0 / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5e+113], N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+113}:\\
\;\;\;\;\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 5e113Initial program 43.9%
Taylor expanded in n around inf 46.4%
log1p-define46.4%
Simplified46.4%
Taylor expanded in x around -inf 39.9%
Taylor expanded in n around 0 39.9%
sub-neg39.9%
associate-*r/39.9%
sub-neg39.9%
metadata-eval39.9%
distribute-lft-in39.9%
neg-mul-139.9%
associate-*r/39.9%
metadata-eval39.9%
distribute-neg-frac39.9%
metadata-eval39.9%
metadata-eval39.9%
metadata-eval39.9%
Simplified39.9%
div-inv39.9%
div-inv39.9%
div-inv39.9%
+-commutative39.9%
Applied egg-rr39.9%
if 5e113 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification52.6%
(FPCore (x n) :precision binary64 (if (<= x 2.5e+114) (/ (+ (/ 1.0 n) (/ (+ -0.5 (/ 0.3333333333333333 x)) (* n x))) x) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 2.5e+114) {
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 (x <= 2.5d+114) 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 (x <= 2.5e+114) {
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 x <= 2.5e+114: 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 (x <= 2.5e+114) 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 (x <= 2.5e+114) 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[LessEqual[x, 2.5e+114], 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}\;x \leq 2.5 \cdot 10^{+114}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{-0.5 + \frac{0.3333333333333333}{x}}{n \cdot x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.5e114Initial program 43.9%
Taylor expanded in n around inf 46.4%
log1p-define46.4%
Simplified46.4%
log1p-undefine46.4%
diff-log46.5%
Applied egg-rr46.5%
Taylor expanded in x around inf 23.7%
Simplified39.9%
if 2.5e114 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification52.6%
(FPCore (x n) :precision binary64 (if (<= x 3.3e+115) (/ (/ (- (/ (- (/ -0.3333333333333333 (- x)) 0.5) x) -1.0) n) x) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 3.3e+115) {
tmp = (((((-0.3333333333333333 / -x) - 0.5) / x) - -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 (x <= 3.3d+115) then
tmp = ((((((-0.3333333333333333d0) / -x) - 0.5d0) / x) - (-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 (x <= 3.3e+115) {
tmp = (((((-0.3333333333333333 / -x) - 0.5) / x) - -1.0) / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.3e+115: tmp = (((((-0.3333333333333333 / -x) - 0.5) / x) - -1.0) / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 3.3e+115) tmp = Float64(Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 / Float64(-x)) - 0.5) / x) - -1.0) / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.3e+115) tmp = (((((-0.3333333333333333 / -x) - 0.5) / x) - -1.0) / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.3e+115], N[(N[(N[(N[(N[(N[(-0.3333333333333333 / (-x)), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision] - -1.0), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{+115}:\\
\;\;\;\;\frac{\frac{\frac{\frac{-0.3333333333333333}{-x} - 0.5}{x} - -1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 3.30000000000000005e115Initial program 43.9%
Taylor expanded in n around inf 46.4%
log1p-define46.4%
Simplified46.4%
Taylor expanded in x around -inf 39.9%
Taylor expanded in n around 0 39.9%
sub-neg39.9%
associate-*r/39.9%
sub-neg39.9%
metadata-eval39.9%
distribute-lft-in39.9%
neg-mul-139.9%
associate-*r/39.9%
metadata-eval39.9%
distribute-neg-frac39.9%
metadata-eval39.9%
metadata-eval39.9%
metadata-eval39.9%
Simplified39.9%
associate-*r/39.9%
neg-mul-139.9%
distribute-neg-frac239.9%
+-commutative39.9%
Applied egg-rr39.9%
if 3.30000000000000005e115 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification52.6%
(FPCore (x n) :precision binary64 (if (<= x 2.9e+112) (/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 2.9e+112) {
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 (x <= 2.9d+112) 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 (x <= 2.9e+112) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.9e+112: 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 (x <= 2.9e+112) 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 (x <= 2.9e+112) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.9e+112], 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}\;x \leq 2.9 \cdot 10^{+112}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.9000000000000002e112Initial program 43.9%
Taylor expanded in n around inf 46.4%
log1p-define46.4%
Simplified46.4%
log1p-expm1-u30.7%
expm1-undefine30.7%
add-exp-log30.7%
Applied egg-rr37.4%
Taylor expanded in x around -inf 39.9%
Simplified39.9%
if 2.9000000000000002e112 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
(FPCore (x n) :precision binary64 (if (<= x 4.2e+112) (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 4.2e+112) {
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 (x <= 4.2d+112) 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 (x <= 4.2e+112) {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 4.2e+112: 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 (x <= 4.2e+112) tmp = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 4.2e+112) tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 4.2e+112], N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.2 \cdot 10^{+112}:\\
\;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4.1999999999999998e112Initial program 43.9%
Taylor expanded in n around inf 46.4%
log1p-define46.4%
Simplified46.4%
Taylor expanded in x around -inf 39.9%
Taylor expanded in n around -inf 39.5%
mul-1-neg39.5%
unsub-neg39.5%
sub-neg39.5%
associate-*r/39.5%
metadata-eval39.5%
distribute-neg-frac39.5%
metadata-eval39.5%
*-commutative39.5%
Simplified39.5%
if 4.1999999999999998e112 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification52.3%
(FPCore (x n) :precision binary64 (if (<= x 3.8e+113) (* (/ 1.0 n) (/ 1.0 x)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 3.8e+113) {
tmp = (1.0 / n) * (1.0 / 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 (x <= 3.8d+113) then
tmp = (1.0d0 / n) * (1.0d0 / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.8e+113) {
tmp = (1.0 / n) * (1.0 / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.8e+113: tmp = (1.0 / n) * (1.0 / x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 3.8e+113) tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.8e+113) tmp = (1.0 / n) * (1.0 / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.8e+113], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.8 \cdot 10^{+113}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 3.8000000000000003e113Initial program 43.9%
Taylor expanded in n around inf 46.4%
log1p-define46.4%
Simplified46.4%
div-inv46.4%
Applied egg-rr46.4%
Taylor expanded in x around inf 34.8%
if 3.8000000000000003e113 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification48.9%
(FPCore (x n) :precision binary64 (if (<= x 3.5e+112) (/ (/ 1.0 n) x) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 3.5e+112) {
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 (x <= 3.5d+112) 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 (x <= 3.5e+112) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.5e+112: tmp = (1.0 / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 3.5e+112) tmp = Float64(Float64(1.0 / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.5e+112) tmp = (1.0 / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.5e+112], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{+112}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 3.49999999999999997e112Initial program 43.9%
Taylor expanded in x around inf 19.2%
Simplified19.0%
Taylor expanded in x around inf 41.7%
log-rec41.7%
neg-mul-141.7%
associate-*r/41.7%
distribute-lft-neg-in41.7%
metadata-eval41.7%
*-commutative41.7%
*-rgt-identity41.7%
associate-*r/41.7%
*-rgt-identity41.7%
exp-to-pow41.7%
Simplified41.7%
Taylor expanded in n around inf 34.8%
if 3.49999999999999997e112 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
(FPCore (x n) :precision binary64 (if (<= x 7e+114) (/ 1.0 (* n x)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 7e+114) {
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 (x <= 7d+114) 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 (x <= 7e+114) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 7e+114: tmp = 1.0 / (n * x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 7e+114) 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 (x <= 7e+114) tmp = 1.0 / (n * x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 7e+114], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7 \cdot 10^{+114}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 7.0000000000000001e114Initial program 43.9%
Taylor expanded in n around inf 46.4%
log1p-define46.4%
Simplified46.4%
Taylor expanded in x around inf 34.5%
*-commutative34.5%
Simplified34.5%
if 7.0000000000000001e114 < x Initial program 86.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in n around inf 86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Final simplification48.6%
(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 55.5%
Taylor expanded in x around 0 42.2%
Taylor expanded in n around inf 32.4%
metadata-eval32.4%
Applied egg-rr32.4%
herbie shell --seed 2024169
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))