
(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 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (cbrt (pow x (/ 3.0 n))) (* n x))))
(if (<= (/ 1.0 n) -2e-5)
t_0
(if (<= (/ 1.0 n) 5e-153)
(/
(-
(+
(log1p x)
(/
(+
(* 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))
(log x))
n)
(if (<= (/ 1.0 n) 5000.0) t_0 (- (exp (/ x n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double t_0 = cbrt(pow(x, (3.0 / n))) / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-153) {
tmp = ((log1p(x) + (((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)) - log(x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_0;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-153) {
tmp = ((Math.log1p(x) + (((0.5 * (Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0))) + (0.16666666666666666 * ((Math.pow(Math.log1p(x), 3.0) - Math.pow(Math.log(x), 3.0)) / n))) / n)) - Math.log(x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_0;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) t_0 = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-5) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) + Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n)) - log(x)) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = t_0; else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-5], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(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]), $MachinePrecision] + N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], t$95$0, N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000016e-5 or 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 82.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-rgt-identity94.3%
associate-/l*94.3%
exp-to-pow94.3%
*-commutative94.3%
Simplified94.3%
add-cbrt-cube94.3%
pow394.3%
pow-pow94.3%
Applied egg-rr94.3%
associate-*l/94.3%
metadata-eval94.3%
Simplified94.3%
if -2.00000000000000016e-5 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 39.0%
Taylor expanded in n around -inf 86.6%
Simplified86.6%
if 5e3 < (/.f64 #s(literal 1 binary64) n) Initial program 58.4%
Taylor expanded in n around 0 58.4%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification92.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (cbrt (pow x (/ 3.0 n))) (* n x))))
(if (<= (/ 1.0 n) -2e-5)
t_0
(if (<= (/ 1.0 n) 5e-153)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(if (<= (/ 1.0 n) 5000.0) t_0 (- (exp (/ x n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double t_0 = cbrt(pow(x, (3.0 / n))) / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-153) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_0;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-153) {
tmp = (Math.log1p(x) + ((0.5 * ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n)) - Math.log(x))) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_0;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) t_0 = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-5) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(Float64(log1p(x) + Float64(Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)) - log(x))) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = t_0; else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-5], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], t$95$0, N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000016e-5 or 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 82.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-rgt-identity94.3%
associate-/l*94.3%
exp-to-pow94.3%
*-commutative94.3%
Simplified94.3%
add-cbrt-cube94.3%
pow394.3%
pow-pow94.3%
Applied egg-rr94.3%
associate-*l/94.3%
metadata-eval94.3%
Simplified94.3%
if -2.00000000000000016e-5 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 39.0%
Taylor expanded in n around inf 86.6%
Simplified86.6%
if 5e3 < (/.f64 #s(literal 1 binary64) n) Initial program 58.4%
Taylor expanded in n around 0 58.4%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification92.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (cbrt (pow x (/ 3.0 n))) (* n x))))
(if (<= (/ 1.0 n) -2e-5)
t_0
(if (<= (/ 1.0 n) 5e-153)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5000.0) t_0 (- (exp (/ x n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double t_0 = cbrt(pow(x, (3.0 / n))) / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-153) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_0;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.cbrt(Math.pow(x, (3.0 / n))) / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-153) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_0;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) t_0 = Float64(cbrt((x ^ Float64(3.0 / n))) / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-5) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = t_0; else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-5], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], t$95$0, N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000016e-5 or 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 82.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-rgt-identity94.3%
associate-/l*94.3%
exp-to-pow94.3%
*-commutative94.3%
Simplified94.3%
add-cbrt-cube94.3%
pow394.3%
pow-pow94.3%
Applied egg-rr94.3%
associate-*l/94.3%
metadata-eval94.3%
Simplified94.3%
if -2.00000000000000016e-5 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 39.0%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.6%
Applied egg-rr85.6%
+-commutative85.6%
Simplified85.6%
if 5e3 < (/.f64 #s(literal 1 binary64) n) Initial program 58.4%
Taylor expanded in n around 0 58.4%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification92.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-5)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-153)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5000.0)
(/ (exp (/ (log x) n)) (* n x))
(- (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) <= -2e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-153) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = exp((log(x) / n)) / (n * x);
} 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) <= (-2d-5)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-153) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = exp((log(x) / n)) / (n * x)
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) <= -2e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-153) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} 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) <= -2e-5: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-153: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5000.0: tmp = math.exp((math.log(x) / n)) / (n * x) 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) <= -2e-5) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); 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) <= -2e-5) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-153) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5000.0) tmp = exp((log(x) / n)) / (n * x); 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], -2e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $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 -2 \cdot 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000016e-5Initial program 97.9%
Taylor expanded in x around inf 99.0%
mul-1-neg99.0%
log-rec99.0%
mul-1-neg99.0%
distribute-neg-frac99.0%
mul-1-neg99.0%
remove-double-neg99.0%
*-rgt-identity99.0%
associate-/l*99.0%
exp-to-pow99.0%
*-commutative99.0%
Simplified99.0%
if -2.00000000000000016e-5 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 39.0%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.6%
Applied egg-rr85.6%
+-commutative85.6%
Simplified85.6%
if 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 21.1%
Taylor expanded in x around inf 76.1%
mul-1-neg76.1%
log-rec76.2%
mul-1-neg76.2%
distribute-neg-frac76.2%
mul-1-neg76.2%
remove-double-neg76.2%
*-commutative76.2%
Simplified76.2%
if 5e3 < (/.f64 #s(literal 1 binary64) n) Initial program 58.4%
Taylor expanded in n around 0 58.4%
log1p-define100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification92.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-5)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-153)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5000.0)
(/ (exp (/ (log x) n)) (* n x))
(- (+ 1.0 (* x (/ (+ 1.0 (* 0.5 (/ x n))) n))) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-153) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = exp((log(x) / n)) / (n * x);
} else {
tmp = (1.0 + (x * ((1.0 + (0.5 * (x / n))) / 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) <= (-2d-5)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-153) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = exp((log(x) / n)) / (n * x)
else
tmp = (1.0d0 + (x * ((1.0d0 + (0.5d0 * (x / n))) / 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) <= -2e-5) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-153) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else {
tmp = (1.0 + (x * ((1.0 + (0.5 * (x / n))) / n))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-5: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-153: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5000.0: tmp = math.exp((math.log(x) / n)) / (n * x) else: tmp = (1.0 + (x * ((1.0 + (0.5 * (x / n))) / n))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-5) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 + Float64(0.5 * Float64(x / n))) / 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) <= -2e-5) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-153) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5000.0) tmp = exp((log(x) / n)) / (n * x); else tmp = (1.0 + (x * ((1.0 + (0.5 * (x / n))) / 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], -2e-5], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 + N[(0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-5}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \frac{1 + 0.5 \cdot \frac{x}{n}}{n}\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000016e-5Initial program 97.9%
Taylor expanded in x around inf 99.0%
mul-1-neg99.0%
log-rec99.0%
mul-1-neg99.0%
distribute-neg-frac99.0%
mul-1-neg99.0%
remove-double-neg99.0%
*-rgt-identity99.0%
associate-/l*99.0%
exp-to-pow99.0%
*-commutative99.0%
Simplified99.0%
if -2.00000000000000016e-5 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 39.0%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.6%
Applied egg-rr85.6%
+-commutative85.6%
Simplified85.6%
if 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 21.1%
Taylor expanded in x around inf 76.1%
mul-1-neg76.1%
log-rec76.2%
mul-1-neg76.2%
distribute-neg-frac76.2%
mul-1-neg76.2%
remove-double-neg76.2%
*-commutative76.2%
Simplified76.2%
if 5e3 < (/.f64 #s(literal 1 binary64) n) Initial program 58.4%
Taylor expanded in x around 0 63.3%
Taylor expanded in n around inf 80.9%
Taylor expanded in n around 0 80.9%
*-commutative80.9%
Simplified80.9%
Final simplification88.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -2e-5)
t_1
(if (<= (/ 1.0 n) 5e-153)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5000.0)
t_1
(- (+ 1.0 (* x (/ (+ 1.0 (* 0.5 (/ x n))) n))) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-153) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 + (0.5 * (x / n))) / 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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-2d-5)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-153) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = t_1
else
tmp = (1.0d0 + (x * ((1.0d0 + (0.5d0 * (x / n))) / 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 t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-153) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 + (0.5 * (x / n))) / n))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -2e-5: tmp = t_1 elif (1.0 / n) <= 5e-153: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5000.0: tmp = t_1 else: tmp = (1.0 + (x * ((1.0 + (0.5 * (x / n))) / n))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 + Float64(0.5 * Float64(x / n))) / n))) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -2e-5) tmp = t_1; elseif ((1.0 / n) <= 5e-153) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5000.0) tmp = t_1; else tmp = (1.0 + (x * ((1.0 + (0.5 * (x / n))) / n))) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], t$95$1, N[(N[(1.0 + N[(x * N[(N[(1.0 + N[(0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \frac{1 + 0.5 \cdot \frac{x}{n}}{n}\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000016e-5 or 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 82.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-rgt-identity94.3%
associate-/l*94.3%
exp-to-pow94.3%
*-commutative94.3%
Simplified94.3%
if -2.00000000000000016e-5 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 39.0%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.6%
Applied egg-rr85.6%
+-commutative85.6%
Simplified85.6%
if 5e3 < (/.f64 #s(literal 1 binary64) n) Initial program 58.4%
Taylor expanded in x around 0 63.3%
Taylor expanded in n around inf 80.9%
Taylor expanded in n around 0 80.9%
*-commutative80.9%
Simplified80.9%
Final simplification88.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -2e-5)
t_1
(if (<= (/ 1.0 n) 5e-153)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5000.0)
t_1
(if (<= (/ 1.0 n) 1e+251)
(- (+ 1.0 (/ x n)) t_0)
(/
(/ (+ (/ (+ 0.5 (/ -0.3333333333333333 x)) x) -1.0) (- x))
n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-153) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+251) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-2d-5)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-153) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+251) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = ((((0.5d0 + ((-0.3333333333333333d0) / x)) / x) + (-1.0d0)) / -x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-153) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+251) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -2e-5: tmp = t_1 elif (1.0 / n) <= 5e-153: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5000.0: tmp = t_1 elif (1.0 / n) <= 1e+251: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+251) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x) + -1.0) / Float64(-x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -2e-5) tmp = t_1; elseif ((1.0 / n) <= 5e-153) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5000.0) tmp = t_1; elseif ((1.0 / n) <= 1e+251) tmp = (1.0 + (x / n)) - t_0; else tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+251], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+251}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.5 + \frac{-0.3333333333333333}{x}}{x} + -1}{-x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000016e-5 or 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 82.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-rgt-identity94.3%
associate-/l*94.3%
exp-to-pow94.3%
*-commutative94.3%
Simplified94.3%
if -2.00000000000000016e-5 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 39.0%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.6%
Applied egg-rr85.6%
+-commutative85.6%
Simplified85.6%
if 5e3 < (/.f64 #s(literal 1 binary64) n) < 1e251Initial program 73.4%
Taylor expanded in x around 0 71.7%
if 1e251 < (/.f64 #s(literal 1 binary64) n) Initial program 12.0%
Taylor expanded in n around inf 8.1%
log1p-define8.1%
Simplified8.1%
expm1-log1p-u8.1%
Applied egg-rr8.1%
Taylor expanded in x around -inf 82.4%
mul-1-neg82.4%
distribute-neg-frac282.4%
sub-neg82.4%
associate-*r/82.4%
sub-neg82.4%
metadata-eval82.4%
distribute-lft-in82.4%
neg-mul-182.4%
associate-*r/82.4%
metadata-eval82.4%
distribute-neg-frac82.4%
metadata-eval82.4%
metadata-eval82.4%
metadata-eval82.4%
Simplified82.4%
Final simplification87.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -2e-5)
t_1
(if (<= (/ 1.0 n) 5e-153)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5000.0)
t_1
(if (<= (/ 1.0 n) 1e+251)
(- 1.0 t_0)
(/
(/ (+ (/ (+ 0.5 (/ -0.3333333333333333 x)) x) -1.0) (- x))
n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-153) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+251) {
tmp = 1.0 - t_0;
} else {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-2d-5)) then
tmp = t_1
else if ((1.0d0 / n) <= 5d-153) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+251) then
tmp = 1.0d0 - t_0
else
tmp = ((((0.5d0 + ((-0.3333333333333333d0) / x)) / x) + (-1.0d0)) / -x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e-153) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+251) {
tmp = 1.0 - t_0;
} else {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -2e-5: tmp = t_1 elif (1.0 / n) <= 5e-153: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5000.0: tmp = t_1 elif (1.0 / n) <= 1e+251: tmp = 1.0 - t_0 else: tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+251) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x) + -1.0) / Float64(-x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -2e-5) tmp = t_1; elseif ((1.0 / n) <= 5e-153) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5000.0) tmp = t_1; elseif ((1.0 / n) <= 1e+251) tmp = 1.0 - t_0; else tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+251], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+251}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.5 + \frac{-0.3333333333333333}{x}}{x} + -1}{-x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000016e-5 or 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 82.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-rgt-identity94.3%
associate-/l*94.3%
exp-to-pow94.3%
*-commutative94.3%
Simplified94.3%
if -2.00000000000000016e-5 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 39.0%
Taylor expanded in n around inf 85.3%
log1p-define85.3%
Simplified85.3%
log1p-undefine85.3%
diff-log85.6%
Applied egg-rr85.6%
+-commutative85.6%
Simplified85.6%
if 5e3 < (/.f64 #s(literal 1 binary64) n) < 1e251Initial program 73.4%
Taylor expanded in x around 0 70.5%
*-rgt-identity70.5%
associate-/l*70.5%
exp-to-pow70.5%
Simplified70.5%
if 1e251 < (/.f64 #s(literal 1 binary64) n) Initial program 12.0%
Taylor expanded in n around inf 8.1%
log1p-define8.1%
Simplified8.1%
expm1-log1p-u8.1%
Applied egg-rr8.1%
Taylor expanded in x around -inf 82.4%
mul-1-neg82.4%
distribute-neg-frac282.4%
sub-neg82.4%
associate-*r/82.4%
sub-neg82.4%
metadata-eval82.4%
distribute-lft-in82.4%
neg-mul-182.4%
associate-*r/82.4%
metadata-eval82.4%
distribute-neg-frac82.4%
metadata-eval82.4%
metadata-eval82.4%
metadata-eval82.4%
Simplified82.4%
Final simplification87.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -1e+166)
t_0
(if (<= (/ 1.0 n) 5e-153)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 5000.0)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 1e+251)
t_0
(/
(/ (+ (/ (+ 0.5 (/ -0.3333333333333333 x)) x) -1.0) (- x))
n)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e+166) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-153) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 1e+251) {
tmp = t_0;
} else {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-1d+166)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d-153) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 1d+251) then
tmp = t_0
else
tmp = ((((0.5d0 + ((-0.3333333333333333d0) / x)) / x) + (-1.0d0)) / -x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e+166) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-153) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 5000.0) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 1e+251) {
tmp = t_0;
} else {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -1e+166: tmp = t_0 elif (1.0 / n) <= 5e-153: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 5000.0: tmp = (1.0 / x) / n elif (1.0 / n) <= 1e+251: tmp = t_0 else: tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -1e+166) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-153) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 5000.0) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 1e+251) tmp = t_0; else tmp = Float64(Float64(Float64(Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x) + -1.0) / Float64(-x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -1e+166) tmp = t_0; elseif ((1.0 / n) <= 5e-153) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 5000.0) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 1e+251) tmp = t_0; else tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+166], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-153], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+251], t$95$0, N[(N[(N[(N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+166}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+251}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.5 + \frac{-0.3333333333333333}{x}}{x} + -1}{-x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999994e165 or 5e3 < (/.f64 #s(literal 1 binary64) n) < 1e251Initial program 88.2%
Taylor expanded in x around 0 68.1%
*-rgt-identity68.1%
associate-/l*68.1%
exp-to-pow68.1%
Simplified68.1%
if -9.9999999999999994e165 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000033e-153Initial program 58.9%
Taylor expanded in n around inf 72.5%
log1p-define72.5%
Simplified72.5%
log1p-undefine72.5%
diff-log72.6%
Applied egg-rr72.6%
+-commutative72.6%
Simplified72.6%
if 5.00000000000000033e-153 < (/.f64 #s(literal 1 binary64) n) < 5e3Initial program 21.1%
Taylor expanded in n around inf 45.1%
log1p-define45.1%
Simplified45.1%
Taylor expanded in x around inf 68.7%
if 1e251 < (/.f64 #s(literal 1 binary64) n) Initial program 12.0%
Taylor expanded in n around inf 8.1%
log1p-define8.1%
Simplified8.1%
expm1-log1p-u8.1%
Applied egg-rr8.1%
Taylor expanded in x around -inf 82.4%
mul-1-neg82.4%
distribute-neg-frac282.4%
sub-neg82.4%
associate-*r/82.4%
sub-neg82.4%
metadata-eval82.4%
distribute-lft-in82.4%
neg-mul-182.4%
associate-*r/82.4%
metadata-eval82.4%
distribute-neg-frac82.4%
metadata-eval82.4%
metadata-eval82.4%
metadata-eval82.4%
Simplified82.4%
Final simplification71.3%
(FPCore (x n)
:precision binary64
(if (<= x 1.18e-79)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 3.2e-34)
(/ (log x) (- n))
(if (<= x 3.1e+97)
(/ (/ (+ (/ (+ 0.5 (/ -0.3333333333333333 x)) x) -1.0) (- x)) n)
(/ -0.25 (* n (pow x 4.0)))))))
double code(double x, double n) {
double tmp;
if (x <= 1.18e-79) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 3.2e-34) {
tmp = log(x) / -n;
} else if (x <= 3.1e+97) {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
} else {
tmp = -0.25 / (n * pow(x, 4.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.18d-79) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 3.2d-34) then
tmp = log(x) / -n
else if (x <= 3.1d+97) then
tmp = ((((0.5d0 + ((-0.3333333333333333d0) / x)) / x) + (-1.0d0)) / -x) / n
else
tmp = (-0.25d0) / (n * (x ** 4.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.18e-79) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 3.2e-34) {
tmp = Math.log(x) / -n;
} else if (x <= 3.1e+97) {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
} else {
tmp = -0.25 / (n * Math.pow(x, 4.0));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.18e-79: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 3.2e-34: tmp = math.log(x) / -n elif x <= 3.1e+97: tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n else: tmp = -0.25 / (n * math.pow(x, 4.0)) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.18e-79) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 3.2e-34) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 3.1e+97) tmp = Float64(Float64(Float64(Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x) + -1.0) / Float64(-x)) / n); else tmp = Float64(-0.25 / Float64(n * (x ^ 4.0))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.18e-79) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 3.2e-34) tmp = log(x) / -n; elseif (x <= 3.1e+97) tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n; else tmp = -0.25 / (n * (x ^ 4.0)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.18e-79], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.2e-34], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 3.1e+97], N[(N[(N[(N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision], N[(-0.25 / N[(n * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.18 \cdot 10^{-79}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-34}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+97}:\\
\;\;\;\;\frac{\frac{\frac{0.5 + \frac{-0.3333333333333333}{x}}{x} + -1}{-x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{n \cdot {x}^{4}}\\
\end{array}
\end{array}
if x < 1.18e-79Initial program 59.9%
Taylor expanded in x around 0 59.9%
*-rgt-identity59.9%
associate-/l*59.9%
exp-to-pow59.9%
Simplified59.9%
if 1.18e-79 < x < 3.20000000000000003e-34Initial program 26.7%
Taylor expanded in n around inf 62.9%
log1p-define62.9%
Simplified62.9%
Taylor expanded in x around 0 62.9%
neg-mul-162.9%
Simplified62.9%
if 3.20000000000000003e-34 < x < 3.09999999999999981e97Initial program 56.3%
Taylor expanded in n around inf 41.7%
log1p-define41.7%
Simplified41.7%
expm1-log1p-u41.7%
Applied egg-rr41.7%
Taylor expanded in x around -inf 45.9%
mul-1-neg45.9%
distribute-neg-frac245.9%
sub-neg45.9%
associate-*r/45.9%
sub-neg45.9%
metadata-eval45.9%
distribute-lft-in45.9%
neg-mul-145.9%
associate-*r/45.9%
metadata-eval45.9%
distribute-neg-frac45.9%
metadata-eval45.9%
metadata-eval45.9%
metadata-eval45.9%
Simplified45.9%
if 3.09999999999999981e97 < x Initial program 79.6%
Taylor expanded in n around inf 79.6%
log1p-define79.6%
Simplified79.6%
Taylor expanded in x around -inf 62.5%
Taylor expanded in x around 0 79.6%
Final simplification63.7%
(FPCore (x n)
:precision binary64
(if (<= x 1.6e-79)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 3.1e-34)
(/ (log x) (- n))
(/ (/ (+ (/ (+ 0.5 (/ -0.3333333333333333 x)) x) -1.0) (- x)) n))))
double code(double x, double n) {
double tmp;
if (x <= 1.6e-79) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 3.1e-34) {
tmp = log(x) / -n;
} else {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.6d-79) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 3.1d-34) then
tmp = log(x) / -n
else
tmp = ((((0.5d0 + ((-0.3333333333333333d0) / x)) / x) + (-1.0d0)) / -x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.6e-79) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 3.1e-34) {
tmp = Math.log(x) / -n;
} else {
tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.6e-79: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 3.1e-34: tmp = math.log(x) / -n else: tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.6e-79) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 3.1e-34) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(Float64(Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x) + -1.0) / Float64(-x)) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.6e-79) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 3.1e-34) tmp = log(x) / -n; else tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.6e-79], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e-34], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[(N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{-79}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-34}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.5 + \frac{-0.3333333333333333}{x}}{x} + -1}{-x}}{n}\\
\end{array}
\end{array}
if x < 1.59999999999999994e-79Initial program 59.9%
Taylor expanded in x around 0 59.9%
*-rgt-identity59.9%
associate-/l*59.9%
exp-to-pow59.9%
Simplified59.9%
if 1.59999999999999994e-79 < x < 3.0999999999999998e-34Initial program 26.7%
Taylor expanded in n around inf 62.9%
log1p-define62.9%
Simplified62.9%
Taylor expanded in x around 0 62.9%
neg-mul-162.9%
Simplified62.9%
if 3.0999999999999998e-34 < x Initial program 71.2%
Taylor expanded in n around inf 65.9%
log1p-define65.9%
Simplified65.9%
expm1-log1p-u65.9%
Applied egg-rr65.9%
Taylor expanded in x around -inf 56.5%
mul-1-neg56.5%
distribute-neg-frac256.5%
sub-neg56.5%
associate-*r/56.5%
sub-neg56.5%
metadata-eval56.5%
distribute-lft-in56.5%
neg-mul-156.5%
associate-*r/56.5%
metadata-eval56.5%
distribute-neg-frac56.5%
metadata-eval56.5%
metadata-eval56.5%
metadata-eval56.5%
Simplified56.5%
Final simplification58.6%
(FPCore (x n)
:precision binary64
(if (<= n 1.1e+164)
(/
(+
(/ 1.0 n)
(/ (+ (* 0.3333333333333333 (/ 1.0 (* n x))) (* 0.5 (/ -1.0 n))) x))
x)
(/ (log x) (- n))))
double code(double x, double n) {
double tmp;
if (n <= 1.1e+164) {
tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x;
} else {
tmp = log(x) / -n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 1.1d+164) then
tmp = ((1.0d0 / n) + (((0.3333333333333333d0 * (1.0d0 / (n * x))) + (0.5d0 * ((-1.0d0) / n))) / x)) / x
else
tmp = log(x) / -n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= 1.1e+164) {
tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x;
} else {
tmp = Math.log(x) / -n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= 1.1e+164: tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x else: tmp = math.log(x) / -n return tmp
function code(x, n) tmp = 0.0 if (n <= 1.1e+164) tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 * Float64(1.0 / Float64(n * x))) + Float64(0.5 * Float64(-1.0 / n))) / x)) / x); else tmp = Float64(log(x) / Float64(-n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= 1.1e+164) tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x; else tmp = log(x) / -n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, 1.1e+164], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.1 \cdot 10^{+164}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} + 0.5 \cdot \frac{-1}{n}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log x}{-n}\\
\end{array}
\end{array}
if n < 1.10000000000000003e164Initial program 65.3%
Taylor expanded in n around inf 46.3%
log1p-define46.3%
Simplified46.3%
Taylor expanded in x around -inf 49.6%
if 1.10000000000000003e164 < n Initial program 39.6%
Taylor expanded in n around inf 96.4%
log1p-define96.4%
Simplified96.4%
Taylor expanded in x around 0 60.7%
neg-mul-160.7%
Simplified60.7%
Final simplification51.0%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ (* 0.3333333333333333 (/ 1.0 (* n x))) (* 0.5 (/ -1.0 n))) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((0.3333333333333333d0 * (1.0d0 / (n * x))) + (0.5d0 * ((-1.0d0) / n))) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 * Float64(1.0 / Float64(n * x))) + Float64(0.5 * Float64(-1.0 / n))) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 * (1.0 / (n * x))) + (0.5 * (-1.0 / n))) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} + 0.5 \cdot \frac{-1}{n}}{x}}{x}
\end{array}
Initial program 62.2%
Taylor expanded in n around inf 52.4%
log1p-define52.4%
Simplified52.4%
Taylor expanded in x around -inf 48.8%
Final simplification48.8%
(FPCore (x n) :precision binary64 (/ (/ (+ (/ (+ 0.5 (/ -0.3333333333333333 x)) x) -1.0) (- x)) n))
double code(double x, double n) {
return ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
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)) / -x) / n
end function
public static double code(double x, double n) {
return ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n;
}
def code(x, n): return ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n
function code(x, n) return Float64(Float64(Float64(Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x) + -1.0) / Float64(-x)) / n) end
function tmp = code(x, n) tmp = ((((0.5 + (-0.3333333333333333 / x)) / x) + -1.0) / -x) / n; end
code[x_, n_] := N[(N[(N[(N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision] / (-x)), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{0.5 + \frac{-0.3333333333333333}{x}}{x} + -1}{-x}}{n}
\end{array}
Initial program 62.2%
Taylor expanded in n around inf 52.4%
log1p-define52.4%
Simplified52.4%
expm1-log1p-u52.1%
Applied egg-rr52.1%
Taylor expanded in x around -inf 48.8%
mul-1-neg48.8%
distribute-neg-frac248.8%
sub-neg48.8%
associate-*r/48.8%
sub-neg48.8%
metadata-eval48.8%
distribute-lft-in48.8%
neg-mul-148.8%
associate-*r/48.8%
metadata-eval48.8%
distribute-neg-frac48.8%
metadata-eval48.8%
metadata-eval48.8%
metadata-eval48.8%
Simplified48.8%
Final simplification48.8%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(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 62.2%
Taylor expanded in n around inf 52.4%
log1p-define52.4%
Simplified52.4%
Taylor expanded in x around inf 39.7%
associate-/r*40.2%
Simplified40.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(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 62.2%
Taylor expanded in n around inf 52.4%
log1p-define52.4%
Simplified52.4%
Taylor expanded in x around inf 39.7%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 62.2%
Taylor expanded in x around 0 38.4%
Taylor expanded in x around inf 4.5%
herbie shell --seed 2024118
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))