
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -1e-7)
(- 1.0 (cbrt (expm1 (log1p (pow x (/ 3.0 n))))))
(if (<= t_1 1e-13) (/ (- (log1p x) (log x)) n) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -1e-7) {
tmp = 1.0 - cbrt(expm1(log1p(pow(x, (3.0 / n)))));
} else if (t_1 <= 1e-13) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -1e-7) {
tmp = 1.0 - Math.cbrt(Math.expm1(Math.log1p(Math.pow(x, (3.0 / n)))));
} else if (t_1 <= 1e-13) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -1e-7) tmp = Float64(1.0 - cbrt(expm1(log1p((x ^ Float64(3.0 / n)))))); elseif (t_1 <= 1e-13) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-7], N[(1.0 - N[Power[N[(Exp[N[Log[1 + N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-13], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-7}:\\
\;\;\;\;1 - \sqrt[3]{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{\left(\frac{3}{n}\right)}\right)\right)}\\
\mathbf{elif}\;t\_1 \leq 10^{-13}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -9.9999999999999995e-8Initial program 99.2%
add-cbrt-cube99.2%
pow399.2%
pow-pow99.2%
Applied egg-rr99.2%
associate-*l/99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
associate-*r/99.2%
associate-*l/99.1%
*-commutative99.1%
exp-to-pow99.1%
unpow1/399.2%
Simplified99.2%
expm1-log1p-u99.3%
expm1-undefine99.3%
Applied egg-rr99.3%
expm1-define99.3%
Simplified99.3%
if -9.9999999999999995e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 1e-13Initial program 40.8%
Taylor expanded in n around inf 82.3%
+-rgt-identity82.3%
+-rgt-identity82.3%
log1p-define82.3%
Simplified82.3%
if 1e-13 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 44.5%
Taylor expanded in n around 0 44.5%
log1p-define99.6%
*-rgt-identity99.6%
associate-/l*99.6%
exp-to-pow99.6%
Simplified99.6%
Taylor expanded in x around 0 99.6%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -1e-7)
(- 1.0 t_0)
(if (<= t_1 1e-13) (/ (- (log1p x) (log x)) n) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -1e-7) {
tmp = 1.0 - t_0;
} else if (t_1 <= 1e-13) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -1e-7) {
tmp = 1.0 - t_0;
} else if (t_1 <= 1e-13) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -1e-7: tmp = 1.0 - t_0 elif t_1 <= 1e-13: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -1e-7) tmp = Float64(1.0 - t_0); elseif (t_1 <= 1e-13) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-7], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 1e-13], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-7}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{-13}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -9.9999999999999995e-8Initial program 99.2%
Taylor expanded in x around 0 99.2%
*-rgt-identity99.2%
associate-/l*99.2%
exp-to-pow99.2%
Simplified99.2%
if -9.9999999999999995e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 1e-13Initial program 40.8%
Taylor expanded in n around inf 82.3%
+-rgt-identity82.3%
+-rgt-identity82.3%
log1p-define82.3%
Simplified82.3%
if 1e-13 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 44.5%
Taylor expanded in n around 0 44.5%
log1p-define99.6%
*-rgt-identity99.6%
associate-/l*99.6%
exp-to-pow99.6%
Simplified99.6%
Taylor expanded in x around 0 99.6%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 -1e-7)
(- 1.0 (expm1 (log1p t_0)))
(if (<= t_1 1e-13) (/ (- (log1p x) (log x)) n) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -1e-7) {
tmp = 1.0 - expm1(log1p(t_0));
} else if (t_1 <= 1e-13) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -1e-7) {
tmp = 1.0 - Math.expm1(Math.log1p(t_0));
} else if (t_1 <= 1e-13) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -1e-7: tmp = 1.0 - math.expm1(math.log1p(t_0)) elif t_1 <= 1e-13: tmp = (math.log1p(x) - math.log(x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -1e-7) tmp = Float64(1.0 - expm1(log1p(t_0))); elseif (t_1 <= 1e-13) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-7], N[(1.0 - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-13], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-7}:\\
\;\;\;\;1 - \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-13}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -9.9999999999999995e-8Initial program 99.2%
Taylor expanded in x around 0 99.2%
*-rgt-identity99.2%
associate-/l*99.2%
exp-to-pow99.2%
Simplified99.2%
expm1-log1p-u99.2%
expm1-undefine99.2%
Applied egg-rr99.2%
expm1-define99.2%
Simplified99.2%
if -9.9999999999999995e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 1e-13Initial program 40.8%
Taylor expanded in n around inf 82.3%
+-rgt-identity82.3%
+-rgt-identity82.3%
log1p-define82.3%
Simplified82.3%
if 1e-13 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 44.5%
Taylor expanded in n around 0 44.5%
log1p-define99.6%
*-rgt-identity99.6%
associate-/l*99.6%
exp-to-pow99.6%
Simplified99.6%
Taylor expanded in x around 0 99.6%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-7)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) 5e-15)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 2e+121)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ x n))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-7) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 5e-15) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 2e+121) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1((x / n)));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-7) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= 5e-15) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 2e+121) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1((x / n)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-7: tmp = t_0 / (x * n) elif (1.0 / n) <= 5e-15: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 2e+121: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1((x / n))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-7) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= 5e-15) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 2e+121) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(x / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-7], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-15], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+121], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-7}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-15}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+121}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999977e-7Initial program 97.6%
Taylor expanded in x around inf 97.7%
log-rec97.7%
mul-1-neg97.7%
associate-*r/97.7%
associate-*r*97.7%
metadata-eval97.7%
*-commutative97.7%
associate-/l*97.7%
exp-to-pow97.7%
*-commutative97.7%
Simplified97.7%
if -4.99999999999999977e-7 < (/.f64 1 n) < 4.99999999999999999e-15Initial program 30.1%
Taylor expanded in n around inf 81.7%
+-rgt-identity81.7%
+-rgt-identity81.7%
log1p-define81.7%
Simplified81.7%
if 4.99999999999999999e-15 < (/.f64 1 n) < 2.00000000000000007e121Initial program 65.8%
Taylor expanded in x around 0 66.2%
if 2.00000000000000007e121 < (/.f64 1 n) Initial program 30.0%
Taylor expanded in n around inf 0.0%
Taylor expanded in x around inf 0.1%
+-commutative0.1%
mul-1-neg0.1%
distribute-frac-neg0.1%
log-rec0.1%
remove-double-neg0.1%
Simplified0.1%
Taylor expanded in n around inf 55.0%
*-commutative55.0%
Simplified55.0%
log1p-expm1-u79.6%
associate-/r*79.6%
rem-exp-log79.6%
neg-log79.6%
add-sqr-sqrt79.6%
sqrt-unprod79.6%
sqr-neg79.6%
sqrt-unprod0.0%
add-sqr-sqrt80.8%
add-exp-log80.8%
Applied egg-rr80.8%
Final simplification86.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 8.5e-190)
t_0
(if (<= x 4.2e-172)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= x 3.1e-136)
(* (log x) (/ -1.0 n))
(if (<= x 2.8e-73)
(log1p (expm1 (/ x n)))
(if (<= x 2.2e-60) t_0 (/ (pow x (+ (/ 1.0 n) -1.0)) n))))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 8.5e-190) {
tmp = t_0;
} else if (x <= 4.2e-172) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (x <= 3.1e-136) {
tmp = log(x) * (-1.0 / n);
} else if (x <= 2.8e-73) {
tmp = log1p(expm1((x / n)));
} else if (x <= 2.2e-60) {
tmp = t_0;
} else {
tmp = pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 8.5e-190) {
tmp = t_0;
} else if (x <= 4.2e-172) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (x <= 3.1e-136) {
tmp = Math.log(x) * (-1.0 / n);
} else if (x <= 2.8e-73) {
tmp = Math.log1p(Math.expm1((x / n)));
} else if (x <= 2.2e-60) {
tmp = t_0;
} else {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 8.5e-190: tmp = t_0 elif x <= 4.2e-172: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif x <= 3.1e-136: tmp = math.log(x) * (-1.0 / n) elif x <= 2.8e-73: tmp = math.log1p(math.expm1((x / n))) elif x <= 2.2e-60: tmp = t_0 else: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 8.5e-190) tmp = t_0; elseif (x <= 4.2e-172) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (x <= 3.1e-136) tmp = Float64(log(x) * Float64(-1.0 / n)); elseif (x <= 2.8e-73) tmp = log1p(expm1(Float64(x / n))); elseif (x <= 2.2e-60) tmp = t_0; else tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 8.5e-190], t$95$0, If[LessEqual[x, 4.2e-172], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e-136], N[(N[Log[x], $MachinePrecision] * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8e-73], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.2e-60], t$95$0, N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 8.5 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-172}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-136}:\\
\;\;\;\;\log x \cdot \frac{-1}{n}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-73}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\end{array}
\end{array}
if x < 8.5000000000000003e-190 or 2.80000000000000012e-73 < x < 2.1999999999999999e-60Initial program 39.4%
Taylor expanded in x around 0 39.4%
*-rgt-identity39.4%
associate-/l*39.4%
exp-to-pow39.4%
Simplified39.4%
Taylor expanded in n around inf 61.6%
associate-*r/61.6%
mul-1-neg61.6%
Simplified61.6%
if 8.5000000000000003e-190 < x < 4.1999999999999999e-172Initial program 83.9%
Taylor expanded in x around 0 84.0%
if 4.1999999999999999e-172 < x < 3.1e-136Initial program 36.9%
Taylor expanded in x around 0 36.9%
*-rgt-identity36.9%
associate-/l*36.9%
exp-to-pow36.9%
Simplified36.9%
Taylor expanded in n around inf 63.1%
associate-*r/63.1%
mul-1-neg63.1%
Simplified63.1%
div-inv63.3%
Applied egg-rr63.3%
if 3.1e-136 < x < 2.80000000000000012e-73Initial program 39.8%
Taylor expanded in n around inf 34.1%
Taylor expanded in x around inf 27.4%
+-commutative27.4%
mul-1-neg27.4%
distribute-frac-neg27.4%
log-rec27.4%
remove-double-neg27.4%
Simplified27.4%
Taylor expanded in n around inf 37.6%
*-commutative37.6%
Simplified37.6%
log1p-expm1-u60.1%
associate-/r*60.1%
rem-exp-log60.1%
neg-log60.1%
add-sqr-sqrt60.1%
sqrt-unprod60.1%
sqr-neg60.1%
sqrt-unprod0.0%
add-sqr-sqrt57.2%
add-exp-log57.2%
Applied egg-rr57.2%
if 2.1999999999999999e-60 < x Initial program 65.7%
Taylor expanded in x around inf 84.3%
log-rec84.3%
mul-1-neg84.3%
associate-*r/84.3%
associate-*r*84.3%
metadata-eval84.3%
*-commutative84.3%
associate-/l*84.3%
exp-to-pow84.3%
*-commutative84.3%
Simplified84.3%
*-un-lft-identity84.3%
associate-/r*84.7%
pow184.7%
pow-div84.4%
Applied egg-rr84.4%
*-lft-identity84.4%
sub-neg84.4%
metadata-eval84.4%
Simplified84.4%
Final simplification73.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 1e-189)
t_0
(if (<= x 2.4e-171)
t_1
(if (<= x 2.3e-60) t_0 (if (<= x 435.0) t_1 (/ (/ 1.0 n) x)))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 1e-189) {
tmp = t_0;
} else if (x <= 2.4e-171) {
tmp = t_1;
} else if (x <= 2.3e-60) {
tmp = t_0;
} else if (x <= 435.0) {
tmp = t_1;
} 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(x) / -n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 1d-189) then
tmp = t_0
else if (x <= 2.4d-171) then
tmp = t_1
else if (x <= 2.3d-60) then
tmp = t_0
else if (x <= 435.0d0) then
tmp = t_1
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(x) / -n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1e-189) {
tmp = t_0;
} else if (x <= 2.4e-171) {
tmp = t_1;
} else if (x <= 2.3e-60) {
tmp = t_0;
} else if (x <= 435.0) {
tmp = t_1;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 1e-189: tmp = t_0 elif x <= 2.4e-171: tmp = t_1 elif x <= 2.3e-60: tmp = t_0 elif x <= 435.0: tmp = t_1 else: tmp = (1.0 / n) / x return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 1e-189) tmp = t_0; elseif (x <= 2.4e-171) tmp = t_1; elseif (x <= 2.3e-60) tmp = t_0; elseif (x <= 435.0) tmp = t_1; else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 1e-189) tmp = t_0; elseif (x <= 2.4e-171) tmp = t_1; elseif (x <= 2.3e-60) tmp = t_0; elseif (x <= 435.0) tmp = t_1; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1e-189], t$95$0, If[LessEqual[x, 2.4e-171], t$95$1, If[LessEqual[x, 2.3e-60], t$95$0, If[LessEqual[x, 435.0], t$95$1, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 10^{-189}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-171}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 435:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if x < 1.00000000000000007e-189 or 2.39999999999999987e-171 < x < 2.3000000000000001e-60Initial program 39.1%
Taylor expanded in x around 0 39.1%
*-rgt-identity39.1%
associate-/l*39.1%
exp-to-pow39.1%
Simplified39.1%
Taylor expanded in n around inf 56.6%
associate-*r/56.6%
mul-1-neg56.6%
Simplified56.6%
if 1.00000000000000007e-189 < x < 2.39999999999999987e-171 or 2.3000000000000001e-60 < x < 435Initial program 62.6%
Taylor expanded in x around 0 56.0%
*-rgt-identity56.0%
associate-/l*56.0%
exp-to-pow56.0%
Simplified56.0%
if 435 < x Initial program 68.4%
Taylor expanded in n around inf 54.3%
Taylor expanded in x around inf 68.9%
+-commutative68.9%
mul-1-neg68.9%
distribute-frac-neg68.9%
log-rec68.9%
remove-double-neg68.9%
Simplified68.9%
Taylor expanded in n around inf 67.9%
associate-/r*68.4%
Simplified68.4%
Final simplification60.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 2.6e-190)
t_0
(if (<= x 4.1e-171)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 2.3e-60) t_0 (/ (pow x (+ (/ 1.0 n) -1.0)) n))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 2.6e-190) {
tmp = t_0;
} else if (x <= 4.1e-171) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 2.3e-60) {
tmp = t_0;
} else {
tmp = pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 2.6d-190) then
tmp = t_0
else if (x <= 4.1d-171) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 2.3d-60) then
tmp = t_0
else
tmp = (x ** ((1.0d0 / n) + (-1.0d0))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 2.6e-190) {
tmp = t_0;
} else if (x <= 4.1e-171) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 2.3e-60) {
tmp = t_0;
} else {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 2.6e-190: tmp = t_0 elif x <= 4.1e-171: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 2.3e-60: tmp = t_0 else: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 2.6e-190) tmp = t_0; elseif (x <= 4.1e-171) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 2.3e-60) tmp = t_0; else tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 2.6e-190) tmp = t_0; elseif (x <= 4.1e-171) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 2.3e-60) tmp = t_0; else tmp = (x ^ ((1.0 / n) + -1.0)) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 2.6e-190], t$95$0, If[LessEqual[x, 4.1e-171], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e-60], t$95$0, N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 2.6 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{-171}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\end{array}
\end{array}
if x < 2.5999999999999998e-190 or 4.1e-171 < x < 2.3000000000000001e-60Initial program 39.1%
Taylor expanded in x around 0 39.1%
*-rgt-identity39.1%
associate-/l*39.1%
exp-to-pow39.1%
Simplified39.1%
Taylor expanded in n around inf 56.6%
associate-*r/56.6%
mul-1-neg56.6%
Simplified56.6%
if 2.5999999999999998e-190 < x < 4.1e-171Initial program 83.9%
Taylor expanded in x around 0 83.9%
*-rgt-identity83.9%
associate-/l*83.9%
exp-to-pow83.9%
Simplified83.9%
if 2.3000000000000001e-60 < x Initial program 65.7%
Taylor expanded in x around inf 84.3%
log-rec84.3%
mul-1-neg84.3%
associate-*r/84.3%
associate-*r*84.3%
metadata-eval84.3%
*-commutative84.3%
associate-/l*84.3%
exp-to-pow84.3%
*-commutative84.3%
Simplified84.3%
*-un-lft-identity84.3%
associate-/r*84.7%
pow184.7%
pow-div84.4%
Applied egg-rr84.4%
*-lft-identity84.4%
sub-neg84.4%
metadata-eval84.4%
Simplified84.4%
Final simplification71.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 6.4e-190)
t_0
(if (<= x 4.3e-172)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(if (<= x 2.3e-60) t_0 (/ (pow x (+ (/ 1.0 n) -1.0)) n))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 6.4e-190) {
tmp = t_0;
} else if (x <= 4.3e-172) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else if (x <= 2.3e-60) {
tmp = t_0;
} else {
tmp = pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 6.4d-190) then
tmp = t_0
else if (x <= 4.3d-172) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else if (x <= 2.3d-60) then
tmp = t_0
else
tmp = (x ** ((1.0d0 / n) + (-1.0d0))) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 6.4e-190) {
tmp = t_0;
} else if (x <= 4.3e-172) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else if (x <= 2.3e-60) {
tmp = t_0;
} else {
tmp = Math.pow(x, ((1.0 / n) + -1.0)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 6.4e-190: tmp = t_0 elif x <= 4.3e-172: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) elif x <= 2.3e-60: tmp = t_0 else: tmp = math.pow(x, ((1.0 / n) + -1.0)) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 6.4e-190) tmp = t_0; elseif (x <= 4.3e-172) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); elseif (x <= 2.3e-60) tmp = t_0; else tmp = Float64((x ^ Float64(Float64(1.0 / n) + -1.0)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 6.4e-190) tmp = t_0; elseif (x <= 4.3e-172) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); elseif (x <= 2.3e-60) tmp = t_0; else tmp = (x ^ ((1.0 / n) + -1.0)) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 6.4e-190], t$95$0, If[LessEqual[x, 4.3e-172], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e-60], t$95$0, N[(N[Power[x, N[(N[(1.0 / n), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 6.4 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{-172}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\
\end{array}
\end{array}
if x < 6.4000000000000001e-190 or 4.2999999999999997e-172 < x < 2.3000000000000001e-60Initial program 39.1%
Taylor expanded in x around 0 39.1%
*-rgt-identity39.1%
associate-/l*39.1%
exp-to-pow39.1%
Simplified39.1%
Taylor expanded in n around inf 56.6%
associate-*r/56.6%
mul-1-neg56.6%
Simplified56.6%
if 6.4000000000000001e-190 < x < 4.2999999999999997e-172Initial program 83.9%
Taylor expanded in x around 0 84.0%
if 2.3000000000000001e-60 < x Initial program 65.7%
Taylor expanded in x around inf 84.3%
log-rec84.3%
mul-1-neg84.3%
associate-*r/84.3%
associate-*r*84.3%
metadata-eval84.3%
*-commutative84.3%
associate-/l*84.3%
exp-to-pow84.3%
*-commutative84.3%
Simplified84.3%
*-un-lft-identity84.3%
associate-/r*84.7%
pow184.7%
pow-div84.4%
Applied egg-rr84.4%
*-lft-identity84.4%
sub-neg84.4%
metadata-eval84.4%
Simplified84.4%
Final simplification71.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 4.7e-237)
t_0
(if (<= x 5.4e-229)
(/ 1.0 (* x n))
(if (<= x 7.8e-7) t_0 (/ (/ 1.0 n) x))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 4.7e-237) {
tmp = t_0;
} else if (x <= 5.4e-229) {
tmp = 1.0 / (x * n);
} else if (x <= 7.8e-7) {
tmp = 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 = log(x) / -n
if (x <= 4.7d-237) then
tmp = t_0
else if (x <= 5.4d-229) then
tmp = 1.0d0 / (x * n)
else if (x <= 7.8d-7) then
tmp = 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.log(x) / -n;
double tmp;
if (x <= 4.7e-237) {
tmp = t_0;
} else if (x <= 5.4e-229) {
tmp = 1.0 / (x * n);
} else if (x <= 7.8e-7) {
tmp = t_0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 4.7e-237: tmp = t_0 elif x <= 5.4e-229: tmp = 1.0 / (x * n) elif x <= 7.8e-7: tmp = t_0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 4.7e-237) tmp = t_0; elseif (x <= 5.4e-229) tmp = Float64(1.0 / Float64(x * n)); elseif (x <= 7.8e-7) tmp = t_0; else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 4.7e-237) tmp = t_0; elseif (x <= 5.4e-229) tmp = 1.0 / (x * n); elseif (x <= 7.8e-7) tmp = t_0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 4.7e-237], t$95$0, If[LessEqual[x, 5.4e-229], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.8e-7], t$95$0, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 4.7 \cdot 10^{-237}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{-229}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if x < 4.6999999999999998e-237 or 5.3999999999999997e-229 < x < 7.80000000000000049e-7Initial program 43.0%
Taylor expanded in x around 0 41.7%
*-rgt-identity41.7%
associate-/l*41.7%
exp-to-pow41.7%
Simplified41.7%
Taylor expanded in n around inf 53.5%
associate-*r/53.5%
mul-1-neg53.5%
Simplified53.5%
if 4.6999999999999998e-237 < x < 5.3999999999999997e-229Initial program 76.1%
Taylor expanded in n around inf 1.3%
Taylor expanded in x around inf 58.7%
+-commutative58.7%
mul-1-neg58.7%
distribute-frac-neg58.7%
log-rec58.7%
remove-double-neg58.7%
Simplified58.7%
Taylor expanded in n around inf 72.9%
*-commutative72.9%
Simplified72.9%
if 7.80000000000000049e-7 < x Initial program 69.4%
Taylor expanded in n around inf 52.7%
Taylor expanded in x around inf 67.8%
+-commutative67.8%
mul-1-neg67.8%
distribute-frac-neg67.8%
log-rec67.8%
remove-double-neg67.8%
Simplified67.8%
Taylor expanded in n around inf 65.9%
associate-/r*66.4%
Simplified66.4%
Final simplification58.8%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 53.8%
Taylor expanded in n around inf 51.7%
Taylor expanded in x around inf 41.0%
+-commutative41.0%
mul-1-neg41.0%
distribute-frac-neg41.0%
log-rec41.0%
remove-double-neg41.0%
Simplified41.0%
Taylor expanded in n around inf 39.6%
*-commutative39.6%
Simplified39.6%
Final simplification39.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(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 53.8%
Taylor expanded in n around inf 51.7%
Taylor expanded in x around inf 41.0%
+-commutative41.0%
mul-1-neg41.0%
distribute-frac-neg41.0%
log-rec41.0%
remove-double-neg41.0%
Simplified41.0%
Taylor expanded in n around inf 39.6%
associate-/r*39.8%
Simplified39.8%
Final simplification39.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 53.8%
Taylor expanded in n around inf 51.7%
Taylor expanded in x around inf 41.0%
+-commutative41.0%
mul-1-neg41.0%
distribute-frac-neg41.0%
log-rec41.0%
remove-double-neg41.0%
Simplified41.0%
Taylor expanded in n around inf 39.6%
*-commutative39.6%
Simplified39.6%
inv-pow39.6%
unpow-prod-down39.8%
pow-to-exp39.1%
*-commutative39.1%
neg-mul-139.1%
add-sqr-sqrt15.0%
sqrt-unprod16.3%
sqr-neg16.3%
sqrt-unprod1.3%
add-sqr-sqrt4.6%
add-exp-log4.6%
inv-pow4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
Simplified4.6%
Final simplification4.6%
herbie shell --seed 2024039
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))