
(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 15 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 (<= (/ 1.0 n) -5e-26)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-134)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 4e-79)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 2e-22)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-26) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 2e-22) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-26) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 2e-22) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5e-26: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 5e-134: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 4e-79: tmp = (1.0 / x) / n elif (1.0 / n) <= 2e-22: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-26) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-134) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-79) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 2e-22) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-26], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-22], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-26Initial program 89.5%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
log-rec96.6%
mul-1-neg96.6%
distribute-neg-frac96.6%
mul-1-neg96.6%
remove-double-neg96.6%
*-commutative96.6%
Simplified96.6%
if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134Initial program 35.8%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.0%
Applied egg-rr88.0%
clear-num88.0%
log-rec88.0%
Applied egg-rr88.0%
if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79Initial program 26.1%
Taylor expanded in n around inf 50.1%
+-rgt-identity50.1%
+-rgt-identity50.1%
log1p-define50.1%
Simplified50.1%
Taylor expanded in x around inf 76.1%
if 4e-79 < (/.f64 1 n) < 2.0000000000000001e-22Initial program 19.1%
Taylor expanded in n around inf 79.7%
+-rgt-identity79.7%
+-rgt-identity79.7%
log1p-define79.7%
Simplified79.7%
log1p-undefine79.7%
diff-log79.7%
Applied egg-rr79.7%
if 2.0000000000000001e-22 < (/.f64 1 n) Initial program 54.1%
Taylor expanded in n around 0 54.1%
log1p-define95.1%
*-rgt-identity95.1%
associate-/l*95.1%
exp-to-pow95.1%
Simplified95.1%
Final simplification89.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-26)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-134)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 4e-79)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 4e-8)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+157)
(- (+ 1.0 (/ x n)) t_0)
(cbrt (pow (* n x) -3.0)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-26) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = cbrt(pow((n * x), -3.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-26) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.cbrt(Math.pow((n * x), -3.0));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-26) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-134) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-79) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 4e-8) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+157) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = cbrt((Float64(n * x) ^ -3.0)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-26], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-8], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+157], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Power[N[Power[N[(n * x), $MachinePrecision], -3.0], $MachinePrecision], 1/3], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(n \cdot x\right)}^{-3}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-26Initial program 89.5%
Taylor expanded in x around inf 96.6%
log-rec96.6%
mul-1-neg96.6%
associate-*r/96.6%
associate-*r*96.6%
metadata-eval96.6%
*-commutative96.6%
associate-/l*96.6%
exp-to-pow96.6%
*-commutative96.6%
Simplified96.6%
if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134Initial program 35.8%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.0%
Applied egg-rr88.0%
clear-num88.0%
log-rec88.0%
Applied egg-rr88.0%
if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79Initial program 26.1%
Taylor expanded in n around inf 50.1%
+-rgt-identity50.1%
+-rgt-identity50.1%
log1p-define50.1%
Simplified50.1%
Taylor expanded in x around inf 76.1%
if 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8Initial program 18.4%
Taylor expanded in n around inf 76.0%
+-rgt-identity76.0%
+-rgt-identity76.0%
log1p-define76.0%
Simplified76.0%
log1p-undefine76.0%
diff-log76.0%
Applied egg-rr76.0%
if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e157Initial program 92.4%
Taylor expanded in x around 0 93.8%
if 4.99999999999999976e157 < (/.f64 1 n) Initial program 29.6%
Taylor expanded in n around inf 7.3%
+-rgt-identity7.3%
+-rgt-identity7.3%
log1p-define7.3%
Simplified7.3%
Taylor expanded in x around inf 58.5%
*-commutative58.5%
Simplified58.5%
add-cbrt-cube74.7%
pow1/374.7%
pow374.7%
inv-pow74.7%
pow-pow74.7%
metadata-eval74.7%
Applied egg-rr74.7%
unpow1/374.7%
Simplified74.7%
Final simplification87.5%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-26)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-134)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 4e-79)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 4e-8)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+157)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(cbrt (pow (* n x) -3.0))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-26) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else {
tmp = cbrt(pow((n * x), -3.0));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-26) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = Math.cbrt(Math.pow((n * x), -3.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-26) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-134) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-79) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 4e-8) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+157) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = cbrt((Float64(n * x) ^ -3.0)); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-26], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-8], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+157], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(n * x), $MachinePrecision], -3.0], $MachinePrecision], 1/3], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(n \cdot x\right)}^{-3}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-26Initial program 89.5%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
log-rec96.6%
mul-1-neg96.6%
distribute-neg-frac96.6%
mul-1-neg96.6%
remove-double-neg96.6%
*-commutative96.6%
Simplified96.6%
if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134Initial program 35.8%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.0%
Applied egg-rr88.0%
clear-num88.0%
log-rec88.0%
Applied egg-rr88.0%
if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79Initial program 26.1%
Taylor expanded in n around inf 50.1%
+-rgt-identity50.1%
+-rgt-identity50.1%
log1p-define50.1%
Simplified50.1%
Taylor expanded in x around inf 76.1%
if 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8Initial program 18.4%
Taylor expanded in n around inf 76.0%
+-rgt-identity76.0%
+-rgt-identity76.0%
log1p-define76.0%
Simplified76.0%
log1p-undefine76.0%
diff-log76.0%
Applied egg-rr76.0%
if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e157Initial program 92.4%
Taylor expanded in x around 0 93.8%
if 4.99999999999999976e157 < (/.f64 1 n) Initial program 29.6%
Taylor expanded in n around inf 7.3%
+-rgt-identity7.3%
+-rgt-identity7.3%
log1p-define7.3%
Simplified7.3%
Taylor expanded in x around inf 58.5%
*-commutative58.5%
Simplified58.5%
add-cbrt-cube74.7%
pow1/374.7%
pow374.7%
inv-pow74.7%
pow-pow74.7%
metadata-eval74.7%
Applied egg-rr74.7%
unpow1/374.7%
Simplified74.7%
Final simplification87.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ (+ 1.0 x) x)) n)) (t_1 (/ (/ 1.0 x) n)))
(if (<= (/ 1.0 n) -500000.0)
(/ 0.0 n)
(if (<= (/ 1.0 n) -1e-31)
t_1
(if (<= (/ 1.0 n) 5e-134)
t_0
(if (<= (/ 1.0 n) 4e-79)
t_1
(if (<= (/ 1.0 n) 4e-8)
t_0
(if (<= (/ 1.0 n) 5e+246)
(- 1.0 (pow x (/ 1.0 n)))
(/ 1.0 (* n x))))))))))
double code(double x, double n) {
double t_0 = log(((1.0 + x) / x)) / n;
double t_1 = (1.0 / x) / n;
double tmp;
if ((1.0 / n) <= -500000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -1e-31) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-134) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-79) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 5e+246) {
tmp = 1.0 - pow(x, (1.0 / n));
} 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) :: t_1
real(8) :: tmp
t_0 = log(((1.0d0 + x) / x)) / n
t_1 = (1.0d0 / x) / n
if ((1.0d0 / n) <= (-500000.0d0)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= (-1d-31)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-134) then
tmp = t_0
else if ((1.0d0 / n) <= 4d-79) then
tmp = t_1
else if ((1.0d0 / n) <= 4d-8) then
tmp = t_0
else if ((1.0d0 / n) <= 5d+246) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(((1.0 + x) / x)) / n;
double t_1 = (1.0 / x) / n;
double tmp;
if ((1.0 / n) <= -500000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -1e-31) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-134) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-79) {
tmp = t_1;
} else if ((1.0 / n) <= 4e-8) {
tmp = t_0;
} else if ((1.0 / n) <= 5e+246) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.log(((1.0 + x) / x)) / n t_1 = (1.0 / x) / n tmp = 0 if (1.0 / n) <= -500000.0: tmp = 0.0 / n elif (1.0 / n) <= -1e-31: tmp = t_1 elif (1.0 / n) <= 5e-134: tmp = t_0 elif (1.0 / n) <= 4e-79: tmp = t_1 elif (1.0 / n) <= 4e-8: tmp = t_0 elif (1.0 / n) <= 5e+246: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) t_1 = Float64(Float64(1.0 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -500000.0) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -1e-31) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-134) tmp = t_0; elseif (Float64(1.0 / n) <= 4e-79) tmp = t_1; elseif (Float64(1.0 / n) <= 4e-8) tmp = t_0; elseif (Float64(1.0 / n) <= 5e+246) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = log(((1.0 + x) / x)) / n; t_1 = (1.0 / x) / n; tmp = 0.0; if ((1.0 / n) <= -500000.0) tmp = 0.0 / n; elseif ((1.0 / n) <= -1e-31) tmp = t_1; elseif ((1.0 / n) <= 5e-134) tmp = t_0; elseif ((1.0 / n) <= 4e-79) tmp = t_1; elseif ((1.0 / n) <= 4e-8) tmp = t_0; elseif ((1.0 / n) <= 5e+246) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -500000.0], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-31], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-8], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+246], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
t_1 := \frac{\frac{1}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -500000:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-31}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+246}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5e5Initial program 100.0%
Taylor expanded in n around inf 63.3%
+-rgt-identity63.3%
+-rgt-identity63.3%
log1p-define63.3%
Simplified63.3%
log1p-undefine63.3%
diff-log63.3%
Applied egg-rr63.3%
Taylor expanded in x around inf 67.2%
if -5e5 < (/.f64 1 n) < -1e-31 or 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79Initial program 23.7%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-define45.4%
Simplified45.4%
Taylor expanded in x around inf 68.7%
if -1e-31 < (/.f64 1 n) < 5.0000000000000003e-134 or 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8Initial program 33.6%
Taylor expanded in n around inf 86.6%
+-rgt-identity86.6%
+-rgt-identity86.6%
log1p-define86.6%
Simplified86.6%
log1p-undefine86.6%
diff-log86.6%
Applied egg-rr86.6%
if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e246Initial program 75.0%
Taylor expanded in x around 0 71.4%
*-rgt-identity71.4%
associate-/l*71.4%
exp-to-pow71.4%
Simplified71.4%
if 4.99999999999999976e246 < (/.f64 1 n) Initial program 11.2%
Taylor expanded in n around inf 9.6%
+-rgt-identity9.6%
+-rgt-identity9.6%
log1p-define9.6%
Simplified9.6%
Taylor expanded in x around inf 91.9%
*-commutative91.9%
Simplified91.9%
Final simplification78.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 x) n)))
(if (<= (/ 1.0 n) -500000.0)
(/ 0.0 n)
(if (<= (/ 1.0 n) -1e-31)
t_0
(if (<= (/ 1.0 n) 5e-134)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 4e-79)
t_0
(if (<= (/ 1.0 n) 4e-8)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+246)
(- 1.0 (pow x (/ 1.0 n)))
(/ 1.0 (* n x))))))))))
double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if ((1.0 / n) <= -500000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -1e-31) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-134) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-8) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+246) {
tmp = 1.0 - pow(x, (1.0 / n));
} 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 = (1.0d0 / x) / n
if ((1.0d0 / n) <= (-500000.0d0)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= (-1d-31)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d-134) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 4d-79) then
tmp = t_0
else if ((1.0d0 / n) <= 4d-8) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d+246) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if ((1.0 / n) <= -500000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -1e-31) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-134) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-8) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+246) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = (1.0 / x) / n tmp = 0 if (1.0 / n) <= -500000.0: tmp = 0.0 / n elif (1.0 / n) <= -1e-31: tmp = t_0 elif (1.0 / n) <= 5e-134: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 4e-79: tmp = t_0 elif (1.0 / n) <= 4e-8: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+246: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(Float64(1.0 / x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -500000.0) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -1e-31) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-134) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-79) tmp = t_0; elseif (Float64(1.0 / n) <= 4e-8) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+246) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = (1.0 / x) / n; tmp = 0.0; if ((1.0 / n) <= -500000.0) tmp = 0.0 / n; elseif ((1.0 / n) <= -1e-31) tmp = t_0; elseif ((1.0 / n) <= 5e-134) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 4e-79) tmp = t_0; elseif ((1.0 / n) <= 4e-8) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e+246) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -500000.0], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-31], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-8], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+246], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -500000:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+246}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5e5Initial program 100.0%
Taylor expanded in n around inf 63.3%
+-rgt-identity63.3%
+-rgt-identity63.3%
log1p-define63.3%
Simplified63.3%
log1p-undefine63.3%
diff-log63.3%
Applied egg-rr63.3%
Taylor expanded in x around inf 67.2%
if -5e5 < (/.f64 1 n) < -1e-31 or 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79Initial program 23.7%
Taylor expanded in n around inf 45.4%
+-rgt-identity45.4%
+-rgt-identity45.4%
log1p-define45.4%
Simplified45.4%
Taylor expanded in x around inf 68.7%
if -1e-31 < (/.f64 1 n) < 5.0000000000000003e-134Initial program 36.4%
Taylor expanded in n around inf 88.5%
+-rgt-identity88.5%
+-rgt-identity88.5%
log1p-define88.5%
Simplified88.5%
log1p-undefine88.5%
diff-log88.6%
Applied egg-rr88.6%
clear-num88.6%
log-rec88.6%
Applied egg-rr88.6%
if 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8Initial program 18.4%
Taylor expanded in n around inf 76.0%
+-rgt-identity76.0%
+-rgt-identity76.0%
log1p-define76.0%
Simplified76.0%
log1p-undefine76.0%
diff-log76.0%
Applied egg-rr76.0%
if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e246Initial program 75.0%
Taylor expanded in x around 0 71.4%
*-rgt-identity71.4%
associate-/l*71.4%
exp-to-pow71.4%
Simplified71.4%
if 4.99999999999999976e246 < (/.f64 1 n) Initial program 11.2%
Taylor expanded in n around inf 9.6%
+-rgt-identity9.6%
+-rgt-identity9.6%
log1p-define9.6%
Simplified9.6%
Taylor expanded in x around inf 91.9%
*-commutative91.9%
Simplified91.9%
Final simplification78.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-26)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-134)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 4e-79)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 4e-8)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+246)
(- (+ 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) <= -5e-26) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+246) {
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) <= (-5d-26)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-134) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 4d-79) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 4d-8) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d+246) 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) <= -5e-26) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+246) {
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) <= -5e-26: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-134: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 4e-79: tmp = (1.0 / x) / n elif (1.0 / n) <= 4e-8: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+246: 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) <= -5e-26) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-134) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-79) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 4e-8) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+246) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(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) <= -5e-26) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-134) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 4e-79) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 4e-8) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e+246) 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], -5e-26], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-8], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+246], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+246}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-26Initial program 89.5%
Taylor expanded in x around inf 96.6%
log-rec96.6%
mul-1-neg96.6%
associate-*r/96.6%
associate-*r*96.6%
metadata-eval96.6%
*-commutative96.6%
associate-/l*96.6%
exp-to-pow96.6%
*-commutative96.6%
Simplified96.6%
if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134Initial program 35.8%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.0%
Applied egg-rr88.0%
clear-num88.0%
log-rec88.0%
Applied egg-rr88.0%
if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79Initial program 26.1%
Taylor expanded in n around inf 50.1%
+-rgt-identity50.1%
+-rgt-identity50.1%
log1p-define50.1%
Simplified50.1%
Taylor expanded in x around inf 76.1%
if 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8Initial program 18.4%
Taylor expanded in n around inf 76.0%
+-rgt-identity76.0%
+-rgt-identity76.0%
log1p-define76.0%
Simplified76.0%
log1p-undefine76.0%
diff-log76.0%
Applied egg-rr76.0%
if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e246Initial program 75.0%
Taylor expanded in x around 0 74.3%
if 4.99999999999999976e246 < (/.f64 1 n) Initial program 11.2%
Taylor expanded in n around inf 9.6%
+-rgt-identity9.6%
+-rgt-identity9.6%
log1p-define9.6%
Simplified9.6%
Taylor expanded in x around inf 91.9%
*-commutative91.9%
Simplified91.9%
Final simplification87.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-26)
(/ t_1 (* n x))
(if (<= (/ 1.0 n) 5e-134)
(/ (log t_0) (- n))
(if (<= (/ 1.0 n) 4e-79)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 4e-8)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+157)
(- (+ 1.0 (/ x n)) t_1)
(/ (log1p (+ t_0 -1.0)) (- n)))))))))
double code(double x, double n) {
double t_0 = x / (1.0 + x);
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-26) {
tmp = t_1 / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = log(t_0) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = x / (1.0 + x);
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-26) {
tmp = t_1 / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = Math.log(t_0) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = Math.log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = x / (1.0 + x) t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-26: tmp = t_1 / (n * x) elif (1.0 / n) <= 5e-134: tmp = math.log(t_0) / -n elif (1.0 / n) <= 4e-79: tmp = (1.0 / x) / n elif (1.0 / n) <= 4e-8: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+157: tmp = (1.0 + (x / n)) - t_1 else: tmp = math.log1p((t_0 + -1.0)) / -n return tmp
function code(x, n) t_0 = Float64(x / Float64(1.0 + x)) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-26) tmp = Float64(t_1 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-134) tmp = Float64(log(t_0) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-79) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 4e-8) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+157) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); else tmp = Float64(log1p(Float64(t_0 + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-26], N[(t$95$1 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], N[(N[Log[t$95$0], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-8], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+157], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[Log[1 + N[(t$95$0 + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{t\_1}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\
\;\;\;\;\frac{\log t\_0}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(t\_0 + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-26Initial program 89.5%
Taylor expanded in x around inf 96.6%
log-rec96.6%
mul-1-neg96.6%
associate-*r/96.6%
associate-*r*96.6%
metadata-eval96.6%
*-commutative96.6%
associate-/l*96.6%
exp-to-pow96.6%
*-commutative96.6%
Simplified96.6%
if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134Initial program 35.8%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.0%
Applied egg-rr88.0%
clear-num88.0%
log-rec88.0%
Applied egg-rr88.0%
if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79Initial program 26.1%
Taylor expanded in n around inf 50.1%
+-rgt-identity50.1%
+-rgt-identity50.1%
log1p-define50.1%
Simplified50.1%
Taylor expanded in x around inf 76.1%
if 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8Initial program 18.4%
Taylor expanded in n around inf 76.0%
+-rgt-identity76.0%
+-rgt-identity76.0%
log1p-define76.0%
Simplified76.0%
log1p-undefine76.0%
diff-log76.0%
Applied egg-rr76.0%
if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e157Initial program 92.4%
Taylor expanded in x around 0 93.8%
if 4.99999999999999976e157 < (/.f64 1 n) Initial program 29.6%
Taylor expanded in n around inf 7.3%
+-rgt-identity7.3%
+-rgt-identity7.3%
log1p-define7.3%
Simplified7.3%
log1p-undefine7.3%
diff-log7.3%
Applied egg-rr7.3%
clear-num7.3%
log-rec7.3%
Applied egg-rr7.3%
log1p-expm1-u70.7%
expm1-undefine70.7%
add-exp-log70.7%
+-commutative70.7%
Applied egg-rr70.7%
Final simplification87.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-26)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-134)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 4e-79)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 4e-8)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5e+246) (- 1.0 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) <= -5e-26) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+246) {
tmp = 1.0 - 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) <= (-5d-26)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-134) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 4d-79) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 4d-8) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5d+246) then
tmp = 1.0d0 - 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) <= -5e-26) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-134) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 4e-79) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 4e-8) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5e+246) {
tmp = 1.0 - 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) <= -5e-26: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-134: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 4e-79: tmp = (1.0 / x) / n elif (1.0 / n) <= 4e-8: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5e+246: tmp = 1.0 - 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) <= -5e-26) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-134) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 4e-79) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 4e-8) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5e+246) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(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) <= -5e-26) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-134) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 4e-79) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 4e-8) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5e+246) tmp = 1.0 - 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], -5e-26], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-8], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+246], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+246}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000019e-26Initial program 89.5%
Taylor expanded in x around inf 96.6%
log-rec96.6%
mul-1-neg96.6%
associate-*r/96.6%
associate-*r*96.6%
metadata-eval96.6%
*-commutative96.6%
associate-/l*96.6%
exp-to-pow96.6%
*-commutative96.6%
Simplified96.6%
if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134Initial program 35.8%
Taylor expanded in n around inf 87.9%
+-rgt-identity87.9%
+-rgt-identity87.9%
log1p-define87.9%
Simplified87.9%
log1p-undefine87.9%
diff-log88.0%
Applied egg-rr88.0%
clear-num88.0%
log-rec88.0%
Applied egg-rr88.0%
if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79Initial program 26.1%
Taylor expanded in n around inf 50.1%
+-rgt-identity50.1%
+-rgt-identity50.1%
log1p-define50.1%
Simplified50.1%
Taylor expanded in x around inf 76.1%
if 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8Initial program 18.4%
Taylor expanded in n around inf 76.0%
+-rgt-identity76.0%
+-rgt-identity76.0%
log1p-define76.0%
Simplified76.0%
log1p-undefine76.0%
diff-log76.0%
Applied egg-rr76.0%
if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e246Initial program 75.0%
Taylor expanded in x around 0 71.4%
*-rgt-identity71.4%
associate-/l*71.4%
exp-to-pow71.4%
Simplified71.4%
if 4.99999999999999976e246 < (/.f64 1 n) Initial program 11.2%
Taylor expanded in n around inf 9.6%
+-rgt-identity9.6%
+-rgt-identity9.6%
log1p-define9.6%
Simplified9.6%
Taylor expanded in x around inf 91.9%
*-commutative91.9%
Simplified91.9%
Final simplification86.8%
(FPCore (x n) :precision binary64 (if (<= x 21000.0) (/ (- x (log x)) n) (if (or (<= x 1.05e+72) (not (<= x 1.42e+172))) (/ 0.0 n) (/ 1.0 (* n x)))))
double code(double x, double n) {
double tmp;
if (x <= 21000.0) {
tmp = (x - log(x)) / n;
} else if ((x <= 1.05e+72) || !(x <= 1.42e+172)) {
tmp = 0.0 / n;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 21000.0d0) then
tmp = (x - log(x)) / n
else if ((x <= 1.05d+72) .or. (.not. (x <= 1.42d+172))) then
tmp = 0.0d0 / n
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 21000.0) {
tmp = (x - Math.log(x)) / n;
} else if ((x <= 1.05e+72) || !(x <= 1.42e+172)) {
tmp = 0.0 / n;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 21000.0: tmp = (x - math.log(x)) / n elif (x <= 1.05e+72) or not (x <= 1.42e+172): tmp = 0.0 / n else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (x <= 21000.0) tmp = Float64(Float64(x - log(x)) / n); elseif ((x <= 1.05e+72) || !(x <= 1.42e+172)) tmp = Float64(0.0 / n); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 21000.0) tmp = (x - log(x)) / n; elseif ((x <= 1.05e+72) || ~((x <= 1.42e+172))) tmp = 0.0 / n; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 21000.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[x, 1.05e+72], N[Not[LessEqual[x, 1.42e+172]], $MachinePrecision]], N[(0.0 / n), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 21000:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+72} \lor \neg \left(x \leq 1.42 \cdot 10^{+172}\right):\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if x < 21000Initial program 33.0%
Taylor expanded in n around inf 60.5%
+-rgt-identity60.5%
+-rgt-identity60.5%
log1p-define60.5%
Simplified60.5%
Taylor expanded in x around 0 58.9%
neg-mul-158.9%
sub-neg58.9%
Simplified58.9%
if 21000 < x < 1.0500000000000001e72 or 1.41999999999999994e172 < x Initial program 83.1%
Taylor expanded in n around inf 79.6%
+-rgt-identity79.6%
+-rgt-identity79.6%
log1p-define79.6%
Simplified79.6%
log1p-undefine79.6%
diff-log79.6%
Applied egg-rr79.6%
Taylor expanded in x around inf 83.2%
if 1.0500000000000001e72 < x < 1.41999999999999994e172Initial program 42.6%
Taylor expanded in n around inf 42.6%
+-rgt-identity42.6%
+-rgt-identity42.6%
log1p-define42.6%
Simplified42.6%
Taylor expanded in x around inf 82.8%
*-commutative82.8%
Simplified82.8%
Final simplification69.9%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (log x) (- n)) (if (or (<= x 1.05e+72) (not (<= x 5.5e+173))) (/ 0.0 n) (/ 1.0 (* n x)))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = log(x) / -n;
} else if ((x <= 1.05e+72) || !(x <= 5.5e+173)) {
tmp = 0.0 / n;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.0d0) then
tmp = log(x) / -n
else if ((x <= 1.05d+72) .or. (.not. (x <= 5.5d+173))) then
tmp = 0.0d0 / n
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = Math.log(x) / -n;
} else if ((x <= 1.05e+72) || !(x <= 5.5e+173)) {
tmp = 0.0 / n;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = math.log(x) / -n elif (x <= 1.05e+72) or not (x <= 5.5e+173): tmp = 0.0 / n else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(log(x) / Float64(-n)); elseif ((x <= 1.05e+72) || !(x <= 5.5e+173)) tmp = Float64(0.0 / n); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = log(x) / -n; elseif ((x <= 1.05e+72) || ~((x <= 5.5e+173))) tmp = 0.0 / n; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[Or[LessEqual[x, 1.05e+72], N[Not[LessEqual[x, 5.5e+173]], $MachinePrecision]], N[(0.0 / n), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+72} \lor \neg \left(x \leq 5.5 \cdot 10^{+173}\right):\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if x < 1Initial program 33.4%
Taylor expanded in n around inf 60.3%
+-rgt-identity60.3%
+-rgt-identity60.3%
log1p-define60.3%
Simplified60.3%
Taylor expanded in x around 0 58.9%
neg-mul-158.9%
Simplified58.9%
if 1 < x < 1.0500000000000001e72 or 5.50000000000000049e173 < x Initial program 81.3%
Taylor expanded in n around inf 79.6%
+-rgt-identity79.6%
+-rgt-identity79.6%
log1p-define79.6%
Simplified79.6%
log1p-undefine79.6%
diff-log79.7%
Applied egg-rr79.7%
Taylor expanded in x around inf 81.3%
if 1.0500000000000001e72 < x < 5.50000000000000049e173Initial program 42.6%
Taylor expanded in n around inf 42.6%
+-rgt-identity42.6%
+-rgt-identity42.6%
log1p-define42.6%
Simplified42.6%
Taylor expanded in x around inf 82.8%
*-commutative82.8%
Simplified82.8%
Final simplification69.5%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -500000.0) (/ 0.0 n) (* (/ 1.0 n) (/ 1.0 x))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500000.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / n) * (1.0 / 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) <= (-500000.0d0)) then
tmp = 0.0d0 / n
else
tmp = (1.0d0 / n) * (1.0d0 / x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500000.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / n) * (1.0 / x);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -500000.0: tmp = 0.0 / n else: tmp = (1.0 / n) * (1.0 / x) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -500000.0) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -500000.0) tmp = 0.0 / n; else tmp = (1.0 / n) * (1.0 / x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -500000.0], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -500000:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5e5Initial program 100.0%
Taylor expanded in n around inf 63.3%
+-rgt-identity63.3%
+-rgt-identity63.3%
log1p-define63.3%
Simplified63.3%
log1p-undefine63.3%
diff-log63.3%
Applied egg-rr63.3%
Taylor expanded in x around inf 67.2%
if -5e5 < (/.f64 1 n) Initial program 36.3%
Taylor expanded in n around inf 64.6%
+-rgt-identity64.6%
+-rgt-identity64.6%
log1p-define64.6%
Simplified64.6%
Taylor expanded in x around inf 47.6%
*-commutative47.6%
Simplified47.6%
inv-pow47.6%
unpow-prod-down48.0%
inv-pow48.0%
inv-pow48.0%
Applied egg-rr48.0%
Final simplification52.2%
(FPCore (x n) :precision binary64 (* (/ 1.0 n) (/ 1.0 x)))
double code(double x, double n) {
return (1.0 / n) * (1.0 / x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) * (1.0d0 / x)
end function
public static double code(double x, double n) {
return (1.0 / n) * (1.0 / x);
}
def code(x, n): return (1.0 / n) * (1.0 / x)
function code(x, n) return Float64(Float64(1.0 / n) * Float64(1.0 / x)) end
function tmp = code(x, n) tmp = (1.0 / n) * (1.0 / x); end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n} \cdot \frac{1}{x}
\end{array}
Initial program 50.5%
Taylor expanded in n around inf 64.3%
+-rgt-identity64.3%
+-rgt-identity64.3%
log1p-define64.3%
Simplified64.3%
Taylor expanded in x around inf 41.3%
*-commutative41.3%
Simplified41.3%
inv-pow41.3%
unpow-prod-down41.6%
inv-pow41.6%
inv-pow41.6%
Applied egg-rr41.6%
Final simplification41.6%
(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 50.5%
Taylor expanded in n around inf 64.3%
+-rgt-identity64.3%
+-rgt-identity64.3%
log1p-define64.3%
Simplified64.3%
Taylor expanded in x around inf 41.3%
*-commutative41.3%
Simplified41.3%
Final simplification41.3%
(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(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 50.5%
Taylor expanded in n around inf 64.3%
+-rgt-identity64.3%
+-rgt-identity64.3%
log1p-define64.3%
Simplified64.3%
Taylor expanded in x around inf 41.6%
Final simplification41.6%
(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 50.5%
Taylor expanded in x around 0 25.7%
Taylor expanded in x around inf 4.6%
Final simplification4.6%
herbie shell --seed 2024053
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))