
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-72)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-18)
(/
(+
(log1p x)
(- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
n)
(if (<= (/ 1.0 n) 1000000.0)
(/ (fma t_0 (/ (fma 0.5 (pow n -2.0) (/ -0.5 n)) x) (/ t_0 n)) x)
(- (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) <= -4e-72) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-18) {
tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
} else if ((1.0 / n) <= 1000000.0) {
tmp = fma(t_0, (fma(0.5, pow(n, -2.0), (-0.5 / n)) / x), (t_0 / n)) / x;
} else {
tmp = exp((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) <= -4e-72) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-18) 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) <= 1000000.0) tmp = Float64(fma(t_0, Float64(fma(0.5, (n ^ -2.0), Float64(-0.5 / n)) / x), Float64(t_0 / n)) / x); 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], -4e-72], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], 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], 1000000.0], N[(N[(t$95$0 * N[(N[(0.5 * N[Power[n, -2.0], $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $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 -4 \cdot 10^{-72}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\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 1000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, \frac{\mathsf{fma}\left(0.5, {n}^{-2}, \frac{-0.5}{n}\right)}{x}, \frac{t\_0}{n}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.9999999999999999e-72Initial program 83.8%
Taylor expanded in x around inf 93.2%
log-rec93.2%
mul-1-neg93.2%
neg-mul-193.2%
mul-1-neg93.2%
distribute-frac-neg93.2%
remove-double-neg93.2%
*-rgt-identity93.2%
associate-/l*93.2%
exp-to-pow93.2%
*-commutative93.2%
Simplified93.2%
if -3.9999999999999999e-72 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 31.5%
Taylor expanded in n around inf 83.0%
associate--l+83.0%
log1p-define83.0%
+-commutative83.0%
associate--r+83.0%
distribute-lft-out--83.0%
div-sub83.0%
log1p-define83.0%
Simplified83.0%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 1e6Initial program 2.1%
Taylor expanded in x around inf 100.0%
Simplified100.0%
if 1e6 < (/.f64 #s(literal 1 binary64) n) Initial program 63.2%
Taylor expanded in n around 0 63.2%
log1p-define100.0%
*-rgt-identity100.0%
associate-*l/100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification89.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-72)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-18)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1000000.0)
(/ (fma t_0 (/ (fma 0.5 (pow n -2.0) (/ -0.5 n)) x) (/ t_0 n)) x)
(- (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) <= -4e-72) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-18) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1000000.0) {
tmp = fma(t_0, (fma(0.5, pow(n, -2.0), (-0.5 / n)) / x), (t_0 / n)) / x;
} else {
tmp = exp((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) <= -4e-72) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1000000.0) tmp = Float64(fma(t_0, Float64(fma(0.5, (n ^ -2.0), Float64(-0.5 / n)) / x), Float64(t_0 / n)) / x); 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], -4e-72], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000000.0], N[(N[(t$95$0 * N[(N[(0.5 * N[Power[n, -2.0], $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $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 -4 \cdot 10^{-72}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, \frac{\mathsf{fma}\left(0.5, {n}^{-2}, \frac{-0.5}{n}\right)}{x}, \frac{t\_0}{n}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.9999999999999999e-72Initial program 83.8%
Taylor expanded in x around inf 93.2%
log-rec93.2%
mul-1-neg93.2%
neg-mul-193.2%
mul-1-neg93.2%
distribute-frac-neg93.2%
remove-double-neg93.2%
*-rgt-identity93.2%
associate-/l*93.2%
exp-to-pow93.2%
*-commutative93.2%
Simplified93.2%
if -3.9999999999999999e-72 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 31.5%
Taylor expanded in n around inf 83.0%
log1p-define83.0%
Simplified83.0%
if 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 1e6Initial program 2.1%
Taylor expanded in x around inf 100.0%
Simplified100.0%
if 1e6 < (/.f64 #s(literal 1 binary64) n) Initial program 63.2%
Taylor expanded in n around 0 63.2%
log1p-define100.0%
*-rgt-identity100.0%
associate-*l/100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification89.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -4e-72)
t_1
(if (<= (/ 1.0 n) 2e-18)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1000000.0) t_1 (- (exp (/ (log1p x) 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) <= -4e-72) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-18) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1000000.0) {
tmp = t_1;
} 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 t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -4e-72) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-18) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 1000000.0) {
tmp = t_1;
} else {
tmp = Math.exp((Math.log1p(x) / 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) <= -4e-72: tmp = t_1 elif (1.0 / n) <= 2e-18: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 1000000.0: tmp = t_1 else: tmp = math.exp((math.log1p(x) / 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) <= -4e-72) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1000000.0) tmp = t_1; 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]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-72], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000000.0], t$95$1, 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)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-72}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.9999999999999999e-72 or 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 1e6Initial program 78.7%
Taylor expanded in x around inf 93.6%
log-rec93.6%
mul-1-neg93.6%
neg-mul-193.6%
mul-1-neg93.6%
distribute-frac-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
*-commutative93.6%
Simplified93.6%
if -3.9999999999999999e-72 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 31.5%
Taylor expanded in n around inf 83.0%
log1p-define83.0%
Simplified83.0%
if 1e6 < (/.f64 #s(literal 1 binary64) n) Initial program 63.2%
Taylor expanded in n around 0 63.2%
log1p-define100.0%
*-rgt-identity100.0%
associate-*l/100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification89.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -4e-72)
t_1
(if (<= (/ 1.0 n) 2e-18)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 1000000.0)
t_1
(-
(+ 1.0 (* x (+ (/ 1.0 n) (* x (/ (+ -0.5 (/ 0.5 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) <= -4e-72) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-18) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 1000000.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((-0.5 + (0.5 / n)) / n))))) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -4e-72) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-18) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 1000000.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((-0.5 + (0.5 / 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) <= -4e-72: tmp = t_1 elif (1.0 / n) <= 2e-18: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 1000000.0: tmp = t_1 else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((-0.5 + (0.5 / 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) <= -4e-72) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-18) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 1000000.0) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(-0.5 + Float64(0.5 / n)) / n))))) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-72], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1000000.0], t$95$1, N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $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 -4 \cdot 10^{-72}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 1000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \frac{-0.5 + \frac{0.5}{n}}{n}\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.9999999999999999e-72 or 2.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 1e6Initial program 78.7%
Taylor expanded in x around inf 93.6%
log-rec93.6%
mul-1-neg93.6%
neg-mul-193.6%
mul-1-neg93.6%
distribute-frac-neg93.6%
remove-double-neg93.6%
*-rgt-identity93.6%
associate-/l*93.6%
exp-to-pow93.6%
*-commutative93.6%
Simplified93.6%
if -3.9999999999999999e-72 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-18Initial program 31.5%
Taylor expanded in n around inf 83.0%
log1p-define83.0%
Simplified83.0%
if 1e6 < (/.f64 #s(literal 1 binary64) n) Initial program 63.2%
Taylor expanded in x around 0 81.6%
Taylor expanded in n around inf 81.6%
sub-neg81.6%
associate-*r/81.6%
metadata-eval81.6%
metadata-eval81.6%
Simplified81.6%
Final simplification86.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 5.4e-170)
(- (+ 1.0 (* x (/ (+ 1.0 (+ (* x -0.5) (* 0.5 (/ x n)))) n))) t_0)
(if (<= x 3.1e-5)
(/ (+ (* x (+ 1.0 (* x -0.5))) (log (/ 1.0 x))) n)
(/ t_0 (* n x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 5.4e-170) {
tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0;
} else if (x <= 3.1e-5) {
tmp = ((x * (1.0 + (x * -0.5))) + log((1.0 / x))) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 5.4d-170) then
tmp = (1.0d0 + (x * ((1.0d0 + ((x * (-0.5d0)) + (0.5d0 * (x / n)))) / n))) - t_0
else if (x <= 3.1d-5) then
tmp = ((x * (1.0d0 + (x * (-0.5d0)))) + log((1.0d0 / x))) / n
else
tmp = t_0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 5.4e-170) {
tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0;
} else if (x <= 3.1e-5) {
tmp = ((x * (1.0 + (x * -0.5))) + Math.log((1.0 / x))) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 5.4e-170: tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0 elif x <= 3.1e-5: tmp = ((x * (1.0 + (x * -0.5))) + math.log((1.0 / x))) / n else: tmp = t_0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 5.4e-170) tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 + Float64(Float64(x * -0.5) + Float64(0.5 * Float64(x / n)))) / n))) - t_0); elseif (x <= 3.1e-5) tmp = Float64(Float64(Float64(x * Float64(1.0 + Float64(x * -0.5))) + log(Float64(1.0 / x))) / n); else tmp = Float64(t_0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 5.4e-170) tmp = (1.0 + (x * ((1.0 + ((x * -0.5) + (0.5 * (x / n)))) / n))) - t_0; elseif (x <= 3.1e-5) tmp = ((x * (1.0 + (x * -0.5))) + log((1.0 / x))) / n; else tmp = t_0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 5.4e-170], N[(N[(1.0 + N[(x * N[(N[(1.0 + N[(N[(x * -0.5), $MachinePrecision] + N[(0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 3.1e-5], N[(N[(N[(x * N[(1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 5.4 \cdot 10^{-170}:\\
\;\;\;\;\left(1 + x \cdot \frac{1 + \left(x \cdot -0.5 + 0.5 \cdot \frac{x}{n}\right)}{n}\right) - t\_0\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-5}:\\
\;\;\;\;\frac{x \cdot \left(1 + x \cdot -0.5\right) + \log \left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\end{array}
\end{array}
if x < 5.3999999999999997e-170Initial program 53.7%
Taylor expanded in x around 0 42.2%
Taylor expanded in n around inf 54.3%
if 5.3999999999999997e-170 < x < 3.10000000000000014e-5Initial program 37.2%
Taylor expanded in x around 0 33.6%
Taylor expanded in n around inf 53.7%
Taylor expanded in x around inf 53.8%
if 3.10000000000000014e-5 < x Initial program 65.8%
Taylor expanded in x around inf 96.1%
log-rec96.1%
mul-1-neg96.1%
neg-mul-196.1%
mul-1-neg96.1%
distribute-frac-neg96.1%
remove-double-neg96.1%
*-rgt-identity96.1%
associate-/l*96.1%
exp-to-pow96.1%
*-commutative96.1%
Simplified96.1%
Final simplification73.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 4.2e-169)
(- (/ (+ n x) n) t_0)
(if (<= x 4.3e-6)
(/ (+ (* x (+ 1.0 (* x -0.5))) (log (/ 1.0 x))) n)
(/ t_0 (* n x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 4.2e-169) {
tmp = ((n + x) / n) - t_0;
} else if (x <= 4.3e-6) {
tmp = ((x * (1.0 + (x * -0.5))) + log((1.0 / x))) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 4.2d-169) then
tmp = ((n + x) / n) - t_0
else if (x <= 4.3d-6) then
tmp = ((x * (1.0d0 + (x * (-0.5d0)))) + log((1.0d0 / x))) / n
else
tmp = t_0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 4.2e-169) {
tmp = ((n + x) / n) - t_0;
} else if (x <= 4.3e-6) {
tmp = ((x * (1.0 + (x * -0.5))) + Math.log((1.0 / x))) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 4.2e-169: tmp = ((n + x) / n) - t_0 elif x <= 4.3e-6: tmp = ((x * (1.0 + (x * -0.5))) + math.log((1.0 / x))) / n else: tmp = t_0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 4.2e-169) tmp = Float64(Float64(Float64(n + x) / n) - t_0); elseif (x <= 4.3e-6) tmp = Float64(Float64(Float64(x * Float64(1.0 + Float64(x * -0.5))) + log(Float64(1.0 / x))) / n); else tmp = Float64(t_0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 4.2e-169) tmp = ((n + x) / n) - t_0; elseif (x <= 4.3e-6) tmp = ((x * (1.0 + (x * -0.5))) + log((1.0 / x))) / n; else tmp = t_0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 4.2e-169], N[(N[(N[(n + x), $MachinePrecision] / n), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 4.3e-6], N[(N[(N[(x * N[(1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 4.2 \cdot 10^{-169}:\\
\;\;\;\;\frac{n + x}{n} - t\_0\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{-6}:\\
\;\;\;\;\frac{x \cdot \left(1 + x \cdot -0.5\right) + \log \left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\end{array}
\end{array}
if x < 4.2000000000000001e-169Initial program 53.7%
Taylor expanded in x around 0 54.3%
Taylor expanded in n around 0 54.3%
+-commutative54.3%
Simplified54.3%
if 4.2000000000000001e-169 < x < 4.30000000000000033e-6Initial program 37.2%
Taylor expanded in x around 0 33.6%
Taylor expanded in n around inf 53.7%
Taylor expanded in x around inf 53.8%
if 4.30000000000000033e-6 < x Initial program 65.8%
Taylor expanded in x around inf 96.1%
log-rec96.1%
mul-1-neg96.1%
neg-mul-196.1%
mul-1-neg96.1%
distribute-frac-neg96.1%
remove-double-neg96.1%
*-rgt-identity96.1%
associate-/l*96.1%
exp-to-pow96.1%
*-commutative96.1%
Simplified96.1%
Final simplification73.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 6.5e-170)
(- (/ (+ n x) n) t_0)
(if (<= x 1.45e-5) (/ (- x (log x)) n) (/ t_0 (* n x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 6.5e-170) {
tmp = ((n + x) / n) - t_0;
} else if (x <= 1.45e-5) {
tmp = (x - log(x)) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 6.5d-170) then
tmp = ((n + x) / n) - t_0
else if (x <= 1.45d-5) then
tmp = (x - log(x)) / n
else
tmp = t_0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 6.5e-170) {
tmp = ((n + x) / n) - t_0;
} else if (x <= 1.45e-5) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 6.5e-170: tmp = ((n + x) / n) - t_0 elif x <= 1.45e-5: tmp = (x - math.log(x)) / n else: tmp = t_0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 6.5e-170) tmp = Float64(Float64(Float64(n + x) / n) - t_0); elseif (x <= 1.45e-5) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(t_0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 6.5e-170) tmp = ((n + x) / n) - t_0; elseif (x <= 1.45e-5) tmp = (x - log(x)) / n; else tmp = t_0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 6.5e-170], N[(N[(N[(n + x), $MachinePrecision] / n), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 6.5 \cdot 10^{-170}:\\
\;\;\;\;\frac{n + x}{n} - t\_0\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\end{array}
\end{array}
if x < 6.50000000000000035e-170Initial program 53.7%
Taylor expanded in x around 0 54.3%
Taylor expanded in n around 0 54.3%
+-commutative54.3%
Simplified54.3%
if 6.50000000000000035e-170 < x < 1.45e-5Initial program 37.2%
Taylor expanded in x around 0 36.7%
Taylor expanded in n around inf 53.7%
if 1.45e-5 < x Initial program 65.8%
Taylor expanded in x around inf 96.1%
log-rec96.1%
mul-1-neg96.1%
neg-mul-196.1%
mul-1-neg96.1%
distribute-frac-neg96.1%
remove-double-neg96.1%
*-rgt-identity96.1%
associate-/l*96.1%
exp-to-pow96.1%
*-commutative96.1%
Simplified96.1%
Final simplification73.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 6.4e-170)
(- (+ 1.0 (/ x n)) t_0)
(if (<= x 4.8e-6) (/ (- x (log x)) n) (/ t_0 (* n x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 6.4e-170) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 4.8e-6) {
tmp = (x - log(x)) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 6.4d-170) then
tmp = (1.0d0 + (x / n)) - t_0
else if (x <= 4.8d-6) then
tmp = (x - log(x)) / n
else
tmp = t_0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 6.4e-170) {
tmp = (1.0 + (x / n)) - t_0;
} else if (x <= 4.8e-6) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 6.4e-170: tmp = (1.0 + (x / n)) - t_0 elif x <= 4.8e-6: tmp = (x - math.log(x)) / n else: tmp = t_0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 6.4e-170) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif (x <= 4.8e-6) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(t_0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 6.4e-170) tmp = (1.0 + (x / n)) - t_0; elseif (x <= 4.8e-6) tmp = (x - log(x)) / n; else tmp = t_0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 6.4e-170], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 4.8e-6], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 6.4 \cdot 10^{-170}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\end{array}
\end{array}
if x < 6.3999999999999999e-170Initial program 53.7%
Taylor expanded in x around 0 54.3%
if 6.3999999999999999e-170 < x < 4.7999999999999998e-6Initial program 37.2%
Taylor expanded in x around 0 36.7%
Taylor expanded in n around inf 53.7%
if 4.7999999999999998e-6 < x Initial program 65.8%
Taylor expanded in x around inf 96.1%
log-rec96.1%
mul-1-neg96.1%
neg-mul-196.1%
mul-1-neg96.1%
distribute-frac-neg96.1%
remove-double-neg96.1%
*-rgt-identity96.1%
associate-/l*96.1%
exp-to-pow96.1%
*-commutative96.1%
Simplified96.1%
Final simplification73.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 1.1e-169)
(- 1.0 t_0)
(if (<= x 2.15e-5) (/ (- x (log x)) n) (/ t_0 (* n x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 1.1e-169) {
tmp = 1.0 - t_0;
} else if (x <= 2.15e-5) {
tmp = (x - log(x)) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 1.1d-169) then
tmp = 1.0d0 - t_0
else if (x <= 2.15d-5) then
tmp = (x - log(x)) / n
else
tmp = t_0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.1e-169) {
tmp = 1.0 - t_0;
} else if (x <= 2.15e-5) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = t_0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.1e-169: tmp = 1.0 - t_0 elif x <= 2.15e-5: tmp = (x - math.log(x)) / n else: tmp = t_0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1.1e-169) tmp = Float64(1.0 - t_0); elseif (x <= 2.15e-5) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(t_0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 1.1e-169) tmp = 1.0 - t_0; elseif (x <= 2.15e-5) tmp = (x - log(x)) / n; else tmp = t_0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.1e-169], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 2.15e-5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.1 \cdot 10^{-169}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;x \leq 2.15 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\end{array}
\end{array}
if x < 1.10000000000000004e-169Initial program 53.7%
Taylor expanded in x around 0 53.7%
*-rgt-identity53.7%
associate-*l/53.7%
associate-/l*53.7%
exp-to-pow53.7%
Simplified53.7%
if 1.10000000000000004e-169 < x < 2.1500000000000001e-5Initial program 37.2%
Taylor expanded in x around 0 36.7%
Taylor expanded in n around inf 53.7%
if 2.1500000000000001e-5 < x Initial program 65.8%
Taylor expanded in x around inf 96.1%
log-rec96.1%
mul-1-neg96.1%
neg-mul-196.1%
mul-1-neg96.1%
distribute-frac-neg96.1%
remove-double-neg96.1%
*-rgt-identity96.1%
associate-/l*96.1%
exp-to-pow96.1%
*-commutative96.1%
Simplified96.1%
Final simplification72.9%
(FPCore (x n)
:precision binary64
(if (<= x 5.8e-170)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 7.2e-7)
(/ (log x) (- n))
(if (<= x 1.4e+24) (/ (/ 1.0 x) n) 0.0))))
double code(double x, double n) {
double tmp;
if (x <= 5.8e-170) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 7.2e-7) {
tmp = log(x) / -n;
} else if (x <= 1.4e+24) {
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 <= 5.8d-170) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 7.2d-7) then
tmp = log(x) / -n
else if (x <= 1.4d+24) 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 <= 5.8e-170) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 7.2e-7) {
tmp = Math.log(x) / -n;
} else if (x <= 1.4e+24) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5.8e-170: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 7.2e-7: tmp = math.log(x) / -n elif x <= 1.4e+24: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 5.8e-170) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 7.2e-7) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.4e+24) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5.8e-170) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 7.2e-7) tmp = log(x) / -n; elseif (x <= 1.4e+24) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5.8e-170], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.2e-7], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.4e+24], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{-170}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+24}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 5.8000000000000001e-170Initial program 53.7%
Taylor expanded in x around 0 53.7%
*-rgt-identity53.7%
associate-*l/53.7%
associate-/l*53.7%
exp-to-pow53.7%
Simplified53.7%
if 5.8000000000000001e-170 < x < 7.19999999999999989e-7Initial program 36.4%
Taylor expanded in x around 0 36.4%
*-rgt-identity36.4%
associate-*l/36.4%
associate-/l*36.4%
exp-to-pow36.4%
Simplified36.4%
Taylor expanded in n around inf 54.2%
associate-*r/54.2%
neg-mul-154.2%
Simplified54.2%
if 7.19999999999999989e-7 < x < 1.4000000000000001e24Initial program 31.5%
Taylor expanded in n around inf 57.3%
associate--l+57.3%
log1p-define57.3%
+-commutative57.3%
associate--r+57.3%
distribute-lft-out--57.3%
div-sub57.3%
log1p-define57.3%
Simplified57.3%
Taylor expanded in x around inf 61.0%
+-commutative61.0%
mul-1-neg61.0%
log-rec61.0%
neg-mul-161.0%
associate-*r/61.0%
mul-1-neg61.0%
remove-double-neg61.0%
Simplified61.0%
Taylor expanded in n around inf 52.9%
if 1.4000000000000001e24 < x Initial program 69.7%
Taylor expanded in x around 0 33.9%
*-rgt-identity33.9%
associate-*l/33.9%
associate-/l*33.9%
exp-to-pow33.9%
Simplified33.9%
add-log-exp33.9%
Applied egg-rr33.9%
Taylor expanded in n around inf 69.8%
Final simplification60.5%
(FPCore (x n) :precision binary64 (if (<= x 7.2e-7) (/ (log x) (- n)) (if (<= x 2.2e+24) (/ (/ 1.0 x) n) 0.0)))
double code(double x, double n) {
double tmp;
if (x <= 7.2e-7) {
tmp = log(x) / -n;
} else if (x <= 2.2e+24) {
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 <= 7.2d-7) then
tmp = log(x) / -n
else if (x <= 2.2d+24) 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 <= 7.2e-7) {
tmp = Math.log(x) / -n;
} else if (x <= 2.2e+24) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 7.2e-7: tmp = math.log(x) / -n elif x <= 2.2e+24: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 7.2e-7) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 2.2e+24) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 7.2e-7) tmp = log(x) / -n; elseif (x <= 2.2e+24) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 7.2e-7], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.2e+24], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+24}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 7.19999999999999989e-7Initial program 44.5%
Taylor expanded in x around 0 44.5%
*-rgt-identity44.5%
associate-*l/44.5%
associate-/l*44.5%
exp-to-pow44.5%
Simplified44.5%
Taylor expanded in n around inf 50.8%
associate-*r/50.8%
neg-mul-150.8%
Simplified50.8%
if 7.19999999999999989e-7 < x < 2.20000000000000002e24Initial program 31.5%
Taylor expanded in n around inf 57.3%
associate--l+57.3%
log1p-define57.3%
+-commutative57.3%
associate--r+57.3%
distribute-lft-out--57.3%
div-sub57.3%
log1p-define57.3%
Simplified57.3%
Taylor expanded in x around inf 61.0%
+-commutative61.0%
mul-1-neg61.0%
log-rec61.0%
neg-mul-161.0%
associate-*r/61.0%
mul-1-neg61.0%
remove-double-neg61.0%
Simplified61.0%
Taylor expanded in n around inf 52.9%
if 2.20000000000000002e24 < x Initial program 69.7%
Taylor expanded in x around 0 33.9%
*-rgt-identity33.9%
associate-*l/33.9%
associate-/l*33.9%
exp-to-pow33.9%
Simplified33.9%
add-log-exp33.9%
Applied egg-rr33.9%
Taylor expanded in n around inf 69.8%
Final simplification58.8%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -5e+39) 0.0 (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e+39) {
tmp = 0.0;
} else {
tmp = (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 ((1.0d0 / n) <= (-5d+39)) then
tmp = 0.0d0
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5e+39) {
tmp = 0.0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5e+39: tmp = 0.0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5e+39) tmp = 0.0; else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -5e+39) tmp = 0.0; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+39], 0.0, N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+39}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000015e39Initial program 100.0%
Taylor expanded in x around 0 45.2%
*-rgt-identity45.2%
associate-*l/45.2%
associate-/l*45.2%
exp-to-pow45.2%
Simplified45.2%
add-log-exp45.2%
Applied egg-rr45.2%
Taylor expanded in n around inf 57.2%
if -5.00000000000000015e39 < (/.f64 #s(literal 1 binary64) n) Initial program 37.6%
Taylor expanded in n around inf 56.4%
associate--l+56.4%
log1p-define56.4%
+-commutative56.4%
associate--r+56.4%
distribute-lft-out--56.4%
div-sub56.4%
log1p-define56.4%
Simplified56.4%
Taylor expanded in x around inf 38.2%
+-commutative38.2%
mul-1-neg38.2%
log-rec38.2%
neg-mul-138.2%
associate-*r/38.2%
mul-1-neg38.2%
remove-double-neg38.2%
Simplified38.2%
Taylor expanded in n around inf 44.2%
Final simplification47.7%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 54.4%
Taylor expanded in n around inf 64.8%
associate--l+49.9%
log1p-define49.9%
+-commutative49.9%
associate--r+64.8%
distribute-lft-out--64.8%
div-sub64.8%
log1p-define64.8%
Simplified64.8%
Taylor expanded in x around inf 38.5%
+-commutative38.5%
mul-1-neg38.5%
log-rec38.5%
neg-mul-138.5%
associate-*r/38.5%
mul-1-neg38.5%
remove-double-neg38.5%
Simplified38.5%
Taylor expanded in n around inf 40.1%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 54.4%
Taylor expanded in n around inf 64.8%
associate--l+49.9%
log1p-define49.9%
+-commutative49.9%
associate--r+64.8%
distribute-lft-out--64.8%
div-sub64.8%
log1p-define64.8%
Simplified64.8%
Taylor expanded in x around inf 38.5%
+-commutative38.5%
mul-1-neg38.5%
log-rec38.5%
neg-mul-138.5%
associate-*r/38.5%
mul-1-neg38.5%
remove-double-neg38.5%
Simplified38.5%
Taylor expanded in n around inf 39.6%
*-commutative39.6%
Simplified39.6%
Final simplification39.6%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 54.4%
Taylor expanded in x around 0 32.0%
Taylor expanded in x around inf 4.9%
herbie shell --seed 2024160
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))