
(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 19 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 (or (<= n -60000000000.0) (not (<= n 470000.0))) (/ (log1p (/ 1.0 x)) n) (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
double tmp;
if ((n <= -60000000000.0) || !(n <= 470000.0)) {
tmp = log1p((1.0 / 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 ((n <= -60000000000.0) || !(n <= 470000.0)) {
tmp = Math.log1p((1.0 / 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 (n <= -60000000000.0) or not (n <= 470000.0): tmp = math.log1p((1.0 / 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 ((n <= -60000000000.0) || !(n <= 470000.0)) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[Or[LessEqual[n, -60000000000.0], N[Not[LessEqual[n, 470000.0]], $MachinePrecision]], N[(N[Log[1 + N[(1.0 / 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}\;n \leq -60000000000 \lor \neg \left(n \leq 470000\right):\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if n < -6e10 or 4.7e5 < n Initial program 29.1%
Taylor expanded in n around inf 79.4%
associate--l+79.4%
log1p-define79.4%
+-commutative79.4%
associate--r+79.4%
distribute-lft-out--79.4%
div-sub79.4%
log1p-define79.4%
Simplified79.4%
log1p-expm1-u79.4%
log1p-undefine79.4%
Applied egg-rr79.4%
Taylor expanded in n around inf 79.3%
sub-neg79.3%
log1p-define79.3%
exp-diff79.3%
log1p-define79.3%
rem-exp-log57.3%
+-commutative57.3%
rem-exp-log79.5%
metadata-eval79.5%
Simplified79.5%
Taylor expanded in n around 0 79.5%
log1p-define99.5%
Simplified99.5%
if -6e10 < n < 4.7e5Initial program 79.9%
Taylor expanded in n around 0 79.9%
log1p-define96.9%
*-rgt-identity96.9%
associate-*l/96.9%
associate-/l*96.9%
exp-to-pow96.9%
Simplified96.9%
Final simplification98.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -10.0)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-15)
(/ (log1p (/ 1.0 x)) n)
(- (exp (/ (* x (+ (* x -0.5) 1.0)) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -10.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-15) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = exp(((x * ((x * -0.5) + 1.0)) / 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) <= -10.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-15) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = Math.exp(((x * ((x * -0.5) + 1.0)) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -10.0: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-15: tmp = math.log1p((1.0 / x)) / n else: tmp = math.exp(((x * ((x * -0.5) + 1.0)) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -10.0) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(exp(Float64(Float64(x * Float64(Float64(x * -0.5) + 1.0)) / 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], -10.0], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[(x * N[(N[(x * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $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 -10:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x \cdot \left(x \cdot -0.5 + 1\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10Initial program 100.0%
Taylor expanded in x around inf 100.0%
associate-/r*100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if -10 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 29.2%
Taylor expanded in n around inf 79.4%
associate--l+79.4%
log1p-define79.4%
+-commutative79.4%
associate--r+79.4%
distribute-lft-out--79.4%
div-sub79.4%
log1p-define79.4%
Simplified79.4%
log1p-expm1-u79.4%
log1p-undefine79.4%
Applied egg-rr79.4%
Taylor expanded in n around inf 79.2%
sub-neg79.2%
log1p-define79.2%
exp-diff79.2%
log1p-define79.2%
rem-exp-log57.2%
+-commutative57.2%
rem-exp-log79.4%
metadata-eval79.4%
Simplified79.4%
Taylor expanded in n around 0 79.4%
log1p-define99.4%
Simplified99.4%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) Initial program 48.8%
Taylor expanded in n around 0 48.8%
log1p-define91.8%
*-rgt-identity91.8%
associate-*l/91.8%
associate-/l*91.8%
exp-to-pow91.8%
Simplified91.8%
Taylor expanded in x around 0 91.8%
Taylor expanded in n around 0 91.8%
Final simplification98.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- 1.0 t_0)))
(if (<= (/ 1.0 n) -10.0)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-15)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+115)
t_1
(if (<= (/ 1.0 n) 2e+129)
(/
(/
(- (* (* n x) 2.0) n)
(* n (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))))
x)
(if (<= (/ 1.0 n) 1e+149)
t_1
(/
(/ (+ n (* n (/ (+ -0.5 (/ 0.3333333333333333 x)) x))) (* n n))
x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double tmp;
if ((1.0 / n) <= -10.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-15) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+115) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+129) {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
} else if ((1.0 / n) <= 1e+149) {
tmp = t_1;
} else {
tmp = ((n + (n * ((-0.5 + (0.3333333333333333 / x)) / x))) / (n * n)) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = 1.0 - t_0;
double tmp;
if ((1.0 / n) <= -10.0) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-15) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+115) {
tmp = t_1;
} else if ((1.0 / n) <= 2e+129) {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
} else if ((1.0 / n) <= 1e+149) {
tmp = t_1;
} else {
tmp = ((n + (n * ((-0.5 + (0.3333333333333333 / x)) / x))) / (n * n)) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = 1.0 - t_0 tmp = 0 if (1.0 / n) <= -10.0: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-15: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+115: tmp = t_1 elif (1.0 / n) <= 2e+129: tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x elif (1.0 / n) <= 1e+149: tmp = t_1 else: tmp = ((n + (n * ((-0.5 + (0.3333333333333333 / x)) / x))) / (n * n)) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(1.0 - t_0) tmp = 0.0 if (Float64(1.0 / n) <= -10.0) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+115) tmp = t_1; elseif (Float64(1.0 / n) <= 2e+129) tmp = Float64(Float64(Float64(Float64(Float64(n * x) * 2.0) - n) / Float64(n * Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))))) / x); elseif (Float64(1.0 / n) <= 1e+149) tmp = t_1; else tmp = Float64(Float64(Float64(n + Float64(n * Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x))) / Float64(n * n)) / x); 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[(1.0 - t$95$0), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -10.0], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+115], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+129], N[(N[(N[(N[(N[(n * x), $MachinePrecision] * 2.0), $MachinePrecision] - n), $MachinePrecision] / N[(n * N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+149], t$95$1, N[(N[(N[(n + N[(n * N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := 1 - t\_0\\
\mathbf{if}\;\frac{1}{n} \leq -10:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+129}:\\
\;\;\;\;\frac{\frac{\left(n \cdot x\right) \cdot 2 - n}{n \cdot \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+149}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n + n \cdot \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{n \cdot n}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10Initial program 100.0%
Taylor expanded in x around inf 100.0%
associate-/r*100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if -10 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 29.2%
Taylor expanded in n around inf 79.4%
associate--l+79.4%
log1p-define79.4%
+-commutative79.4%
associate--r+79.4%
distribute-lft-out--79.4%
div-sub79.4%
log1p-define79.4%
Simplified79.4%
log1p-expm1-u79.4%
log1p-undefine79.4%
Applied egg-rr79.4%
Taylor expanded in n around inf 79.2%
sub-neg79.2%
log1p-define79.2%
exp-diff79.2%
log1p-define79.2%
rem-exp-log57.2%
+-commutative57.2%
rem-exp-log79.4%
metadata-eval79.4%
Simplified79.4%
Taylor expanded in n around 0 79.4%
log1p-define99.4%
Simplified99.4%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000008e115 or 2e129 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e149Initial program 82.9%
Taylor expanded in x around 0 82.9%
*-rgt-identity82.9%
associate-*l/82.9%
associate-/l*82.9%
exp-to-pow82.9%
Simplified82.9%
if 5.00000000000000008e115 < (/.f64 #s(literal 1 binary64) n) < 2e129Initial program 3.1%
Taylor expanded in n around inf 0.1%
associate--l+0.1%
log1p-define0.1%
+-commutative0.1%
associate--r+0.1%
distribute-lft-out--0.1%
div-sub0.1%
log1p-define0.1%
Simplified0.1%
log1p-expm1-u0.0%
log1p-undefine0.0%
Applied egg-rr0.0%
Taylor expanded in n around inf 4.3%
sub-neg4.3%
log1p-define4.3%
exp-diff4.3%
log1p-define4.3%
rem-exp-log4.3%
+-commutative4.3%
rem-exp-log4.3%
metadata-eval4.3%
Simplified4.3%
Taylor expanded in n around 0 4.3%
log1p-define4.3%
Simplified4.3%
Taylor expanded in x around inf 81.7%
Simplified81.7%
frac-2neg81.7%
metadata-eval81.7%
clear-num81.7%
frac-add100.0%
associate-/l*100.0%
associate-/l*100.0%
Applied egg-rr100.0%
*-rgt-identity100.0%
unsub-neg100.0%
mul-1-neg100.0%
associate-*r/100.0%
*-commutative100.0%
distribute-neg-frac2100.0%
*-commutative100.0%
+-commutative100.0%
distribute-neg-in100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
if 1.00000000000000005e149 < (/.f64 #s(literal 1 binary64) n) Initial program 21.8%
Taylor expanded in n around inf 0.1%
associate--l+0.1%
log1p-define0.1%
+-commutative0.1%
associate--r+0.1%
distribute-lft-out--0.1%
div-sub0.1%
log1p-define0.1%
Simplified0.1%
log1p-expm1-u0.1%
log1p-undefine0.1%
Applied egg-rr0.1%
Taylor expanded in n around inf 6.8%
sub-neg6.8%
log1p-define6.8%
exp-diff6.8%
log1p-define6.8%
rem-exp-log6.8%
+-commutative6.8%
rem-exp-log6.8%
metadata-eval6.8%
Simplified6.8%
Taylor expanded in n around 0 6.8%
log1p-define6.8%
Simplified6.8%
Taylor expanded in x around inf 12.7%
Simplified68.9%
frac-2neg68.9%
metadata-eval68.9%
associate-/r*68.9%
frac-add78.5%
neg-mul-178.5%
Applied egg-rr78.5%
Final simplification96.7%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e+248)
(/ 0.0 n)
(if (<= (/ 1.0 n) -500000000000.0)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= (/ 1.0 n) 2e-14)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+115)
(- 1.0 (pow x (/ 1.0 n)))
(/
(/
(- (* (* n x) 2.0) n)
(* n (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))))
x))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e+248) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -500000000000.0) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if ((1.0 / n) <= 2e-14) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+115) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e+248) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -500000000000.0) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+115) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -1e+248: tmp = 0.0 / n elif (1.0 / n) <= -500000000000.0: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif (1.0 / n) <= 2e-14: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+115: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+248) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -500000000000.0) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+115) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(Float64(Float64(Float64(n * x) * 2.0) - n) / Float64(n * Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))))) / x); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+248], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -500000000000.0], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+115], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(n * x), $MachinePrecision] * 2.0), $MachinePrecision] - n), $MachinePrecision] / N[(n * N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+248}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -500000000000:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+115}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(n \cdot x\right) \cdot 2 - n}{n \cdot \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.00000000000000005e248Initial program 100.0%
Taylor expanded in n around inf 94.8%
associate--l+32.7%
log1p-define32.7%
+-commutative32.7%
associate--r+94.8%
distribute-lft-out--94.8%
div-sub94.8%
log1p-define94.8%
Simplified94.8%
log1p-expm1-u94.8%
log1p-undefine94.8%
Applied egg-rr94.8%
Taylor expanded in n around inf 66.1%
sub-neg66.1%
log1p-define66.1%
exp-diff66.1%
log1p-define66.1%
rem-exp-log4.1%
+-commutative4.1%
rem-exp-log66.1%
metadata-eval66.1%
Simplified66.1%
Taylor expanded in x around inf 68.9%
if -1.00000000000000005e248 < (/.f64 #s(literal 1 binary64) n) < -5e11Initial program 100.0%
Taylor expanded in n around inf 64.3%
associate--l+23.1%
log1p-define23.1%
+-commutative23.1%
associate--r+64.3%
distribute-lft-out--64.3%
div-sub64.3%
log1p-define64.3%
Simplified64.3%
log1p-expm1-u100.0%
log1p-undefine100.0%
Applied egg-rr100.0%
Taylor expanded in n around inf 44.8%
sub-neg44.8%
log1p-define44.8%
exp-diff44.8%
log1p-define44.8%
rem-exp-log3.7%
+-commutative3.7%
rem-exp-log44.8%
metadata-eval44.8%
Simplified44.8%
Taylor expanded in x around inf 28.6%
Simplified53.1%
Taylor expanded in x around 0 72.4%
if -5e11 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 30.7%
Taylor expanded in n around inf 78.7%
associate--l+78.0%
log1p-define78.0%
+-commutative78.0%
associate--r+78.7%
distribute-lft-out--78.7%
div-sub78.7%
log1p-define78.7%
Simplified78.7%
log1p-expm1-u80.0%
log1p-undefine80.0%
Applied egg-rr80.0%
Taylor expanded in n around inf 78.3%
sub-neg78.3%
log1p-define78.3%
exp-diff78.3%
log1p-define78.3%
rem-exp-log56.3%
+-commutative56.3%
rem-exp-log78.5%
metadata-eval78.5%
Simplified78.5%
Taylor expanded in n around 0 78.5%
log1p-define97.3%
Simplified97.3%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000008e115Initial program 83.2%
Taylor expanded in x around 0 83.2%
*-rgt-identity83.2%
associate-*l/83.2%
associate-/l*83.2%
exp-to-pow83.2%
Simplified83.2%
if 5.00000000000000008e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.3%
Taylor expanded in n around inf 0.2%
associate--l+0.2%
log1p-define0.2%
+-commutative0.2%
associate--r+0.2%
distribute-lft-out--0.2%
div-sub0.2%
log1p-define0.2%
Simplified0.2%
log1p-expm1-u0.2%
log1p-undefine0.2%
Applied egg-rr0.2%
Taylor expanded in n around inf 6.2%
sub-neg6.2%
log1p-define6.2%
exp-diff6.2%
log1p-define6.2%
rem-exp-log6.2%
+-commutative6.2%
rem-exp-log6.2%
metadata-eval6.2%
Simplified6.2%
Taylor expanded in n around 0 6.2%
log1p-define6.2%
Simplified6.2%
Taylor expanded in x around inf 25.5%
Simplified66.2%
frac-2neg66.2%
metadata-eval66.2%
clear-num66.2%
frac-add76.8%
associate-/l*76.8%
associate-/l*76.8%
Applied egg-rr76.8%
*-rgt-identity76.8%
unsub-neg76.8%
mul-1-neg76.8%
associate-*r/76.8%
*-commutative76.8%
distribute-neg-frac276.8%
*-commutative76.8%
+-commutative76.8%
distribute-neg-in76.8%
metadata-eval76.8%
distribute-neg-frac76.8%
metadata-eval76.8%
distribute-lft-neg-out76.8%
distribute-rgt-neg-in76.8%
associate-*r/76.8%
Simplified76.8%
Taylor expanded in x around inf 76.8%
*-commutative76.8%
*-commutative76.8%
Simplified76.8%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -500000000000.0)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= (/ 1.0 n) 2e-14)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+115)
(- 1.0 (pow x (/ 1.0 n)))
(/
(/
(- (* (* n x) 2.0) n)
(* n (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))))
x)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500000000000.0) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if ((1.0 / n) <= 2e-14) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+115) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -500000000000.0) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+115) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -500000000000.0: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif (1.0 / n) <= 2e-14: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+115: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -500000000000.0) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+115) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(Float64(Float64(Float64(n * x) * 2.0) - n) / Float64(n * Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))))) / x); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -500000000000.0], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+115], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(n * x), $MachinePrecision] * 2.0), $MachinePrecision] - n), $MachinePrecision] / N[(n * N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -500000000000:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+115}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(n \cdot x\right) \cdot 2 - n}{n \cdot \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e11Initial program 100.0%
Taylor expanded in n around inf 73.4%
associate--l+26.0%
log1p-define26.0%
+-commutative26.0%
associate--r+73.4%
distribute-lft-out--73.4%
div-sub73.4%
log1p-define73.4%
Simplified73.4%
log1p-expm1-u98.5%
log1p-undefine98.5%
Applied egg-rr98.5%
Taylor expanded in n around inf 51.2%
sub-neg51.2%
log1p-define51.2%
exp-diff51.2%
log1p-define51.2%
rem-exp-log3.8%
+-commutative3.8%
rem-exp-log51.2%
metadata-eval51.2%
Simplified51.2%
Taylor expanded in x around inf 20.7%
Simplified45.7%
Taylor expanded in x around 0 63.9%
if -5e11 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 30.7%
Taylor expanded in n around inf 78.7%
associate--l+78.0%
log1p-define78.0%
+-commutative78.0%
associate--r+78.7%
distribute-lft-out--78.7%
div-sub78.7%
log1p-define78.7%
Simplified78.7%
log1p-expm1-u80.0%
log1p-undefine80.0%
Applied egg-rr80.0%
Taylor expanded in n around inf 78.3%
sub-neg78.3%
log1p-define78.3%
exp-diff78.3%
log1p-define78.3%
rem-exp-log56.3%
+-commutative56.3%
rem-exp-log78.5%
metadata-eval78.5%
Simplified78.5%
Taylor expanded in n around 0 78.5%
log1p-define97.3%
Simplified97.3%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000008e115Initial program 83.2%
Taylor expanded in x around 0 83.2%
*-rgt-identity83.2%
associate-*l/83.2%
associate-/l*83.2%
exp-to-pow83.2%
Simplified83.2%
if 5.00000000000000008e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.3%
Taylor expanded in n around inf 0.2%
associate--l+0.2%
log1p-define0.2%
+-commutative0.2%
associate--r+0.2%
distribute-lft-out--0.2%
div-sub0.2%
log1p-define0.2%
Simplified0.2%
log1p-expm1-u0.2%
log1p-undefine0.2%
Applied egg-rr0.2%
Taylor expanded in n around inf 6.2%
sub-neg6.2%
log1p-define6.2%
exp-diff6.2%
log1p-define6.2%
rem-exp-log6.2%
+-commutative6.2%
rem-exp-log6.2%
metadata-eval6.2%
Simplified6.2%
Taylor expanded in n around 0 6.2%
log1p-define6.2%
Simplified6.2%
Taylor expanded in x around inf 25.5%
Simplified66.2%
frac-2neg66.2%
metadata-eval66.2%
clear-num66.2%
frac-add76.8%
associate-/l*76.8%
associate-/l*76.8%
Applied egg-rr76.8%
*-rgt-identity76.8%
unsub-neg76.8%
mul-1-neg76.8%
associate-*r/76.8%
*-commutative76.8%
distribute-neg-frac276.8%
*-commutative76.8%
+-commutative76.8%
distribute-neg-in76.8%
metadata-eval76.8%
distribute-neg-frac76.8%
metadata-eval76.8%
distribute-lft-neg-out76.8%
distribute-rgt-neg-in76.8%
associate-*r/76.8%
Simplified76.8%
Taylor expanded in x around inf 76.8%
*-commutative76.8%
*-commutative76.8%
Simplified76.8%
Final simplification86.0%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -50.0)
(* 0.3333333333333333 (/ (pow x -3.0) n))
(if (<= (/ 1.0 n) 2e-14)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+115)
(- 1.0 (pow x (/ 1.0 n)))
(/
(/
(- (* (* n x) 2.0) n)
(* n (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))))
x)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -50.0) {
tmp = 0.3333333333333333 * (pow(x, -3.0) / n);
} else if ((1.0 / n) <= 2e-14) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+115) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -50.0) {
tmp = 0.3333333333333333 * (Math.pow(x, -3.0) / n);
} else if ((1.0 / n) <= 2e-14) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+115) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -50.0: tmp = 0.3333333333333333 * (math.pow(x, -3.0) / n) elif (1.0 / n) <= 2e-14: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+115: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -50.0) tmp = Float64(0.3333333333333333 * Float64((x ^ -3.0) / n)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+115) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(Float64(Float64(Float64(n * x) * 2.0) - n) / Float64(n * Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))))) / x); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -50.0], N[(0.3333333333333333 * N[(N[Power[x, -3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+115], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(n * x), $MachinePrecision] * 2.0), $MachinePrecision] - n), $MachinePrecision] / N[(n * N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -50:\\
\;\;\;\;0.3333333333333333 \cdot \frac{{x}^{-3}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+115}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(n \cdot x\right) \cdot 2 - n}{n \cdot \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -50Initial program 100.0%
Taylor expanded in n around inf 72.7%
associate--l+25.3%
log1p-define25.3%
+-commutative25.3%
associate--r+72.7%
distribute-lft-out--72.7%
div-sub72.7%
log1p-define72.7%
Simplified72.7%
log1p-expm1-u98.5%
log1p-undefine98.5%
Applied egg-rr98.5%
Taylor expanded in n around inf 51.2%
sub-neg51.2%
log1p-define51.2%
exp-diff51.2%
log1p-define51.2%
rem-exp-log3.8%
+-commutative3.8%
rem-exp-log51.2%
metadata-eval51.2%
Simplified51.2%
Taylor expanded in n around 0 51.2%
log1p-define4.2%
Simplified4.2%
Taylor expanded in x around inf 44.5%
associate--l+44.5%
metadata-eval44.5%
associate-*r/44.5%
associate-*r/44.5%
metadata-eval44.5%
unpow244.5%
associate-/r*44.5%
associate-*r/44.5%
metadata-eval44.5%
div-sub44.5%
metadata-eval44.5%
associate-*r/44.5%
sub-neg44.5%
associate-*r/44.5%
metadata-eval44.5%
metadata-eval44.5%
Simplified44.5%
Taylor expanded in x around 0 63.6%
associate-/r*63.6%
Simplified63.6%
*-un-lft-identity63.6%
div-inv63.6%
pow-flip62.1%
metadata-eval62.1%
Applied egg-rr62.1%
*-lft-identity62.1%
associate-*l/62.1%
associate-/l*62.1%
Simplified62.1%
if -50 < (/.f64 #s(literal 1 binary64) n) < 2e-14Initial program 29.7%
Taylor expanded in n around inf 79.1%
associate--l+79.1%
log1p-define79.1%
+-commutative79.1%
associate--r+79.1%
distribute-lft-out--79.1%
div-sub79.1%
log1p-define79.1%
Simplified79.1%
log1p-expm1-u79.7%
log1p-undefine79.7%
Applied egg-rr79.7%
Taylor expanded in n around inf 78.7%
sub-neg78.7%
log1p-define78.7%
exp-diff78.7%
log1p-define78.7%
rem-exp-log57.0%
+-commutative57.0%
rem-exp-log78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in n around 0 78.9%
log1p-define98.6%
Simplified98.6%
if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000008e115Initial program 83.2%
Taylor expanded in x around 0 83.2%
*-rgt-identity83.2%
associate-*l/83.2%
associate-/l*83.2%
exp-to-pow83.2%
Simplified83.2%
if 5.00000000000000008e115 < (/.f64 #s(literal 1 binary64) n) Initial program 24.3%
Taylor expanded in n around inf 0.2%
associate--l+0.2%
log1p-define0.2%
+-commutative0.2%
associate--r+0.2%
distribute-lft-out--0.2%
div-sub0.2%
log1p-define0.2%
Simplified0.2%
log1p-expm1-u0.2%
log1p-undefine0.2%
Applied egg-rr0.2%
Taylor expanded in n around inf 6.2%
sub-neg6.2%
log1p-define6.2%
exp-diff6.2%
log1p-define6.2%
rem-exp-log6.2%
+-commutative6.2%
rem-exp-log6.2%
metadata-eval6.2%
Simplified6.2%
Taylor expanded in n around 0 6.2%
log1p-define6.2%
Simplified6.2%
Taylor expanded in x around inf 25.5%
Simplified66.2%
frac-2neg66.2%
metadata-eval66.2%
clear-num66.2%
frac-add76.8%
associate-/l*76.8%
associate-/l*76.8%
Applied egg-rr76.8%
*-rgt-identity76.8%
unsub-neg76.8%
mul-1-neg76.8%
associate-*r/76.8%
*-commutative76.8%
distribute-neg-frac276.8%
*-commutative76.8%
+-commutative76.8%
distribute-neg-in76.8%
metadata-eval76.8%
distribute-neg-frac76.8%
metadata-eval76.8%
distribute-lft-neg-out76.8%
distribute-rgt-neg-in76.8%
associate-*r/76.8%
Simplified76.8%
Taylor expanded in x around inf 76.8%
*-commutative76.8%
*-commutative76.8%
Simplified76.8%
Final simplification86.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.2e-152)
t_0
(if (<= x 5.1e-101)
(/
(/
(- (* (* n x) 2.0) n)
(* n (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))))
x)
(if (<= x 1.6e-25)
t_0
(/ (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) n) x))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.2e-152) {
tmp = t_0;
} else if (x <= 5.1e-101) {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
} else if (x <= 1.6e-25) {
tmp = t_0;
} else {
tmp = ((((-0.5 + (0.3333333333333333 / x)) / x) + 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 <= 1.2d-152) then
tmp = t_0
else if (x <= 5.1d-101) then
tmp = ((((n * x) * 2.0d0) - n) / (n * ((n * x) / (0.5d0 + ((-0.3333333333333333d0) / x))))) / x
else if (x <= 1.6d-25) then
tmp = t_0
else
tmp = (((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 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 <= 1.2e-152) {
tmp = t_0;
} else if (x <= 5.1e-101) {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
} else if (x <= 1.6e-25) {
tmp = t_0;
} else {
tmp = ((((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.2e-152: tmp = t_0 elif x <= 5.1e-101: tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x elif x <= 1.6e-25: tmp = t_0 else: tmp = ((((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / n) / x return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.2e-152) tmp = t_0; elseif (x <= 5.1e-101) tmp = Float64(Float64(Float64(Float64(Float64(n * x) * 2.0) - n) / Float64(n * Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))))) / x); elseif (x <= 1.6e-25) tmp = t_0; else tmp = Float64(Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.2e-152) tmp = t_0; elseif (x <= 5.1e-101) tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x; elseif (x <= 1.6e-25) tmp = t_0; else tmp = ((((-0.5 + (0.3333333333333333 / x)) / x) + 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, 1.2e-152], t$95$0, If[LessEqual[x, 5.1e-101], N[(N[(N[(N[(N[(n * x), $MachinePrecision] * 2.0), $MachinePrecision] - n), $MachinePrecision] / N[(n * N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 1.6e-25], t$95$0, N[(N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.2 \cdot 10^{-152}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-101}:\\
\;\;\;\;\frac{\frac{\left(n \cdot x\right) \cdot 2 - n}{n \cdot \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}}}{x}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-25}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{n}}{x}\\
\end{array}
\end{array}
if x < 1.2e-152 or 5.1000000000000002e-101 < x < 1.6000000000000001e-25Initial program 38.7%
Taylor expanded in x around 0 38.7%
*-rgt-identity38.7%
associate-*l/38.7%
associate-/l*38.7%
exp-to-pow38.7%
Simplified38.7%
Taylor expanded in n around inf 56.1%
mul-1-neg56.1%
distribute-frac-neg256.1%
Simplified56.1%
if 1.2e-152 < x < 5.1000000000000002e-101Initial program 50.6%
Taylor expanded in n around inf 50.2%
associate--l+50.2%
log1p-define50.2%
+-commutative50.2%
associate--r+50.2%
distribute-lft-out--50.2%
div-sub50.2%
log1p-define50.2%
Simplified50.2%
log1p-expm1-u64.9%
log1p-undefine64.9%
Applied egg-rr64.9%
Taylor expanded in n around inf 36.8%
sub-neg36.8%
log1p-define36.8%
exp-diff36.8%
log1p-define36.8%
rem-exp-log36.8%
+-commutative36.8%
rem-exp-log36.8%
metadata-eval36.8%
Simplified36.8%
Taylor expanded in n around 0 36.8%
log1p-define36.8%
Simplified36.8%
Taylor expanded in x around inf 29.4%
Simplified53.4%
frac-2neg53.4%
metadata-eval53.4%
clear-num53.4%
frac-add54.0%
associate-/l*54.0%
associate-/l*54.0%
Applied egg-rr54.0%
*-rgt-identity54.0%
unsub-neg54.0%
mul-1-neg54.0%
associate-*r/54.0%
*-commutative54.0%
distribute-neg-frac254.0%
*-commutative54.0%
+-commutative54.0%
distribute-neg-in54.0%
metadata-eval54.0%
distribute-neg-frac54.0%
metadata-eval54.0%
distribute-lft-neg-out54.0%
distribute-rgt-neg-in54.0%
associate-*r/54.0%
Simplified54.0%
Taylor expanded in x around inf 54.0%
*-commutative54.0%
*-commutative54.0%
Simplified54.0%
if 1.6000000000000001e-25 < x Initial program 63.9%
Taylor expanded in n around inf 68.9%
associate--l+41.5%
log1p-define41.5%
+-commutative41.5%
associate--r+68.9%
distribute-lft-out--68.9%
div-sub68.9%
log1p-define68.9%
Simplified68.9%
log1p-expm1-u69.8%
log1p-undefine69.8%
Applied egg-rr69.8%
Taylor expanded in n around inf 68.2%
sub-neg68.2%
log1p-define68.2%
exp-diff68.2%
log1p-define68.2%
rem-exp-log12.7%
+-commutative12.7%
rem-exp-log68.4%
metadata-eval68.4%
Simplified68.4%
Taylor expanded in n around 0 68.4%
log1p-define66.6%
Simplified66.6%
Taylor expanded in x around inf 61.9%
Simplified61.9%
Taylor expanded in n around 0 61.9%
associate--l+61.9%
+-commutative61.9%
associate-*r/61.9%
metadata-eval61.9%
unpow261.9%
associate-/r*61.9%
associate-*r/61.9%
metadata-eval61.9%
div-sub61.9%
sub-neg61.9%
metadata-eval61.9%
+-commutative61.9%
+-commutative61.9%
Simplified61.9%
Final simplification58.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))))
(if (<= (/ 1.0 n) -50.0)
(* 0.3333333333333333 (/ (pow x -3.0) n))
(if (<= (/ 1.0 n) 5e-29)
(/ (log1p (/ 1.0 x)) n)
(/ (/ (- t_0 n) (* n t_0)) x)))))
double code(double x, double n) {
double t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x));
double tmp;
if ((1.0 / n) <= -50.0) {
tmp = 0.3333333333333333 * (pow(x, -3.0) / n);
} else if ((1.0 / n) <= 5e-29) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = ((t_0 - n) / (n * t_0)) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x));
double tmp;
if ((1.0 / n) <= -50.0) {
tmp = 0.3333333333333333 * (Math.pow(x, -3.0) / n);
} else if ((1.0 / n) <= 5e-29) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = ((t_0 - n) / (n * t_0)) / x;
}
return tmp;
}
def code(x, n): t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x)) tmp = 0 if (1.0 / n) <= -50.0: tmp = 0.3333333333333333 * (math.pow(x, -3.0) / n) elif (1.0 / n) <= 5e-29: tmp = math.log1p((1.0 / x)) / n else: tmp = ((t_0 - n) / (n * t_0)) / x return tmp
function code(x, n) t_0 = Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))) tmp = 0.0 if (Float64(1.0 / n) <= -50.0) tmp = Float64(0.3333333333333333 * Float64((x ^ -3.0) / n)); elseif (Float64(1.0 / n) <= 5e-29) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(Float64(Float64(t_0 - n) / Float64(n * t_0)) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -50.0], N[(0.3333333333333333 * N[(N[Power[x, -3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-29], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(t$95$0 - n), $MachinePrecision] / N[(n * t$95$0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}\\
\mathbf{if}\;\frac{1}{n} \leq -50:\\
\;\;\;\;0.3333333333333333 \cdot \frac{{x}^{-3}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-29}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0 - n}{n \cdot t\_0}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -50Initial program 100.0%
Taylor expanded in n around inf 72.7%
associate--l+25.3%
log1p-define25.3%
+-commutative25.3%
associate--r+72.7%
distribute-lft-out--72.7%
div-sub72.7%
log1p-define72.7%
Simplified72.7%
log1p-expm1-u98.5%
log1p-undefine98.5%
Applied egg-rr98.5%
Taylor expanded in n around inf 51.2%
sub-neg51.2%
log1p-define51.2%
exp-diff51.2%
log1p-define51.2%
rem-exp-log3.8%
+-commutative3.8%
rem-exp-log51.2%
metadata-eval51.2%
Simplified51.2%
Taylor expanded in n around 0 51.2%
log1p-define4.2%
Simplified4.2%
Taylor expanded in x around inf 44.5%
associate--l+44.5%
metadata-eval44.5%
associate-*r/44.5%
associate-*r/44.5%
metadata-eval44.5%
unpow244.5%
associate-/r*44.5%
associate-*r/44.5%
metadata-eval44.5%
div-sub44.5%
metadata-eval44.5%
associate-*r/44.5%
sub-neg44.5%
associate-*r/44.5%
metadata-eval44.5%
metadata-eval44.5%
Simplified44.5%
Taylor expanded in x around 0 63.6%
associate-/r*63.6%
Simplified63.6%
*-un-lft-identity63.6%
div-inv63.6%
pow-flip62.1%
metadata-eval62.1%
Applied egg-rr62.1%
*-lft-identity62.1%
associate-*l/62.1%
associate-/l*62.1%
Simplified62.1%
if -50 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999986e-29Initial program 30.7%
Taylor expanded in n around inf 80.7%
associate--l+80.7%
log1p-define80.7%
+-commutative80.7%
associate--r+80.7%
distribute-lft-out--80.7%
div-sub80.7%
log1p-define80.7%
Simplified80.7%
log1p-expm1-u81.4%
log1p-undefine81.4%
Applied egg-rr81.4%
Taylor expanded in n around inf 80.5%
sub-neg80.5%
log1p-define80.5%
exp-diff80.5%
log1p-define80.5%
rem-exp-log57.8%
+-commutative57.8%
rem-exp-log80.7%
metadata-eval80.7%
Simplified80.7%
Taylor expanded in n around 0 80.7%
log1p-define98.8%
Simplified98.8%
if 4.99999999999999986e-29 < (/.f64 #s(literal 1 binary64) n) Initial program 43.5%
Taylor expanded in n around inf 7.5%
associate--l+7.6%
log1p-define7.6%
+-commutative7.6%
associate--r+7.5%
distribute-lft-out--7.5%
div-sub7.5%
log1p-define7.5%
Simplified7.5%
log1p-expm1-u7.3%
log1p-undefine7.3%
Applied egg-rr7.3%
Taylor expanded in n around inf 12.2%
sub-neg12.2%
log1p-define12.2%
exp-diff12.2%
log1p-define12.2%
rem-exp-log12.0%
+-commutative12.0%
rem-exp-log12.2%
metadata-eval12.2%
Simplified12.2%
Taylor expanded in n around 0 12.2%
log1p-define19.3%
Simplified19.3%
Taylor expanded in x around inf 21.6%
Simplified42.1%
frac-2neg42.1%
metadata-eval42.1%
clear-num42.1%
frac-add47.3%
associate-/l*47.3%
associate-/l*47.3%
Applied egg-rr47.3%
*-rgt-identity47.3%
unsub-neg47.3%
mul-1-neg47.3%
associate-*r/47.3%
*-commutative47.3%
distribute-neg-frac247.3%
*-commutative47.3%
+-commutative47.3%
distribute-neg-in47.3%
metadata-eval47.3%
distribute-neg-frac47.3%
metadata-eval47.3%
distribute-lft-neg-out47.3%
distribute-rgt-neg-in47.3%
associate-*r/47.3%
Simplified47.3%
Final simplification79.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))) (t_1 (* n t_0)))
(if (<= (/ 1.0 n) -500000000000.0)
(/ (/ (- (* (* n x) 2.0) n) t_1) x)
(if (<= (/ 1.0 n) 5e-29)
(/ (log1p (/ 1.0 x)) n)
(/ (/ (- t_0 n) t_1) x)))))
double code(double x, double n) {
double t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x));
double t_1 = n * t_0;
double tmp;
if ((1.0 / n) <= -500000000000.0) {
tmp = ((((n * x) * 2.0) - n) / t_1) / x;
} else if ((1.0 / n) <= 5e-29) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = ((t_0 - n) / t_1) / x;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x));
double t_1 = n * t_0;
double tmp;
if ((1.0 / n) <= -500000000000.0) {
tmp = ((((n * x) * 2.0) - n) / t_1) / x;
} else if ((1.0 / n) <= 5e-29) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = ((t_0 - n) / t_1) / x;
}
return tmp;
}
def code(x, n): t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x)) t_1 = n * t_0 tmp = 0 if (1.0 / n) <= -500000000000.0: tmp = ((((n * x) * 2.0) - n) / t_1) / x elif (1.0 / n) <= 5e-29: tmp = math.log1p((1.0 / x)) / n else: tmp = ((t_0 - n) / t_1) / x return tmp
function code(x, n) t_0 = Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))) t_1 = Float64(n * t_0) tmp = 0.0 if (Float64(1.0 / n) <= -500000000000.0) tmp = Float64(Float64(Float64(Float64(Float64(n * x) * 2.0) - n) / t_1) / x); elseif (Float64(1.0 / n) <= 5e-29) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(Float64(Float64(t_0 - n) / t_1) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(n * t$95$0), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -500000000000.0], N[(N[(N[(N[(N[(n * x), $MachinePrecision] * 2.0), $MachinePrecision] - n), $MachinePrecision] / t$95$1), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-29], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(t$95$0 - n), $MachinePrecision] / t$95$1), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}\\
t_1 := n \cdot t\_0\\
\mathbf{if}\;\frac{1}{n} \leq -500000000000:\\
\;\;\;\;\frac{\frac{\left(n \cdot x\right) \cdot 2 - n}{t\_1}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-29}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0 - n}{t\_1}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e11Initial program 100.0%
Taylor expanded in n around inf 73.4%
associate--l+26.0%
log1p-define26.0%
+-commutative26.0%
associate--r+73.4%
distribute-lft-out--73.4%
div-sub73.4%
log1p-define73.4%
Simplified73.4%
log1p-expm1-u98.5%
log1p-undefine98.5%
Applied egg-rr98.5%
Taylor expanded in n around inf 51.2%
sub-neg51.2%
log1p-define51.2%
exp-diff51.2%
log1p-define51.2%
rem-exp-log3.8%
+-commutative3.8%
rem-exp-log51.2%
metadata-eval51.2%
Simplified51.2%
Taylor expanded in n around 0 51.2%
log1p-define4.1%
Simplified4.1%
Taylor expanded in x around inf 20.7%
Simplified45.7%
frac-2neg45.7%
metadata-eval45.7%
clear-num45.7%
frac-add48.4%
associate-/l*48.4%
associate-/l*48.4%
Applied egg-rr48.4%
*-rgt-identity48.4%
unsub-neg48.4%
mul-1-neg48.4%
associate-*r/48.4%
*-commutative48.4%
distribute-neg-frac248.4%
*-commutative48.4%
+-commutative48.4%
distribute-neg-in48.4%
metadata-eval48.4%
distribute-neg-frac48.4%
metadata-eval48.4%
distribute-lft-neg-out48.4%
distribute-rgt-neg-in48.4%
associate-*r/48.4%
Simplified48.4%
Taylor expanded in x around inf 48.4%
*-commutative48.4%
*-commutative48.4%
Simplified48.4%
if -5e11 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999986e-29Initial program 31.7%
Taylor expanded in n around inf 80.3%
associate--l+79.6%
log1p-define79.6%
+-commutative79.6%
associate--r+80.3%
distribute-lft-out--80.3%
div-sub80.3%
log1p-define80.3%
Simplified80.3%
log1p-expm1-u81.7%
log1p-undefine81.7%
Applied egg-rr81.7%
Taylor expanded in n around inf 80.1%
sub-neg80.1%
log1p-define80.1%
exp-diff80.1%
log1p-define80.1%
rem-exp-log57.0%
+-commutative57.0%
rem-exp-log80.2%
metadata-eval80.2%
Simplified80.2%
Taylor expanded in n around 0 80.2%
log1p-define97.5%
Simplified97.5%
if 4.99999999999999986e-29 < (/.f64 #s(literal 1 binary64) n) Initial program 43.5%
Taylor expanded in n around inf 7.5%
associate--l+7.6%
log1p-define7.6%
+-commutative7.6%
associate--r+7.5%
distribute-lft-out--7.5%
div-sub7.5%
log1p-define7.5%
Simplified7.5%
log1p-expm1-u7.3%
log1p-undefine7.3%
Applied egg-rr7.3%
Taylor expanded in n around inf 12.2%
sub-neg12.2%
log1p-define12.2%
exp-diff12.2%
log1p-define12.2%
rem-exp-log12.0%
+-commutative12.0%
rem-exp-log12.2%
metadata-eval12.2%
Simplified12.2%
Taylor expanded in n around 0 12.2%
log1p-define19.3%
Simplified19.3%
Taylor expanded in x around inf 21.6%
Simplified42.1%
frac-2neg42.1%
metadata-eval42.1%
clear-num42.1%
frac-add47.3%
associate-/l*47.3%
associate-/l*47.3%
Applied egg-rr47.3%
*-rgt-identity47.3%
unsub-neg47.3%
mul-1-neg47.3%
associate-*r/47.3%
*-commutative47.3%
distribute-neg-frac247.3%
*-commutative47.3%
+-commutative47.3%
distribute-neg-in47.3%
metadata-eval47.3%
distribute-neg-frac47.3%
metadata-eval47.3%
distribute-lft-neg-out47.3%
distribute-rgt-neg-in47.3%
associate-*r/47.3%
Simplified47.3%
Final simplification75.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))) (t_1 (* n t_0)))
(if (<= (/ 1.0 n) -10.0)
(/ (/ (- (* (* n x) 2.0) n) t_1) x)
(if (<= (/ 1.0 n) 5e-70)
(/ 1.0 (* n (* x (+ (/ 0.5 x) 1.0))))
(/ (/ (- t_0 n) t_1) x)))))
double code(double x, double n) {
double t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x));
double t_1 = n * t_0;
double tmp;
if ((1.0 / n) <= -10.0) {
tmp = ((((n * x) * 2.0) - n) / t_1) / x;
} else if ((1.0 / n) <= 5e-70) {
tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0)));
} else {
tmp = ((t_0 - n) / t_1) / 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 = (n * x) / (0.5d0 + ((-0.3333333333333333d0) / x))
t_1 = n * t_0
if ((1.0d0 / n) <= (-10.0d0)) then
tmp = ((((n * x) * 2.0d0) - n) / t_1) / x
else if ((1.0d0 / n) <= 5d-70) then
tmp = 1.0d0 / (n * (x * ((0.5d0 / x) + 1.0d0)))
else
tmp = ((t_0 - n) / t_1) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x));
double t_1 = n * t_0;
double tmp;
if ((1.0 / n) <= -10.0) {
tmp = ((((n * x) * 2.0) - n) / t_1) / x;
} else if ((1.0 / n) <= 5e-70) {
tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0)));
} else {
tmp = ((t_0 - n) / t_1) / x;
}
return tmp;
}
def code(x, n): t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x)) t_1 = n * t_0 tmp = 0 if (1.0 / n) <= -10.0: tmp = ((((n * x) * 2.0) - n) / t_1) / x elif (1.0 / n) <= 5e-70: tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0))) else: tmp = ((t_0 - n) / t_1) / x return tmp
function code(x, n) t_0 = Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))) t_1 = Float64(n * t_0) tmp = 0.0 if (Float64(1.0 / n) <= -10.0) tmp = Float64(Float64(Float64(Float64(Float64(n * x) * 2.0) - n) / t_1) / x); elseif (Float64(1.0 / n) <= 5e-70) tmp = Float64(1.0 / Float64(n * Float64(x * Float64(Float64(0.5 / x) + 1.0)))); else tmp = Float64(Float64(Float64(t_0 - n) / t_1) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = (n * x) / (0.5 + (-0.3333333333333333 / x)); t_1 = n * t_0; tmp = 0.0; if ((1.0 / n) <= -10.0) tmp = ((((n * x) * 2.0) - n) / t_1) / x; elseif ((1.0 / n) <= 5e-70) tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0))); else tmp = ((t_0 - n) / t_1) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(n * t$95$0), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -10.0], N[(N[(N[(N[(N[(n * x), $MachinePrecision] * 2.0), $MachinePrecision] - n), $MachinePrecision] / t$95$1), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-70], N[(1.0 / N[(n * N[(x * N[(N[(0.5 / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 - n), $MachinePrecision] / t$95$1), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}\\
t_1 := n \cdot t\_0\\
\mathbf{if}\;\frac{1}{n} \leq -10:\\
\;\;\;\;\frac{\frac{\left(n \cdot x\right) \cdot 2 - n}{t\_1}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-70}:\\
\;\;\;\;\frac{1}{n \cdot \left(x \cdot \left(\frac{0.5}{x} + 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0 - n}{t\_1}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10Initial program 100.0%
Taylor expanded in n around inf 71.7%
associate--l+24.9%
log1p-define24.9%
+-commutative24.9%
associate--r+71.7%
distribute-lft-out--71.7%
div-sub71.7%
log1p-define71.7%
Simplified71.7%
log1p-expm1-u98.5%
log1p-undefine98.5%
Applied egg-rr98.5%
Taylor expanded in n around inf 50.4%
sub-neg50.4%
log1p-define50.4%
exp-diff50.4%
log1p-define50.4%
rem-exp-log3.8%
+-commutative3.8%
rem-exp-log50.4%
metadata-eval50.4%
Simplified50.4%
Taylor expanded in n around 0 50.4%
log1p-define4.1%
Simplified4.1%
Taylor expanded in x around inf 21.4%
Simplified45.3%
frac-2neg45.3%
metadata-eval45.3%
clear-num45.3%
frac-add47.9%
associate-/l*47.9%
associate-/l*47.9%
Applied egg-rr47.9%
*-rgt-identity47.9%
unsub-neg47.9%
mul-1-neg47.9%
associate-*r/47.9%
*-commutative47.9%
distribute-neg-frac247.9%
*-commutative47.9%
+-commutative47.9%
distribute-neg-in47.9%
metadata-eval47.9%
distribute-neg-frac47.9%
metadata-eval47.9%
distribute-lft-neg-out47.9%
distribute-rgt-neg-in47.9%
associate-*r/47.9%
Simplified47.9%
Taylor expanded in x around inf 47.9%
*-commutative47.9%
*-commutative47.9%
Simplified47.9%
if -10 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e-70Initial program 31.8%
Taylor expanded in n around inf 82.4%
associate--l+82.4%
log1p-define82.4%
+-commutative82.4%
associate--r+82.4%
distribute-lft-out--82.4%
div-sub82.4%
log1p-define82.4%
Simplified82.4%
log1p-expm1-u82.4%
log1p-undefine82.3%
Applied egg-rr82.3%
Taylor expanded in n around inf 82.1%
sub-neg82.1%
log1p-define82.1%
exp-diff82.1%
log1p-define82.1%
rem-exp-log57.8%
+-commutative57.8%
rem-exp-log82.3%
metadata-eval82.3%
Simplified82.3%
Taylor expanded in n around 0 82.3%
log1p-define99.5%
Simplified99.5%
clear-num99.1%
inv-pow99.1%
Applied egg-rr99.1%
unpow-199.1%
Simplified99.1%
clear-num99.1%
associate-/r/99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 54.2%
associate-*r/54.2%
metadata-eval54.2%
Simplified54.2%
if 4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) Initial program 38.1%
Taylor expanded in n around inf 15.3%
associate--l+15.3%
log1p-define15.3%
+-commutative15.3%
associate--r+15.3%
distribute-lft-out--15.3%
div-sub15.3%
log1p-define15.3%
Simplified15.3%
log1p-expm1-u15.1%
log1p-undefine15.1%
Applied egg-rr15.1%
Taylor expanded in n around inf 19.3%
sub-neg19.3%
log1p-define19.3%
exp-diff19.2%
log1p-define19.2%
rem-exp-log19.1%
+-commutative19.1%
rem-exp-log19.3%
metadata-eval19.3%
Simplified19.3%
Taylor expanded in n around 0 19.3%
log1p-define30.4%
Simplified30.4%
Taylor expanded in x around inf 24.9%
Simplified42.5%
frac-2neg42.5%
metadata-eval42.5%
clear-num42.5%
frac-add47.0%
associate-/l*47.0%
associate-/l*47.0%
Applied egg-rr47.0%
*-rgt-identity47.0%
unsub-neg47.0%
mul-1-neg47.0%
associate-*r/47.0%
*-commutative47.0%
distribute-neg-frac247.0%
*-commutative47.0%
+-commutative47.0%
distribute-neg-in47.0%
metadata-eval47.0%
distribute-neg-frac47.0%
metadata-eval47.0%
distribute-lft-neg-out47.0%
distribute-rgt-neg-in47.0%
associate-*r/47.0%
Simplified47.0%
Final simplification50.9%
(FPCore (x n)
:precision binary64
(if (or (<= (/ 1.0 n) -10.0) (not (<= (/ 1.0 n) 5e-70)))
(/
(/
(- (* (* n x) 2.0) n)
(* n (/ (* n x) (+ 0.5 (/ -0.3333333333333333 x)))))
x)
(/ 1.0 (* n (* x (+ (/ 0.5 x) 1.0))))))
double code(double x, double n) {
double tmp;
if (((1.0 / n) <= -10.0) || !((1.0 / n) <= 5e-70)) {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
} else {
tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0)));
}
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) <= (-10.0d0)) .or. (.not. ((1.0d0 / n) <= 5d-70))) then
tmp = ((((n * x) * 2.0d0) - n) / (n * ((n * x) / (0.5d0 + ((-0.3333333333333333d0) / x))))) / x
else
tmp = 1.0d0 / (n * (x * ((0.5d0 / x) + 1.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (((1.0 / n) <= -10.0) || !((1.0 / n) <= 5e-70)) {
tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x;
} else {
tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0)));
}
return tmp;
}
def code(x, n): tmp = 0 if ((1.0 / n) <= -10.0) or not ((1.0 / n) <= 5e-70): tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x else: tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0))) return tmp
function code(x, n) tmp = 0.0 if ((Float64(1.0 / n) <= -10.0) || !(Float64(1.0 / n) <= 5e-70)) tmp = Float64(Float64(Float64(Float64(Float64(n * x) * 2.0) - n) / Float64(n * Float64(Float64(n * x) / Float64(0.5 + Float64(-0.3333333333333333 / x))))) / x); else tmp = Float64(1.0 / Float64(n * Float64(x * Float64(Float64(0.5 / x) + 1.0)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (((1.0 / n) <= -10.0) || ~(((1.0 / n) <= 5e-70))) tmp = ((((n * x) * 2.0) - n) / (n * ((n * x) / (0.5 + (-0.3333333333333333 / x))))) / x; else tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0))); end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[N[(1.0 / n), $MachinePrecision], -10.0], N[Not[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-70]], $MachinePrecision]], N[(N[(N[(N[(N[(n * x), $MachinePrecision] * 2.0), $MachinePrecision] - n), $MachinePrecision] / N[(n * N[(N[(n * x), $MachinePrecision] / N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(n * N[(x * N[(N[(0.5 / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10 \lor \neg \left(\frac{1}{n} \leq 5 \cdot 10^{-70}\right):\\
\;\;\;\;\frac{\frac{\left(n \cdot x\right) \cdot 2 - n}{n \cdot \frac{n \cdot x}{0.5 + \frac{-0.3333333333333333}{x}}}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot \left(x \cdot \left(\frac{0.5}{x} + 1\right)\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10 or 4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) Initial program 71.3%
Taylor expanded in n around inf 45.5%
associate--l+20.5%
log1p-define20.5%
+-commutative20.5%
associate--r+45.5%
distribute-lft-out--45.5%
div-sub45.5%
log1p-define45.5%
Simplified45.5%
log1p-expm1-u59.8%
log1p-undefine59.8%
Applied egg-rr59.8%
Taylor expanded in n around inf 36.0%
sub-neg36.0%
log1p-define36.0%
exp-diff36.0%
log1p-define36.0%
rem-exp-log10.9%
+-commutative10.9%
rem-exp-log36.0%
metadata-eval36.0%
Simplified36.0%
Taylor expanded in n around 0 36.0%
log1p-define16.3%
Simplified16.3%
Taylor expanded in x around inf 23.0%
Simplified44.0%
frac-2neg44.0%
metadata-eval44.0%
clear-num44.0%
frac-add47.5%
associate-/l*47.5%
associate-/l*47.5%
Applied egg-rr47.5%
*-rgt-identity47.5%
unsub-neg47.5%
mul-1-neg47.5%
associate-*r/47.5%
*-commutative47.5%
distribute-neg-frac247.5%
*-commutative47.5%
+-commutative47.5%
distribute-neg-in47.5%
metadata-eval47.5%
distribute-neg-frac47.5%
metadata-eval47.5%
distribute-lft-neg-out47.5%
distribute-rgt-neg-in47.5%
associate-*r/47.5%
Simplified47.5%
Taylor expanded in x around inf 47.4%
*-commutative47.4%
*-commutative47.4%
Simplified47.4%
if -10 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e-70Initial program 31.8%
Taylor expanded in n around inf 82.4%
associate--l+82.4%
log1p-define82.4%
+-commutative82.4%
associate--r+82.4%
distribute-lft-out--82.4%
div-sub82.4%
log1p-define82.4%
Simplified82.4%
log1p-expm1-u82.4%
log1p-undefine82.3%
Applied egg-rr82.3%
Taylor expanded in n around inf 82.1%
sub-neg82.1%
log1p-define82.1%
exp-diff82.1%
log1p-define82.1%
rem-exp-log57.8%
+-commutative57.8%
rem-exp-log82.3%
metadata-eval82.3%
Simplified82.3%
Taylor expanded in n around 0 82.3%
log1p-define99.5%
Simplified99.5%
clear-num99.1%
inv-pow99.1%
Applied egg-rr99.1%
unpow-199.1%
Simplified99.1%
clear-num99.1%
associate-/r/99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 54.2%
associate-*r/54.2%
metadata-eval54.2%
Simplified54.2%
Final simplification50.9%
(FPCore (x n) :precision binary64 (if (or (<= (/ 1.0 n) -10.0) (not (<= (/ 1.0 n) 5e-70))) (/ (/ (+ n (* n (/ (+ -0.5 (/ 0.3333333333333333 x)) x))) (* n n)) x) (/ 1.0 (* n (* x (+ (/ 0.5 x) 1.0))))))
double code(double x, double n) {
double tmp;
if (((1.0 / n) <= -10.0) || !((1.0 / n) <= 5e-70)) {
tmp = ((n + (n * ((-0.5 + (0.3333333333333333 / x)) / x))) / (n * n)) / x;
} else {
tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0)));
}
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) <= (-10.0d0)) .or. (.not. ((1.0d0 / n) <= 5d-70))) then
tmp = ((n + (n * (((-0.5d0) + (0.3333333333333333d0 / x)) / x))) / (n * n)) / x
else
tmp = 1.0d0 / (n * (x * ((0.5d0 / x) + 1.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (((1.0 / n) <= -10.0) || !((1.0 / n) <= 5e-70)) {
tmp = ((n + (n * ((-0.5 + (0.3333333333333333 / x)) / x))) / (n * n)) / x;
} else {
tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0)));
}
return tmp;
}
def code(x, n): tmp = 0 if ((1.0 / n) <= -10.0) or not ((1.0 / n) <= 5e-70): tmp = ((n + (n * ((-0.5 + (0.3333333333333333 / x)) / x))) / (n * n)) / x else: tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0))) return tmp
function code(x, n) tmp = 0.0 if ((Float64(1.0 / n) <= -10.0) || !(Float64(1.0 / n) <= 5e-70)) tmp = Float64(Float64(Float64(n + Float64(n * Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x))) / Float64(n * n)) / x); else tmp = Float64(1.0 / Float64(n * Float64(x * Float64(Float64(0.5 / x) + 1.0)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (((1.0 / n) <= -10.0) || ~(((1.0 / n) <= 5e-70))) tmp = ((n + (n * ((-0.5 + (0.3333333333333333 / x)) / x))) / (n * n)) / x; else tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0))); end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[N[(1.0 / n), $MachinePrecision], -10.0], N[Not[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-70]], $MachinePrecision]], N[(N[(N[(n + N[(n * N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(n * N[(x * N[(N[(0.5 / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10 \lor \neg \left(\frac{1}{n} \leq 5 \cdot 10^{-70}\right):\\
\;\;\;\;\frac{\frac{n + n \cdot \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{n \cdot n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot \left(x \cdot \left(\frac{0.5}{x} + 1\right)\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -10 or 4.9999999999999998e-70 < (/.f64 #s(literal 1 binary64) n) Initial program 71.3%
Taylor expanded in n around inf 45.5%
associate--l+20.5%
log1p-define20.5%
+-commutative20.5%
associate--r+45.5%
distribute-lft-out--45.5%
div-sub45.5%
log1p-define45.5%
Simplified45.5%
log1p-expm1-u59.8%
log1p-undefine59.8%
Applied egg-rr59.8%
Taylor expanded in n around inf 36.0%
sub-neg36.0%
log1p-define36.0%
exp-diff36.0%
log1p-define36.0%
rem-exp-log10.9%
+-commutative10.9%
rem-exp-log36.0%
metadata-eval36.0%
Simplified36.0%
Taylor expanded in n around 0 36.0%
log1p-define16.3%
Simplified16.3%
Taylor expanded in x around inf 23.0%
Simplified44.0%
frac-2neg44.0%
metadata-eval44.0%
associate-/r*44.0%
frac-add46.7%
neg-mul-146.7%
Applied egg-rr46.7%
if -10 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e-70Initial program 31.8%
Taylor expanded in n around inf 82.4%
associate--l+82.4%
log1p-define82.4%
+-commutative82.4%
associate--r+82.4%
distribute-lft-out--82.4%
div-sub82.4%
log1p-define82.4%
Simplified82.4%
log1p-expm1-u82.4%
log1p-undefine82.3%
Applied egg-rr82.3%
Taylor expanded in n around inf 82.1%
sub-neg82.1%
log1p-define82.1%
exp-diff82.1%
log1p-define82.1%
rem-exp-log57.8%
+-commutative57.8%
rem-exp-log82.3%
metadata-eval82.3%
Simplified82.3%
Taylor expanded in n around 0 82.3%
log1p-define99.5%
Simplified99.5%
clear-num99.1%
inv-pow99.1%
Applied egg-rr99.1%
unpow-199.1%
Simplified99.1%
clear-num99.1%
associate-/r/99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 54.2%
associate-*r/54.2%
metadata-eval54.2%
Simplified54.2%
Final simplification50.6%
(FPCore (x n) :precision binary64 (if (<= n 1.56e-192) (/ (/ 1.0 n) x) (/ 1.0 (* n (* x (+ (/ 0.5 x) 1.0))))))
double code(double x, double n) {
double tmp;
if (n <= 1.56e-192) {
tmp = (1.0 / n) / x;
} else {
tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0)));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 1.56d-192) then
tmp = (1.0d0 / n) / x
else
tmp = 1.0d0 / (n * (x * ((0.5d0 / x) + 1.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= 1.56e-192) {
tmp = (1.0 / n) / x;
} else {
tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0)));
}
return tmp;
}
def code(x, n): tmp = 0 if n <= 1.56e-192: tmp = (1.0 / n) / x else: tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0))) return tmp
function code(x, n) tmp = 0.0 if (n <= 1.56e-192) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(1.0 / Float64(n * Float64(x * Float64(Float64(0.5 / x) + 1.0)))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= 1.56e-192) tmp = (1.0 / n) / x; else tmp = 1.0 / (n * (x * ((0.5 / x) + 1.0))); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, 1.56e-192], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(n * N[(x * N[(N[(0.5 / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.56 \cdot 10^{-192}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot \left(x \cdot \left(\frac{0.5}{x} + 1\right)\right)}\\
\end{array}
\end{array}
if n < 1.5599999999999999e-192Initial program 60.6%
Taylor expanded in x around inf 68.1%
associate-/r*68.5%
mul-1-neg68.5%
log-rec68.5%
mul-1-neg68.5%
distribute-neg-frac68.5%
mul-1-neg68.5%
remove-double-neg68.5%
*-rgt-identity68.5%
associate-/l*68.5%
exp-to-pow68.5%
Simplified68.5%
Taylor expanded in n around inf 43.9%
associate-/r*44.2%
Simplified44.2%
if 1.5599999999999999e-192 < n Initial program 35.2%
Taylor expanded in n around inf 55.6%
associate--l+55.7%
log1p-define55.7%
+-commutative55.7%
associate--r+55.6%
distribute-lft-out--55.6%
div-sub55.6%
log1p-define55.6%
Simplified55.6%
log1p-expm1-u55.5%
log1p-undefine55.6%
Applied egg-rr55.6%
Taylor expanded in n around inf 57.0%
sub-neg57.0%
log1p-define57.0%
exp-diff57.0%
log1p-define57.0%
rem-exp-log45.0%
+-commutative45.0%
rem-exp-log57.1%
metadata-eval57.1%
Simplified57.1%
Taylor expanded in n around 0 57.1%
log1p-define71.3%
Simplified71.3%
clear-num71.3%
inv-pow71.3%
Applied egg-rr71.3%
unpow-171.3%
Simplified71.3%
clear-num71.3%
associate-/r/71.3%
Applied egg-rr71.3%
Taylor expanded in x around inf 36.7%
associate-*r/36.7%
metadata-eval36.7%
Simplified36.7%
Final simplification41.4%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ -0.5 (/ 0.3333333333333333 x)) (* n x))) x))
double code(double x, double n) {
return ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (n * x))) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((-0.5d0) + (0.3333333333333333d0 / x)) / (n * x))) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (n * x))) / x;
}
def code(x, n): return ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (n * x))) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / Float64(n * x))) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (n * x))) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{-0.5 + \frac{0.3333333333333333}{x}}{n \cdot x}}{x}
\end{array}
Initial program 51.1%
Taylor expanded in n around inf 64.4%
associate--l+52.1%
log1p-define52.1%
+-commutative52.1%
associate--r+64.4%
distribute-lft-out--64.4%
div-sub64.4%
log1p-define64.4%
Simplified64.4%
log1p-expm1-u71.4%
log1p-undefine71.4%
Applied egg-rr71.4%
Taylor expanded in n around inf 59.6%
sub-neg59.6%
log1p-define59.6%
exp-diff59.6%
log1p-define59.6%
rem-exp-log34.9%
+-commutative34.9%
rem-exp-log59.7%
metadata-eval59.7%
Simplified59.7%
Taylor expanded in n around 0 59.7%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 36.2%
Simplified46.4%
Final simplification46.4%
(FPCore (x n) :precision binary64 (/ (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) n) x))
double code(double x, double n) {
return ((((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / n) / x
end function
public static double code(double x, double n) {
return ((((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / n) / x;
}
def code(x, n): return ((((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / n) / x
function code(x, n) return Float64(Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / n) / x) end
function tmp = code(x, n) tmp = ((((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / n) / x; end
code[x_, n_] := N[(N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{n}}{x}
\end{array}
Initial program 51.1%
Taylor expanded in n around inf 64.4%
associate--l+52.1%
log1p-define52.1%
+-commutative52.1%
associate--r+64.4%
distribute-lft-out--64.4%
div-sub64.4%
log1p-define64.4%
Simplified64.4%
log1p-expm1-u71.4%
log1p-undefine71.4%
Applied egg-rr71.4%
Taylor expanded in n around inf 59.6%
sub-neg59.6%
log1p-define59.6%
exp-diff59.6%
log1p-define59.6%
rem-exp-log34.9%
+-commutative34.9%
rem-exp-log59.7%
metadata-eval59.7%
Simplified59.7%
Taylor expanded in n around 0 59.7%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 36.2%
Simplified46.4%
Taylor expanded in n around 0 46.4%
associate--l+46.4%
+-commutative46.4%
associate-*r/46.4%
metadata-eval46.4%
unpow246.4%
associate-/r*46.4%
associate-*r/46.4%
metadata-eval46.4%
div-sub46.4%
sub-neg46.4%
metadata-eval46.4%
+-commutative46.4%
+-commutative46.4%
Simplified46.4%
Final simplification46.4%
(FPCore (x n) :precision binary64 (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* n x)))
double code(double x, double n) {
return (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (n * x)
end function
public static double code(double x, double n) {
return (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (n * x);
}
def code(x, n): return (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (n * x)
function code(x, n) return Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(n * x)) end
function tmp = code(x, n) tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (n * x); end
code[x_, n_] := N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{n \cdot x}
\end{array}
Initial program 51.1%
Taylor expanded in n around inf 64.4%
associate--l+52.1%
log1p-define52.1%
+-commutative52.1%
associate--r+64.4%
distribute-lft-out--64.4%
div-sub64.4%
log1p-define64.4%
Simplified64.4%
log1p-expm1-u71.4%
log1p-undefine71.4%
Applied egg-rr71.4%
Taylor expanded in n around inf 59.6%
sub-neg59.6%
log1p-define59.6%
exp-diff59.6%
log1p-define59.6%
rem-exp-log34.9%
+-commutative34.9%
rem-exp-log59.7%
metadata-eval59.7%
Simplified59.7%
Taylor expanded in n around 0 59.7%
log1p-define58.9%
Simplified58.9%
Taylor expanded in x around inf 36.2%
Simplified46.4%
Taylor expanded in n around 0 46.2%
associate--l+46.2%
sub-neg46.2%
sub-neg46.2%
associate-*r/46.2%
metadata-eval46.2%
unpow246.2%
associate-/r*46.2%
associate-*r/46.2%
metadata-eval46.2%
div-sub46.2%
metadata-eval46.2%
associate-*r/46.2%
sub-neg46.2%
associate-*r/46.2%
metadata-eval46.2%
metadata-eval46.2%
+-commutative46.2%
Simplified46.2%
Final simplification46.2%
(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 51.1%
Taylor expanded in x around inf 55.5%
associate-/r*55.8%
mul-1-neg55.8%
log-rec55.8%
mul-1-neg55.8%
distribute-neg-frac55.8%
mul-1-neg55.8%
remove-double-neg55.8%
*-rgt-identity55.8%
associate-/l*55.8%
exp-to-pow55.8%
Simplified55.8%
Taylor expanded in n around inf 39.4%
associate-/r*39.6%
Simplified39.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 51.1%
Taylor expanded in x around inf 55.5%
mul-1-neg55.5%
log-rec55.5%
mul-1-neg55.5%
distribute-neg-frac55.5%
mul-1-neg55.5%
remove-double-neg55.5%
*-commutative55.5%
Simplified55.5%
Taylor expanded in n around inf 39.4%
Final simplification39.4%
(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 51.1%
Taylor expanded in x around 0 30.3%
Taylor expanded in x around inf 4.7%
herbie shell --seed 2024107
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))