
(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 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(if (<= x 330.0)
(/
(log
(/
x
(exp
(+
(log1p x)
(/
(fma
0.5
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
(*
0.16666666666666666
(/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)))
n)))))
(- n))
(/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 330.0) {
tmp = log((x / exp((log1p(x) + (fma(0.5, (pow(log1p(x), 2.0) - pow(log(x), 2.0)), (0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n))) / n))))) / -n;
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 330.0) tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(0.5, Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n))))) / Float64(-n)); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 330.0], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 330:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(0.5, {\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}\right)}{n}}}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 330Initial program 48.4%
Taylor expanded in n around -inf 74.9%
Simplified74.9%
add-log-exp83.2%
diff-log83.2%
fma-define83.2%
Applied egg-rr83.2%
if 330 < x Initial program 68.6%
Taylor expanded in x around inf 98.5%
mul-1-neg98.5%
log-rec98.5%
mul-1-neg98.5%
distribute-neg-frac98.5%
mul-1-neg98.5%
remove-double-neg98.5%
*-rgt-identity98.5%
associate-/l*98.5%
exp-to-pow98.5%
*-commutative98.5%
Simplified98.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (- (pow (+ x 1.0) (/ 1.0 n)) t_0) 2e-8)
(/
(log
(/
(*
(sqrt (exp (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)))
(+ x 1.0))
x))
n)
(- (exp (* x (+ (/ 1.0 n) (* -0.5 (/ x n))))) t_0))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((pow((x + 1.0), (1.0 / n)) - t_0) <= 2e-8) {
tmp = log(((sqrt(exp(((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n))) * (x + 1.0)) / x)) / n;
} else {
tmp = exp((x * ((1.0 / n) + (-0.5 * (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 ((Math.pow((x + 1.0), (1.0 / n)) - t_0) <= 2e-8) {
tmp = Math.log(((Math.sqrt(Math.exp(((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n))) * (x + 1.0)) / x)) / n;
} else {
tmp = Math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (math.pow((x + 1.0), (1.0 / n)) - t_0) <= 2e-8: tmp = math.log(((math.sqrt(math.exp(((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n))) * (x + 1.0)) / x)) / n else: tmp = math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) <= 2e-8) tmp = Float64(log(Float64(Float64(sqrt(exp(Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n))) * Float64(x + 1.0)) / x)) / n); else tmp = Float64(exp(Float64(x * Float64(Float64(1.0 / n) + Float64(-0.5 * 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[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], 2e-8], N[(N[Log[N[(N[(N[Sqrt[N[Exp[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[(x + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(-0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot \left(x + 1\right)}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 2e-8Initial program 53.3%
Taylor expanded in n around inf 77.1%
associate--l+62.2%
log1p-define62.2%
+-commutative62.2%
associate--r+77.1%
distribute-lft-out--77.1%
div-sub78.1%
log1p-define78.1%
Simplified78.1%
add-log-exp85.5%
associate-+r-85.5%
exp-diff85.5%
add-exp-log57.3%
Applied egg-rr57.3%
+-commutative57.3%
exp-sum57.3%
*-commutative57.3%
exp-prod57.3%
unpow1/257.3%
log1p-define57.3%
rem-exp-log85.6%
Simplified85.6%
if 2e-8 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 71.2%
Taylor expanded in n around 0 71.2%
log1p-define97.5%
*-rgt-identity97.5%
associate-/l*97.5%
exp-to-pow97.5%
Simplified97.5%
Taylor expanded in x around 0 97.5%
Final simplification87.4%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -40.0)
(-
(pow (+ x 1.0) (/ 1.0 n))
(* (pow (pow (cbrt x) 2.0) (/ 1.0 n)) (pow (cbrt x) (/ 1.0 n))))
(if (<= (/ 1.0 n) 5e-11)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(- (exp (* x (+ (/ 1.0 n) (* -0.5 (/ x n))))) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = pow((x + 1.0), (1.0 / n)) - (pow(pow(cbrt(x), 2.0), (1.0 / n)) * pow(cbrt(x), (1.0 / n)));
} else if ((1.0 / n) <= 5e-11) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else {
tmp = exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = Math.pow((x + 1.0), (1.0 / n)) - (Math.pow(Math.pow(Math.cbrt(x), 2.0), (1.0 / n)) * Math.pow(Math.cbrt(x), (1.0 / n)));
} else if ((1.0 / n) <= 5e-11) {
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 * ((1.0 / n) + (-0.5 * (x / n))))) - Math.pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -40.0) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - Float64(((cbrt(x) ^ 2.0) ^ Float64(1.0 / n)) * (cbrt(x) ^ Float64(1.0 / n)))); elseif (Float64(1.0 / n) <= 5e-11) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); else tmp = Float64(exp(Float64(x * Float64(Float64(1.0 / n) + Float64(-0.5 * Float64(x / n))))) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -40.0], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] * N[Power[N[Power[x, 1/3], $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-11], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(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] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(-0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -40:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -40Initial program 99.9%
add-cube-cbrt99.9%
unpow-prod-down100.0%
pow2100.0%
Applied egg-rr100.0%
if -40 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000018e-11Initial program 27.5%
Taylor expanded in n around inf 78.9%
associate--l+78.9%
log1p-define78.9%
+-commutative78.9%
associate--r+78.9%
distribute-lft-out--78.9%
div-sub78.9%
log1p-define78.9%
Simplified78.9%
if 5.00000000000000018e-11 < (/.f64 #s(literal 1 binary64) n) Initial program 71.2%
Taylor expanded in n around 0 71.2%
log1p-define97.5%
*-rgt-identity97.5%
associate-/l*97.5%
exp-to-pow97.5%
Simplified97.5%
Taylor expanded in x around 0 97.5%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow (sqrt x) (/ 1.0 n))))
(if (<= (/ 1.0 n) -40.0)
(- (pow (+ x 1.0) (/ 1.0 n)) (* t_0 t_0))
(if (<= (/ 1.0 n) 5e-11)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(- (exp (* x (+ (/ 1.0 n) (* -0.5 (/ x n))))) (pow x (/ 1.0 n)))))))
double code(double x, double n) {
double t_0 = pow(sqrt(x), (1.0 / n));
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = pow((x + 1.0), (1.0 / n)) - (t_0 * t_0);
} else if ((1.0 / n) <= 5e-11) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else {
tmp = exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(Math.sqrt(x), (1.0 / n));
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = Math.pow((x + 1.0), (1.0 / n)) - (t_0 * t_0);
} else if ((1.0 / n) <= 5e-11) {
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 * ((1.0 / n) + (-0.5 * (x / n))))) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): t_0 = math.pow(math.sqrt(x), (1.0 / n)) tmp = 0 if (1.0 / n) <= -40.0: tmp = math.pow((x + 1.0), (1.0 / n)) - (t_0 * t_0) elif (1.0 / n) <= 5e-11: 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 * ((1.0 / n) + (-0.5 * (x / n))))) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) t_0 = sqrt(x) ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -40.0) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - Float64(t_0 * t_0)); elseif (Float64(1.0 / n) <= 5e-11) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); else tmp = Float64(exp(Float64(x * Float64(Float64(1.0 / n) + Float64(-0.5 * Float64(x / n))))) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[N[Sqrt[x], $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40.0], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-11], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(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] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(-0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sqrt{x}\right)}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -40:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0 \cdot t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -40Initial program 99.9%
add-sqr-sqrt99.9%
unpow-prod-down99.9%
Applied egg-rr99.9%
if -40 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000018e-11Initial program 27.5%
Taylor expanded in n around inf 78.9%
associate--l+78.9%
log1p-define78.9%
+-commutative78.9%
associate--r+78.9%
distribute-lft-out--78.9%
div-sub78.9%
log1p-define78.9%
Simplified78.9%
if 5.00000000000000018e-11 < (/.f64 #s(literal 1 binary64) n) Initial program 71.2%
Taylor expanded in n around 0 71.2%
log1p-define97.5%
*-rgt-identity97.5%
associate-/l*97.5%
exp-to-pow97.5%
Simplified97.5%
Taylor expanded in x around 0 97.5%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -2e-12)
(- (pow (+ x 1.0) (/ 1.0 n)) (pow (sqrt x) (/ 2.0 n)))
(if (<= (/ 1.0 n) 5e-12)
(/ (log (+ (+ 1.0 (/ (/ (log x) n) x)) (/ 1.0 x))) n)
(log
(exp
(- (exp (* x (+ (/ 1.0 n) (* -0.5 (/ x n))))) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-12) {
tmp = pow((x + 1.0), (1.0 / n)) - pow(sqrt(x), (2.0 / n));
} else if ((1.0 / n) <= 5e-12) {
tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n;
} else {
tmp = log(exp((exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - pow(x, (1.0 / n)))));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-2d-12)) then
tmp = ((x + 1.0d0) ** (1.0d0 / n)) - (sqrt(x) ** (2.0d0 / n))
else if ((1.0d0 / n) <= 5d-12) then
tmp = log(((1.0d0 + ((log(x) / n) / x)) + (1.0d0 / x))) / n
else
tmp = log(exp((exp((x * ((1.0d0 / n) + ((-0.5d0) * (x / n))))) - (x ** (1.0d0 / n)))))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-12) {
tmp = Math.pow((x + 1.0), (1.0 / n)) - Math.pow(Math.sqrt(x), (2.0 / n));
} else if ((1.0 / n) <= 5e-12) {
tmp = Math.log(((1.0 + ((Math.log(x) / n) / x)) + (1.0 / x))) / n;
} else {
tmp = Math.log(Math.exp((Math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - Math.pow(x, (1.0 / n)))));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e-12: tmp = math.pow((x + 1.0), (1.0 / n)) - math.pow(math.sqrt(x), (2.0 / n)) elif (1.0 / n) <= 5e-12: tmp = math.log(((1.0 + ((math.log(x) / n) / x)) + (1.0 / x))) / n else: tmp = math.log(math.exp((math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - math.pow(x, (1.0 / n))))) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-12) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (sqrt(x) ^ Float64(2.0 / n))); elseif (Float64(1.0 / n) <= 5e-12) tmp = Float64(log(Float64(Float64(1.0 + Float64(Float64(log(x) / n) / x)) + Float64(1.0 / x))) / n); else tmp = log(exp(Float64(exp(Float64(x * Float64(Float64(1.0 / n) + Float64(-0.5 * Float64(x / n))))) - (x ^ Float64(1.0 / n))))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -2e-12) tmp = ((x + 1.0) ^ (1.0 / n)) - (sqrt(x) ^ (2.0 / n)); elseif ((1.0 / n) <= 5e-12) tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n; else tmp = log(exp((exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - (x ^ (1.0 / n))))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-12], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[N[Sqrt[x], $MachinePrecision], N[(2.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-12], N[(N[Log[N[(N[(1.0 + N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Log[N[Exp[N[(N[Exp[N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(-0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-12}:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {\left(\sqrt{x}\right)}^{\left(\frac{2}{n}\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\log \left(\left(1 + \frac{\frac{\log x}{n}}{x}\right) + \frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{e^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.99999999999999996e-12Initial program 99.2%
add-sqr-sqrt99.3%
unpow-prod-down99.1%
Applied egg-rr99.1%
pow-sqr99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
if -1.99999999999999996e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 26.5%
Taylor expanded in n around inf 78.6%
associate--l+78.6%
log1p-define78.6%
+-commutative78.6%
associate--r+78.6%
distribute-lft-out--78.6%
div-sub78.6%
log1p-define78.6%
Simplified78.6%
add-log-exp78.6%
associate-+r-78.6%
exp-diff78.5%
add-exp-log58.8%
Applied egg-rr58.8%
+-commutative58.8%
exp-sum58.8%
*-commutative58.8%
exp-prod58.8%
unpow1/258.8%
log1p-define58.8%
rem-exp-log78.6%
Simplified78.6%
Taylor expanded in x around inf 78.4%
associate-+r+78.4%
mul-1-neg78.4%
associate-/r*78.4%
distribute-neg-frac78.4%
log-rec78.4%
distribute-neg-frac78.4%
remove-double-neg78.4%
Simplified78.4%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 71.0%
add-log-exp71.2%
pow-to-exp71.2%
un-div-inv71.2%
+-commutative71.2%
log1p-define96.8%
Applied egg-rr96.8%
Taylor expanded in x around 0 96.8%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -2e-12)
(- (pow (+ x 1.0) (/ 1.0 n)) (pow (sqrt x) (/ 2.0 n)))
(if (<= (/ 1.0 n) 5e-12)
(/ (log (+ (+ 1.0 (/ (/ (log x) n) x)) (/ 1.0 x))) n)
(- (exp (* x (+ (/ 1.0 n) (* -0.5 (/ x n))))) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-12) {
tmp = pow((x + 1.0), (1.0 / n)) - pow(sqrt(x), (2.0 / n));
} else if ((1.0 / n) <= 5e-12) {
tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n;
} else {
tmp = exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - pow(x, (1.0 / n));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-2d-12)) then
tmp = ((x + 1.0d0) ** (1.0d0 / n)) - (sqrt(x) ** (2.0d0 / n))
else if ((1.0d0 / n) <= 5d-12) then
tmp = log(((1.0d0 + ((log(x) / n) / x)) + (1.0d0 / x))) / n
else
tmp = exp((x * ((1.0d0 / n) + ((-0.5d0) * (x / n))))) - (x ** (1.0d0 / n))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -2e-12) {
tmp = Math.pow((x + 1.0), (1.0 / n)) - Math.pow(Math.sqrt(x), (2.0 / n));
} else if ((1.0 / n) <= 5e-12) {
tmp = Math.log(((1.0 + ((Math.log(x) / n) / x)) + (1.0 / x))) / n;
} else {
tmp = Math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -2e-12: tmp = math.pow((x + 1.0), (1.0 / n)) - math.pow(math.sqrt(x), (2.0 / n)) elif (1.0 / n) <= 5e-12: tmp = math.log(((1.0 + ((math.log(x) / n) / x)) + (1.0 / x))) / n else: tmp = math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-12) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (sqrt(x) ^ Float64(2.0 / n))); elseif (Float64(1.0 / n) <= 5e-12) tmp = Float64(log(Float64(Float64(1.0 + Float64(Float64(log(x) / n) / x)) + Float64(1.0 / x))) / n); else tmp = Float64(exp(Float64(x * Float64(Float64(1.0 / n) + Float64(-0.5 * Float64(x / n))))) - (x ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -2e-12) tmp = ((x + 1.0) ^ (1.0 / n)) - (sqrt(x) ^ (2.0 / n)); elseif ((1.0 / n) <= 5e-12) tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n; else tmp = exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - (x ^ (1.0 / n)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-12], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[N[Sqrt[x], $MachinePrecision], N[(2.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-12], N[(N[Log[N[(N[(1.0 + N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(-0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-12}:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {\left(\sqrt{x}\right)}^{\left(\frac{2}{n}\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\log \left(\left(1 + \frac{\frac{\log x}{n}}{x}\right) + \frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.99999999999999996e-12Initial program 99.2%
add-sqr-sqrt99.3%
unpow-prod-down99.1%
Applied egg-rr99.1%
pow-sqr99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
if -1.99999999999999996e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 26.5%
Taylor expanded in n around inf 78.6%
associate--l+78.6%
log1p-define78.6%
+-commutative78.6%
associate--r+78.6%
distribute-lft-out--78.6%
div-sub78.6%
log1p-define78.6%
Simplified78.6%
add-log-exp78.6%
associate-+r-78.6%
exp-diff78.5%
add-exp-log58.8%
Applied egg-rr58.8%
+-commutative58.8%
exp-sum58.8%
*-commutative58.8%
exp-prod58.8%
unpow1/258.8%
log1p-define58.8%
rem-exp-log78.6%
Simplified78.6%
Taylor expanded in x around inf 78.4%
associate-+r+78.4%
mul-1-neg78.4%
associate-/r*78.4%
distribute-neg-frac78.4%
log-rec78.4%
distribute-neg-frac78.4%
remove-double-neg78.4%
Simplified78.4%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 71.0%
Taylor expanded in n around 0 71.0%
log1p-define96.6%
*-rgt-identity96.6%
associate-/l*96.6%
exp-to-pow96.6%
Simplified96.6%
Taylor expanded in x around 0 96.6%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-12)
(- (exp (/ x n)) t_0)
(if (<= (/ 1.0 n) 5e-12)
(/ (log (+ (+ 1.0 (/ (/ (log x) n) x)) (/ 1.0 x))) n)
(- (exp (* x (+ (/ 1.0 n) (* -0.5 (/ x n))))) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-12) {
tmp = exp((x / n)) - t_0;
} else if ((1.0 / n) <= 5e-12) {
tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n;
} else {
tmp = exp((x * ((1.0 / n) + (-0.5 * (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) <= (-2d-12)) then
tmp = exp((x / n)) - t_0
else if ((1.0d0 / n) <= 5d-12) then
tmp = log(((1.0d0 + ((log(x) / n) / x)) + (1.0d0 / x))) / n
else
tmp = exp((x * ((1.0d0 / n) + ((-0.5d0) * (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) <= -2e-12) {
tmp = Math.exp((x / n)) - t_0;
} else if ((1.0 / n) <= 5e-12) {
tmp = Math.log(((1.0 + ((Math.log(x) / n) / x)) + (1.0 / x))) / n;
} else {
tmp = Math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-12: tmp = math.exp((x / n)) - t_0 elif (1.0 / n) <= 5e-12: tmp = math.log(((1.0 + ((math.log(x) / n) / x)) + (1.0 / x))) / n else: tmp = math.exp((x * ((1.0 / n) + (-0.5 * (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) <= -2e-12) tmp = Float64(exp(Float64(x / n)) - t_0); elseif (Float64(1.0 / n) <= 5e-12) tmp = Float64(log(Float64(Float64(1.0 + Float64(Float64(log(x) / n) / x)) + Float64(1.0 / x))) / n); else tmp = Float64(exp(Float64(x * Float64(Float64(1.0 / n) + Float64(-0.5 * 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) <= -2e-12) tmp = exp((x / n)) - t_0; elseif ((1.0 / n) <= 5e-12) tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n; else tmp = exp((x * ((1.0 / n) + (-0.5 * (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], -2e-12], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-12], N[(N[Log[N[(N[(1.0 + N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(-0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $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 -2 \cdot 10^{-12}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\log \left(\left(1 + \frac{\frac{\log x}{n}}{x}\right) + \frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.99999999999999996e-12Initial program 99.2%
Taylor expanded in n around 0 99.3%
log1p-define99.3%
*-rgt-identity99.3%
associate-/l*99.3%
exp-to-pow99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
if -1.99999999999999996e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 26.5%
Taylor expanded in n around inf 78.6%
associate--l+78.6%
log1p-define78.6%
+-commutative78.6%
associate--r+78.6%
distribute-lft-out--78.6%
div-sub78.6%
log1p-define78.6%
Simplified78.6%
add-log-exp78.6%
associate-+r-78.6%
exp-diff78.5%
add-exp-log58.8%
Applied egg-rr58.8%
+-commutative58.8%
exp-sum58.8%
*-commutative58.8%
exp-prod58.8%
unpow1/258.8%
log1p-define58.8%
rem-exp-log78.6%
Simplified78.6%
Taylor expanded in x around inf 78.4%
associate-+r+78.4%
mul-1-neg78.4%
associate-/r*78.4%
distribute-neg-frac78.4%
log-rec78.4%
distribute-neg-frac78.4%
remove-double-neg78.4%
Simplified78.4%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 71.0%
Taylor expanded in n around 0 71.0%
log1p-define96.6%
*-rgt-identity96.6%
associate-/l*96.6%
exp-to-pow96.6%
Simplified96.6%
Taylor expanded in x around 0 96.6%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -40.0)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+178)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ x n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+178) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1((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) <= -40.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+178) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1((x / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -40.0: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+178: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1((x / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -40.0) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+178) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(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], -40.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+178], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -40:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+178}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -40Initial program 99.9%
Taylor expanded in x around inf 98.9%
mul-1-neg98.9%
log-rec98.9%
mul-1-neg98.9%
distribute-neg-frac98.9%
mul-1-neg98.9%
remove-double-neg98.9%
*-rgt-identity98.9%
associate-/l*98.9%
exp-to-pow98.9%
*-commutative98.9%
Simplified98.9%
if -40 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 27.4%
Taylor expanded in n around inf 78.6%
log1p-define78.6%
Simplified78.6%
log1p-undefine78.6%
diff-log78.6%
Applied egg-rr78.6%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e178Initial program 82.9%
Taylor expanded in x around 0 77.0%
if 4.9999999999999999e178 < (/.f64 #s(literal 1 binary64) n) Initial program 31.1%
Taylor expanded in n around inf 6.7%
log1p-define6.7%
Simplified6.7%
Taylor expanded in x around inf 48.4%
*-commutative48.4%
Simplified48.4%
log1p-expm1-u73.6%
associate-/r*73.6%
add-exp-log73.6%
rec-exp73.6%
add-sqr-sqrt73.6%
sqrt-unprod73.6%
sqr-neg73.6%
sqrt-prod0.0%
add-sqr-sqrt75.7%
add-exp-log75.7%
Applied egg-rr75.7%
Final simplification84.4%
(FPCore (x n) :precision binary64 (if (or (<= n -380000000000.0) (not (<= n 23000000000.0))) (/ (log (/ (+ x 1.0) x)) n) (- (exp (/ x n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
double tmp;
if ((n <= -380000000000.0) || !(n <= 23000000000.0)) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-380000000000.0d0)) .or. (.not. (n <= 23000000000.0d0))) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = exp((x / n)) - (x ** (1.0d0 / n))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -380000000000.0) || !(n <= 23000000000.0)) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -380000000000.0) or not (n <= 23000000000.0): tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if ((n <= -380000000000.0) || !(n <= 23000000000.0)) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -380000000000.0) || ~((n <= 23000000000.0))) tmp = log(((x + 1.0) / x)) / n; else tmp = exp((x / n)) - (x ^ (1.0 / n)); end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -380000000000.0], N[Not[LessEqual[n, 23000000000.0]], $MachinePrecision]], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -380000000000 \lor \neg \left(n \leq 23000000000\right):\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if n < -3.8e11 or 2.3e10 < n Initial program 26.5%
Taylor expanded in n around inf 78.3%
log1p-define78.3%
Simplified78.3%
log1p-undefine78.3%
diff-log78.4%
Applied egg-rr78.4%
if -3.8e11 < n < 2.3e10Initial program 89.6%
Taylor expanded in n around 0 89.6%
log1p-define98.4%
*-rgt-identity98.4%
associate-/l*98.4%
exp-to-pow98.3%
Simplified98.3%
Taylor expanded in x around 0 98.3%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(if (<= n -380000000000.0)
(/ (log (+ (+ 1.0 (/ (/ (log x) n) x)) (/ 1.0 x))) n)
(if (<= n 26000000000.0)
(- (exp (/ x n)) (pow x (/ 1.0 n)))
(/ (log (/ (+ x 1.0) x)) n))))
double code(double x, double n) {
double tmp;
if (n <= -380000000000.0) {
tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n;
} else if (n <= 26000000000.0) {
tmp = exp((x / n)) - pow(x, (1.0 / n));
} else {
tmp = log(((x + 1.0) / x)) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-380000000000.0d0)) then
tmp = log(((1.0d0 + ((log(x) / n) / x)) + (1.0d0 / x))) / n
else if (n <= 26000000000.0d0) then
tmp = exp((x / n)) - (x ** (1.0d0 / n))
else
tmp = log(((x + 1.0d0) / x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -380000000000.0) {
tmp = Math.log(((1.0 + ((Math.log(x) / n) / x)) + (1.0 / x))) / n;
} else if (n <= 26000000000.0) {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = Math.log(((x + 1.0) / x)) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -380000000000.0: tmp = math.log(((1.0 + ((math.log(x) / n) / x)) + (1.0 / x))) / n elif n <= 26000000000.0: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) else: tmp = math.log(((x + 1.0) / x)) / n return tmp
function code(x, n) tmp = 0.0 if (n <= -380000000000.0) tmp = Float64(log(Float64(Float64(1.0 + Float64(Float64(log(x) / n) / x)) + Float64(1.0 / x))) / n); elseif (n <= 26000000000.0) tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -380000000000.0) tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n; elseif (n <= 26000000000.0) tmp = exp((x / n)) - (x ^ (1.0 / n)); else tmp = log(((x + 1.0) / x)) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -380000000000.0], N[(N[Log[N[(N[(1.0 + N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 26000000000.0], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -380000000000:\\
\;\;\;\;\frac{\log \left(\left(1 + \frac{\frac{\log x}{n}}{x}\right) + \frac{1}{x}\right)}{n}\\
\mathbf{elif}\;n \leq 26000000000:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\end{array}
\end{array}
if n < -3.8e11Initial program 34.4%
Taylor expanded in n around inf 76.7%
associate--l+76.7%
log1p-define76.7%
+-commutative76.7%
associate--r+76.7%
distribute-lft-out--76.7%
div-sub76.7%
log1p-define76.7%
Simplified76.7%
add-log-exp76.7%
associate-+r-76.7%
exp-diff76.7%
add-exp-log49.2%
Applied egg-rr49.2%
+-commutative49.2%
exp-sum49.2%
*-commutative49.2%
exp-prod49.2%
unpow1/249.2%
log1p-define49.2%
rem-exp-log76.9%
Simplified76.9%
Taylor expanded in x around inf 76.4%
associate-+r+76.4%
mul-1-neg76.4%
associate-/r*76.4%
distribute-neg-frac76.4%
log-rec76.4%
distribute-neg-frac76.4%
remove-double-neg76.4%
Simplified76.4%
if -3.8e11 < n < 2.6e10Initial program 89.6%
Taylor expanded in n around 0 89.6%
log1p-define98.4%
*-rgt-identity98.4%
associate-/l*98.4%
exp-to-pow98.3%
Simplified98.3%
Taylor expanded in x around 0 98.3%
if 2.6e10 < n Initial program 20.2%
Taylor expanded in n around inf 80.0%
log1p-define80.0%
Simplified80.0%
log1p-undefine80.0%
diff-log80.0%
Applied egg-rr80.0%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -40.0)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 2e-14)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+214) (- (+ 1.0 (/ x n)) t_0) (/ (/ 1.0 n) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+214) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-40.0d0)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= 2d-14) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+214) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -40.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+214) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -40.0: tmp = t_0 / (x * n) elif (1.0 / n) <= 2e-14: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+214: tmp = (1.0 + (x / n)) - t_0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -40.0) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+214) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -40.0) tmp = t_0 / (x * n); elseif ((1.0 / n) <= 2e-14) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+214) tmp = (1.0 + (x / n)) - t_0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+214], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -40:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+214}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -40Initial program 99.9%
Taylor expanded in x around inf 98.9%
mul-1-neg98.9%
log-rec98.9%
mul-1-neg98.9%
distribute-neg-frac98.9%
mul-1-neg98.9%
remove-double-neg98.9%
*-rgt-identity98.9%
associate-/l*98.9%
exp-to-pow98.9%
*-commutative98.9%
Simplified98.9%
if -40 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 27.4%
Taylor expanded in n around inf 78.6%
log1p-define78.6%
Simplified78.6%
log1p-undefine78.6%
diff-log78.6%
Applied egg-rr78.6%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e214Initial program 79.9%
Taylor expanded in x around 0 72.3%
if 1.9999999999999999e214 < (/.f64 #s(literal 1 binary64) n) Initial program 6.0%
Taylor expanded in n around inf 8.2%
log1p-define8.2%
Simplified8.2%
Taylor expanded in x around -inf 83.9%
Taylor expanded in x around inf 83.9%
associate-/r*83.9%
Simplified83.9%
Final simplification84.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -40.0)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 5e-12)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+178) (- 1.0 t_0) (/ (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) <= -40.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 5e-12) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+178) {
tmp = 1.0 - t_0;
} else {
tmp = 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) <= -40.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 5e-12) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+178) {
tmp = 1.0 - t_0;
} else {
tmp = 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) <= -40.0: tmp = t_0 / (x * n) elif (1.0 / n) <= 5e-12: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+178: tmp = 1.0 - t_0 else: tmp = 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) <= -40.0) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 5e-12) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+178) tmp = Float64(1.0 - t_0); else tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-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], -40.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-12], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+178], N[(1.0 - t$95$0), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -40:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+178}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -40Initial program 99.9%
Taylor expanded in x around inf 98.9%
mul-1-neg98.9%
log-rec98.9%
mul-1-neg98.9%
distribute-neg-frac98.9%
mul-1-neg98.9%
remove-double-neg98.9%
*-rgt-identity98.9%
associate-/l*98.9%
exp-to-pow98.9%
*-commutative98.9%
Simplified98.9%
if -40 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 27.2%
Taylor expanded in n around inf 78.0%
log1p-define78.0%
Simplified78.0%
log1p-undefine78.0%
diff-log78.1%
Applied egg-rr78.1%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e178Initial program 85.6%
Taylor expanded in x around 0 79.1%
*-rgt-identity79.1%
associate-/l*79.1%
exp-to-pow79.1%
Simplified79.1%
if 4.9999999999999999e178 < (/.f64 #s(literal 1 binary64) n) Initial program 31.1%
Taylor expanded in n around inf 6.7%
log1p-define6.7%
Simplified6.7%
Taylor expanded in x around 0 6.7%
neg-mul-16.7%
Simplified6.7%
log1p-expm1-u65.0%
expm1-undefine65.0%
add-exp-log65.0%
Applied egg-rr65.0%
Final simplification83.9%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -4000000000000.0)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= (/ 1.0 n) 5e-12)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+178)
(- 1.0 (pow x (/ 1.0 n)))
(/ (log1p (+ x -1.0)) (- n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -4000000000000.0) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if ((1.0 / n) <= 5e-12) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+178) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = log1p((x + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -4000000000000.0) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if ((1.0 / n) <= 5e-12) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+178) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = Math.log1p((x + -1.0)) / -n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -4000000000000.0: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif (1.0 / n) <= 5e-12: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+178: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = math.log1p((x + -1.0)) / -n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -4000000000000.0) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (Float64(1.0 / n) <= 5e-12) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+178) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000000000000.0], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-12], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+178], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -4000000000000:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+178}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4e12Initial program 100.0%
Taylor expanded in n around inf 49.0%
log1p-define49.0%
Simplified49.0%
Taylor expanded in x around -inf 44.3%
Taylor expanded in x around 0 79.6%
if -4e12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 28.7%
Taylor expanded in n around inf 77.1%
log1p-define77.1%
Simplified77.1%
log1p-undefine77.1%
diff-log77.2%
Applied egg-rr77.2%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e178Initial program 85.6%
Taylor expanded in x around 0 79.1%
*-rgt-identity79.1%
associate-/l*79.1%
exp-to-pow79.1%
Simplified79.1%
if 4.9999999999999999e178 < (/.f64 #s(literal 1 binary64) n) Initial program 31.1%
Taylor expanded in n around inf 6.7%
log1p-define6.7%
Simplified6.7%
Taylor expanded in x around 0 6.7%
neg-mul-16.7%
Simplified6.7%
log1p-expm1-u65.0%
expm1-undefine65.0%
add-exp-log65.0%
Applied egg-rr65.0%
Final simplification77.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- x (log x)) n)))
(if (<= n -1.15e+89)
(/ (+ (/ 1.0 n) (/ (+ -0.5 (/ 0.3333333333333333 x)) (* x n))) x)
(if (<= n -1.58)
t_0
(if (<= n 7.6e-215)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= n 35000000000.0) (- 1.0 (pow x (/ 1.0 n))) t_0))))))
double code(double x, double n) {
double t_0 = (x - log(x)) / n;
double tmp;
if (n <= -1.15e+89) {
tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x;
} else if (n <= -1.58) {
tmp = t_0;
} else if (n <= 7.6e-215) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if (n <= 35000000000.0) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (x - log(x)) / n
if (n <= (-1.15d+89)) then
tmp = ((1.0d0 / n) + (((-0.5d0) + (0.3333333333333333d0 / x)) / (x * n))) / x
else if (n <= (-1.58d0)) then
tmp = t_0
else if (n <= 7.6d-215) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if (n <= 35000000000.0d0) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (x - Math.log(x)) / n;
double tmp;
if (n <= -1.15e+89) {
tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x;
} else if (n <= -1.58) {
tmp = t_0;
} else if (n <= 7.6e-215) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if (n <= 35000000000.0) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = (x - math.log(x)) / n tmp = 0 if n <= -1.15e+89: tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x elif n <= -1.58: tmp = t_0 elif n <= 7.6e-215: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif n <= 35000000000.0: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(Float64(x - log(x)) / n) tmp = 0.0 if (n <= -1.15e+89) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / Float64(x * n))) / x); elseif (n <= -1.58) tmp = t_0; elseif (n <= 7.6e-215) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (n <= 35000000000.0) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = (x - log(x)) / n; tmp = 0.0; if (n <= -1.15e+89) tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x; elseif (n <= -1.58) tmp = t_0; elseif (n <= 7.6e-215) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif (n <= 35000000000.0) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -1.15e+89], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[n, -1.58], t$95$0, If[LessEqual[n, 7.6e-215], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 35000000000.0], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;n \leq -1.15 \cdot 10^{+89}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x \cdot n}}{x}\\
\mathbf{elif}\;n \leq -1.58:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 7.6 \cdot 10^{-215}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;n \leq 35000000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -1.1499999999999999e89Initial program 44.4%
Taylor expanded in n around inf 78.9%
log1p-define78.9%
Simplified78.9%
Taylor expanded in x around -inf 65.4%
Taylor expanded in x around inf 65.4%
Simplified65.4%
if -1.1499999999999999e89 < n < -1.5800000000000001 or 3.5e10 < n Initial program 19.7%
Taylor expanded in n around inf 77.6%
log1p-define77.6%
Simplified77.6%
Taylor expanded in x around 0 63.1%
if -1.5800000000000001 < n < 7.59999999999999954e-215Initial program 93.1%
Taylor expanded in n around inf 45.6%
log1p-define45.6%
Simplified45.6%
Taylor expanded in x around -inf 45.8%
Taylor expanded in x around 0 77.2%
if 7.59999999999999954e-215 < n < 3.5e10Initial program 82.1%
Taylor expanded in x around 0 73.8%
*-rgt-identity73.8%
associate-/l*73.8%
exp-to-pow73.8%
Simplified73.8%
Final simplification69.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 6.5e-276)
t_0
(if (<= x 4.35e-240)
(/ (log x) (- n))
(if (<= x 1.8e-154)
t_0
(if (<= x 0.74)
(/ (- x (log x)) n)
(if (<= x 3.1e+165)
(/ (+ 1.0 (/ (- (/ 0.3333333333333333 x) 0.5) x)) (* x n))
0.0)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 6.5e-276) {
tmp = t_0;
} else if (x <= 4.35e-240) {
tmp = log(x) / -n;
} else if (x <= 1.8e-154) {
tmp = t_0;
} else if (x <= 0.74) {
tmp = (x - log(x)) / n;
} else if (x <= 3.1e+165) {
tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 6.5d-276) then
tmp = t_0
else if (x <= 4.35d-240) then
tmp = log(x) / -n
else if (x <= 1.8d-154) then
tmp = t_0
else if (x <= 0.74d0) then
tmp = (x - log(x)) / n
else if (x <= 3.1d+165) then
tmp = (1.0d0 + (((0.3333333333333333d0 / x) - 0.5d0) / x)) / (x * n)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 6.5e-276) {
tmp = t_0;
} else if (x <= 4.35e-240) {
tmp = Math.log(x) / -n;
} else if (x <= 1.8e-154) {
tmp = t_0;
} else if (x <= 0.74) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 3.1e+165) {
tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 6.5e-276: tmp = t_0 elif x <= 4.35e-240: tmp = math.log(x) / -n elif x <= 1.8e-154: tmp = t_0 elif x <= 0.74: tmp = (x - math.log(x)) / n elif x <= 3.1e+165: tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n) else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 6.5e-276) tmp = t_0; elseif (x <= 4.35e-240) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.8e-154) tmp = t_0; elseif (x <= 0.74) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 3.1e+165) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x)) / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 6.5e-276) tmp = t_0; elseif (x <= 4.35e-240) tmp = log(x) / -n; elseif (x <= 1.8e-154) tmp = t_0; elseif (x <= 0.74) tmp = (x - log(x)) / n; elseif (x <= 3.1e+165) tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 6.5e-276], t$95$0, If[LessEqual[x, 4.35e-240], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.8e-154], t$95$0, If[LessEqual[x, 0.74], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3.1e+165], N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 6.5 \cdot 10^{-276}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.35 \cdot 10^{-240}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-154}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.74:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+165}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333}{x} - 0.5}{x}}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 6.49999999999999981e-276 or 4.3500000000000003e-240 < x < 1.8000000000000001e-154Initial program 63.9%
Taylor expanded in x around 0 63.9%
*-rgt-identity63.9%
associate-/l*63.9%
exp-to-pow63.9%
Simplified63.9%
if 6.49999999999999981e-276 < x < 4.3500000000000003e-240Initial program 33.6%
Taylor expanded in n around inf 75.3%
log1p-define75.3%
Simplified75.3%
Taylor expanded in x around 0 75.3%
neg-mul-175.3%
Simplified75.3%
if 1.8000000000000001e-154 < x < 0.73999999999999999Initial program 38.7%
Taylor expanded in n around inf 57.7%
log1p-define57.7%
Simplified57.7%
Taylor expanded in x around 0 55.9%
if 0.73999999999999999 < x < 3.1000000000000002e165Initial program 52.1%
Taylor expanded in n around inf 50.5%
log1p-define50.5%
Simplified50.5%
Taylor expanded in x around -inf 70.7%
Taylor expanded in n around -inf 70.7%
mul-1-neg70.7%
unsub-neg70.7%
associate-*r/70.7%
metadata-eval70.7%
*-commutative70.7%
Simplified70.7%
if 3.1000000000000002e165 < x Initial program 95.9%
add-log-exp95.9%
pow-to-exp95.9%
un-div-inv95.9%
+-commutative95.9%
log1p-define95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 95.9%
Final simplification68.8%
(FPCore (x n)
:precision binary64
(if (<= x 0.74)
(/ (- x (log x)) n)
(if (<= x 5.5e+165)
(/ (+ 1.0 (/ (- (/ 0.3333333333333333 x) 0.5) x)) (* x n))
0.0)))
double code(double x, double n) {
double tmp;
if (x <= 0.74) {
tmp = (x - log(x)) / n;
} else if (x <= 5.5e+165) {
tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.74d0) then
tmp = (x - log(x)) / n
else if (x <= 5.5d+165) then
tmp = (1.0d0 + (((0.3333333333333333d0 / x) - 0.5d0) / x)) / (x * n)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.74) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 5.5e+165) {
tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.74: tmp = (x - math.log(x)) / n elif x <= 5.5e+165: tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.74) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 5.5e+165) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x)) / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.74) tmp = (x - log(x)) / n; elseif (x <= 5.5e+165) tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.74], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 5.5e+165], N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.74:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+165}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333}{x} - 0.5}{x}}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.73999999999999999Initial program 48.0%
Taylor expanded in n around inf 51.4%
log1p-define51.4%
Simplified51.4%
Taylor expanded in x around 0 50.5%
if 0.73999999999999999 < x < 5.4999999999999998e165Initial program 52.1%
Taylor expanded in n around inf 50.5%
log1p-define50.5%
Simplified50.5%
Taylor expanded in x around -inf 70.7%
Taylor expanded in n around -inf 70.7%
mul-1-neg70.7%
unsub-neg70.7%
associate-*r/70.7%
metadata-eval70.7%
*-commutative70.7%
Simplified70.7%
if 5.4999999999999998e165 < x Initial program 95.9%
add-log-exp95.9%
pow-to-exp95.9%
un-div-inv95.9%
+-commutative95.9%
log1p-define95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 95.9%
Final simplification62.1%
(FPCore (x n)
:precision binary64
(if (<= x 0.6)
(/ (log x) (- n))
(if (<= x 3.55e+165)
(/ (+ 1.0 (/ (- (/ 0.3333333333333333 x) 0.5) x)) (* x n))
0.0)))
double code(double x, double n) {
double tmp;
if (x <= 0.6) {
tmp = log(x) / -n;
} else if (x <= 3.55e+165) {
tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.6d0) then
tmp = log(x) / -n
else if (x <= 3.55d+165) then
tmp = (1.0d0 + (((0.3333333333333333d0 / x) - 0.5d0) / x)) / (x * n)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.6) {
tmp = Math.log(x) / -n;
} else if (x <= 3.55e+165) {
tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.6: tmp = math.log(x) / -n elif x <= 3.55e+165: tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.6) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 3.55e+165) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x)) / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.6) tmp = log(x) / -n; elseif (x <= 3.55e+165) tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.6], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 3.55e+165], N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.6:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 3.55 \cdot 10^{+165}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333}{x} - 0.5}{x}}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.599999999999999978Initial program 48.0%
Taylor expanded in n around inf 51.4%
log1p-define51.4%
Simplified51.4%
Taylor expanded in x around 0 50.2%
neg-mul-150.2%
Simplified50.2%
if 0.599999999999999978 < x < 3.54999999999999988e165Initial program 52.1%
Taylor expanded in n around inf 50.5%
log1p-define50.5%
Simplified50.5%
Taylor expanded in x around -inf 70.7%
Taylor expanded in n around -inf 70.7%
mul-1-neg70.7%
unsub-neg70.7%
associate-*r/70.7%
metadata-eval70.7%
*-commutative70.7%
Simplified70.7%
if 3.54999999999999988e165 < x Initial program 95.9%
add-log-exp95.9%
pow-to-exp95.9%
un-div-inv95.9%
+-commutative95.9%
log1p-define95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 95.9%
Final simplification61.9%
(FPCore (x n) :precision binary64 (if (<= x 1.2e+166) (/ (+ 1.0 (/ (- (/ 0.3333333333333333 x) 0.5) x)) (* x n)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.2e+166) {
tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.2d+166) then
tmp = (1.0d0 + (((0.3333333333333333d0 / x) - 0.5d0) / x)) / (x * n)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.2e+166) {
tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.2e+166: tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.2e+166) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x)) / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.2e+166) tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.2e+166], N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2 \cdot 10^{+166}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333}{x} - 0.5}{x}}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.19999999999999996e166Initial program 49.2%
Taylor expanded in n around inf 51.1%
log1p-define51.1%
Simplified51.1%
Taylor expanded in x around -inf 39.7%
Taylor expanded in n around -inf 39.8%
mul-1-neg39.8%
unsub-neg39.8%
associate-*r/39.8%
metadata-eval39.8%
*-commutative39.8%
Simplified39.8%
if 1.19999999999999996e166 < x Initial program 95.9%
add-log-exp95.9%
pow-to-exp95.9%
un-div-inv95.9%
+-commutative95.9%
log1p-define95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 95.9%
Final simplification48.1%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ -0.5 (/ 0.3333333333333333 x)) (* x n))) x))
double code(double x, double n) {
return ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((-0.5d0) + (0.3333333333333333d0 / x)) / (x * n))) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x;
}
def code(x, n): return ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / Float64(x * n))) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x \cdot n}}{x}
\end{array}
Initial program 56.1%
Taylor expanded in n around inf 57.8%
log1p-define57.8%
Simplified57.8%
Taylor expanded in x around -inf 41.2%
Taylor expanded in x around inf 32.7%
Simplified41.2%
Final simplification41.2%
(FPCore (x n) :precision binary64 (/ (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) n) (- x)))
double code(double x, double n) {
return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / n) / -x;
}
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)) / n) / -x
end function
public static double code(double x, double n) {
return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / n) / -x;
}
def code(x, n): return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / n) / -x
function code(x, n) return Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / n) / Float64(-x)) end
function tmp = code(x, n) tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / n) / -x; end
code[x_, n_] := N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / (-x)), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n}}{-x}
\end{array}
Initial program 56.1%
Taylor expanded in n around inf 57.8%
log1p-define57.8%
Simplified57.8%
Taylor expanded in x around -inf 41.2%
Taylor expanded in n around 0 41.2%
sub-neg41.2%
associate-*r/41.2%
sub-neg41.2%
metadata-eval41.2%
distribute-lft-in41.2%
neg-mul-141.2%
associate-*r/41.2%
metadata-eval41.2%
distribute-neg-frac41.2%
metadata-eval41.2%
metadata-eval41.2%
metadata-eval41.2%
Simplified41.2%
Final simplification41.2%
(FPCore (x n) :precision binary64 (/ (+ 1.0 (/ (- (/ 0.3333333333333333 x) 0.5) x)) (* x n)))
double code(double x, double n) {
return (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 + (((0.3333333333333333d0 / x) - 0.5d0) / x)) / (x * n)
end function
public static double code(double x, double n) {
return (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n);
}
def code(x, n): return (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n)
function code(x, n) return Float64(Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x)) / Float64(x * n)) end
function tmp = code(x, n) tmp = (1.0 + (((0.3333333333333333 / x) - 0.5) / x)) / (x * n); end
code[x_, n_] := N[(N[(1.0 + N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \frac{\frac{0.3333333333333333}{x} - 0.5}{x}}{x \cdot n}
\end{array}
Initial program 56.1%
Taylor expanded in n around inf 57.8%
log1p-define57.8%
Simplified57.8%
Taylor expanded in x around -inf 41.2%
Taylor expanded in n around -inf 41.0%
mul-1-neg41.0%
unsub-neg41.0%
associate-*r/41.0%
metadata-eval41.0%
*-commutative41.0%
Simplified41.0%
Final simplification41.0%
(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 56.1%
Taylor expanded in n around inf 57.8%
log1p-define57.8%
Simplified57.8%
Taylor expanded in x around -inf 41.2%
Taylor expanded in x around inf 34.7%
associate-/r*34.9%
Simplified34.9%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 56.1%
Taylor expanded in n around inf 57.8%
log1p-define57.8%
Simplified57.8%
Taylor expanded in x around inf 34.7%
*-commutative34.7%
Simplified34.7%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 56.1%
Taylor expanded in n around inf 57.8%
log1p-define57.8%
Simplified57.8%
Taylor expanded in x around inf 34.7%
*-commutative34.7%
Simplified34.7%
associate-/r*34.9%
div-inv34.9%
add-exp-log34.0%
rec-exp34.0%
add-sqr-sqrt11.1%
sqrt-unprod12.3%
sqr-neg12.3%
sqrt-prod1.3%
add-sqr-sqrt4.6%
add-exp-log4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
Simplified4.6%
herbie shell --seed 2024145
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))