
(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 (<= x 320.0)
(/
(log
(/
x
(exp
(+
(log1p x)
(/
(fma
0.5
(- (pow (log1p x) 2.0) (pow (log x) 2.0))
(/
(* 0.16666666666666666 (- (pow (log1p x) 3.0) (pow (log x) 3.0)))
n))
n)))))
(- n))
(/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 320.0) {
tmp = log((x / exp((log1p(x) + (fma(0.5, (pow(log1p(x), 2.0) - pow(log(x), 2.0)), ((0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0))) / n)) / n))))) / -n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 320.0) tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(0.5, Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), Float64(Float64(0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / n)) / n))))) / Float64(-n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 320.0], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.16666666666666666 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 320:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(0.5, {\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n}\right)}{n}}}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
\end{array}
if x < 320Initial program 42.3%
Taylor expanded in n around -inf 78.8%
Simplified78.8%
add-log-exp87.1%
diff-log87.1%
Applied egg-rr87.1%
if 320 < x Initial program 73.2%
Taylor expanded in x around inf 82.3%
Simplified82.3%
Taylor expanded in x around inf 99.3%
distribute-frac-neg299.3%
log-rec99.3%
distribute-frac-neg99.3%
distribute-neg-frac299.3%
neg-mul-199.3%
distribute-lft-neg-in99.3%
metadata-eval99.3%
*-commutative99.3%
*-rgt-identity99.3%
associate-*r/99.3%
*-rgt-identity99.3%
exp-to-pow99.3%
Simplified99.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (sqrt t_0)))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(fma t_1 (- t_1) (exp (/ (log1p x) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = sqrt(t_0);
double tmp;
if ((1.0 / n) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = fma(t_1, -t_1, exp((log1p(x) / n)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = sqrt(t_0) tmp = 0.0 if (Float64(1.0 / n) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = fma(t_1, Float64(-t_1), exp(Float64(log1p(x) / n))); 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[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(t$95$1 * (-t$95$1) + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;\frac{1}{n} \leq -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -t\_1, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) Initial program 47.5%
sub-neg47.5%
+-commutative47.5%
sqr-pow47.5%
distribute-rgt-neg-in47.5%
fma-define47.6%
sqrt-pow147.6%
sqrt-pow147.6%
pow-to-exp47.6%
un-div-inv47.6%
+-commutative47.6%
log1p-define97.2%
Applied egg-rr97.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(- (pow E (/ (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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = pow(((double) M_E), (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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.pow(Math.E, (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) <= -8e-31: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.pow(math.e, (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) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64((exp(1) ^ 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], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Power[E, 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 -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;{e}^{\left(\frac{\mathsf{log1p}\left(x\right)}{n}\right)} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) Initial program 47.5%
Taylor expanded in n around 0 47.5%
log1p-define97.1%
Simplified97.1%
*-un-lft-identity97.1%
exp-prod97.2%
Applied egg-rr97.2%
exp-1-e97.2%
Simplified97.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) 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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / 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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / 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) <= -8e-31: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / 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) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / 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], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $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 -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\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) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) Initial program 47.5%
Taylor expanded in n around 0 47.5%
log1p-define97.1%
Simplified97.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+157)
(- (+ 1.0 (/ x n)) t_0)
(* -0.16666666666666666 (pow (/ (log x) n) 3.0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = -0.16666666666666666 * pow((log(x) / n), 3.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 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-8d-31)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-18) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 5d+157) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (-0.16666666666666666d0) * ((log(x) / n) ** 3.0d0)
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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = -0.16666666666666666 * Math.pow((Math.log(x) / n), 3.0);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -8e-31: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+157: tmp = (1.0 + (x / n)) - t_0 else: tmp = -0.16666666666666666 * math.pow((math.log(x) / n), 3.0) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+157) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(-0.16666666666666666 * (Float64(log(x) / n) ^ 3.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -8e-31) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-18) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 5e+157) tmp = (1.0 + (x / n)) - t_0; else tmp = -0.16666666666666666 * ((log(x) / n) ^ 3.0); 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], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+157], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(-0.16666666666666666 * N[Power[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {\left(\frac{\log x}{n}\right)}^{3}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999976e157Initial program 73.9%
Taylor expanded in x around 0 78.5%
if 4.99999999999999976e157 < (/.f64 #s(literal 1 binary64) n) Initial program 28.0%
Taylor expanded in x around 0 19.6%
Taylor expanded in n around -inf 74.7%
Taylor expanded in n around 0 74.7%
cube-div74.7%
Simplified74.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(- (pow E (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = pow(((double) M_E), (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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.pow(Math.E, (x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -8e-31: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.pow(math.e, (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) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64((exp(1) ^ Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -8e-31) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-18) tmp = log(((x + 1.0) / x)) / n; else tmp = (2.71828182845904523536 ^ (x / n)) - t_0; 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], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Power[E, N[(x / 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 -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;{e}^{\left(\frac{x}{n}\right)} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) Initial program 47.5%
Taylor expanded in n around 0 47.5%
log1p-define97.1%
Simplified97.1%
*-un-lft-identity97.1%
exp-prod97.2%
Applied egg-rr97.2%
exp-1-e97.2%
Simplified97.2%
Taylor expanded in x around 0 97.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((x / n)) - t_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 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-8d-31)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2d-18) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = exp((x / n)) - t_0
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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -8e-31: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((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) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -8e-31) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2e-18) tmp = log(((x + 1.0) / x)) / n; else tmp = exp((x / n)) - t_0; 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], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $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)}\\
\mathbf{if}\;\frac{1}{n} \leq -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) Initial program 47.5%
Taylor expanded in n around 0 47.5%
log1p-define97.1%
Simplified97.1%
Taylor expanded in x around 0 97.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+157)
(- (+ 1.0 (/ x n)) t_0)
(/
(expm1 (/ (+ 1.0 (/ (+ -1.0 (* 1.1666666666666667 (/ 1.0 x))) x)) x))
n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = expm1(((1.0 + ((-1.0 + (1.1666666666666667 * (1.0 / x))) / x)) / x)) / n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.expm1(((1.0 + ((-1.0 + (1.1666666666666667 * (1.0 / x))) / x)) / x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -8e-31: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+157: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.expm1(((1.0 + ((-1.0 + (1.1666666666666667 * (1.0 / x))) / x)) / x)) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+157) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(expm1(Float64(Float64(1.0 + Float64(Float64(-1.0 + Float64(1.1666666666666667 * Float64(1.0 / x))) / x)) / x)) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+157], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(Exp[N[(N[(1.0 + N[(N[(-1.0 + N[(1.1666666666666667 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]] - 1), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 + 1.1666666666666667 \cdot \frac{1}{x}}{x}}{x}\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999976e157Initial program 73.9%
Taylor expanded in x around 0 78.5%
if 4.99999999999999976e157 < (/.f64 #s(literal 1 binary64) n) Initial program 28.0%
Taylor expanded in n around inf 5.8%
expm1-log1p-u5.8%
log1p-define5.8%
Applied egg-rr5.8%
Taylor expanded in x around -inf 74.7%
Final simplification86.1%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -50000000.0)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= (/ 1.0 n) 2e-262)
(/ 1.0 (* x (+ n (* 0.5 (/ n x)))))
(if (<= (/ 1.0 n) 2e-18)
(* (log x) (/ -1.0 n))
(if (<= (/ 1.0 n) 1e+144)
(- 1.0 (pow x (/ 1.0 n)))
(/ (log1p (+ x -1.0)) (- n)))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -50000000.0) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if ((1.0 / n) <= 2e-262) {
tmp = 1.0 / (x * (n + (0.5 * (n / x))));
} else if ((1.0 / n) <= 2e-18) {
tmp = log(x) * (-1.0 / n);
} else if ((1.0 / n) <= 1e+144) {
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) <= -50000000.0) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if ((1.0 / n) <= 2e-262) {
tmp = 1.0 / (x * (n + (0.5 * (n / x))));
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(x) * (-1.0 / n);
} else if ((1.0 / n) <= 1e+144) {
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) <= -50000000.0: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif (1.0 / n) <= 2e-262: tmp = 1.0 / (x * (n + (0.5 * (n / x)))) elif (1.0 / n) <= 2e-18: tmp = math.log(x) * (-1.0 / n) elif (1.0 / n) <= 1e+144: 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) <= -50000000.0) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (Float64(1.0 / n) <= 2e-262) tmp = Float64(1.0 / Float64(x * Float64(n + Float64(0.5 * Float64(n / x))))); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(x) * Float64(-1.0 / n)); elseif (Float64(1.0 / n) <= 1e+144) 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], -50000000.0], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-262], N[(1.0 / N[(x * N[(n + N[(0.5 * N[(n / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[x], $MachinePrecision] * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+144], 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 -50000000:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-262}:\\
\;\;\;\;\frac{1}{x \cdot \left(n + 0.5 \cdot \frac{n}{x}\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\log x \cdot \frac{-1}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\
\;\;\;\;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) < -5e7Initial program 100.0%
Taylor expanded in n around inf 52.6%
Taylor expanded in x around -inf 45.4%
Taylor expanded in x around 0 77.1%
if -5e7 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000002e-262Initial program 41.3%
Taylor expanded in n around inf 80.0%
clear-num79.9%
inv-pow79.9%
log1p-define79.9%
Applied egg-rr79.9%
unpow-179.9%
Simplified79.9%
Taylor expanded in x around inf 58.7%
if 2.00000000000000002e-262 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 25.5%
Taylor expanded in n around inf 78.8%
Taylor expanded in x around 0 58.2%
neg-mul-158.2%
Simplified58.2%
div-inv58.3%
Applied egg-rr58.3%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e144Initial program 76.9%
Taylor expanded in x around 0 76.7%
if 1.00000000000000002e144 < (/.f64 #s(literal 1 binary64) n) Initial program 29.9%
Taylor expanded in n around inf 5.7%
Taylor expanded in x around 0 5.7%
neg-mul-15.7%
Simplified5.7%
log1p-expm1-u65.4%
expm1-undefine65.4%
add-exp-log65.4%
Applied egg-rr65.4%
Final simplification65.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+157)
(- (+ 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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+157) {
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) <= -8e-31: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+157: 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) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+157) 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], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+157], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(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 -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\
\;\;\;\;\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) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999976e157Initial program 73.9%
Taylor expanded in x around 0 78.5%
if 4.99999999999999976e157 < (/.f64 #s(literal 1 binary64) n) Initial program 28.0%
Taylor expanded in n around inf 5.8%
Taylor expanded in x around 0 5.8%
neg-mul-15.8%
Simplified5.8%
log1p-expm1-u66.6%
expm1-undefine66.6%
add-exp-log66.6%
Applied egg-rr66.6%
Final simplification85.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -8e-31)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 1e+144) (- 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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+144) {
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) <= -8e-31) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+144) {
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) <= -8e-31: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+144: 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) <= -8e-31) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+144) 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], -8e-31], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+144], 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 -8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -8.000000000000001e-31Initial program 90.1%
Taylor expanded in x around inf 29.9%
Simplified29.9%
Taylor expanded in x around inf 95.6%
distribute-frac-neg295.6%
log-rec95.6%
distribute-frac-neg95.6%
distribute-neg-frac295.6%
neg-mul-195.6%
distribute-lft-neg-in95.6%
metadata-eval95.6%
*-commutative95.6%
*-rgt-identity95.6%
associate-*r/95.6%
*-rgt-identity95.6%
exp-to-pow95.6%
Simplified95.6%
if -8.000000000000001e-31 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.8%
Taylor expanded in n around inf 82.5%
diff-log82.7%
+-commutative82.7%
Applied egg-rr82.7%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e144Initial program 76.9%
Taylor expanded in x around 0 76.7%
if 1.00000000000000002e144 < (/.f64 #s(literal 1 binary64) n) Initial program 29.9%
Taylor expanded in n around inf 5.7%
Taylor expanded in x around 0 5.7%
neg-mul-15.7%
Simplified5.7%
log1p-expm1-u65.4%
expm1-undefine65.4%
add-exp-log65.4%
Applied egg-rr65.4%
Final simplification85.1%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -5e-5)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= (/ 1.0 n) 2e-18)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 1e+144)
(- 1.0 (pow x (/ 1.0 n)))
(/ (log1p (+ x -1.0)) (- n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e-5) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if ((1.0 / n) <= 2e-18) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+144) {
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) <= -5e-5) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if ((1.0 / n) <= 2e-18) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 1e+144) {
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) <= -5e-5: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif (1.0 / n) <= 2e-18: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 1e+144: 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) <= -5e-5) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 1e+144) 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], -5e-5], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+144], 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 -5 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\
\;\;\;\;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) < -5.00000000000000024e-5Initial program 98.7%
Taylor expanded in n around inf 52.0%
Taylor expanded in x around -inf 45.2%
Taylor expanded in x around 0 76.2%
if -5.00000000000000024e-5 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 34.0%
Taylor expanded in n around inf 80.0%
diff-log80.3%
+-commutative80.3%
Applied egg-rr80.3%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e144Initial program 76.9%
Taylor expanded in x around 0 76.7%
if 1.00000000000000002e144 < (/.f64 #s(literal 1 binary64) n) Initial program 29.9%
Taylor expanded in n around inf 5.7%
Taylor expanded in x around 0 5.7%
neg-mul-15.7%
Simplified5.7%
log1p-expm1-u65.4%
expm1-undefine65.4%
add-exp-log65.4%
Applied egg-rr65.4%
Final simplification77.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (+ (* n -0.3333333333333333) (* n 0.25))))
(if (<= x 0.35)
(* (log x) (/ -1.0 n))
(if (<= x 1.9e+118)
(/
-1.0
(*
x
(-
(/
(+
(/
(-
(+
(* -0.5 (/ t_0 x))
(+ (* (/ n x) -0.25) (* 0.16666666666666666 (/ n x))))
t_0)
x)
(* n -0.5))
x)
n)))
0.0))))
double code(double x, double n) {
double t_0 = (n * -0.3333333333333333) + (n * 0.25);
double tmp;
if (x <= 0.35) {
tmp = log(x) * (-1.0 / n);
} else if (x <= 1.9e+118) {
tmp = -1.0 / (x * (((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + (0.16666666666666666 * (n / x)))) - t_0) / x) + (n * -0.5)) / 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 = (n * (-0.3333333333333333d0)) + (n * 0.25d0)
if (x <= 0.35d0) then
tmp = log(x) * ((-1.0d0) / n)
else if (x <= 1.9d+118) then
tmp = (-1.0d0) / (x * ((((((((-0.5d0) * (t_0 / x)) + (((n / x) * (-0.25d0)) + (0.16666666666666666d0 * (n / x)))) - t_0) / x) + (n * (-0.5d0))) / x) - n))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (n * -0.3333333333333333) + (n * 0.25);
double tmp;
if (x <= 0.35) {
tmp = Math.log(x) * (-1.0 / n);
} else if (x <= 1.9e+118) {
tmp = -1.0 / (x * (((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + (0.16666666666666666 * (n / x)))) - t_0) / x) + (n * -0.5)) / x) - n));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = (n * -0.3333333333333333) + (n * 0.25) tmp = 0 if x <= 0.35: tmp = math.log(x) * (-1.0 / n) elif x <= 1.9e+118: tmp = -1.0 / (x * (((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + (0.16666666666666666 * (n / x)))) - t_0) / x) + (n * -0.5)) / x) - n)) else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(Float64(n * -0.3333333333333333) + Float64(n * 0.25)) tmp = 0.0 if (x <= 0.35) tmp = Float64(log(x) * Float64(-1.0 / n)); elseif (x <= 1.9e+118) tmp = Float64(-1.0 / Float64(x * Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.5 * Float64(t_0 / x)) + Float64(Float64(Float64(n / x) * -0.25) + Float64(0.16666666666666666 * Float64(n / x)))) - t_0) / x) + Float64(n * -0.5)) / x) - n))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = (n * -0.3333333333333333) + (n * 0.25); tmp = 0.0; if (x <= 0.35) tmp = log(x) * (-1.0 / n); elseif (x <= 1.9e+118) tmp = -1.0 / (x * (((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + (0.16666666666666666 * (n / x)))) - t_0) / x) + (n * -0.5)) / x) - n)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(n * -0.3333333333333333), $MachinePrecision] + N[(n * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 0.35], N[(N[Log[x], $MachinePrecision] * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.9e+118], N[(-1.0 / N[(x * N[(N[(N[(N[(N[(N[(N[(-0.5 * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(n / x), $MachinePrecision] * -0.25), $MachinePrecision] + N[(0.16666666666666666 * N[(n / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / x), $MachinePrecision] + N[(n * -0.5), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot -0.3333333333333333 + n \cdot 0.25\\
\mathbf{if}\;x \leq 0.35:\\
\;\;\;\;\log x \cdot \frac{-1}{n}\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+118}:\\
\;\;\;\;\frac{-1}{x \cdot \left(\frac{\frac{\left(-0.5 \cdot \frac{t\_0}{x} + \left(\frac{n}{x} \cdot -0.25 + 0.16666666666666666 \cdot \frac{n}{x}\right)\right) - t\_0}{x} + n \cdot -0.5}{x} - n\right)}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.34999999999999998Initial program 42.6%
Taylor expanded in n around inf 50.2%
Taylor expanded in x around 0 50.2%
neg-mul-150.2%
Simplified50.2%
div-inv50.2%
Applied egg-rr50.2%
if 0.34999999999999998 < x < 1.90000000000000008e118Initial program 46.5%
Taylor expanded in n around inf 47.8%
clear-num47.8%
inv-pow47.8%
log1p-define47.8%
Applied egg-rr47.8%
unpow-147.8%
Simplified47.8%
Taylor expanded in x around -inf 61.8%
if 1.90000000000000008e118 < x Initial program 88.5%
Taylor expanded in x around 0 55.5%
Taylor expanded in n around inf 88.5%
metadata-eval88.5%
Applied egg-rr88.5%
Final simplification62.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (+ (* n -0.3333333333333333) (* n 0.25))))
(if (<= x 0.35)
(/ (log x) (- n))
(if (<= x 2.35e+118)
(/
-1.0
(*
x
(-
(/
(+
(/
(-
(+
(* -0.5 (/ t_0 x))
(+ (* (/ n x) -0.25) (* 0.16666666666666666 (/ n x))))
t_0)
x)
(* n -0.5))
x)
n)))
0.0))))
double code(double x, double n) {
double t_0 = (n * -0.3333333333333333) + (n * 0.25);
double tmp;
if (x <= 0.35) {
tmp = log(x) / -n;
} else if (x <= 2.35e+118) {
tmp = -1.0 / (x * (((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + (0.16666666666666666 * (n / x)))) - t_0) / x) + (n * -0.5)) / 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 = (n * (-0.3333333333333333d0)) + (n * 0.25d0)
if (x <= 0.35d0) then
tmp = log(x) / -n
else if (x <= 2.35d+118) then
tmp = (-1.0d0) / (x * ((((((((-0.5d0) * (t_0 / x)) + (((n / x) * (-0.25d0)) + (0.16666666666666666d0 * (n / x)))) - t_0) / x) + (n * (-0.5d0))) / x) - n))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (n * -0.3333333333333333) + (n * 0.25);
double tmp;
if (x <= 0.35) {
tmp = Math.log(x) / -n;
} else if (x <= 2.35e+118) {
tmp = -1.0 / (x * (((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + (0.16666666666666666 * (n / x)))) - t_0) / x) + (n * -0.5)) / x) - n));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = (n * -0.3333333333333333) + (n * 0.25) tmp = 0 if x <= 0.35: tmp = math.log(x) / -n elif x <= 2.35e+118: tmp = -1.0 / (x * (((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + (0.16666666666666666 * (n / x)))) - t_0) / x) + (n * -0.5)) / x) - n)) else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(Float64(n * -0.3333333333333333) + Float64(n * 0.25)) tmp = 0.0 if (x <= 0.35) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 2.35e+118) tmp = Float64(-1.0 / Float64(x * Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.5 * Float64(t_0 / x)) + Float64(Float64(Float64(n / x) * -0.25) + Float64(0.16666666666666666 * Float64(n / x)))) - t_0) / x) + Float64(n * -0.5)) / x) - n))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = (n * -0.3333333333333333) + (n * 0.25); tmp = 0.0; if (x <= 0.35) tmp = log(x) / -n; elseif (x <= 2.35e+118) tmp = -1.0 / (x * (((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + (0.16666666666666666 * (n / x)))) - t_0) / x) + (n * -0.5)) / x) - n)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(n * -0.3333333333333333), $MachinePrecision] + N[(n * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 0.35], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.35e+118], N[(-1.0 / N[(x * N[(N[(N[(N[(N[(N[(N[(-0.5 * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(n / x), $MachinePrecision] * -0.25), $MachinePrecision] + N[(0.16666666666666666 * N[(n / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / x), $MachinePrecision] + N[(n * -0.5), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot -0.3333333333333333 + n \cdot 0.25\\
\mathbf{if}\;x \leq 0.35:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{+118}:\\
\;\;\;\;\frac{-1}{x \cdot \left(\frac{\frac{\left(-0.5 \cdot \frac{t\_0}{x} + \left(\frac{n}{x} \cdot -0.25 + 0.16666666666666666 \cdot \frac{n}{x}\right)\right) - t\_0}{x} + n \cdot -0.5}{x} - n\right)}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.34999999999999998Initial program 42.6%
Taylor expanded in n around inf 50.2%
Taylor expanded in x around 0 50.2%
neg-mul-150.2%
Simplified50.2%
if 0.34999999999999998 < x < 2.3499999999999999e118Initial program 46.5%
Taylor expanded in n around inf 47.8%
clear-num47.8%
inv-pow47.8%
log1p-define47.8%
Applied egg-rr47.8%
unpow-147.8%
Simplified47.8%
Taylor expanded in x around -inf 61.8%
if 2.3499999999999999e118 < x Initial program 88.5%
Taylor expanded in x around 0 55.5%
Taylor expanded in n around inf 88.5%
metadata-eval88.5%
Applied egg-rr88.5%
Final simplification62.4%
(FPCore (x n) :precision binary64 (if (<= x 1.95e+118) (/ (+ (/ 1.0 n) (/ (+ -0.5 (/ 0.3333333333333333 x)) (* x n))) x) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.95e+118) {
tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x;
} 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.95d+118) then
tmp = ((1.0d0 / n) + (((-0.5d0) + (0.3333333333333333d0 / x)) / (x * n))) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.95e+118) {
tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.95e+118: tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.95e+118) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / Float64(x * n))) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.95e+118) tmp = ((1.0 / n) + ((-0.5 + (0.3333333333333333 / x)) / (x * n))) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.95e+118], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.95 \cdot 10^{+118}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x \cdot n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.95e118Initial program 43.5%
Taylor expanded in n around inf 49.7%
Taylor expanded in x around inf 25.6%
Taylor expanded in x around -inf 41.3%
Simplified41.3%
if 1.95e118 < x Initial program 88.5%
Taylor expanded in x around 0 55.5%
Taylor expanded in n around inf 88.5%
metadata-eval88.5%
Applied egg-rr88.5%
Final simplification54.0%
(FPCore (x n) :precision binary64 (if (<= x 2.1e+118) (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* x n)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 2.1e+118) {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / 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 <= 2.1d+118) then
tmp = (1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / 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 <= 2.1e+118) {
tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.1e+118: tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (x * n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 2.1e+118) tmp = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.1e+118) tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.1e+118], N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.1 \cdot 10^{+118}:\\
\;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.1e118Initial program 43.5%
Taylor expanded in n around inf 49.7%
Taylor expanded in x around -inf 41.3%
Taylor expanded in n around -inf 41.3%
mul-1-neg41.3%
unsub-neg41.3%
sub-neg41.3%
associate-*r/41.3%
metadata-eval41.3%
distribute-neg-frac41.3%
metadata-eval41.3%
*-commutative41.3%
Simplified41.3%
if 2.1e118 < x Initial program 88.5%
Taylor expanded in x around 0 55.5%
Taylor expanded in n around inf 88.5%
metadata-eval88.5%
Applied egg-rr88.5%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -50000000.0) 0.0 (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -50000000.0) {
tmp = 0.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-50000000.0d0)) then
tmp = 0.0d0
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -50000000.0) {
tmp = 0.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -50000000.0: tmp = 0.0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -50000000.0) tmp = 0.0; else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -50000000.0) tmp = 0.0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -50000000.0], 0.0, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -50000000:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5e7Initial program 100.0%
Taylor expanded in x around 0 51.6%
Taylor expanded in n around inf 50.8%
metadata-eval50.8%
Applied egg-rr50.8%
if -5e7 < (/.f64 #s(literal 1 binary64) n) Initial program 36.8%
Taylor expanded in n around inf 63.3%
Taylor expanded in x around inf 43.9%
Taylor expanded in x around inf 46.4%
(FPCore (x n) :precision binary64 (if (<= x 1.8e+118) (/ 1.0 (* x n)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.8e+118) {
tmp = 1.0 / (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.8d+118) then
tmp = 1.0d0 / (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.8e+118) {
tmp = 1.0 / (x * n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.8e+118: tmp = 1.0 / (x * n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.8e+118) tmp = Float64(1.0 / Float64(x * n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.8e+118) tmp = 1.0 / (x * n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.8e+118], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{+118}:\\
\;\;\;\;\frac{1}{x \cdot n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.8e118Initial program 43.5%
Taylor expanded in n around inf 49.7%
Taylor expanded in x around inf 32.3%
*-commutative32.3%
Simplified32.3%
if 1.8e118 < x Initial program 88.5%
Taylor expanded in x around 0 55.5%
Taylor expanded in n around inf 88.5%
metadata-eval88.5%
Applied egg-rr88.5%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 55.6%
Taylor expanded in x around 0 40.3%
Taylor expanded in n around inf 33.5%
metadata-eval33.5%
Applied egg-rr33.5%
herbie shell --seed 2024141
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))