
(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) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2000000.0)
(/
(+
(log1p x)
(- (/ (* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0))) n) (log x)))
n)
(pow (cbrt (- (exp (/ (log1p x) n)) t_0)) 3.0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = (log1p(x) + (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) / n) - log(x))) / n;
} else {
tmp = pow(cbrt((exp((log1p(x) / n)) - t_0)), 3.0);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
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 {
tmp = Math.pow(Math.cbrt((Math.exp((Math.log1p(x) / n)) - t_0)), 3.0);
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2000000.0) tmp = Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) / n) - log(x))) / n); else tmp = cbrt(Float64(exp(Float64(log1p(x) / n)) - t_0)) ^ 3.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], -5e-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000000.0], 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), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000000:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) + \left(\frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right)}{n} - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0}\right)}^{3}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
distribute-frac-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 2e6Initial program 28.4%
Taylor expanded in n around inf 80.6%
Simplified80.6%
if 2e6 < (/.f64 #s(literal 1 binary64) n) Initial program 59.8%
add-cube-cbrt59.8%
pow359.8%
pow-to-exp59.8%
un-div-inv59.8%
+-commutative59.8%
log1p-define99.8%
Applied egg-rr99.8%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2000000.0)
(/ (log (/ (+ x 1.0) x)) n)
(pow (cbrt (- (exp (/ (log1p x) n)) t_0)) 3.0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = pow(cbrt((exp((log1p(x) / n)) - t_0)), 3.0);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.pow(Math.cbrt((Math.exp((Math.log1p(x) / n)) - t_0)), 3.0);
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2000000.0) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = cbrt(Float64(exp(Float64(log1p(x) / n)) - t_0)) ^ 3.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], -5e-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000000.0], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000000:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0}\right)}^{3}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
distribute-frac-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 2e6Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-define80.0%
Simplified80.0%
log1p-undefine80.0%
diff-log80.2%
Applied egg-rr80.2%
if 2e6 < (/.f64 #s(literal 1 binary64) n) Initial program 59.8%
add-cube-cbrt59.8%
pow359.8%
pow-to-exp59.8%
un-div-inv59.8%
+-commutative59.8%
log1p-define99.8%
Applied egg-rr99.8%
Final simplification87.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2000000.0)
(/ (log (/ (+ x 1.0) x)) n)
(- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 2000000.0: tmp = math.log(((x + 1.0) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2000000.0) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000000.0], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000000:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
distribute-frac-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 2e6Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-define80.0%
Simplified80.0%
log1p-undefine80.0%
diff-log80.2%
Applied egg-rr80.2%
if 2e6 < (/.f64 #s(literal 1 binary64) n) Initial program 59.8%
Taylor expanded in n around 0 59.8%
log1p-define99.8%
*-rgt-identity99.8%
associate-/l*99.8%
exp-to-pow99.8%
Simplified99.8%
Final simplification87.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2000000.0)
(/ (log (/ (+ x 1.0) x)) n)
(- (+ (* x (/ (+ (/ (* x 0.5) n) 1.0) n)) 1.0) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = log(((x + 1.0) / x)) / n;
} else {
tmp = ((x * ((((x * 0.5) / n) + 1.0) / n)) + 1.0) - 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) <= (-5d-10)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2000000.0d0) then
tmp = log(((x + 1.0d0) / x)) / n
else
tmp = ((x * ((((x * 0.5d0) / n) + 1.0d0) / n)) + 1.0d0) - 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) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2000000.0) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else {
tmp = ((x * ((((x * 0.5) / n) + 1.0) / n)) + 1.0) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 2000000.0: tmp = math.log(((x + 1.0) / x)) / n else: tmp = ((x * ((((x * 0.5) / n) + 1.0) / n)) + 1.0) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2000000.0) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); else tmp = Float64(Float64(Float64(x * Float64(Float64(Float64(Float64(x * 0.5) / n) + 1.0) / n)) + 1.0) - 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) <= -5e-10) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2000000.0) tmp = log(((x + 1.0) / x)) / n; else tmp = ((x * ((((x * 0.5) / n) + 1.0) / n)) + 1.0) - 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], -5e-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000000.0], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(x * N[(N[(N[(N[(x * 0.5), $MachinePrecision] / n), $MachinePrecision] + 1.0), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + 1.0), $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 -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000000:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \frac{\frac{x \cdot 0.5}{n} + 1}{n} + 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
distribute-frac-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 2e6Initial program 28.4%
Taylor expanded in n around inf 80.0%
log1p-define80.0%
Simplified80.0%
log1p-undefine80.0%
diff-log80.2%
Applied egg-rr80.2%
if 2e6 < (/.f64 #s(literal 1 binary64) n) Initial program 59.8%
Taylor expanded in x around 0 71.4%
Taylor expanded in n around inf 79.4%
Taylor expanded in n around 0 79.4%
associate-*r/79.4%
*-commutative79.4%
Simplified79.4%
Final simplification84.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e+17)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 5e+195)
(+ (/ x n) (- 1.0 t_0))
(/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+195) {
tmp = (x / n) + (1.0 - t_0);
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-10)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d+17) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 5d+195) then
tmp = (x / n) + (1.0d0 - t_0)
else
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 5e+195) {
tmp = (x / n) + (1.0 - t_0);
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e+17: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 5e+195: tmp = (x / n) + (1.0 - t_0) else: tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e+17) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 5e+195) tmp = Float64(Float64(x / n) + Float64(1.0 - t_0)); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-10) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e+17) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 5e+195) tmp = (x / n) + (1.0 - t_0); else tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; 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], -5e-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+17], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], N[(N[(x / n), $MachinePrecision] + N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;\frac{x}{n} + \left(1 - t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
distribute-frac-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 5e17Initial program 28.9%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
log1p-undefine79.5%
diff-log79.7%
Applied egg-rr79.7%
if 5e17 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999998e195Initial program 78.9%
Taylor expanded in x around 0 80.9%
sub-neg80.9%
+-commutative80.9%
associate-+l+80.9%
sub-neg80.9%
*-rgt-identity80.9%
associate-/l*80.9%
exp-to-pow80.9%
Simplified80.9%
if 4.9999999999999998e195 < (/.f64 #s(literal 1 binary64) n) Initial program 33.4%
Taylor expanded in n around inf 6.8%
log1p-define6.8%
Simplified6.8%
Taylor expanded in x around -inf 0.2%
Taylor expanded in x around -inf 70.0%
mul-1-neg70.0%
distribute-neg-frac270.0%
sub-neg70.0%
associate-*r/70.0%
sub-neg70.0%
metadata-eval70.0%
distribute-lft-in70.0%
neg-mul-170.0%
associate-*r/70.0%
metadata-eval70.0%
distribute-neg-frac70.0%
metadata-eval70.0%
metadata-eval70.0%
metadata-eval70.0%
Simplified70.0%
Final simplification83.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-10)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e+17)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+178)
(- 1.0 t_0)
(/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-10)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d+17) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+178) then
tmp = 1.0d0 - t_0
else
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-10) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e+17) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = 1.0 - t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-10: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e+17: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+178: tmp = 1.0 - t_0 else: tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-10) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e+17) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+178) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-10) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e+17) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+178) tmp = 1.0 - t_0; else tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; 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], -5e-10], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+17], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+178], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10Initial program 94.3%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
log-rec98.3%
distribute-frac-neg98.3%
remove-double-neg98.3%
*-rgt-identity98.3%
associate-/l*98.3%
exp-to-pow98.4%
*-commutative98.4%
Simplified98.4%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 5e17Initial program 28.9%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
log1p-undefine79.5%
diff-log79.7%
Applied egg-rr79.7%
if 5e17 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e178Initial program 81.9%
Taylor expanded in x around 0 81.9%
*-rgt-identity81.9%
associate-/l*81.9%
exp-to-pow81.9%
Simplified81.9%
if 2.0000000000000001e178 < (/.f64 #s(literal 1 binary64) n) Initial program 35.4%
Taylor expanded in n around inf 6.6%
log1p-define6.6%
Simplified6.6%
Taylor expanded in x around -inf 0.2%
Taylor expanded in x around -inf 68.0%
mul-1-neg68.0%
distribute-neg-frac268.0%
sub-neg68.0%
associate-*r/68.0%
sub-neg68.0%
metadata-eval68.0%
distribute-lft-in68.0%
neg-mul-168.0%
associate-*r/68.0%
metadata-eval68.0%
distribute-neg-frac68.0%
metadata-eval68.0%
metadata-eval68.0%
metadata-eval68.0%
Simplified68.0%
Final simplification83.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -2e+227)
t_0
(if (<= (/ 1.0 n) 5e+17)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= (/ 1.0 n) 2e+178)
t_0
(/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+227) {
tmp = t_0;
} else if ((1.0 / n) <= 5e+17) {
tmp = log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-2d+227)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d+17) then
tmp = log(((x + 1.0d0) / x)) / n
else if ((1.0d0 / n) <= 2d+178) then
tmp = t_0
else
tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+227) {
tmp = t_0;
} else if ((1.0 / n) <= 5e+17) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+178) {
tmp = t_0;
} else {
tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e+227: tmp = t_0 elif (1.0 / n) <= 5e+17: tmp = math.log(((x + 1.0) / x)) / n elif (1.0 / n) <= 2e+178: tmp = t_0 else: tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / 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) <= -2e+227) tmp = t_0; elseif (Float64(1.0 / n) <= 5e+17) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+178) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / 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) <= -2e+227) tmp = t_0; elseif ((1.0 / n) <= 5e+17) tmp = log(((x + 1.0) / x)) / n; elseif ((1.0 / n) <= 2e+178) tmp = t_0; else tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / 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], -2e+227], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+17], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+178], t$95$0, N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+227}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000002e227 or 5e17 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e178Initial program 90.4%
Taylor expanded in x around 0 76.2%
*-rgt-identity76.2%
associate-/l*76.2%
exp-to-pow76.2%
Simplified76.2%
if -2.0000000000000002e227 < (/.f64 #s(literal 1 binary64) n) < 5e17Initial program 44.1%
Taylor expanded in n around inf 74.7%
log1p-define74.7%
Simplified74.7%
log1p-undefine74.7%
diff-log74.8%
Applied egg-rr74.8%
if 2.0000000000000001e178 < (/.f64 #s(literal 1 binary64) n) Initial program 35.4%
Taylor expanded in n around inf 6.6%
log1p-define6.6%
Simplified6.6%
Taylor expanded in x around -inf 0.2%
Taylor expanded in x around -inf 68.0%
mul-1-neg68.0%
distribute-neg-frac268.0%
sub-neg68.0%
associate-*r/68.0%
sub-neg68.0%
metadata-eval68.0%
distribute-lft-in68.0%
neg-mul-168.0%
associate-*r/68.0%
metadata-eval68.0%
distribute-neg-frac68.0%
metadata-eval68.0%
metadata-eval68.0%
metadata-eval68.0%
Simplified68.0%
Final simplification74.5%
(FPCore (x n)
:precision binary64
(if (<= x 0.88)
(/ (- x (log x)) n)
(if (<= x 2.5e+132)
(*
(/ 1.0 n)
(/ (+ (/ (- (/ (+ 0.3333333333333333 (/ -0.25 x)) x) 0.5) x) 1.0) x))
(/ (/ -0.25 n) (pow x 4.0)))))
double code(double x, double n) {
double tmp;
if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else if (x <= 2.5e+132) {
tmp = (1.0 / n) * ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x);
} 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 <= 0.88d0) then
tmp = (x - log(x)) / n
else if (x <= 2.5d+132) then
tmp = (1.0d0 / n) * ((((((0.3333333333333333d0 + ((-0.25d0) / x)) / x) - 0.5d0) / x) + 1.0d0) / x)
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 <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.5e+132) {
tmp = (1.0 / n) * ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x);
} else {
tmp = (-0.25 / n) / Math.pow(x, 4.0);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.88: tmp = (x - math.log(x)) / n elif x <= 2.5e+132: tmp = (1.0 / n) * ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) else: tmp = (-0.25 / n) / math.pow(x, 4.0) return tmp
function code(x, n) tmp = 0.0 if (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.5e+132) tmp = Float64(Float64(1.0 / n) * Float64(Float64(Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x) - 0.5) / x) + 1.0) / x)); else tmp = Float64(Float64(-0.25 / n) / (x ^ 4.0)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.88) tmp = (x - log(x)) / n; elseif (x <= 2.5e+132) tmp = (1.0 / n) * ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x); else tmp = (-0.25 / n) / (x ^ 4.0); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.5e+132], N[(N[(1.0 / n), $MachinePrecision] * N[(N[(N[(N[(N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(-0.25 / n), $MachinePrecision] / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+132}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{\frac{\frac{0.3333333333333333 + \frac{-0.25}{x}}{x} - 0.5}{x} + 1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-0.25}{n}}{{x}^{4}}\\
\end{array}
\end{array}
if x < 0.880000000000000004Initial program 37.4%
Taylor expanded in x around 0 36.5%
sub-neg36.5%
+-commutative36.5%
associate-+l+37.1%
sub-neg37.1%
*-rgt-identity37.1%
associate-/l*37.0%
exp-to-pow37.1%
Simplified37.1%
Taylor expanded in n around inf 58.6%
if 0.880000000000000004 < x < 2.5000000000000001e132Initial program 44.1%
Taylor expanded in n around inf 48.6%
log1p-define48.6%
Simplified48.6%
Taylor expanded in x around -inf 63.3%
clear-num62.2%
inv-pow62.2%
Applied egg-rr62.2%
Simplified62.2%
associate-/r/63.4%
Applied egg-rr63.4%
if 2.5000000000000001e132 < x Initial program 79.8%
Taylor expanded in n around inf 79.8%
log1p-define79.8%
Simplified79.8%
Taylor expanded in x around -inf 65.0%
Taylor expanded in x around 0 79.8%
associate-/r*79.8%
Simplified79.8%
Final simplification64.9%
(FPCore (x n) :precision binary64 (if (<= x 0.9) (/ (- x (log x)) n) (/ (/ (+ (/ (- (/ (+ 0.3333333333333333 (/ -0.25 x)) x) 0.5) x) 1.0) x) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else {
tmp = ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / 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 <= 0.9d0) then
tmp = (x - log(x)) / n
else
tmp = ((((((0.3333333333333333d0 + ((-0.25d0) / x)) / x) - 0.5d0) / x) + 1.0d0) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.9: tmp = (x - math.log(x)) / n else: tmp = ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.9) tmp = (x - log(x)) / n; else tmp = ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{0.3333333333333333 + \frac{-0.25}{x}}{x} - 0.5}{x} + 1}{x}}{n}\\
\end{array}
\end{array}
if x < 0.900000000000000022Initial program 37.4%
Taylor expanded in x around 0 36.5%
sub-neg36.5%
+-commutative36.5%
associate-+l+37.1%
sub-neg37.1%
*-rgt-identity37.1%
associate-/l*37.0%
exp-to-pow37.1%
Simplified37.1%
Taylor expanded in n around inf 58.6%
if 0.900000000000000022 < x Initial program 67.0%
Taylor expanded in n around inf 68.6%
log1p-define68.6%
Simplified68.6%
Taylor expanded in x around -inf 64.4%
associate-*r/64.4%
fmm-def64.4%
fmm-def64.4%
sub-neg64.4%
un-div-inv64.4%
metadata-eval64.4%
metadata-eval64.4%
metadata-eval64.4%
Applied egg-rr64.4%
Simplified64.4%
Final simplification61.0%
(FPCore (x n) :precision binary64 (if (<= x 0.7) (/ (log x) (- n)) (/ (/ (+ (/ (- (/ (+ 0.3333333333333333 (/ -0.25 x)) x) 0.5) x) 1.0) x) n)))
double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = log(x) / -n;
} else {
tmp = ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / 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 <= 0.7d0) then
tmp = log(x) / -n
else
tmp = ((((((0.3333333333333333d0 + ((-0.25d0) / x)) / x) - 0.5d0) / x) + 1.0d0) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.7) {
tmp = Math.log(x) / -n;
} else {
tmp = ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.7: tmp = math.log(x) / -n else: tmp = ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.7) tmp = Float64(log(x) / Float64(-n)); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.3333333333333333 + Float64(-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.7) tmp = log(x) / -n; else tmp = ((((((0.3333333333333333 + (-0.25 / x)) / x) - 0.5) / x) + 1.0) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.7], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(0.3333333333333333 + N[(-0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{0.3333333333333333 + \frac{-0.25}{x}}{x} - 0.5}{x} + 1}{x}}{n}\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial program 37.4%
Taylor expanded in x around 0 36.1%
*-rgt-identity36.1%
associate-/l*36.1%
exp-to-pow36.1%
Simplified36.1%
Taylor expanded in n around inf 58.1%
associate-*r/58.1%
neg-mul-158.1%
Simplified58.1%
if 0.69999999999999996 < x Initial program 67.0%
Taylor expanded in n around inf 68.6%
log1p-define68.6%
Simplified68.6%
Taylor expanded in x around -inf 64.4%
associate-*r/64.4%
fmm-def64.4%
fmm-def64.4%
sub-neg64.4%
un-div-inv64.4%
metadata-eval64.4%
metadata-eval64.4%
metadata-eval64.4%
Applied egg-rr64.4%
Simplified64.4%
Final simplification60.7%
(FPCore (x n) :precision binary64 (/ (- (/ 1.0 n) (/ (- (/ 0.5 n) (/ 0.3333333333333333 (* n x))) x)) x))
double code(double x, double n) {
return ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (n * x))) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) - (((0.5d0 / n) - (0.3333333333333333d0 / (n * x))) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (n * x))) / x)) / x;
}
def code(x, n): return ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (n * x))) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(0.5 / n) - Float64(0.3333333333333333 / Float64(n * x))) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) - (((0.5 / n) - (0.3333333333333333 / (n * x))) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(0.5 / n), $MachinePrecision] - N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{n \cdot x}}{x}}{x}
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 62.8%
log1p-define62.8%
Simplified62.8%
Taylor expanded in x around -inf 27.2%
Taylor expanded in x around -inf 41.1%
mul-1-neg41.1%
mul-1-neg41.1%
associate-*r/41.1%
metadata-eval41.1%
*-commutative41.1%
associate-*r/41.1%
metadata-eval41.1%
Simplified41.1%
Final simplification41.1%
(FPCore (x n) :precision binary64 (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))
double code(double x, double n) {
return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
}
def code(x, n): return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 62.8%
log1p-define62.8%
Simplified62.8%
Taylor expanded in x around -inf 27.2%
Taylor expanded in x around -inf 41.1%
mul-1-neg41.1%
distribute-neg-frac241.1%
sub-neg41.1%
associate-*r/41.1%
sub-neg41.1%
metadata-eval41.1%
distribute-lft-in41.1%
neg-mul-141.1%
associate-*r/41.1%
metadata-eval41.1%
distribute-neg-frac41.1%
metadata-eval41.1%
metadata-eval41.1%
metadata-eval41.1%
Simplified41.1%
Final simplification41.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(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 49.7%
Taylor expanded in n around inf 62.8%
log1p-define62.8%
Simplified62.8%
Taylor expanded in x around -inf 27.2%
clear-num26.7%
inv-pow26.7%
Applied egg-rr26.7%
Simplified26.7%
Taylor expanded in x around inf 37.6%
associate-/r*38.0%
Simplified38.0%
(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 49.7%
Taylor expanded in n around inf 62.8%
log1p-define62.8%
Simplified62.8%
Taylor expanded in x around inf 37.6%
*-commutative37.6%
Simplified37.6%
Final simplification37.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 49.7%
Taylor expanded in x around 0 27.0%
sub-neg27.0%
+-commutative27.0%
associate-+l+23.1%
sub-neg23.1%
*-rgt-identity23.1%
associate-/l*23.0%
exp-to-pow23.0%
Simplified23.0%
Taylor expanded in x around inf 4.6%
herbie shell --seed 2024117
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))