
(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 16 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) -4e-68)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-13)
(/
(-
(+ (log1p x) (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)))
(log x))
n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = ((log1p(x) + (0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n))) - log(x)) / n;
} else {
tmp = exp((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) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = ((Math.log1p(x) + (0.5 * ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n))) - Math.log(x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-68: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-13: tmp = ((math.log1p(x) + (0.5 * ((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n))) - math.log(x)) / n else: tmp = math.exp((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) <= -4e-68) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(Float64(Float64(log1p(x) + Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n))) - log(x)) / n); else tmp = Float64(exp(Float64(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], -4e-68], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / 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 -4 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.00000000000000027e-68Initial program 84.2%
Taylor expanded in x around inf 93.6%
associate-/r*93.6%
mul-1-neg93.6%
log-rec93.6%
mul-1-neg93.6%
distribute-neg-frac93.6%
mul-1-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
Simplified93.6%
if -4.00000000000000027e-68 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e-13Initial program 34.8%
Taylor expanded in n around inf 81.0%
Simplified81.0%
if 4.9999999999999999e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 67.5%
Taylor expanded in n around 0 67.5%
log1p-define99.8%
*-rgt-identity99.8%
associate-/l*99.8%
exp-to-pow99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
Final simplification88.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-68)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((x / 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) <= (-4d-68)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = exp((x / 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) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-68: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-13: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((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) <= -4e-68) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(x / 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) <= -4e-68) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-13) tmp = log(((1.0 + x) / x)) / n; else tmp = exp((x / 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], -4e-68], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / 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 -4 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.00000000000000027e-68Initial program 84.2%
Taylor expanded in x around inf 93.6%
associate-/r*93.6%
mul-1-neg93.6%
log-rec93.6%
mul-1-neg93.6%
distribute-neg-frac93.6%
mul-1-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
Simplified93.6%
if -4.00000000000000027e-68 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e-13Initial program 34.8%
Taylor expanded in n around inf 80.7%
log1p-define80.7%
Simplified80.7%
log1p-undefine80.7%
diff-log80.9%
Applied egg-rr80.9%
+-commutative80.9%
Simplified80.9%
if 4.9999999999999999e-13 < (/.f64 #s(literal 1 binary64) n) Initial program 67.5%
Taylor expanded in n around 0 67.5%
log1p-define99.8%
*-rgt-identity99.8%
associate-/l*99.8%
exp-to-pow99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
Final simplification88.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-68)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2e+197)
(- (+ 1.0 (/ x n)) t_0)
(/
(expm1 (/ (+ 1.0 (/ (+ -1.0 (* 1.1666666666666667 (/ 1.0 x))) x)) x))
n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+197) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = expm1(((1.0 + ((-1.0 + (1.1666666666666667 * (1.0 / 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) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+197) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.expm1(((1.0 + ((-1.0 + (1.1666666666666667 * (1.0 / x))) / x)) / x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-68: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-13: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+197: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.expm1(((1.0 + ((-1.0 + (1.1666666666666667 * (1.0 / 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) <= -4e-68) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+197) 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 * Float64(1.0 / 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], -4e-68], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+197], 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 * N[(1.0 / x), $MachinePrecision]), $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 -4 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+197}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 + 1.1666666666666667 \cdot \frac{1}{x}}{x}}{x}\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.00000000000000027e-68Initial program 84.2%
Taylor expanded in x around inf 93.6%
associate-/r*93.6%
mul-1-neg93.6%
log-rec93.6%
mul-1-neg93.6%
distribute-neg-frac93.6%
mul-1-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
Simplified93.6%
if -4.00000000000000027e-68 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e-13Initial program 34.8%
Taylor expanded in n around inf 80.7%
log1p-define80.7%
Simplified80.7%
log1p-undefine80.7%
diff-log80.9%
Applied egg-rr80.9%
+-commutative80.9%
Simplified80.9%
if 4.9999999999999999e-13 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e197Initial program 78.9%
Taylor expanded in x around 0 75.5%
*-rgt-identity75.5%
associate-/l*75.5%
exp-to-pow75.5%
Simplified75.5%
if 1.9999999999999999e197 < (/.f64 #s(literal 1 binary64) n) Initial program 27.3%
Taylor expanded in n around inf 18.9%
log1p-define18.9%
Simplified18.9%
expm1-log1p-u18.9%
Applied egg-rr18.9%
Taylor expanded in x around -inf 87.9%
Final simplification85.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-68)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2e+244)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (- x)) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+244) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-4d-68)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2d+244) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (((-1.0d0) + ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / -x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+244) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-68: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-13: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+244: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-68) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+244) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(-x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -4e-68) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-13) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2e+244) tmp = (1.0 + (x / n)) - t_0; else tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-68], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+244], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+244}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{-x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.00000000000000027e-68Initial program 84.2%
Taylor expanded in x around inf 93.6%
associate-/r*93.6%
mul-1-neg93.6%
log-rec93.6%
mul-1-neg93.6%
distribute-neg-frac93.6%
mul-1-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
Simplified93.6%
if -4.00000000000000027e-68 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e-13Initial program 34.8%
Taylor expanded in n around inf 80.7%
log1p-define80.7%
Simplified80.7%
log1p-undefine80.7%
diff-log80.9%
Applied egg-rr80.9%
+-commutative80.9%
Simplified80.9%
if 4.9999999999999999e-13 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000015e244Initial program 77.8%
Taylor expanded in x around 0 71.8%
*-rgt-identity71.8%
associate-/l*71.8%
exp-to-pow71.8%
Simplified71.8%
if 2.00000000000000015e244 < (/.f64 #s(literal 1 binary64) n) Initial program 3.1%
Taylor expanded in n around inf 27.0%
log1p-define27.0%
Simplified27.0%
expm1-log1p-u27.0%
Applied egg-rr27.0%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
associate-*r/100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-lft-in100.0%
neg-mul-1100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification85.0%
(FPCore (x n)
:precision binary64
(if (<= n -9.8e+253)
(/ (log x) (- n))
(if (<= n -4.6)
(* (/ 1.0 n) (/ 1.0 x))
(if (<= n 2.05e-198)
(/ (/ -0.25 n) (- (pow x 4.0)))
(if (<= n 16200000000.0)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= n 3.3e+93)
(/ (- x (log x)) n)
(/
(+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* n x)) (/ 0.5 n)) x))
x)))))))
double code(double x, double n) {
double tmp;
if (n <= -9.8e+253) {
tmp = log(x) / -n;
} else if (n <= -4.6) {
tmp = (1.0 / n) * (1.0 / x);
} else if (n <= 2.05e-198) {
tmp = (-0.25 / n) / -pow(x, 4.0);
} else if (n <= 16200000000.0) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (n <= 3.3e+93) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-9.8d+253)) then
tmp = log(x) / -n
else if (n <= (-4.6d0)) then
tmp = (1.0d0 / n) * (1.0d0 / x)
else if (n <= 2.05d-198) then
tmp = ((-0.25d0) / n) / -(x ** 4.0d0)
else if (n <= 16200000000.0d0) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (n <= 3.3d+93) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) - (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -9.8e+253) {
tmp = Math.log(x) / -n;
} else if (n <= -4.6) {
tmp = (1.0 / n) * (1.0 / x);
} else if (n <= 2.05e-198) {
tmp = (-0.25 / n) / -Math.pow(x, 4.0);
} else if (n <= 16200000000.0) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (n <= 3.3e+93) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -9.8e+253: tmp = math.log(x) / -n elif n <= -4.6: tmp = (1.0 / n) * (1.0 / x) elif n <= 2.05e-198: tmp = (-0.25 / n) / -math.pow(x, 4.0) elif n <= 16200000000.0: tmp = 1.0 - math.pow(x, (1.0 / n)) elif n <= 3.3e+93: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (n <= -9.8e+253) tmp = Float64(log(x) / Float64(-n)); elseif (n <= -4.6) tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); elseif (n <= 2.05e-198) tmp = Float64(Float64(-0.25 / n) / Float64(-(x ^ 4.0))); elseif (n <= 16200000000.0) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (n <= 3.3e+93) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) - Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -9.8e+253) tmp = log(x) / -n; elseif (n <= -4.6) tmp = (1.0 / n) * (1.0 / x); elseif (n <= 2.05e-198) tmp = (-0.25 / n) / -(x ^ 4.0); elseif (n <= 16200000000.0) tmp = 1.0 - (x ^ (1.0 / n)); elseif (n <= 3.3e+93) tmp = (x - log(x)) / n; else tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -9.8e+253], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[n, -4.6], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.05e-198], N[(N[(-0.25 / n), $MachinePrecision] / (-N[Power[x, 4.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[n, 16200000000.0], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.3e+93], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.8 \cdot 10^{+253}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;n \leq -4.6:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;n \leq 2.05 \cdot 10^{-198}:\\
\;\;\;\;\frac{\frac{-0.25}{n}}{-{x}^{4}}\\
\mathbf{elif}\;n \leq 16200000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 3.3 \cdot 10^{+93}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if n < -9.8000000000000002e253Initial program 29.1%
Taylor expanded in n around inf 99.5%
log1p-define99.5%
Simplified99.5%
Taylor expanded in x around 0 79.0%
neg-mul-179.0%
Simplified79.0%
if -9.8000000000000002e253 < n < -4.5999999999999996Initial program 33.6%
Taylor expanded in n around inf 71.9%
log1p-define71.9%
Simplified71.9%
Taylor expanded in x around inf 57.8%
*-commutative57.8%
Simplified57.8%
inv-pow57.8%
unpow-prod-down60.4%
inv-pow60.4%
inv-pow60.4%
Applied egg-rr60.4%
if -4.5999999999999996 < n < 2.05000000000000006e-198Initial program 93.3%
Taylor expanded in n around inf 47.8%
log1p-define47.8%
Simplified47.8%
Taylor expanded in x around -inf 1.5%
mul-1-neg1.5%
Simplified1.5%
add-sqr-sqrt1.5%
sqrt-unprod46.6%
sqr-neg46.6%
sqrt-unprod42.9%
add-sqr-sqrt51.4%
neg-sub051.4%
associate-/r*51.4%
sub-div51.4%
Applied egg-rr51.4%
neg-sub051.4%
distribute-neg-frac51.4%
distribute-neg-frac51.4%
mul-1-neg51.4%
sub-neg51.4%
metadata-eval51.4%
associate-*r/51.4%
metadata-eval51.4%
distribute-lft-in51.4%
neg-mul-151.4%
associate-*r/51.4%
metadata-eval51.4%
distribute-neg-frac51.4%
metadata-eval51.4%
metadata-eval51.4%
Simplified51.4%
Taylor expanded in x around 0 85.8%
associate-/r*85.8%
Simplified85.8%
if 2.05000000000000006e-198 < n < 1.62e10Initial program 78.9%
Taylor expanded in x around 0 75.5%
*-rgt-identity75.5%
associate-/l*75.5%
exp-to-pow75.5%
Simplified75.5%
if 1.62e10 < n < 3.30000000000000009e93Initial program 6.7%
Taylor expanded in n around inf 73.2%
log1p-define73.2%
Simplified73.2%
Taylor expanded in x around 0 68.3%
if 3.30000000000000009e93 < n Initial program 40.6%
Taylor expanded in n around inf 78.1%
log1p-define78.1%
Simplified78.1%
Taylor expanded in x around -inf 63.1%
mul-1-neg63.1%
mul-1-neg63.1%
associate-*r/63.1%
metadata-eval63.1%
*-commutative63.1%
associate-*r/63.1%
metadata-eval63.1%
Simplified63.1%
Final simplification72.4%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -20.0)
(/ (/ -0.25 n) (- (pow x 4.0)))
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2e+197)
(- 1.0 (pow x (/ 1.0 n)))
(/ (- (/ 1.0 n) (/ (+ (/ (/ -0.25 (* n x)) x) (/ 0.5 n)) x)) x)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20.0) {
tmp = (-0.25 / n) / -pow(x, 4.0);
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+197) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-20.0d0)) then
tmp = ((-0.25d0) / n) / -(x ** 4.0d0)
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2d+197) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = ((1.0d0 / n) - (((((-0.25d0) / (n * x)) / x) + (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20.0) {
tmp = (-0.25 / n) / -Math.pow(x, 4.0);
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+197) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -20.0: tmp = (-0.25 / n) / -math.pow(x, 4.0) elif (1.0 / n) <= 5e-13: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+197: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -20.0) tmp = Float64(Float64(-0.25 / n) / Float64(-(x ^ 4.0))); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+197) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(Float64(-0.25 / Float64(n * x)) / x) + Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -20.0) tmp = (-0.25 / n) / -(x ^ 4.0); elseif ((1.0 / n) <= 5e-13) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2e+197) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -20.0], N[(N[(-0.25 / n), $MachinePrecision] / (-N[Power[x, 4.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+197], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(N[(-0.25 / N[(n * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -20:\\
\;\;\;\;\frac{\frac{-0.25}{n}}{-{x}^{4}}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+197}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} - \frac{\frac{\frac{-0.25}{n \cdot x}}{x} + \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf 50.8%
log1p-define50.8%
Simplified50.8%
Taylor expanded in x around -inf 1.7%
mul-1-neg1.7%
Simplified1.7%
add-sqr-sqrt1.7%
sqrt-unprod51.3%
sqr-neg51.3%
sqrt-unprod47.2%
add-sqr-sqrt48.9%
neg-sub048.9%
associate-/r*48.9%
sub-div48.9%
Applied egg-rr48.9%
neg-sub048.9%
distribute-neg-frac48.9%
distribute-neg-frac48.9%
mul-1-neg48.9%
sub-neg48.9%
metadata-eval48.9%
associate-*r/48.9%
metadata-eval48.9%
distribute-lft-in48.9%
neg-mul-148.9%
associate-*r/48.9%
metadata-eval48.9%
distribute-neg-frac48.9%
metadata-eval48.9%
metadata-eval48.9%
Simplified48.9%
Taylor expanded in x around 0 86.7%
associate-/r*86.7%
Simplified86.7%
if -20 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e-13Initial program 32.3%
Taylor expanded in n around inf 76.1%
log1p-define76.1%
Simplified76.1%
log1p-undefine76.1%
diff-log76.4%
Applied egg-rr76.4%
+-commutative76.4%
Simplified76.4%
if 4.9999999999999999e-13 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e197Initial program 78.9%
Taylor expanded in x around 0 75.5%
*-rgt-identity75.5%
associate-/l*75.5%
exp-to-pow75.5%
Simplified75.5%
if 1.9999999999999999e197 < (/.f64 #s(literal 1 binary64) n) Initial program 27.3%
Taylor expanded in n around inf 18.9%
log1p-define18.9%
Simplified18.9%
Taylor expanded in x around -inf 0.1%
mul-1-neg0.1%
Simplified0.1%
add-sqr-sqrt0.1%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.0%
add-sqr-sqrt76.4%
neg-sub076.4%
associate-/r*76.4%
sub-div76.4%
Applied egg-rr76.4%
neg-sub076.4%
distribute-neg-frac76.4%
distribute-neg-frac76.4%
mul-1-neg76.4%
sub-neg76.4%
metadata-eval76.4%
associate-*r/76.4%
metadata-eval76.4%
distribute-lft-in76.4%
neg-mul-176.4%
associate-*r/76.4%
metadata-eval76.4%
distribute-neg-frac76.4%
metadata-eval76.4%
metadata-eval76.4%
Simplified76.4%
Taylor expanded in x around 0 76.4%
*-commutative76.4%
Simplified76.4%
Final simplification79.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-68)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2e+197)
(- 1.0 t_0)
(/ (- (/ 1.0 n) (/ (+ (/ (/ -0.25 (* n x)) x) (/ 0.5 n)) x)) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+197) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-4d-68)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2d+197) then
tmp = 1.0d0 - t_0
else
tmp = ((1.0d0 / n) - (((((-0.25d0) / (n * x)) / x) + (0.5d0 / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-68) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+197) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-68: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-13: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+197: tmp = 1.0 - t_0 else: tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-68) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+197) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(Float64(-0.25 / Float64(n * x)) / x) + Float64(0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -4e-68) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-13) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2e+197) tmp = 1.0 - t_0; else tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-68], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+197], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(N[(-0.25 / N[(n * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+197}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} - \frac{\frac{\frac{-0.25}{n \cdot x}}{x} + \frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.00000000000000027e-68Initial program 84.2%
Taylor expanded in x around inf 93.6%
associate-/r*93.6%
mul-1-neg93.6%
log-rec93.6%
mul-1-neg93.6%
distribute-neg-frac93.6%
mul-1-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
Simplified93.6%
if -4.00000000000000027e-68 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e-13Initial program 34.8%
Taylor expanded in n around inf 80.7%
log1p-define80.7%
Simplified80.7%
log1p-undefine80.7%
diff-log80.9%
Applied egg-rr80.9%
+-commutative80.9%
Simplified80.9%
if 4.9999999999999999e-13 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e197Initial program 78.9%
Taylor expanded in x around 0 75.5%
*-rgt-identity75.5%
associate-/l*75.5%
exp-to-pow75.5%
Simplified75.5%
if 1.9999999999999999e197 < (/.f64 #s(literal 1 binary64) n) Initial program 27.3%
Taylor expanded in n around inf 18.9%
log1p-define18.9%
Simplified18.9%
Taylor expanded in x around -inf 0.1%
mul-1-neg0.1%
Simplified0.1%
add-sqr-sqrt0.1%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.0%
add-sqr-sqrt76.4%
neg-sub076.4%
associate-/r*76.4%
sub-div76.4%
Applied egg-rr76.4%
neg-sub076.4%
distribute-neg-frac76.4%
distribute-neg-frac76.4%
mul-1-neg76.4%
sub-neg76.4%
metadata-eval76.4%
associate-*r/76.4%
metadata-eval76.4%
distribute-lft-in76.4%
neg-mul-176.4%
associate-*r/76.4%
metadata-eval76.4%
distribute-neg-frac76.4%
metadata-eval76.4%
metadata-eval76.4%
Simplified76.4%
Taylor expanded in x around 0 76.4%
*-commutative76.4%
Simplified76.4%
Final simplification85.0%
(FPCore (x n)
:precision binary64
(if (<= x 3.9e-184)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 2.6e-89)
(/ (log x) (- n))
(if (<= x 2.4e-84)
(/ (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (- x)) n)
(if (<= x 0.9)
(/ (- x (log x)) n)
(/
(+
(/ 1.0 n)
(/ (+ (/ (/ (- 0.3333333333333333 (/ 0.25 x)) x) n) (/ -0.5 n)) x))
x))))))
double code(double x, double n) {
double tmp;
if (x <= 3.9e-184) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 2.6e-89) {
tmp = log(x) / -n;
} else if (x <= 2.4e-84) {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.9d-184) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 2.6d-89) then
tmp = log(x) / -n
else if (x <= 2.4d-84) then
tmp = (((-1.0d0) + ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / -x) / n
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / n) + (((((0.3333333333333333d0 - (0.25d0 / x)) / x) / n) + ((-0.5d0) / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.9e-184) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 2.6e-89) {
tmp = Math.log(x) / -n;
} else if (x <= 2.4e-84) {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.9e-184: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 2.6e-89: tmp = math.log(x) / -n elif x <= 2.4e-84: tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n elif x <= 0.9: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 3.9e-184) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 2.6e-89) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 2.4e-84) tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(-x)) / n); elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 / x)) / x) / n) + Float64(-0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.9e-184) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 2.6e-89) tmp = log(x) / -n; elseif (x <= 2.4e-84) tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n; elseif (x <= 0.9) tmp = (x - log(x)) / n; else tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.9e-184], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e-89], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.4e-84], N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(0.3333333333333333 - N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.9 \cdot 10^{-184}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-89}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-84}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{-x}}{n}\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.3333333333333333 - \frac{0.25}{x}}{x}}{n} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 3.89999999999999994e-184Initial program 68.3%
Taylor expanded in x around 0 68.3%
*-rgt-identity68.3%
associate-/l*68.3%
exp-to-pow68.3%
Simplified68.3%
if 3.89999999999999994e-184 < x < 2.5999999999999999e-89Initial program 40.5%
Taylor expanded in n around inf 63.7%
log1p-define63.7%
Simplified63.7%
Taylor expanded in x around 0 63.7%
neg-mul-163.7%
Simplified63.7%
if 2.5999999999999999e-89 < x < 2.40000000000000017e-84Initial program 80.6%
Taylor expanded in n around inf 4.4%
log1p-define4.4%
Simplified4.4%
expm1-log1p-u4.4%
Applied egg-rr4.4%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
associate-*r/100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-lft-in100.0%
neg-mul-1100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
if 2.40000000000000017e-84 < x < 0.900000000000000022Initial program 31.9%
Taylor expanded in n around inf 59.2%
log1p-define59.2%
Simplified59.2%
Taylor expanded in x around 0 55.1%
if 0.900000000000000022 < x Initial program 69.1%
Taylor expanded in n around inf 70.1%
log1p-define70.1%
Simplified70.1%
add-exp-log70.1%
Applied egg-rr70.1%
Taylor expanded in x around -inf 67.0%
Simplified67.0%
Final simplification65.4%
(FPCore (x n)
:precision binary64
(if (<= x 1.12e-89)
(/ (log x) (- n))
(if (<= x 2.4e-84)
(/ (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (- x)) n)
(if (<= x 0.9)
(/ (- x (log x)) n)
(/
(+
(/ 1.0 n)
(/ (+ (/ (/ (- 0.3333333333333333 (/ 0.25 x)) x) n) (/ -0.5 n)) x))
x)))))
double code(double x, double n) {
double tmp;
if (x <= 1.12e-89) {
tmp = log(x) / -n;
} else if (x <= 2.4e-84) {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.12d-89) then
tmp = log(x) / -n
else if (x <= 2.4d-84) then
tmp = (((-1.0d0) + ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / -x) / n
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / n) + (((((0.3333333333333333d0 - (0.25d0 / x)) / x) / n) + ((-0.5d0) / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.12e-89) {
tmp = Math.log(x) / -n;
} else if (x <= 2.4e-84) {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.12e-89: tmp = math.log(x) / -n elif x <= 2.4e-84: tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n elif x <= 0.9: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 1.12e-89) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 2.4e-84) tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(-x)) / n); elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 / x)) / x) / n) + Float64(-0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.12e-89) tmp = log(x) / -n; elseif (x <= 2.4e-84) tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n; elseif (x <= 0.9) tmp = (x - log(x)) / n; else tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.12e-89], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.4e-84], N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(0.3333333333333333 - N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.12 \cdot 10^{-89}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-84}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{-x}}{n}\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.3333333333333333 - \frac{0.25}{x}}{x}}{n} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 1.12e-89Initial program 55.4%
Taylor expanded in n around inf 48.3%
log1p-define48.3%
Simplified48.3%
Taylor expanded in x around 0 48.3%
neg-mul-148.3%
Simplified48.3%
if 1.12e-89 < x < 2.40000000000000017e-84Initial program 80.6%
Taylor expanded in n around inf 4.4%
log1p-define4.4%
Simplified4.4%
expm1-log1p-u4.4%
Applied egg-rr4.4%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
associate-*r/100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-lft-in100.0%
neg-mul-1100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
if 2.40000000000000017e-84 < x < 0.900000000000000022Initial program 31.9%
Taylor expanded in n around inf 59.2%
log1p-define59.2%
Simplified59.2%
Taylor expanded in x around 0 55.1%
if 0.900000000000000022 < x Initial program 69.1%
Taylor expanded in n around inf 70.1%
log1p-define70.1%
Simplified70.1%
add-exp-log70.1%
Applied egg-rr70.1%
Taylor expanded in x around -inf 67.0%
Simplified67.0%
Final simplification58.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.7e-89)
t_0
(if (<= x 2.4e-84)
(/ (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (- x)) n)
(if (<= x 0.72)
t_0
(/
(+
(/ 1.0 n)
(/ (+ (/ (/ (- 0.3333333333333333 (/ 0.25 x)) x) n) (/ -0.5 n)) x))
x))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.7e-89) {
tmp = t_0;
} else if (x <= 2.4e-84) {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
} else if (x <= 0.72) {
tmp = t_0;
} else {
tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 1.7d-89) then
tmp = t_0
else if (x <= 2.4d-84) then
tmp = (((-1.0d0) + ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / -x) / n
else if (x <= 0.72d0) then
tmp = t_0
else
tmp = ((1.0d0 / n) + (((((0.3333333333333333d0 - (0.25d0 / x)) / x) / n) + ((-0.5d0) / n)) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 1.7e-89) {
tmp = t_0;
} else if (x <= 2.4e-84) {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
} else if (x <= 0.72) {
tmp = t_0;
} else {
tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.7e-89: tmp = t_0 elif x <= 2.4e-84: tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n elif x <= 0.72: tmp = t_0 else: tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.7e-89) tmp = t_0; elseif (x <= 2.4e-84) tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(-x)) / n); elseif (x <= 0.72) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 / x)) / x) / n) + Float64(-0.5 / n)) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.7e-89) tmp = t_0; elseif (x <= 2.4e-84) tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n; elseif (x <= 0.72) tmp = t_0; else tmp = ((1.0 / n) + (((((0.3333333333333333 - (0.25 / x)) / x) / n) + (-0.5 / n)) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.7e-89], t$95$0, If[LessEqual[x, 2.4e-84], N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 0.72], t$95$0, N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(0.3333333333333333 - N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.7 \cdot 10^{-89}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-84}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{-x}}{n}\\
\mathbf{elif}\;x \leq 0.72:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.3333333333333333 - \frac{0.25}{x}}{x}}{n} + \frac{-0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 1.7e-89 or 2.40000000000000017e-84 < x < 0.71999999999999997Initial program 48.2%
Taylor expanded in n around inf 51.6%
log1p-define51.6%
Simplified51.6%
Taylor expanded in x around 0 50.0%
neg-mul-150.0%
Simplified50.0%
if 1.7e-89 < x < 2.40000000000000017e-84Initial program 80.6%
Taylor expanded in n around inf 4.4%
log1p-define4.4%
Simplified4.4%
expm1-log1p-u4.4%
Applied egg-rr4.4%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
associate-*r/100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-lft-in100.0%
neg-mul-1100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
if 0.71999999999999997 < x Initial program 69.1%
Taylor expanded in n around inf 70.1%
log1p-define70.1%
Simplified70.1%
add-exp-log70.1%
Applied egg-rr70.1%
Taylor expanded in x around -inf 67.0%
Simplified67.0%
Final simplification58.5%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ -0.5 (/ (+ -0.3333333333333333 (/ 0.25 x)) x)) (* n x))) x))
double code(double x, double n) {
return ((1.0 / n) + ((-0.5 + ((-0.3333333333333333 + (0.25 / x)) / x)) / (n * x))) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((-0.5d0) + (((-0.3333333333333333d0) + (0.25d0 / x)) / x)) / (n * x))) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + ((-0.5 + ((-0.3333333333333333 + (0.25 / x)) / x)) / (n * x))) / x;
}
def code(x, n): return ((1.0 / n) + ((-0.5 + ((-0.3333333333333333 + (0.25 / x)) / x)) / (n * x))) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(-0.5 + Float64(Float64(-0.3333333333333333 + Float64(0.25 / x)) / x)) / Float64(n * x))) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + ((-0.5 + ((-0.3333333333333333 + (0.25 / x)) / x)) / (n * x))) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(-0.5 + N[(N[(-0.3333333333333333 + N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{-0.5 + \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{n \cdot x}}{x}
\end{array}
Initial program 58.1%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around -inf 30.3%
mul-1-neg30.3%
Simplified30.3%
add-sqr-sqrt22.9%
sqrt-unprod45.6%
sqr-neg45.6%
sqrt-unprod36.4%
add-sqr-sqrt48.9%
neg-sub048.9%
associate-/r*48.9%
sub-div48.9%
Applied egg-rr48.9%
neg-sub048.9%
distribute-neg-frac48.9%
distribute-neg-frac48.9%
mul-1-neg48.9%
sub-neg48.9%
metadata-eval48.9%
associate-*r/48.9%
metadata-eval48.9%
distribute-lft-in48.9%
neg-mul-148.9%
associate-*r/48.9%
metadata-eval48.9%
distribute-neg-frac48.9%
metadata-eval48.9%
metadata-eval48.9%
Simplified48.9%
Taylor expanded in n around -inf 48.9%
Simplified48.9%
Final simplification48.9%
(FPCore (x n) :precision binary64 (/ (- (/ 1.0 n) (/ (+ (/ (/ -0.25 (* n x)) x) (/ 0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) - (((((-0.25d0) / (n * x)) / x) + (0.5d0 / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(Float64(-0.25 / Float64(n * x)) / x) + Float64(0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) - ((((-0.25 / (n * x)) / x) + (0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(N[(-0.25 / N[(n * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} - \frac{\frac{\frac{-0.25}{n \cdot x}}{x} + \frac{0.5}{n}}{x}}{x}
\end{array}
Initial program 58.1%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around -inf 30.3%
mul-1-neg30.3%
Simplified30.3%
add-sqr-sqrt22.9%
sqrt-unprod45.6%
sqr-neg45.6%
sqrt-unprod36.4%
add-sqr-sqrt48.9%
neg-sub048.9%
associate-/r*48.9%
sub-div48.9%
Applied egg-rr48.9%
neg-sub048.9%
distribute-neg-frac48.9%
distribute-neg-frac48.9%
mul-1-neg48.9%
sub-neg48.9%
metadata-eval48.9%
associate-*r/48.9%
metadata-eval48.9%
distribute-lft-in48.9%
neg-mul-148.9%
associate-*r/48.9%
metadata-eval48.9%
distribute-neg-frac48.9%
metadata-eval48.9%
metadata-eval48.9%
Simplified48.9%
Taylor expanded in x around 0 48.9%
*-commutative48.9%
Simplified48.9%
Final simplification48.9%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* n x)) (/ 0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) - (0.5d0 / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) - Float64(0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}
\end{array}
Initial program 58.1%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around -inf 48.8%
mul-1-neg48.8%
mul-1-neg48.8%
associate-*r/48.8%
metadata-eval48.8%
*-commutative48.8%
associate-*r/48.8%
metadata-eval48.8%
Simplified48.8%
Final simplification48.8%
(FPCore (x n) :precision binary64 (/ (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (- x)) n))
double code(double x, double n) {
return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (((-1.0d0) + ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / -x) / n
end function
public static double code(double x, double n) {
return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
}
def code(x, n): return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n
function code(x, n) return Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(-x)) / n) end
function tmp = code(x, n) tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n; end
code[x_, n_] := N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{-x}}{n}
\end{array}
Initial program 58.1%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
expm1-log1p-u58.6%
Applied egg-rr58.6%
Taylor expanded in x around -inf 48.8%
mul-1-neg48.8%
distribute-neg-frac248.8%
sub-neg48.8%
associate-*r/48.8%
sub-neg48.8%
metadata-eval48.8%
distribute-lft-in48.8%
neg-mul-148.8%
associate-*r/48.8%
metadata-eval48.8%
distribute-neg-frac48.8%
metadata-eval48.8%
metadata-eval48.8%
metadata-eval48.8%
Simplified48.8%
Final simplification48.8%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 58.1%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 40.1%
*-commutative40.1%
Simplified40.1%
Final simplification40.1%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 58.1%
Taylor expanded in n around inf 58.9%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 40.1%
*-commutative40.1%
Simplified40.1%
Taylor expanded in x around 0 40.1%
associate-/r*40.7%
Simplified40.7%
Final simplification40.7%
herbie shell --seed 2024079
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))