
(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
(if (<= n -33000000.0)
(/
(+
(log1p x)
(- (* (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n) 0.5) (log x)))
n)
(if (<= n 310000.0)
(- (exp (/ x n)) (pow x (/ 1.0 n)))
(/ (log (/ (+ 1.0 x) x)) n))))
double code(double x, double n) {
double tmp;
if (n <= -33000000.0) {
tmp = (log1p(x) + ((((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n) * 0.5) - log(x))) / n;
} else if (n <= 310000.0) {
tmp = exp((x / n)) - pow(x, (1.0 / n));
} else {
tmp = log(((1.0 + x) / x)) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (n <= -33000000.0) {
tmp = (Math.log1p(x) + ((((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n) * 0.5) - Math.log(x))) / n;
} else if (n <= 310000.0) {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = Math.log(((1.0 + x) / x)) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -33000000.0: tmp = (math.log1p(x) + ((((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n) * 0.5) - math.log(x))) / n elif n <= 310000.0: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) else: tmp = math.log(((1.0 + x) / x)) / n return tmp
function code(x, n) tmp = 0.0 if (n <= -33000000.0) tmp = Float64(Float64(log1p(x) + Float64(Float64(Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n) * 0.5) - log(x))) / n); elseif (n <= 310000.0) tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); end return tmp end
code[x_, n_] := If[LessEqual[n, -33000000.0], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * 0.5), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 310000.0], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -33000000:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} \cdot 0.5 - \log x\right)}{n}\\
\mathbf{elif}\;n \leq 310000:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\end{array}
\end{array}
if n < -3.3e7Initial program 36.2%
Taylor expanded in n around inf 87.8%
associate--l+87.8%
log1p-define87.8%
+-commutative87.8%
associate--r+87.8%
distribute-lft-out--87.8%
div-sub87.8%
log1p-define87.8%
Simplified87.8%
if -3.3e7 < n < 3.1e5Initial program 83.5%
Taylor expanded in n around 0 83.5%
log1p-define98.1%
*-rgt-identity98.1%
associate-/l*98.1%
exp-to-pow98.1%
Simplified98.1%
Taylor expanded in x around 0 98.1%
if 3.1e5 < n Initial program 30.3%
Taylor expanded in n around inf 78.3%
log1p-define78.3%
Simplified78.3%
log1p-undefine78.3%
diff-log78.8%
Applied egg-rr78.8%
Final simplification89.6%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) 5e-32)
(/
(log
(/
(*
(sqrt (exp (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)))
(+ 1.0 x))
x))
n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 5e-32) {
tmp = log(((sqrt(exp(((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n))) * (1.0 + x)) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 5e-32) {
tmp = Math.log(((Math.sqrt(Math.exp(((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n))) * (1.0 + x)) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 5e-32: tmp = math.log(((math.sqrt(math.exp(((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n))) * (1.0 + x)) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 5e-32) tmp = Float64(log(Float64(Float64(sqrt(exp(Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n))) * Float64(1.0 + x)) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-32], N[(N[Log[N[(N[(N[Sqrt[N[Exp[N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 5 \cdot 10^{-32}:\\
\;\;\;\;\frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot \left(1 + x\right)}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < 5e-32Initial program 54.5%
Taylor expanded in n around inf 78.4%
associate--l+66.1%
log1p-define66.1%
+-commutative66.1%
associate--r+78.4%
distribute-lft-out--78.4%
div-sub78.4%
log1p-define78.4%
Simplified78.4%
associate-+r-78.4%
add-log-exp87.6%
exp-diff87.6%
add-exp-log59.3%
Applied egg-rr59.3%
+-commutative59.3%
exp-sum59.3%
*-commutative59.3%
exp-prod59.3%
unpow1/259.3%
log1p-define59.3%
rem-exp-log87.9%
Simplified87.9%
if 5e-32 < (/.f64 #s(literal 1 binary64) n) Initial program 57.0%
Taylor expanded in n around 0 57.0%
log1p-define95.5%
*-rgt-identity95.5%
associate-/l*95.5%
exp-to-pow95.5%
Simplified95.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ 1.0 x) (/ 1.0 n)) t_0)))
(if (<= t_1 -2e-6)
(pow (cbrt (- 1.0 t_0)) 3.0)
(if (<= t_1 0.0) (/ (log (/ (+ 1.0 x) x)) n) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((1.0 + x), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -2e-6) {
tmp = pow(cbrt((1.0 - t_0)), 3.0);
} else if (t_1 <= 0.0) {
tmp = log(((1.0 + x) / 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((1.0 + x), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -2e-6) {
tmp = Math.pow(Math.cbrt((1.0 - t_0)), 3.0);
} else if (t_1 <= 0.0) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -2e-6) tmp = cbrt(Float64(1.0 - t_0)) ^ 3.0; elseif (t_1 <= 0.0) tmp = Float64(log(Float64(Float64(1.0 + x) / 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[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-6], N[Power[N[Power[N[(1.0 - t$95$0), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-6}:\\
\;\;\;\;{\left(\sqrt[3]{1 - t\_0}\right)}^{3}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -1.99999999999999991e-6Initial program 98.9%
Taylor expanded in x around 0 98.9%
*-rgt-identity98.9%
associate-/l*98.9%
exp-to-pow98.9%
Simplified98.9%
add-cube-cbrt98.9%
pow399.0%
Applied egg-rr99.0%
if -1.99999999999999991e-6 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 42.9%
Taylor expanded in n around inf 84.3%
log1p-define84.3%
Simplified84.3%
log1p-undefine84.3%
diff-log84.7%
Applied egg-rr84.7%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 59.6%
Taylor expanded in n around 0 59.6%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification89.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-8)
(- (exp (/ x n)) t_0)
(if (<= (/ 1.0 n) 5e-32)
(/ (log (+ 1.0 (+ (/ 1.0 x) (/ (log x) (* n x))))) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-8) {
tmp = exp((x / n)) - t_0;
} else if ((1.0 / n) <= 5e-32) {
tmp = log((1.0 + ((1.0 / x) + (log(x) / (n * x))))) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-8) {
tmp = Math.exp((x / n)) - t_0;
} else if ((1.0 / n) <= 5e-32) {
tmp = Math.log((1.0 + ((1.0 / x) + (Math.log(x) / (n * x))))) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-8: tmp = math.exp((x / n)) - t_0 elif (1.0 / n) <= 5e-32: tmp = math.log((1.0 + ((1.0 / x) + (math.log(x) / (n * x))))) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-8) tmp = Float64(exp(Float64(x / n)) - t_0); elseif (Float64(1.0 / n) <= 5e-32) tmp = Float64(log(Float64(1.0 + Float64(Float64(1.0 / x) + Float64(log(x) / Float64(n * x))))) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-8], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-32], N[(N[Log[N[(1.0 + N[(N[(1.0 / x), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-8}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-32}:\\
\;\;\;\;\frac{\log \left(1 + \left(\frac{1}{x} + \frac{\log x}{n \cdot x}\right)\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-8Initial program 98.0%
Taylor expanded in n around 0 98.0%
log1p-define98.0%
*-rgt-identity98.0%
associate-/l*98.0%
exp-to-pow98.0%
Simplified98.0%
Taylor expanded in x around 0 98.0%
if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 5e-32Initial program 32.9%
Taylor expanded in n around inf 83.3%
associate--l+83.3%
log1p-define83.3%
+-commutative83.3%
associate--r+83.3%
distribute-lft-out--83.3%
div-sub83.3%
log1p-define83.3%
Simplified83.3%
associate-+r-83.3%
add-log-exp83.3%
exp-diff83.3%
add-exp-log58.6%
Applied egg-rr58.6%
+-commutative58.6%
exp-sum58.6%
*-commutative58.6%
exp-prod58.6%
unpow1/258.6%
log1p-define58.6%
rem-exp-log83.7%
Simplified83.7%
Taylor expanded in x around inf 83.4%
+-commutative83.4%
mul-1-neg83.4%
log-rec83.4%
distribute-frac-neg83.4%
remove-double-neg83.4%
*-commutative83.4%
Simplified83.4%
if 5e-32 < (/.f64 #s(literal 1 binary64) n) Initial program 57.0%
Taylor expanded in n around 0 57.0%
log1p-define95.5%
*-rgt-identity95.5%
associate-/l*95.5%
exp-to-pow95.5%
Simplified95.5%
Final simplification89.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (+ 1.0 x) x)))
(if (<= (/ 1.0 n) -0.1)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-6)
(/ (log t_0) n)
(if (<= (/ 1.0 n) 1e+115)
(- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
(log (pow t_0 (/ 1.0 n))))))))
double code(double x, double n) {
double t_0 = (1.0 + x) / x;
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = log(t_0) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
} else {
tmp = log(pow(t_0, (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 = (1.0d0 + x) / x
if ((1.0d0 / n) <= (-0.1d0)) then
tmp = exp((log(x) / n)) / (n * x)
else if ((1.0d0 / n) <= 5d-6) then
tmp = log(t_0) / n
else if ((1.0d0 / n) <= 1d+115) then
tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
else
tmp = log((t_0 ** (1.0d0 / n)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (1.0 + x) / x;
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = Math.log(t_0) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = Math.log(Math.pow(t_0, (1.0 / n)));
}
return tmp;
}
def code(x, n): t_0 = (1.0 + x) / x tmp = 0 if (1.0 / n) <= -0.1: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 5e-6: tmp = math.log(t_0) / n elif (1.0 / n) <= 1e+115: tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n)) else: tmp = math.log(math.pow(t_0, (1.0 / n))) return tmp
function code(x, n) t_0 = Float64(Float64(1.0 + x) / x) tmp = 0.0 if (Float64(1.0 / n) <= -0.1) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-6) tmp = Float64(log(t_0) / n); elseif (Float64(1.0 / n) <= 1e+115) tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = log((t_0 ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) t_0 = (1.0 + x) / x; tmp = 0.0; if ((1.0 / n) <= -0.1) tmp = exp((log(x) / n)) / (n * x); elseif ((1.0 / n) <= 5e-6) tmp = log(t_0) / n; elseif ((1.0 / n) <= 1e+115) tmp = (1.0 + (x / n)) - (x ^ (1.0 / n)); else tmp = log((t_0 ^ (1.0 / n))); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-6], N[(N[Log[t$95$0], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+115], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[N[Power[t$95$0, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 + x}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+115}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\log \left({t\_0}^{\left(\frac{1}{n}\right)}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.10000000000000001Initial program 98.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
if -0.10000000000000001 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000041e-6Initial program 33.8%
Taylor expanded in n around inf 81.5%
log1p-define81.5%
Simplified81.5%
log1p-undefine81.5%
diff-log81.9%
Applied egg-rr81.9%
if 5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 1e115Initial program 90.8%
Taylor expanded in x around 0 86.2%
if 1e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.0%
Taylor expanded in n around inf 6.4%
log1p-define6.4%
Simplified6.4%
add-log-exp80.6%
div-inv80.6%
exp-prod80.6%
exp-diff80.6%
add-exp-log80.6%
log1p-undefine80.6%
rem-exp-log80.6%
Applied egg-rr80.6%
Final simplification86.9%
(FPCore (x n) :precision binary64 (if (or (<= n -8500000000.0) (not (<= n 310000.0))) (/ (log (/ (+ 1.0 x) x)) n) (- (exp (/ x n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
double tmp;
if ((n <= -8500000000.0) || !(n <= 310000.0)) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-8500000000.0d0)) .or. (.not. (n <= 310000.0d0))) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = exp((x / n)) - (x ** (1.0d0 / n))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -8500000000.0) || !(n <= 310000.0)) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -8500000000.0) or not (n <= 310000.0): tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if ((n <= -8500000000.0) || !(n <= 310000.0)) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -8500000000.0) || ~((n <= 310000.0))) tmp = log(((1.0 + x) / x)) / n; else tmp = exp((x / n)) - (x ^ (1.0 / n)); end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -8500000000.0], N[Not[LessEqual[n, 310000.0]], $MachinePrecision]], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8500000000 \lor \neg \left(n \leq 310000\right):\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if n < -8.5e9 or 3.1e5 < n Initial program 32.8%
Taylor expanded in n around inf 82.5%
log1p-define82.5%
Simplified82.5%
log1p-undefine82.5%
diff-log82.9%
Applied egg-rr82.9%
if -8.5e9 < n < 3.1e5Initial program 83.4%
Taylor expanded in n around 0 83.4%
log1p-define97.9%
*-rgt-identity97.9%
associate-/l*97.9%
exp-to-pow97.9%
Simplified97.9%
Taylor expanded in x around 0 97.9%
Final simplification89.5%
(FPCore (x n)
:precision binary64
(if (<= n -10000000000.0)
(/ (log (+ 1.0 (+ (/ 1.0 x) (/ (log x) (* n x))))) n)
(if (<= n 310000.0)
(- (exp (/ x n)) (pow x (/ 1.0 n)))
(/ (log (/ (+ 1.0 x) x)) n))))
double code(double x, double n) {
double tmp;
if (n <= -10000000000.0) {
tmp = log((1.0 + ((1.0 / x) + (log(x) / (n * x))))) / n;
} else if (n <= 310000.0) {
tmp = exp((x / n)) - pow(x, (1.0 / n));
} else {
tmp = log(((1.0 + 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 (n <= (-10000000000.0d0)) then
tmp = log((1.0d0 + ((1.0d0 / x) + (log(x) / (n * x))))) / n
else if (n <= 310000.0d0) then
tmp = exp((x / n)) - (x ** (1.0d0 / n))
else
tmp = log(((1.0d0 + x) / x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -10000000000.0) {
tmp = Math.log((1.0 + ((1.0 / x) + (Math.log(x) / (n * x))))) / n;
} else if (n <= 310000.0) {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = Math.log(((1.0 + x) / x)) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -10000000000.0: tmp = math.log((1.0 + ((1.0 / x) + (math.log(x) / (n * x))))) / n elif n <= 310000.0: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) else: tmp = math.log(((1.0 + x) / x)) / n return tmp
function code(x, n) tmp = 0.0 if (n <= -10000000000.0) tmp = Float64(log(Float64(1.0 + Float64(Float64(1.0 / x) + Float64(log(x) / Float64(n * x))))) / n); elseif (n <= 310000.0) tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -10000000000.0) tmp = log((1.0 + ((1.0 / x) + (log(x) / (n * x))))) / n; elseif (n <= 310000.0) tmp = exp((x / n)) - (x ^ (1.0 / n)); else tmp = log(((1.0 + x) / x)) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -10000000000.0], N[(N[Log[N[(1.0 + N[(N[(1.0 / x), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 310000.0], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -10000000000:\\
\;\;\;\;\frac{\log \left(1 + \left(\frac{1}{x} + \frac{\log x}{n \cdot x}\right)\right)}{n}\\
\mathbf{elif}\;n \leq 310000:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\end{array}
\end{array}
if n < -1e10Initial program 35.6%
Taylor expanded in n around inf 87.9%
associate--l+87.9%
log1p-define87.9%
+-commutative87.9%
associate--r+87.9%
distribute-lft-out--87.9%
div-sub87.9%
log1p-define87.9%
Simplified87.9%
associate-+r-87.9%
add-log-exp87.9%
exp-diff87.9%
add-exp-log61.3%
Applied egg-rr61.3%
+-commutative61.3%
exp-sum61.3%
*-commutative61.3%
exp-prod61.3%
unpow1/261.3%
log1p-define61.3%
rem-exp-log88.2%
Simplified88.2%
Taylor expanded in x around inf 87.7%
+-commutative87.7%
mul-1-neg87.7%
log-rec87.7%
distribute-frac-neg87.7%
remove-double-neg87.7%
*-commutative87.7%
Simplified87.7%
if -1e10 < n < 3.1e5Initial program 83.4%
Taylor expanded in n around 0 83.4%
log1p-define97.9%
*-rgt-identity97.9%
associate-/l*97.9%
exp-to-pow97.9%
Simplified97.9%
Taylor expanded in x around 0 97.9%
if 3.1e5 < n Initial program 30.3%
Taylor expanded in n around inf 78.3%
log1p-define78.3%
Simplified78.3%
log1p-undefine78.3%
diff-log78.8%
Applied egg-rr78.8%
Final simplification89.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.1)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-6)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+115)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ 1.0 t_0) (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / t_0) / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-0.1d0)) then
tmp = exp((log(x) / n)) / (n * x)
else if ((1.0d0 / n) <= 5d-6) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d+115) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (1.0d0 / t_0) / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / t_0) / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.1: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 5e-6: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+115: tmp = (1.0 + (x / n)) - t_0 else: tmp = (1.0 / t_0) / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.1) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-6) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+115) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(1.0 / t_0) / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -0.1) tmp = exp((log(x) / n)) / (n * x); elseif ((1.0 / n) <= 5e-6) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e+115) tmp = (1.0 + (x / n)) - t_0; else tmp = (1.0 / t_0) / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-6], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+115], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+115}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.10000000000000001Initial program 98.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
if -0.10000000000000001 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000041e-6Initial program 33.8%
Taylor expanded in n around inf 81.5%
log1p-define81.5%
Simplified81.5%
log1p-undefine81.5%
diff-log81.9%
Applied egg-rr81.9%
if 5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 1e115Initial program 90.8%
Taylor expanded in x around 0 86.2%
if 1e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.0%
Taylor expanded in x around inf 0.8%
mul-1-neg0.8%
log-rec0.8%
mul-1-neg0.8%
distribute-neg-frac0.8%
mul-1-neg0.8%
remove-double-neg0.8%
*-commutative0.8%
Simplified0.8%
add-sqr-sqrt0.0%
sqrt-unprod80.6%
sqr-neg80.6%
distribute-frac-neg80.6%
distribute-frac-neg80.6%
sqrt-unprod80.6%
add-sqr-sqrt80.6%
distribute-frac-neg80.6%
exp-neg80.6%
div-inv80.6%
exp-to-pow80.6%
Applied egg-rr80.6%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.1)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-6)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+115)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ 1.0 t_0) (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / t_0) / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-0.1d0)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-6) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d+115) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (1.0d0 / t_0) / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / t_0) / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.1: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-6: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+115: tmp = (1.0 + (x / n)) - t_0 else: tmp = (1.0 / t_0) / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.1) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-6) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+115) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(1.0 / t_0) / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -0.1) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-6) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e+115) tmp = (1.0 + (x / n)) - t_0; else tmp = (1.0 / t_0) / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-6], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+115], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+115}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.10000000000000001Initial program 98.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-/l*99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -0.10000000000000001 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000041e-6Initial program 33.8%
Taylor expanded in n around inf 81.5%
log1p-define81.5%
Simplified81.5%
log1p-undefine81.5%
diff-log81.9%
Applied egg-rr81.9%
if 5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 1e115Initial program 90.8%
Taylor expanded in x around 0 86.2%
if 1e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.0%
Taylor expanded in x around inf 0.8%
mul-1-neg0.8%
log-rec0.8%
mul-1-neg0.8%
distribute-neg-frac0.8%
mul-1-neg0.8%
remove-double-neg0.8%
*-commutative0.8%
Simplified0.8%
add-sqr-sqrt0.0%
sqrt-unprod80.6%
sqr-neg80.6%
distribute-frac-neg80.6%
distribute-frac-neg80.6%
sqrt-unprod80.6%
add-sqr-sqrt80.6%
distribute-frac-neg80.6%
exp-neg80.6%
div-inv80.6%
exp-to-pow80.6%
Applied egg-rr80.6%
Final simplification86.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.1)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-6)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+115)
(- (+ 1.0 (/ x n)) t_0)
(/ (log1p (+ x -1.0)) (- n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p((x + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p((x + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.1: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-6: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+115: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p((x + -1.0)) / -n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.1) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-6) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+115) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-6], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+115], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+115}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.10000000000000001Initial program 98.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-/l*99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -0.10000000000000001 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000041e-6Initial program 33.8%
Taylor expanded in n around inf 81.5%
log1p-define81.5%
Simplified81.5%
log1p-undefine81.5%
diff-log81.9%
Applied egg-rr81.9%
if 5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 1e115Initial program 90.8%
Taylor expanded in x around 0 86.2%
if 1e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.0%
Taylor expanded in n around inf 6.4%
log1p-define6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
neg-mul-16.4%
Simplified6.4%
log1p-expm1-u75.9%
expm1-undefine75.9%
add-exp-log75.9%
Applied egg-rr75.9%
Final simplification86.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.1)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-6)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+115) (- 1.0 t_0) (/ (log1p (+ x -1.0)) (- n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = 1.0 - t_0;
} else {
tmp = log1p((x + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.1) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-6) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = 1.0 - t_0;
} else {
tmp = Math.log1p((x + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.1: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-6: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+115: tmp = 1.0 - t_0 else: tmp = math.log1p((x + -1.0)) / -n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.1) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-6) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+115) tmp = Float64(1.0 - t_0); else tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-6], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+115], N[(1.0 - t$95$0), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+115}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.10000000000000001Initial program 98.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-rgt-identity99.9%
associate-/l*99.9%
exp-to-pow99.9%
*-commutative99.9%
Simplified99.9%
if -0.10000000000000001 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000041e-6Initial program 33.8%
Taylor expanded in n around inf 81.5%
log1p-define81.5%
Simplified81.5%
log1p-undefine81.5%
diff-log81.9%
Applied egg-rr81.9%
if 5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 1e115Initial program 90.8%
Taylor expanded in x around 0 86.1%
*-rgt-identity86.1%
associate-/l*86.1%
exp-to-pow86.1%
Simplified86.1%
if 1e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.0%
Taylor expanded in n around inf 6.4%
log1p-define6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
neg-mul-16.4%
Simplified6.4%
log1p-expm1-u75.9%
expm1-undefine75.9%
add-exp-log75.9%
Applied egg-rr75.9%
Final simplification86.5%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -500.0)
(/
(/
(- (* x (/ (+ (/ (+ (/ 0.25 x) -0.3333333333333333) x) -0.5) x)) x)
(* x x))
n)
(if (<= (/ 1.0 n) 5e-6)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+115)
(- 1.0 (pow x (/ 1.0 n)))
(/ (log1p (+ x -1.0)) (- n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (((x * (((((0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / (x * x)) / n;
} else if ((1.0 / n) <= 5e-6) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = log1p((x + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500.0) {
tmp = (((x * (((((0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / (x * x)) / n;
} else if ((1.0 / n) <= 5e-6) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+115) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = Math.log1p((x + -1.0)) / -n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -500.0: tmp = (((x * (((((0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / (x * x)) / n elif (1.0 / n) <= 5e-6: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+115: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = math.log1p((x + -1.0)) / -n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -500.0) tmp = Float64(Float64(Float64(Float64(x * Float64(Float64(Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / Float64(x * x)) / n); elseif (Float64(1.0 / n) <= 5e-6) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+115) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -500.0], N[(N[(N[(N[(x * N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / x), $MachinePrecision] + -0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-6], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+115], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{\frac{x \cdot \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+115}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -500Initial program 100.0%
Taylor expanded in n around inf 43.5%
log1p-define43.5%
Simplified43.5%
Taylor expanded in x around -inf 1.3%
Applied egg-rr71.3%
if -500 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000041e-6Initial program 33.6%
Taylor expanded in n around inf 81.0%
log1p-define81.0%
Simplified81.0%
log1p-undefine81.0%
diff-log81.3%
Applied egg-rr81.3%
if 5.00000000000000041e-6 < (/.f64 #s(literal 1 binary64) n) < 1e115Initial program 90.8%
Taylor expanded in x around 0 86.1%
*-rgt-identity86.1%
associate-/l*86.1%
exp-to-pow86.1%
Simplified86.1%
if 1e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.0%
Taylor expanded in n around inf 6.4%
log1p-define6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
neg-mul-16.4%
Simplified6.4%
log1p-expm1-u75.9%
expm1-undefine75.9%
add-exp-log75.9%
Applied egg-rr75.9%
Final simplification78.7%
(FPCore (x n)
:precision binary64
(if (<= x 1.85e-140)
(/ (log x) (- n))
(if (<= x 9.8e-99)
(/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* n x)) (/ 0.5 n)) x)) x)
(if (<= x 0.9)
(/ (- x (log x)) n)
(if (<= x 5.2e+73)
(/
(/
(+
1.0
(/ (- (/ (- 0.3333333333333333 (* (/ 1.0 x) 0.25)) x) 0.5) x))
x)
n)
0.0)))))
double code(double x, double n) {
double tmp;
if (x <= 1.85e-140) {
tmp = log(x) / -n;
} else if (x <= 9.8e-99) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else if (x <= 5.2e+73) {
tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.85d-140) then
tmp = log(x) / -n
else if (x <= 9.8d-99) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) - (0.5d0 / n)) / x)) / x
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else if (x <= 5.2d+73) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - ((1.0d0 / x) * 0.25d0)) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.85e-140) {
tmp = Math.log(x) / -n;
} else if (x <= 9.8e-99) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 5.2e+73) {
tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.85e-140: tmp = math.log(x) / -n elif x <= 9.8e-99: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x elif x <= 0.9: tmp = (x - math.log(x)) / n elif x <= 5.2e+73: tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.85e-140) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 9.8e-99) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) - Float64(0.5 / n)) / x)) / x); elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 5.2e+73) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(Float64(1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.85e-140) tmp = log(x) / -n; elseif (x <= 9.8e-99) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x; elseif (x <= 0.9) tmp = (x - log(x)) / n; elseif (x <= 5.2e+73) tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.85e-140], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 9.8e-99], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 5.2e+73], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(N[(1.0 / x), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.85 \cdot 10^{-140}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{-99}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+73}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - \frac{1}{x} \cdot 0.25}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.84999999999999989e-140Initial program 45.3%
Taylor expanded in n around inf 56.3%
log1p-define56.3%
Simplified56.3%
Taylor expanded in x around 0 56.3%
neg-mul-156.3%
Simplified56.3%
if 1.84999999999999989e-140 < x < 9.8000000000000006e-99Initial program 59.6%
Taylor expanded in n around inf 23.2%
log1p-define23.2%
Simplified23.2%
Taylor expanded in x around -inf 73.2%
associate-*r/73.2%
mul-1-neg73.2%
associate-*r/73.2%
mul-1-neg73.2%
associate-*r/73.2%
metadata-eval73.2%
*-commutative73.2%
associate-*r/73.2%
metadata-eval73.2%
Simplified73.2%
if 9.8000000000000006e-99 < x < 0.900000000000000022Initial program 35.7%
Taylor expanded in n around inf 59.2%
log1p-define59.2%
Simplified59.2%
Taylor expanded in x around 0 58.6%
if 0.900000000000000022 < x < 5.2000000000000001e73Initial program 33.6%
Taylor expanded in n around inf 39.1%
log1p-define39.1%
Simplified39.1%
Taylor expanded in x around -inf 79.4%
if 5.2000000000000001e73 < x Initial program 82.0%
add-log-exp82.0%
pow-to-exp82.0%
un-div-inv82.0%
+-commutative82.0%
log1p-define82.0%
Applied egg-rr82.0%
Taylor expanded in x around inf 82.0%
Final simplification68.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.85e-140)
t_0
(if (<= x 1.45e-98)
(/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* n x)) (/ 0.5 n)) x)) x)
(if (<= x 0.7)
t_0
(if (<= x 1.6e+75)
(/
(/
(+
1.0
(/ (- (/ (- 0.3333333333333333 (* (/ 1.0 x) 0.25)) x) 0.5) x))
x)
n)
0.0))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.85e-140) {
tmp = t_0;
} else if (x <= 1.45e-98) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
} else if (x <= 0.7) {
tmp = t_0;
} else if (x <= 1.6e+75) {
tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 1.85d-140) then
tmp = t_0
else if (x <= 1.45d-98) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) - (0.5d0 / n)) / x)) / x
else if (x <= 0.7d0) then
tmp = t_0
else if (x <= 1.6d+75) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - ((1.0d0 / x) * 0.25d0)) / x) - 0.5d0) / x)) / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 1.85e-140) {
tmp = t_0;
} else if (x <= 1.45e-98) {
tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
} else if (x <= 0.7) {
tmp = t_0;
} else if (x <= 1.6e+75) {
tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.85e-140: tmp = t_0 elif x <= 1.45e-98: tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x elif x <= 0.7: tmp = t_0 elif x <= 1.6e+75: tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.85e-140) tmp = t_0; elseif (x <= 1.45e-98) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) - Float64(0.5 / n)) / x)) / x); elseif (x <= 0.7) tmp = t_0; elseif (x <= 1.6e+75) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(Float64(1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.85e-140) tmp = t_0; elseif (x <= 1.45e-98) tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x; elseif (x <= 0.7) tmp = t_0; elseif (x <= 1.6e+75) tmp = ((1.0 + ((((0.3333333333333333 - ((1.0 / x) * 0.25)) / x) - 0.5) / x)) / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.85e-140], t$95$0, If[LessEqual[x, 1.45e-98], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 0.7], t$95$0, If[LessEqual[x, 1.6e+75], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(N[(1.0 / x), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.85 \cdot 10^{-140}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-98}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\
\mathbf{elif}\;x \leq 0.7:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+75}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - \frac{1}{x} \cdot 0.25}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.84999999999999989e-140 or 1.45e-98 < x < 0.69999999999999996Initial program 41.5%
Taylor expanded in n around inf 57.4%
log1p-define57.4%
Simplified57.4%
Taylor expanded in x around 0 56.4%
neg-mul-156.4%
Simplified56.4%
if 1.84999999999999989e-140 < x < 1.45e-98Initial program 59.6%
Taylor expanded in n around inf 23.2%
log1p-define23.2%
Simplified23.2%
Taylor expanded in x around -inf 73.2%
associate-*r/73.2%
mul-1-neg73.2%
associate-*r/73.2%
mul-1-neg73.2%
associate-*r/73.2%
metadata-eval73.2%
*-commutative73.2%
associate-*r/73.2%
metadata-eval73.2%
Simplified73.2%
if 0.69999999999999996 < x < 1.59999999999999992e75Initial program 33.6%
Taylor expanded in n around inf 39.1%
log1p-define39.1%
Simplified39.1%
Taylor expanded in x around -inf 79.4%
if 1.59999999999999992e75 < x Initial program 82.0%
add-log-exp82.0%
pow-to-exp82.0%
un-div-inv82.0%
+-commutative82.0%
log1p-define82.0%
Applied egg-rr82.0%
Taylor expanded in x around inf 82.0%
Final simplification67.8%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e+18)
(/
(/
(- (* x (/ (+ (/ (+ (/ 0.25 x) -0.3333333333333333) x) -0.5) x)) x)
(* x x))
n)
(/ (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (- x)) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e+18) {
tmp = (((x * (((((0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / (x * x)) / n;
} else {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-1d+18)) then
tmp = (((x * (((((0.25d0 / x) + (-0.3333333333333333d0)) / x) + (-0.5d0)) / x)) - x) / (x * x)) / n
else
tmp = (((-1.0d0) + ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / -x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e+18) {
tmp = (((x * (((((0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / (x * x)) / n;
} else {
tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1e+18: tmp = (((x * (((((0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / (x * x)) / n else: tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+18) tmp = Float64(Float64(Float64(Float64(x * Float64(Float64(Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / Float64(x * x)) / n); else tmp = Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(-x)) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -1e+18) tmp = (((x * (((((0.25 / x) + -0.3333333333333333) / x) + -0.5) / x)) - x) / (x * x)) / n; else tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+18], N[(N[(N[(N[(x * N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / x), $MachinePrecision] + -0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+18}:\\
\;\;\;\;\frac{\frac{x \cdot \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{-x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e18Initial program 100.0%
Taylor expanded in n around inf 45.2%
log1p-define45.2%
Simplified45.2%
Taylor expanded in x around -inf 1.3%
Applied egg-rr70.5%
if -1e18 < (/.f64 #s(literal 1 binary64) n) Initial program 40.5%
Taylor expanded in n around inf 63.9%
log1p-define63.9%
Simplified63.9%
Taylor expanded in x around -inf 35.2%
Taylor expanded in x around -inf 45.7%
mul-1-neg45.7%
distribute-neg-frac245.7%
sub-neg45.7%
associate-*r/45.7%
sub-neg45.7%
metadata-eval45.7%
distribute-lft-in45.7%
neg-mul-145.7%
associate-*r/45.7%
metadata-eval45.7%
distribute-neg-frac45.7%
metadata-eval45.7%
metadata-eval45.7%
metadata-eval45.7%
Simplified45.7%
Final simplification51.7%
(FPCore (x n) :precision binary64 (/ (/ (+ -1.0 (/ (+ 0.5 (/ (+ 0.3333333333333333 (/ -0.25 x)) x)) x)) x) (- n)))
double code(double x, double n) {
return ((-1.0 + ((0.5 + ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / -n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (((-1.0d0) + ((0.5d0 + ((0.3333333333333333d0 + ((-0.25d0) / x)) / x)) / x)) / x) / -n
end function
public static double code(double x, double n) {
return ((-1.0 + ((0.5 + ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / -n;
}
def code(x, n): return ((-1.0 + ((0.5 + ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / -n
function code(x, n) return Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x)) / x)) / x) / Float64(-n)) end
function tmp = code(x, n) tmp = ((-1.0 + ((0.5 + ((0.3333333333333333 + (-0.25 / x)) / x)) / x)) / x) / -n; end
code[x_, n_] := N[(N[(N[(-1.0 + N[(N[(0.5 + N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / (-n)), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1 + \frac{0.5 + \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{-n}
\end{array}
Initial program 54.9%
Taylor expanded in n around inf 59.4%
log1p-define59.4%
Simplified59.4%
Taylor expanded in x around -inf 27.0%
fma-neg27.0%
Applied egg-rr46.7%
fma-undefine46.7%
metadata-eval46.7%
distribute-lft-in46.7%
+-commutative46.7%
distribute-lft-in46.7%
metadata-eval46.7%
associate-*r/46.7%
Simplified46.7%
Final simplification46.7%
(FPCore (x n) :precision binary64 (/ (/ (+ -1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (- x)) n))
double code(double x, double n) {
return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (((-1.0d0) + ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / -x) / n
end function
public static double code(double x, double n) {
return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n;
}
def code(x, n): return ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n
function code(x, n) return Float64(Float64(Float64(-1.0 + Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(-x)) / n) end
function tmp = code(x, n) tmp = ((-1.0 + ((0.5 + (-0.3333333333333333 / x)) / x)) / -x) / n; end
code[x_, n_] := N[(N[(N[(-1.0 + N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1 + \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{-x}}{n}
\end{array}
Initial program 54.9%
Taylor expanded in n around inf 59.4%
log1p-define59.4%
Simplified59.4%
Taylor expanded in x around -inf 27.0%
Taylor expanded in x around -inf 46.4%
mul-1-neg46.4%
distribute-neg-frac246.4%
sub-neg46.4%
associate-*r/46.4%
sub-neg46.4%
metadata-eval46.4%
distribute-lft-in46.4%
neg-mul-146.4%
associate-*r/46.4%
metadata-eval46.4%
distribute-neg-frac46.4%
metadata-eval46.4%
metadata-eval46.4%
metadata-eval46.4%
Simplified46.4%
Final simplification46.4%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 54.9%
Taylor expanded in n around inf 59.4%
log1p-define59.4%
Simplified59.4%
Taylor expanded in x around inf 38.6%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 54.9%
Taylor expanded in n around inf 59.4%
log1p-define59.4%
Simplified59.4%
Taylor expanded in x around inf 37.7%
*-commutative37.7%
Simplified37.7%
Final simplification37.7%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 54.9%
Taylor expanded in n around inf 59.4%
log1p-define59.4%
Simplified59.4%
Taylor expanded in x around inf 37.7%
*-commutative37.7%
Simplified37.7%
associate-/r*38.6%
div-inv38.6%
rem-exp-log38.0%
neg-log38.0%
add-sqr-sqrt12.3%
sqrt-unprod13.6%
sqr-neg13.6%
unpow213.6%
sqrt-pow14.6%
metadata-eval4.6%
pow14.6%
add-exp-log4.6%
Applied egg-rr4.6%
associate-*r/4.6%
*-rgt-identity4.6%
Simplified4.6%
herbie shell --seed 2024137
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))