
(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 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) n)))
(if (<= (/ 1.0 n) -1e-28)
(/ (exp t_0) (* n x))
(if (<= (/ 1.0 n) 1e-9)
(-
(fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) (/ (log1p x) n))
(fma 0.5 (/ (pow (log x) 2.0) (* n n)) t_0))
(- (cbrt (exp (* (/ x n) 3.0))) (pow x (/ 1.0 n)))))))
double code(double x, double n) {
double t_0 = log(x) / n;
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = exp(t_0) / (n * x);
} else if ((1.0 / n) <= 1e-9) {
tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), (log1p(x) / n)) - fma(0.5, (pow(log(x), 2.0) / (n * n)), t_0);
} else {
tmp = cbrt(exp(((x / n) * 3.0))) - pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) t_0 = Float64(log(x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-28) tmp = Float64(exp(t_0) / Float64(n * x)); elseif (Float64(1.0 / n) <= 1e-9) tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), Float64(log1p(x) / n)) - fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), t_0)); else tmp = Float64(cbrt(exp(Float64(Float64(x / n) * 3.0))) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-28], N[(N[Exp[t$95$0], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-9], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Exp[N[(N[(x / n), $MachinePrecision] * 3.0), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{t_0}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, t_0\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{e^{\frac{x}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.99999999999999971e-29Initial program 96.3%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
distribute-frac-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
if -9.99999999999999971e-29 < (/.f64 1 n) < 1.00000000000000006e-9Initial program 26.9%
Taylor expanded in n around inf 78.2%
fma-def78.2%
log1p-def78.2%
unpow278.2%
log1p-def78.2%
fma-def78.2%
unpow278.2%
Simplified78.2%
if 1.00000000000000006e-9 < (/.f64 1 n) Initial program 61.3%
add-cbrt-cube61.3%
pow361.3%
pow-to-exp61.3%
pow-exp61.3%
un-div-inv61.3%
+-commutative61.3%
log1p-udef99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification87.4%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-28)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-22)
(/ (- (log1p x) (log x)) n)
(- (cbrt (exp (* (/ (log1p x) n) 3.0))) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-22) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = cbrt(exp(((log1p(x) / n) * 3.0))) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-22) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.cbrt(Math.exp(((Math.log1p(x) / n) * 3.0))) - Math.pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-28) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-22) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(cbrt(exp(Float64(Float64(log1p(x) / n) * 3.0))) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-28], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-22], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[N[Exp[N[(N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision] * 3.0), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.99999999999999971e-29Initial program 96.3%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
distribute-frac-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
if -9.99999999999999971e-29 < (/.f64 1 n) < 4.99999999999999954e-22Initial program 27.0%
Taylor expanded in n around inf 79.7%
+-rgt-identity79.7%
+-rgt-identity79.7%
log1p-def79.7%
Simplified79.7%
if 4.99999999999999954e-22 < (/.f64 1 n) Initial program 58.1%
add-cbrt-cube58.1%
pow358.1%
pow-to-exp58.1%
pow-exp58.1%
un-div-inv58.1%
+-commutative58.1%
log1p-udef93.6%
Applied egg-rr93.6%
Final simplification87.3%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-28)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 9.5e-10)
(/ (- (log1p x) (log x)) n)
(- (cbrt (exp (* (/ x n) 3.0))) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 9.5e-10) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = cbrt(exp(((x / n) * 3.0))) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 9.5e-10) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.cbrt(Math.exp(((x / n) * 3.0))) - Math.pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-28) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 9.5e-10) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(cbrt(exp(Float64(Float64(x / n) * 3.0))) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-28], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 9.5e-10], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[N[Exp[N[(N[(x / n), $MachinePrecision] * 3.0), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 9.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{e^{\frac{x}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.99999999999999971e-29Initial program 96.3%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
distribute-frac-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
if -9.99999999999999971e-29 < (/.f64 1 n) < 9.50000000000000028e-10Initial program 26.6%
Taylor expanded in n around inf 78.1%
+-rgt-identity78.1%
+-rgt-identity78.1%
log1p-def78.1%
Simplified78.1%
if 9.50000000000000028e-10 < (/.f64 1 n) Initial program 61.4%
add-cbrt-cube61.4%
pow361.4%
pow-to-exp61.4%
pow-exp61.4%
un-div-inv61.4%
+-commutative61.4%
log1p-udef99.3%
Applied egg-rr99.3%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
Final simplification87.3%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-28)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-22)
(/ (- (log1p x) (log x)) n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-22) {
tmp = (log1p(x) - log(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) <= -1e-28) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-22) {
tmp = (Math.log1p(x) - Math.log(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) <= -1e-28: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 5e-22: tmp = (math.log1p(x) - math.log(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) <= -1e-28) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-22) tmp = Float64(Float64(log1p(x) - log(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], -1e-28], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-22], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[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 -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{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) < -9.99999999999999971e-29Initial program 96.3%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
distribute-frac-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
if -9.99999999999999971e-29 < (/.f64 1 n) < 4.99999999999999954e-22Initial program 27.0%
Taylor expanded in n around inf 79.7%
+-rgt-identity79.7%
+-rgt-identity79.7%
log1p-def79.7%
Simplified79.7%
if 4.99999999999999954e-22 < (/.f64 1 n) Initial program 58.1%
Taylor expanded in n around 0 58.1%
log1p-def93.6%
Simplified93.6%
Final simplification87.3%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-28)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 9.5e-10)
(/ (- (log1p x) (log x)) n)
(- (exp (/ x n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 9.5e-10) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 9.5e-10) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1e-28: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 9.5e-10: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-28) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 9.5e-10) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-28], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 9.5e-10], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[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}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 9.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.99999999999999971e-29Initial program 96.3%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
distribute-frac-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
if -9.99999999999999971e-29 < (/.f64 1 n) < 9.50000000000000028e-10Initial program 26.6%
Taylor expanded in n around inf 78.1%
+-rgt-identity78.1%
+-rgt-identity78.1%
log1p-def78.1%
Simplified78.1%
if 9.50000000000000028e-10 < (/.f64 1 n) Initial program 61.4%
Taylor expanded in n around 0 61.4%
log1p-def99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
Final simplification87.3%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e-28)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 9.5e-10)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e+118)
(-
(+ (+ 1.0 (/ x n)) (* (* x (/ x n)) (+ -0.5 (/ 0.5 n))))
(pow x (/ 1.0 n)))
(* x (* x (/ 0.5 (* n n))))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 9.5e-10) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e+118) {
tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - pow(x, (1.0 / n));
} else {
tmp = x * (x * (0.5 / (n * n)));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e-28) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 9.5e-10) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e+118) {
tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - Math.pow(x, (1.0 / n));
} else {
tmp = x * (x * (0.5 / (n * n)));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1e-28: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 9.5e-10: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e+118: tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - math.pow(x, (1.0 / n)) else: tmp = x * (x * (0.5 / (n * n))) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e-28) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 9.5e-10) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e+118) tmp = Float64(Float64(Float64(1.0 + Float64(x / n)) + Float64(Float64(x * Float64(x / n)) * Float64(-0.5 + Float64(0.5 / n)))) - (x ^ Float64(1.0 / n))); else tmp = Float64(x * Float64(x * Float64(0.5 / Float64(n * n)))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-28], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 9.5e-10], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+118], N[(N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] + N[(N[(x * N[(x / n), $MachinePrecision]), $MachinePrecision] * N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 9.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+118}:\\
\;\;\;\;\left(\left(1 + \frac{x}{n}\right) + \left(x \cdot \frac{x}{n}\right) \cdot \left(-0.5 + \frac{0.5}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{n \cdot n}\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -9.99999999999999971e-29Initial program 96.3%
Taylor expanded in x around inf 97.3%
mul-1-neg97.3%
log-rec97.3%
distribute-frac-neg97.3%
remove-double-neg97.3%
*-commutative97.3%
Simplified97.3%
if -9.99999999999999971e-29 < (/.f64 1 n) < 9.50000000000000028e-10Initial program 26.6%
Taylor expanded in n around inf 78.1%
+-rgt-identity78.1%
+-rgt-identity78.1%
log1p-def78.1%
Simplified78.1%
if 9.50000000000000028e-10 < (/.f64 1 n) < 4.99999999999999972e118Initial program 90.1%
Taylor expanded in n around 0 90.1%
log1p-def98.3%
Simplified98.3%
Taylor expanded in x around 0 90.1%
+-commutative90.1%
associate-+r+90.1%
sub-neg90.1%
associate-*r/90.1%
metadata-eval90.1%
unpow290.1%
associate-*r/90.1%
metadata-eval90.1%
distribute-neg-frac90.1%
metadata-eval90.1%
+-commutative90.1%
distribute-rgt-in90.1%
associate-*l/90.1%
associate-*r/90.1%
associate-/r*90.1%
Simplified90.1%
if 4.99999999999999972e118 < (/.f64 1 n) Initial program 36.2%
Taylor expanded in x around 0 56.8%
fma-def56.8%
unpow256.8%
associate-*r/56.8%
metadata-eval56.8%
unpow256.8%
associate-*r/56.8%
metadata-eval56.8%
Simplified56.8%
Taylor expanded in n around 0 53.0%
unpow253.0%
unpow253.0%
Simplified53.0%
Taylor expanded in x around 0 53.0%
*-commutative53.0%
associate-*l/53.0%
associate-*r/56.8%
unpow256.8%
unpow256.8%
associate-*l*73.3%
Simplified73.3%
Final simplification84.0%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) 9.5e-10)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 5e+118)
(-
(+ (+ 1.0 (/ x n)) (* (* x (/ x n)) (+ -0.5 (/ 0.5 n))))
(pow x (/ 1.0 n)))
(* x (* x (/ 0.5 (* n n)))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 9.5e-10) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 5e+118) {
tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - pow(x, (1.0 / n));
} else {
tmp = x * (x * (0.5 / (n * n)));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 9.5e-10) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5e+118) {
tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - Math.pow(x, (1.0 / n));
} else {
tmp = x * (x * (0.5 / (n * n)));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 9.5e-10: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 5e+118: tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - math.pow(x, (1.0 / n)) else: tmp = x * (x * (0.5 / (n * n))) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 9.5e-10) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 5e+118) tmp = Float64(Float64(Float64(1.0 + Float64(x / n)) + Float64(Float64(x * Float64(x / n)) * Float64(-0.5 + Float64(0.5 / n)))) - (x ^ Float64(1.0 / n))); else tmp = Float64(x * Float64(x * Float64(0.5 / Float64(n * n)))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 9.5e-10], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+118], N[(N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] + N[(N[(x * N[(x / n), $MachinePrecision]), $MachinePrecision] * N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 9.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+118}:\\
\;\;\;\;\left(\left(1 + \frac{x}{n}\right) + \left(x \cdot \frac{x}{n}\right) \cdot \left(-0.5 + \frac{0.5}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{n \cdot n}\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < 9.50000000000000028e-10Initial program 50.2%
Taylor expanded in n around inf 69.8%
+-rgt-identity69.8%
+-rgt-identity69.8%
log1p-def69.8%
Simplified69.8%
if 9.50000000000000028e-10 < (/.f64 1 n) < 4.99999999999999972e118Initial program 90.1%
Taylor expanded in n around 0 90.1%
log1p-def98.3%
Simplified98.3%
Taylor expanded in x around 0 90.1%
+-commutative90.1%
associate-+r+90.1%
sub-neg90.1%
associate-*r/90.1%
metadata-eval90.1%
unpow290.1%
associate-*r/90.1%
metadata-eval90.1%
distribute-neg-frac90.1%
metadata-eval90.1%
+-commutative90.1%
distribute-rgt-in90.1%
associate-*l/90.1%
associate-*r/90.1%
associate-/r*90.1%
Simplified90.1%
if 4.99999999999999972e118 < (/.f64 1 n) Initial program 36.2%
Taylor expanded in x around 0 56.8%
fma-def56.8%
unpow256.8%
associate-*r/56.8%
metadata-eval56.8%
unpow256.8%
associate-*r/56.8%
metadata-eval56.8%
Simplified56.8%
Taylor expanded in n around 0 53.0%
unpow253.0%
unpow253.0%
Simplified53.0%
Taylor expanded in x around 0 53.0%
*-commutative53.0%
associate-*l/53.0%
associate-*r/56.8%
unpow256.8%
unpow256.8%
associate-*l*73.3%
Simplified73.3%
Final simplification71.9%
(FPCore (x n)
:precision binary64
(if (<= x 3.3e-177)
(/ (- (log x)) n)
(if (<= x 1.56e-155)
(-
(+ (+ 1.0 (/ x n)) (* (* x (/ x n)) (+ -0.5 (/ 0.5 n))))
(pow x (/ 1.0 n)))
(if (<= x 3.6e-6)
(* (+ x (- (* x (* x -0.5)) (log x))) (/ -1.0 (- n)))
(/
(+ (/ 0.3333333333333333 (pow x 3.0)) (- (/ 1.0 x) (/ 0.5 (* x x))))
n)))))
double code(double x, double n) {
double tmp;
if (x <= 3.3e-177) {
tmp = -log(x) / n;
} else if (x <= 1.56e-155) {
tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - pow(x, (1.0 / n));
} else if (x <= 3.6e-6) {
tmp = (x + ((x * (x * -0.5)) - log(x))) * (-1.0 / -n);
} else {
tmp = ((0.3333333333333333 / pow(x, 3.0)) + ((1.0 / x) - (0.5 / (x * x)))) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.3d-177) then
tmp = -log(x) / n
else if (x <= 1.56d-155) then
tmp = ((1.0d0 + (x / n)) + ((x * (x / n)) * ((-0.5d0) + (0.5d0 / n)))) - (x ** (1.0d0 / n))
else if (x <= 3.6d-6) then
tmp = (x + ((x * (x * (-0.5d0))) - log(x))) * ((-1.0d0) / -n)
else
tmp = ((0.3333333333333333d0 / (x ** 3.0d0)) + ((1.0d0 / x) - (0.5d0 / (x * x)))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.3e-177) {
tmp = -Math.log(x) / n;
} else if (x <= 1.56e-155) {
tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - Math.pow(x, (1.0 / n));
} else if (x <= 3.6e-6) {
tmp = (x + ((x * (x * -0.5)) - Math.log(x))) * (-1.0 / -n);
} else {
tmp = ((0.3333333333333333 / Math.pow(x, 3.0)) + ((1.0 / x) - (0.5 / (x * x)))) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.3e-177: tmp = -math.log(x) / n elif x <= 1.56e-155: tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - math.pow(x, (1.0 / n)) elif x <= 3.6e-6: tmp = (x + ((x * (x * -0.5)) - math.log(x))) * (-1.0 / -n) else: tmp = ((0.3333333333333333 / math.pow(x, 3.0)) + ((1.0 / x) - (0.5 / (x * x)))) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 3.3e-177) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.56e-155) tmp = Float64(Float64(Float64(1.0 + Float64(x / n)) + Float64(Float64(x * Float64(x / n)) * Float64(-0.5 + Float64(0.5 / n)))) - (x ^ Float64(1.0 / n))); elseif (x <= 3.6e-6) tmp = Float64(Float64(x + Float64(Float64(x * Float64(x * -0.5)) - log(x))) * Float64(-1.0 / Float64(-n))); else tmp = Float64(Float64(Float64(0.3333333333333333 / (x ^ 3.0)) + Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x)))) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.3e-177) tmp = -log(x) / n; elseif (x <= 1.56e-155) tmp = ((1.0 + (x / n)) + ((x * (x / n)) * (-0.5 + (0.5 / n)))) - (x ^ (1.0 / n)); elseif (x <= 3.6e-6) tmp = (x + ((x * (x * -0.5)) - log(x))) * (-1.0 / -n); else tmp = ((0.3333333333333333 / (x ^ 3.0)) + ((1.0 / x) - (0.5 / (x * x)))) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.3e-177], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.56e-155], N[(N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] + N[(N[(x * N[(x / n), $MachinePrecision]), $MachinePrecision] * N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.6e-6], N[(N[(x + N[(N[(x * N[(x * -0.5), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / (-n)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{-177}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.56 \cdot 10^{-155}:\\
\;\;\;\;\left(\left(1 + \frac{x}{n}\right) + \left(x \cdot \frac{x}{n}\right) \cdot \left(-0.5 + \frac{0.5}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-6}:\\
\;\;\;\;\left(x + \left(x \cdot \left(x \cdot -0.5\right) - \log x\right)\right) \cdot \frac{-1}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{x \cdot x}\right)}{n}\\
\end{array}
\end{array}
if x < 3.3e-177Initial program 43.6%
Taylor expanded in x around 0 43.6%
Taylor expanded in n around inf 56.5%
mul-1-neg56.5%
Simplified56.5%
if 3.3e-177 < x < 1.56e-155Initial program 71.1%
Taylor expanded in n around 0 71.1%
log1p-def79.9%
Simplified79.9%
Taylor expanded in x around 0 52.6%
+-commutative52.6%
associate-+r+52.6%
sub-neg52.6%
associate-*r/52.6%
metadata-eval52.6%
unpow252.6%
associate-*r/52.6%
metadata-eval52.6%
distribute-neg-frac52.6%
metadata-eval52.6%
+-commutative52.6%
distribute-rgt-in52.6%
associate-*l/52.6%
associate-*r/52.6%
associate-/r*52.6%
Simplified71.1%
if 1.56e-155 < x < 3.59999999999999984e-6Initial program 34.1%
Taylor expanded in x around 0 37.5%
fma-def37.5%
unpow237.5%
associate-*r/37.5%
metadata-eval37.5%
unpow237.5%
associate-*r/37.5%
metadata-eval37.5%
Simplified37.5%
Taylor expanded in n around inf 54.7%
associate--l+54.7%
*-commutative54.7%
unpow254.7%
Simplified54.7%
frac-2neg54.7%
div-inv54.7%
associate-*l*54.7%
Applied egg-rr54.7%
if 3.59999999999999984e-6 < x Initial program 68.5%
Taylor expanded in n around inf 65.2%
+-rgt-identity65.2%
+-rgt-identity65.2%
log1p-def65.2%
Simplified65.2%
Taylor expanded in x around inf 62.3%
associate--l+62.3%
associate-*r/62.3%
metadata-eval62.3%
associate-*r/62.3%
metadata-eval62.3%
unpow262.3%
Simplified62.3%
Final simplification59.0%
(FPCore (x n)
:precision binary64
(if (<= x 5.6e-177)
(/ (- (log x)) n)
(if (<= x 1.25e-155)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= x 3.6e-6)
(* (+ x (- (* x (* x -0.5)) (log x))) (/ -1.0 (- n)))
(/
(+ (/ 0.3333333333333333 (pow x 3.0)) (- (/ 1.0 x) (/ 0.5 (* x x))))
n)))))
double code(double x, double n) {
double tmp;
if (x <= 5.6e-177) {
tmp = -log(x) / n;
} else if (x <= 1.25e-155) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (x <= 3.6e-6) {
tmp = (x + ((x * (x * -0.5)) - log(x))) * (-1.0 / -n);
} else {
tmp = ((0.3333333333333333 / pow(x, 3.0)) + ((1.0 / x) - (0.5 / (x * x)))) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 5.6d-177) then
tmp = -log(x) / n
else if (x <= 1.25d-155) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else if (x <= 3.6d-6) then
tmp = (x + ((x * (x * (-0.5d0))) - log(x))) * ((-1.0d0) / -n)
else
tmp = ((0.3333333333333333d0 / (x ** 3.0d0)) + ((1.0d0 / x) - (0.5d0 / (x * x)))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 5.6e-177) {
tmp = -Math.log(x) / n;
} else if (x <= 1.25e-155) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (x <= 3.6e-6) {
tmp = (x + ((x * (x * -0.5)) - Math.log(x))) * (-1.0 / -n);
} else {
tmp = ((0.3333333333333333 / Math.pow(x, 3.0)) + ((1.0 / x) - (0.5 / (x * x)))) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5.6e-177: tmp = -math.log(x) / n elif x <= 1.25e-155: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif x <= 3.6e-6: tmp = (x + ((x * (x * -0.5)) - math.log(x))) * (-1.0 / -n) else: tmp = ((0.3333333333333333 / math.pow(x, 3.0)) + ((1.0 / x) - (0.5 / (x * x)))) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 5.6e-177) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.25e-155) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (x <= 3.6e-6) tmp = Float64(Float64(x + Float64(Float64(x * Float64(x * -0.5)) - log(x))) * Float64(-1.0 / Float64(-n))); else tmp = Float64(Float64(Float64(0.3333333333333333 / (x ^ 3.0)) + Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x)))) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5.6e-177) tmp = -log(x) / n; elseif (x <= 1.25e-155) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); elseif (x <= 3.6e-6) tmp = (x + ((x * (x * -0.5)) - log(x))) * (-1.0 / -n); else tmp = ((0.3333333333333333 / (x ^ 3.0)) + ((1.0 / x) - (0.5 / (x * x)))) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5.6e-177], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.25e-155], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.6e-6], N[(N[(x + N[(N[(x * N[(x * -0.5), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / (-n)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{-177}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-155}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-6}:\\
\;\;\;\;\left(x + \left(x \cdot \left(x \cdot -0.5\right) - \log x\right)\right) \cdot \frac{-1}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{x \cdot x}\right)}{n}\\
\end{array}
\end{array}
if x < 5.59999999999999973e-177Initial program 43.6%
Taylor expanded in x around 0 43.6%
Taylor expanded in n around inf 56.5%
mul-1-neg56.5%
Simplified56.5%
if 5.59999999999999973e-177 < x < 1.25e-155Initial program 71.1%
Taylor expanded in x around 0 71.1%
if 1.25e-155 < x < 3.59999999999999984e-6Initial program 34.1%
Taylor expanded in x around 0 37.5%
fma-def37.5%
unpow237.5%
associate-*r/37.5%
metadata-eval37.5%
unpow237.5%
associate-*r/37.5%
metadata-eval37.5%
Simplified37.5%
Taylor expanded in n around inf 54.7%
associate--l+54.7%
*-commutative54.7%
unpow254.7%
Simplified54.7%
frac-2neg54.7%
div-inv54.7%
associate-*l*54.7%
Applied egg-rr54.7%
if 3.59999999999999984e-6 < x Initial program 68.5%
Taylor expanded in n around inf 65.2%
+-rgt-identity65.2%
+-rgt-identity65.2%
log1p-def65.2%
Simplified65.2%
Taylor expanded in x around inf 62.3%
associate--l+62.3%
associate-*r/62.3%
metadata-eval62.3%
associate-*r/62.3%
metadata-eval62.3%
unpow262.3%
Simplified62.3%
Final simplification59.0%
(FPCore (x n)
:precision binary64
(if (<= x 5.6e-177)
(/ (- (log x)) n)
(if (<= x 2.65e-155)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= x 1.0)
(* (+ x (- (* x (* x -0.5)) (log x))) (/ -1.0 (- n)))
(- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))))
double code(double x, double n) {
double tmp;
if (x <= 5.6e-177) {
tmp = -log(x) / n;
} else if (x <= 2.65e-155) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x + ((x * (x * -0.5)) - log(x))) * (-1.0 / -n);
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 5.6d-177) then
tmp = -log(x) / n
else if (x <= 2.65d-155) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else if (x <= 1.0d0) then
tmp = (x + ((x * (x * (-0.5d0))) - log(x))) * ((-1.0d0) / -n)
else
tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 5.6e-177) {
tmp = -Math.log(x) / n;
} else if (x <= 2.65e-155) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x + ((x * (x * -0.5)) - Math.log(x))) * (-1.0 / -n);
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5.6e-177: tmp = -math.log(x) / n elif x <= 2.65e-155: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif x <= 1.0: tmp = (x + ((x * (x * -0.5)) - math.log(x))) * (-1.0 / -n) else: tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))) return tmp
function code(x, n) tmp = 0.0 if (x <= 5.6e-177) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.65e-155) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (x <= 1.0) tmp = Float64(Float64(x + Float64(Float64(x * Float64(x * -0.5)) - log(x))) * Float64(-1.0 / Float64(-n))); else tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5.6e-177) tmp = -log(x) / n; elseif (x <= 2.65e-155) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); elseif (x <= 1.0) tmp = (x + ((x * (x * -0.5)) - log(x))) * (-1.0 / -n); else tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5.6e-177], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.65e-155], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x + N[(N[(x * N[(x * -0.5), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / (-n)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{-177}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.65 \cdot 10^{-155}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\left(x + \left(x \cdot \left(x \cdot -0.5\right) - \log x\right)\right) \cdot \frac{-1}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if x < 5.59999999999999973e-177Initial program 43.6%
Taylor expanded in x around 0 43.6%
Taylor expanded in n around inf 56.5%
mul-1-neg56.5%
Simplified56.5%
if 5.59999999999999973e-177 < x < 2.6499999999999999e-155Initial program 71.1%
Taylor expanded in x around 0 71.1%
if 2.6499999999999999e-155 < x < 1Initial program 37.2%
Taylor expanded in x around 0 39.4%
fma-def39.4%
unpow239.4%
associate-*r/39.4%
metadata-eval39.4%
unpow239.4%
associate-*r/39.4%
metadata-eval39.4%
Simplified39.4%
Taylor expanded in n around inf 52.3%
associate--l+52.3%
*-commutative52.3%
unpow252.3%
Simplified52.3%
frac-2neg52.3%
div-inv52.3%
associate-*l*52.3%
Applied egg-rr52.3%
if 1 < x Initial program 67.3%
Taylor expanded in n around inf 67.5%
+-rgt-identity67.5%
+-rgt-identity67.5%
log1p-def67.5%
Simplified67.5%
Taylor expanded in x around inf 63.0%
associate-/r*64.2%
associate-*r/64.2%
metadata-eval64.2%
unpow264.2%
Simplified64.2%
Final simplification58.9%
(FPCore (x n)
:precision binary64
(if (<= x 8.5e-178)
(/ (- (log x)) n)
(if (<= x 1.32e-155)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= x 1.0)
(/ (+ x (- (* -0.5 (* x x)) (log x))) n)
(- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))))
double code(double x, double n) {
double tmp;
if (x <= 8.5e-178) {
tmp = -log(x) / n;
} else if (x <= 1.32e-155) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x + ((-0.5 * (x * x)) - log(x))) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 8.5d-178) then
tmp = -log(x) / n
else if (x <= 1.32d-155) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else if (x <= 1.0d0) then
tmp = (x + (((-0.5d0) * (x * x)) - log(x))) / n
else
tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 8.5e-178) {
tmp = -Math.log(x) / n;
} else if (x <= 1.32e-155) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (x <= 1.0) {
tmp = (x + ((-0.5 * (x * x)) - Math.log(x))) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 8.5e-178: tmp = -math.log(x) / n elif x <= 1.32e-155: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif x <= 1.0: tmp = (x + ((-0.5 * (x * x)) - math.log(x))) / n else: tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))) return tmp
function code(x, n) tmp = 0.0 if (x <= 8.5e-178) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.32e-155) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (x <= 1.0) tmp = Float64(Float64(x + Float64(Float64(-0.5 * Float64(x * x)) - log(x))) / n); else tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 8.5e-178) tmp = -log(x) / n; elseif (x <= 1.32e-155) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); elseif (x <= 1.0) tmp = (x + ((-0.5 * (x * x)) - log(x))) / n; else tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 8.5e-178], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.32e-155], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x + N[(N[(-0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{-178}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.32 \cdot 10^{-155}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x + \left(-0.5 \cdot \left(x \cdot x\right) - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if x < 8.5000000000000001e-178Initial program 43.6%
Taylor expanded in x around 0 43.6%
Taylor expanded in n around inf 56.5%
mul-1-neg56.5%
Simplified56.5%
if 8.5000000000000001e-178 < x < 1.3199999999999999e-155Initial program 71.1%
Taylor expanded in x around 0 71.1%
if 1.3199999999999999e-155 < x < 1Initial program 37.2%
Taylor expanded in x around 0 39.4%
fma-def39.4%
unpow239.4%
associate-*r/39.4%
metadata-eval39.4%
unpow239.4%
associate-*r/39.4%
metadata-eval39.4%
Simplified39.4%
Taylor expanded in n around inf 52.3%
associate--l+52.3%
*-commutative52.3%
unpow252.3%
Simplified52.3%
if 1 < x Initial program 67.3%
Taylor expanded in n around inf 67.5%
+-rgt-identity67.5%
+-rgt-identity67.5%
log1p-def67.5%
Simplified67.5%
Taylor expanded in x around inf 63.0%
associate-/r*64.2%
associate-*r/64.2%
metadata-eval64.2%
unpow264.2%
Simplified64.2%
Final simplification58.9%
(FPCore (x n)
:precision binary64
(if (<= x 5.2e-177)
(/ (- (log x)) n)
(if (<= x 1.55e-155)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= x 0.95)
(/ (- x (log x)) n)
(- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))))
double code(double x, double n) {
double tmp;
if (x <= 5.2e-177) {
tmp = -log(x) / n;
} else if (x <= 1.55e-155) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (x <= 0.95) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 5.2d-177) then
tmp = -log(x) / n
else if (x <= 1.55d-155) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else if (x <= 0.95d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 5.2e-177) {
tmp = -Math.log(x) / n;
} else if (x <= 1.55e-155) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (x <= 0.95) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5.2e-177: tmp = -math.log(x) / n elif x <= 1.55e-155: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif x <= 0.95: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))) return tmp
function code(x, n) tmp = 0.0 if (x <= 5.2e-177) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.55e-155) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (x <= 0.95) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5.2e-177) tmp = -log(x) / n; elseif (x <= 1.55e-155) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); elseif (x <= 0.95) tmp = (x - log(x)) / n; else tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5.2e-177], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.55e-155], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.95], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.2 \cdot 10^{-177}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-155}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if x < 5.2000000000000002e-177Initial program 43.6%
Taylor expanded in x around 0 43.6%
Taylor expanded in n around inf 56.5%
mul-1-neg56.5%
Simplified56.5%
if 5.2000000000000002e-177 < x < 1.55e-155Initial program 71.1%
Taylor expanded in x around 0 71.1%
if 1.55e-155 < x < 0.94999999999999996Initial program 37.2%
Taylor expanded in x around 0 39.4%
fma-def39.4%
unpow239.4%
associate-*r/39.4%
metadata-eval39.4%
unpow239.4%
associate-*r/39.4%
metadata-eval39.4%
Simplified39.4%
Taylor expanded in n around inf 52.3%
associate--l+52.3%
*-commutative52.3%
unpow252.3%
Simplified52.3%
Taylor expanded in x around 0 52.2%
mul-1-neg52.2%
unsub-neg52.2%
Simplified52.2%
if 0.94999999999999996 < x Initial program 67.3%
Taylor expanded in n around inf 67.5%
+-rgt-identity67.5%
+-rgt-identity67.5%
log1p-def67.5%
Simplified67.5%
Taylor expanded in x around inf 63.0%
associate-/r*64.2%
associate-*r/64.2%
metadata-eval64.2%
unpow264.2%
Simplified64.2%
Final simplification58.8%
(FPCore (x n)
:precision binary64
(if (<= x 3.3e-177)
(/ (- (log x)) n)
(if (<= x 1.25e-155)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.95)
(/ (- x (log x)) n)
(- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))))
double code(double x, double n) {
double tmp;
if (x <= 3.3e-177) {
tmp = -log(x) / n;
} else if (x <= 1.25e-155) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.95) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 3.3d-177) then
tmp = -log(x) / n
else if (x <= 1.25d-155) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.95d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 3.3e-177) {
tmp = -Math.log(x) / n;
} else if (x <= 1.25e-155) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.95) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 3.3e-177: tmp = -math.log(x) / n elif x <= 1.25e-155: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.95: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))) return tmp
function code(x, n) tmp = 0.0 if (x <= 3.3e-177) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.25e-155) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.95) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 3.3e-177) tmp = -log(x) / n; elseif (x <= 1.25e-155) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.95) tmp = (x - log(x)) / n; else tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 3.3e-177], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.25e-155], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.95], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{-177}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-155}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if x < 3.3e-177Initial program 43.6%
Taylor expanded in x around 0 43.6%
Taylor expanded in n around inf 56.5%
mul-1-neg56.5%
Simplified56.5%
if 3.3e-177 < x < 1.25e-155Initial program 71.1%
Taylor expanded in x around 0 71.1%
if 1.25e-155 < x < 0.94999999999999996Initial program 37.2%
Taylor expanded in x around 0 39.4%
fma-def39.4%
unpow239.4%
associate-*r/39.4%
metadata-eval39.4%
unpow239.4%
associate-*r/39.4%
metadata-eval39.4%
Simplified39.4%
Taylor expanded in n around inf 52.3%
associate--l+52.3%
*-commutative52.3%
unpow252.3%
Simplified52.3%
Taylor expanded in x around 0 52.2%
mul-1-neg52.2%
unsub-neg52.2%
Simplified52.2%
if 0.94999999999999996 < x Initial program 67.3%
Taylor expanded in n around inf 67.5%
+-rgt-identity67.5%
+-rgt-identity67.5%
log1p-def67.5%
Simplified67.5%
Taylor expanded in x around inf 63.0%
associate-/r*64.2%
associate-*r/64.2%
metadata-eval64.2%
unpow264.2%
Simplified64.2%
Final simplification58.8%
(FPCore (x n) :precision binary64 (if (<= x 0.98) (/ (- x (log x)) n) (- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))
double code(double x, double n) {
double tmp;
if (x <= 0.98) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.98d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.98) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.98: tmp = (x - math.log(x)) / n else: tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))) return tmp
function code(x, n) tmp = 0.0 if (x <= 0.98) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.98) tmp = (x - log(x)) / n; else tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.98], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.98:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if x < 0.97999999999999998Initial program 42.1%
Taylor expanded in x around 0 34.3%
fma-def34.3%
unpow234.3%
associate-*r/34.3%
metadata-eval34.3%
unpow234.3%
associate-*r/34.3%
metadata-eval34.3%
Simplified34.3%
Taylor expanded in n around inf 52.1%
associate--l+52.1%
*-commutative52.1%
unpow252.1%
Simplified52.1%
Taylor expanded in x around 0 52.0%
mul-1-neg52.0%
unsub-neg52.0%
Simplified52.0%
if 0.97999999999999998 < x Initial program 67.3%
Taylor expanded in n around inf 67.5%
+-rgt-identity67.5%
+-rgt-identity67.5%
log1p-def67.5%
Simplified67.5%
Taylor expanded in x around inf 63.0%
associate-/r*64.2%
associate-*r/64.2%
metadata-eval64.2%
unpow264.2%
Simplified64.2%
Final simplification57.0%
(FPCore (x n) :precision binary64 (if (<= x 0.66) (/ (- (log x)) n) (- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))
double code(double x, double n) {
double tmp;
if (x <= 0.66) {
tmp = -log(x) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.66d0) then
tmp = -log(x) / n
else
tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.66) {
tmp = -Math.log(x) / n;
} else {
tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.66: tmp = -math.log(x) / n else: tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))) return tmp
function code(x, n) tmp = 0.0 if (x <= 0.66) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.66) tmp = -log(x) / n; else tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.66], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.66:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if x < 0.660000000000000031Initial program 41.7%
Taylor expanded in x around 0 38.5%
Taylor expanded in n around inf 51.7%
mul-1-neg51.7%
Simplified51.7%
if 0.660000000000000031 < x Initial program 67.6%
Taylor expanded in n around inf 66.9%
+-rgt-identity66.9%
+-rgt-identity66.9%
log1p-def66.9%
Simplified66.9%
Taylor expanded in x around inf 62.4%
associate-/r*63.6%
associate-*r/63.6%
metadata-eval63.6%
unpow263.6%
Simplified63.6%
Final simplification56.6%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) 2e+74) (/ (/ 1.0 n) x) (if (<= (/ 1.0 n) 2e+214) (* 0.5 (/ (* x x) (* n n))) (/ 1.0 (* n x)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 2e+74) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e+214) {
tmp = 0.5 * ((x * x) / (n * 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 ((1.0d0 / n) <= 2d+74) then
tmp = (1.0d0 / n) / x
else if ((1.0d0 / n) <= 2d+214) then
tmp = 0.5d0 * ((x * x) / (n * n))
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 2e+74) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 2e+214) {
tmp = 0.5 * ((x * x) / (n * n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 2e+74: tmp = (1.0 / n) / x elif (1.0 / n) <= 2e+214: tmp = 0.5 * ((x * x) / (n * n)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 2e+74) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 2e+214) tmp = Float64(0.5 * Float64(Float64(x * x) / Float64(n * n))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= 2e+74) tmp = (1.0 / n) / x; elseif ((1.0 / n) <= 2e+214) tmp = 0.5 * ((x * x) / (n * n)); else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+74], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+214], N[(0.5 * N[(N[(x * x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{+74}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+214}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot x}{n \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < 1.9999999999999999e74Initial program 52.6%
Taylor expanded in n around inf 66.4%
+-rgt-identity66.4%
+-rgt-identity66.4%
log1p-def66.4%
Simplified66.4%
Taylor expanded in x around inf 39.1%
associate-/r*39.7%
Simplified39.7%
if 1.9999999999999999e74 < (/.f64 1 n) < 1.9999999999999999e214Initial program 61.5%
Taylor expanded in x around 0 69.2%
fma-def69.2%
unpow269.2%
associate-*r/69.2%
metadata-eval69.2%
unpow269.2%
associate-*r/69.2%
metadata-eval69.2%
Simplified69.2%
Taylor expanded in n around 0 34.7%
unpow234.7%
unpow234.7%
Simplified34.7%
if 1.9999999999999999e214 < (/.f64 1 n) Initial program 19.7%
Taylor expanded in n around inf 8.2%
+-rgt-identity8.2%
+-rgt-identity8.2%
log1p-def8.2%
Simplified8.2%
Taylor expanded in x around inf 89.2%
Final simplification41.0%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) 2e+48) (/ (/ 1.0 n) x) (* x (* x (/ 0.5 (* n n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 2e+48) {
tmp = (1.0 / n) / x;
} else {
tmp = x * (x * (0.5 / (n * 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+48) then
tmp = (1.0d0 / n) / x
else
tmp = x * (x * (0.5d0 / (n * n)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 2e+48) {
tmp = (1.0 / n) / x;
} else {
tmp = x * (x * (0.5 / (n * n)));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 2e+48: tmp = (1.0 / n) / x else: tmp = x * (x * (0.5 / (n * n))) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 2e+48) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(x * Float64(x * Float64(0.5 / Float64(n * n)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= 2e+48) tmp = (1.0 / n) / x; else tmp = x * (x * (0.5 / (n * n))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+48], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(x * N[(x * N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{+48}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{n \cdot n}\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < 2.00000000000000009e48Initial program 51.9%
Taylor expanded in n around inf 67.2%
+-rgt-identity67.2%
+-rgt-identity67.2%
log1p-def67.2%
Simplified67.2%
Taylor expanded in x around inf 39.6%
associate-/r*40.2%
Simplified40.2%
if 2.00000000000000009e48 < (/.f64 1 n) Initial program 54.5%
Taylor expanded in x around 0 68.4%
fma-def68.4%
unpow268.4%
associate-*r/68.4%
metadata-eval68.4%
unpow268.4%
associate-*r/68.4%
metadata-eval68.4%
Simplified68.4%
Taylor expanded in n around 0 37.2%
unpow237.2%
unpow237.2%
Simplified37.2%
Taylor expanded in x around 0 37.2%
*-commutative37.2%
associate-*l/37.2%
associate-*r/39.8%
unpow239.8%
unpow239.8%
associate-*l*51.0%
Simplified51.0%
Final simplification41.8%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 52.3%
Taylor expanded in n around inf 58.4%
+-rgt-identity58.4%
+-rgt-identity58.4%
log1p-def58.4%
Simplified58.4%
Taylor expanded in x around inf 38.3%
Final simplification38.3%
(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 52.3%
Taylor expanded in n around inf 58.4%
+-rgt-identity58.4%
+-rgt-identity58.4%
log1p-def58.4%
Simplified58.4%
Taylor expanded in x around inf 38.3%
associate-/r*38.8%
Simplified38.8%
Final simplification38.8%
(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 52.3%
Taylor expanded in x around 0 21.6%
fma-def21.6%
unpow221.6%
associate-*r/21.6%
metadata-eval21.6%
unpow221.6%
associate-*r/21.6%
metadata-eval21.6%
Simplified21.6%
Taylor expanded in x around inf 8.6%
fma-def8.6%
unpow28.6%
sub-neg8.6%
associate-*r/8.6%
metadata-eval8.6%
associate-*r/8.6%
metadata-eval8.6%
unpow28.6%
distribute-neg-frac8.6%
metadata-eval8.6%
Simplified8.6%
Taylor expanded in x around 0 4.6%
Final simplification4.6%
herbie shell --seed 2023275
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))