
(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 16 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 (/ (log1p x) n)) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-65)
(/ t_1 (* n x))
(if (<= (/ 1.0 n) 5e-13)
(-
(fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) t_0)
(+ (/ (log x) n) (* 0.5 (/ (pow (log x) 2.0) (* n n)))))
(- (exp t_0) t_1)))))
double code(double x, double n) {
double t_0 = log1p(x) / n;
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-65) {
tmp = t_1 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), t_0) - ((log(x) / n) + (0.5 * (pow(log(x), 2.0) / (n * n))));
} else {
tmp = exp(t_0) - t_1;
}
return tmp;
}
function code(x, n) t_0 = Float64(log1p(x) / n) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-65) tmp = Float64(t_1 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), t_0) - Float64(Float64(log(x) / n) + Float64(0.5 * Float64((log(x) ^ 2.0) / Float64(n * n))))); else tmp = Float64(exp(t_0) - t_1); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-65], N[(t$95$1 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] - N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] + N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-65}:\\
\;\;\;\;\frac{t_1}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, t_0\right) - \left(\frac{\log x}{n} + 0.5 \cdot \frac{{\log x}^{2}}{n \cdot n}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{t_0} - t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999983e-65Initial program 86.6%
Taylor expanded in x around inf 93.9%
log-rec93.9%
mul-1-neg93.9%
mul-1-neg93.9%
distribute-frac-neg93.9%
neg-mul-193.9%
remove-double-neg93.9%
*-rgt-identity93.9%
associate-*r/93.9%
unpow-193.9%
exp-to-pow93.9%
unpow-193.9%
*-commutative93.9%
Simplified93.9%
if -4.99999999999999983e-65 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 34.6%
Taylor expanded in n around inf 85.1%
fma-def85.1%
log1p-def85.1%
unpow285.1%
log1p-def85.1%
unpow285.1%
Simplified85.1%
if 4.9999999999999999e-13 < (/.f64 1 n) Initial program 68.1%
Taylor expanded in n around 0 68.1%
log1p-def99.7%
*-rgt-identity99.7%
associate-*r/99.7%
unpow-199.7%
exp-to-pow99.7%
/-rgt-identity99.7%
metadata-eval99.7%
associate-/l*99.7%
*-commutative99.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
unpow-199.7%
Simplified99.7%
Final simplification90.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-65)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-13)
(/ (- (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-65) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
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-65) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
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-65: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-13: 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-65) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(Float64(-log(Float64(x / Float64(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-65], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $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^{-65}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\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 1 n) < -4.99999999999999983e-65Initial program 86.6%
Taylor expanded in x around inf 93.9%
log-rec93.9%
mul-1-neg93.9%
mul-1-neg93.9%
distribute-frac-neg93.9%
neg-mul-193.9%
remove-double-neg93.9%
*-rgt-identity93.9%
associate-*r/93.9%
unpow-193.9%
exp-to-pow93.9%
unpow-193.9%
*-commutative93.9%
Simplified93.9%
if -4.99999999999999983e-65 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 34.6%
Taylor expanded in n around inf 84.9%
log1p-def84.9%
Simplified84.9%
log1p-udef84.9%
diff-log85.1%
Applied egg-rr85.1%
clear-num85.1%
log-rec85.1%
Applied egg-rr85.1%
if 4.9999999999999999e-13 < (/.f64 1 n) Initial program 68.1%
Taylor expanded in n around 0 68.1%
log1p-def99.7%
*-rgt-identity99.7%
associate-*r/99.7%
unpow-199.7%
exp-to-pow99.7%
/-rgt-identity99.7%
metadata-eval99.7%
associate-/l*99.7%
*-commutative99.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
unpow-199.7%
Simplified99.7%
Final simplification90.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-65)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-13)
(/ (- (log (/ x (+ 1.0 x)))) n)
(-
(+ (* (- (/ 0.5 (* n n)) (/ 0.5 n)) (* x x)) (+ 1.0 (/ 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-65) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
tmp = -log((x / (1.0 + x))) / n;
} else {
tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (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) <= (-5d-65)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-13) then
tmp = -log((x / (1.0d0 + x))) / n
else
tmp = ((((0.5d0 / (n * n)) - (0.5d0 / n)) * (x * x)) + (1.0d0 + (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) <= -5e-65) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else {
tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (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-65: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-13: tmp = -math.log((x / (1.0 + x))) / n else: tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (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-65) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); else tmp = Float64(Float64(Float64(Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)) * Float64(x * x)) + Float64(1.0 + 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) <= -5e-65) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-13) tmp = -log((x / (1.0 + x))) / n; else tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (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], -5e-65], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], N[(N[(N[(N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(x / 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 -5 \cdot 10^{-65}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \left(x \cdot x\right) + \left(1 + \frac{x}{n}\right)\right) - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999983e-65Initial program 86.6%
Taylor expanded in x around inf 93.9%
log-rec93.9%
mul-1-neg93.9%
mul-1-neg93.9%
distribute-frac-neg93.9%
neg-mul-193.9%
remove-double-neg93.9%
*-rgt-identity93.9%
associate-*r/93.9%
unpow-193.9%
exp-to-pow93.9%
unpow-193.9%
*-commutative93.9%
Simplified93.9%
if -4.99999999999999983e-65 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 34.6%
Taylor expanded in n around inf 84.9%
log1p-def84.9%
Simplified84.9%
log1p-udef84.9%
diff-log85.1%
Applied egg-rr85.1%
clear-num85.1%
log-rec85.1%
Applied egg-rr85.1%
if 4.9999999999999999e-13 < (/.f64 1 n) Initial program 68.1%
Taylor expanded in x around 0 78.7%
associate-+r+78.7%
+-commutative78.7%
associate-*r/78.7%
metadata-eval78.7%
unpow278.7%
associate-*r/78.7%
metadata-eval78.7%
unpow278.7%
Simplified78.7%
Final simplification87.5%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -20000.0)
(/ 0.0 n)
(if (<= (/ 1.0 n) -5e-65)
(/ 1.0 (* n (+ x 0.5)))
(if (<= (/ 1.0 n) 5e-13)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+231) (- 1.0 (pow x (/ 1.0 n))) (/ 1.0 (* n x)))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -5e-65) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 5e-13) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+231) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-20000.0d0)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= (-5d-65)) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else if ((1.0d0 / n) <= 5d-13) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d+231) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -5e-65) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 5e-13) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+231) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -20000.0: tmp = 0.0 / n elif (1.0 / n) <= -5e-65: tmp = 1.0 / (n * (x + 0.5)) elif (1.0 / n) <= 5e-13: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+231: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -20000.0) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -5e-65) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+231) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -20000.0) tmp = 0.0 / n; elseif ((1.0 / n) <= -5e-65) tmp = 1.0 / (n * (x + 0.5)); elseif ((1.0 / n) <= 5e-13) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e+231) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -20000.0], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-65], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+231], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -20000:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-65}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+231}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e4Initial program 100.0%
Taylor expanded in n around inf 61.0%
log1p-def61.0%
Simplified61.0%
log1p-udef61.0%
diff-log61.0%
Applied egg-rr61.0%
Taylor expanded in x around inf 63.4%
if -2e4 < (/.f64 1 n) < -4.99999999999999983e-65Initial program 16.8%
Taylor expanded in n around inf 31.6%
log1p-def31.6%
Simplified31.6%
clear-num31.6%
inv-pow31.6%
Applied egg-rr31.6%
unpow-131.6%
Simplified31.6%
Taylor expanded in x around inf 58.5%
*-commutative58.5%
distribute-lft-out58.5%
Simplified58.5%
if -4.99999999999999983e-65 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 34.6%
Taylor expanded in n around inf 84.9%
log1p-def84.9%
Simplified84.9%
log1p-udef84.9%
diff-log85.1%
Applied egg-rr85.1%
if 4.9999999999999999e-13 < (/.f64 1 n) < 1.0000000000000001e231Initial program 80.1%
Taylor expanded in x around 0 76.6%
*-rgt-identity76.6%
associate-*r/76.6%
unpow-176.6%
exp-to-pow76.6%
unpow-176.6%
Simplified76.6%
if 1.0000000000000001e231 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 8.3%
log1p-def8.3%
Simplified8.3%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification76.3%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -20000.0)
(/ 0.0 n)
(if (<= (/ 1.0 n) -5e-65)
(/ 1.0 (* n (+ x 0.5)))
(if (<= (/ 1.0 n) 5e-13)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e+231) (- 1.0 (pow x (/ 1.0 n))) (/ 1.0 (* n x)))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -5e-65) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 5e-13) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+231) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-20000.0d0)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= (-5d-65)) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else if ((1.0d0 / n) <= 5d-13) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d+231) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -5e-65) {
tmp = 1.0 / (n * (x + 0.5));
} else if ((1.0 / n) <= 5e-13) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+231) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -20000.0: tmp = 0.0 / n elif (1.0 / n) <= -5e-65: tmp = 1.0 / (n * (x + 0.5)) elif (1.0 / n) <= 5e-13: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e+231: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -20000.0) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -5e-65) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e+231) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -20000.0) tmp = 0.0 / n; elseif ((1.0 / n) <= -5e-65) tmp = 1.0 / (n * (x + 0.5)); elseif ((1.0 / n) <= 5e-13) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e+231) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -20000.0], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-65], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+231], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -20000:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-65}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+231}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e4Initial program 100.0%
Taylor expanded in n around inf 61.0%
log1p-def61.0%
Simplified61.0%
log1p-udef61.0%
diff-log61.0%
Applied egg-rr61.0%
Taylor expanded in x around inf 63.4%
if -2e4 < (/.f64 1 n) < -4.99999999999999983e-65Initial program 16.8%
Taylor expanded in n around inf 31.6%
log1p-def31.6%
Simplified31.6%
clear-num31.6%
inv-pow31.6%
Applied egg-rr31.6%
unpow-131.6%
Simplified31.6%
Taylor expanded in x around inf 58.5%
*-commutative58.5%
distribute-lft-out58.5%
Simplified58.5%
if -4.99999999999999983e-65 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 34.6%
Taylor expanded in n around inf 84.9%
log1p-def84.9%
Simplified84.9%
log1p-udef84.9%
diff-log85.1%
Applied egg-rr85.1%
clear-num85.1%
log-rec85.1%
Applied egg-rr85.1%
if 4.9999999999999999e-13 < (/.f64 1 n) < 1.0000000000000001e231Initial program 80.1%
Taylor expanded in x around 0 76.6%
*-rgt-identity76.6%
associate-*r/76.6%
unpow-176.6%
exp-to-pow76.6%
unpow-176.6%
Simplified76.6%
if 1.0000000000000001e231 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 8.3%
log1p-def8.3%
Simplified8.3%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification76.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-65)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-13)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e+231) (- (+ 1.0 (/ x n)) t_0) (/ 1.0 (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-65) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+231) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-65)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-13) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d+231) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (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 ((1.0 / n) <= -5e-65) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+231) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-65: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-13: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e+231: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-65) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e+231) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-65) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-13) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e+231) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.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[N[(1.0 / n), $MachinePrecision], -5e-65], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+231], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-65}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+231}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999983e-65Initial program 86.6%
Taylor expanded in x around inf 93.9%
log-rec93.9%
mul-1-neg93.9%
mul-1-neg93.9%
distribute-frac-neg93.9%
neg-mul-193.9%
remove-double-neg93.9%
*-rgt-identity93.9%
associate-*r/93.9%
unpow-193.9%
exp-to-pow93.9%
unpow-193.9%
*-commutative93.9%
Simplified93.9%
if -4.99999999999999983e-65 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 34.6%
Taylor expanded in n around inf 84.9%
log1p-def84.9%
Simplified84.9%
log1p-udef84.9%
diff-log85.1%
Applied egg-rr85.1%
clear-num85.1%
log-rec85.1%
Applied egg-rr85.1%
if 4.9999999999999999e-13 < (/.f64 1 n) < 1.0000000000000001e231Initial program 80.1%
Taylor expanded in x around 0 77.8%
if 1.0000000000000001e231 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 8.3%
log1p-def8.3%
Simplified8.3%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-65)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5e-13)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e+231) (- 1.0 t_0) (/ 1.0 (* n x)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-65) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+231) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-65)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5d-13) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d+231) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (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 ((1.0 / n) <= -5e-65) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5e-13) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+231) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-65: tmp = t_0 / (n * x) elif (1.0 / n) <= 5e-13: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e+231: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-65) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-13) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e+231) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-65) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5e-13) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e+231) tmp = 1.0 - t_0; else tmp = 1.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[N[(1.0 / n), $MachinePrecision], -5e-65], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-13], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+231], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-65}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+231}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999983e-65Initial program 86.6%
Taylor expanded in x around inf 93.9%
log-rec93.9%
mul-1-neg93.9%
mul-1-neg93.9%
distribute-frac-neg93.9%
neg-mul-193.9%
remove-double-neg93.9%
*-rgt-identity93.9%
associate-*r/93.9%
unpow-193.9%
exp-to-pow93.9%
unpow-193.9%
*-commutative93.9%
Simplified93.9%
if -4.99999999999999983e-65 < (/.f64 1 n) < 4.9999999999999999e-13Initial program 34.6%
Taylor expanded in n around inf 84.9%
log1p-def84.9%
Simplified84.9%
log1p-udef84.9%
diff-log85.1%
Applied egg-rr85.1%
clear-num85.1%
log-rec85.1%
Applied egg-rr85.1%
if 4.9999999999999999e-13 < (/.f64 1 n) < 1.0000000000000001e231Initial program 80.1%
Taylor expanded in x around 0 76.6%
*-rgt-identity76.6%
associate-*r/76.6%
unpow-176.6%
exp-to-pow76.6%
unpow-176.6%
Simplified76.6%
if 1.0000000000000001e231 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 8.3%
log1p-def8.3%
Simplified8.3%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification87.7%
(FPCore (x n)
:precision binary64
(if (<= x 1.75e-48)
(/ (- (log x)) n)
(if (<= x 1.02e-18)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 100.0) (/ (- x (log x)) n) (/ 0.0 n)))))
double code(double x, double n) {
double tmp;
if (x <= 1.75e-48) {
tmp = -log(x) / n;
} else if (x <= 1.02e-18) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 100.0) {
tmp = (x - log(x)) / n;
} else {
tmp = 0.0 / 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.75d-48) then
tmp = -log(x) / n
else if (x <= 1.02d-18) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 100.0d0) then
tmp = (x - log(x)) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.75e-48) {
tmp = -Math.log(x) / n;
} else if (x <= 1.02e-18) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 100.0) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.75e-48: tmp = -math.log(x) / n elif x <= 1.02e-18: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 100.0: tmp = (x - math.log(x)) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.75e-48) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.02e-18) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 100.0) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.75e-48) tmp = -log(x) / n; elseif (x <= 1.02e-18) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 100.0) tmp = (x - log(x)) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.75e-48], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.02e-18], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 100.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{-48}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{-18}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 100:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1.74999999999999996e-48Initial program 40.2%
Taylor expanded in n around inf 58.7%
log1p-def58.7%
Simplified58.7%
Taylor expanded in x around 0 58.7%
neg-mul-158.7%
Simplified58.7%
if 1.74999999999999996e-48 < x < 1.02e-18Initial program 65.9%
Taylor expanded in x around 0 66.0%
*-rgt-identity66.0%
associate-*r/65.9%
unpow-165.9%
exp-to-pow65.9%
unpow-165.9%
Simplified65.9%
if 1.02e-18 < x < 100Initial program 24.2%
Taylor expanded in n around inf 78.4%
log1p-def78.4%
Simplified78.4%
Taylor expanded in x around 0 42.8%
neg-mul-142.8%
sub-neg42.8%
Simplified42.8%
if 100 < x Initial program 76.7%
Taylor expanded in n around inf 74.2%
log1p-def74.2%
Simplified74.2%
log1p-udef74.2%
diff-log74.3%
Applied egg-rr74.3%
Taylor expanded in x around inf 76.7%
Final simplification66.7%
(FPCore (x n) :precision binary64 (if (<= x 100.0) (/ (- x (log x)) n) (/ 0.0 n)))
double code(double x, double n) {
double tmp;
if (x <= 100.0) {
tmp = (x - log(x)) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 100.0d0) then
tmp = (x - log(x)) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 100.0) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 100.0: tmp = (x - math.log(x)) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 100.0) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 100.0) tmp = (x - log(x)) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 100.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 100:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 100Initial program 41.4%
Taylor expanded in n around inf 56.8%
log1p-def56.8%
Simplified56.8%
Taylor expanded in x around 0 54.2%
neg-mul-154.2%
sub-neg54.2%
Simplified54.2%
if 100 < x Initial program 76.7%
Taylor expanded in n around inf 74.2%
log1p-def74.2%
Simplified74.2%
log1p-udef74.2%
diff-log74.3%
Applied egg-rr74.3%
Taylor expanded in x around inf 76.7%
Final simplification64.5%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- (log x)) n) (/ 0.0 n)))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = -log(x) / n;
} else {
tmp = 0.0 / 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.0d0) then
tmp = -log(x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = -Math.log(x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = -math.log(x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = -log(x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1Initial program 42.2%
Taylor expanded in n around inf 56.0%
log1p-def56.0%
Simplified56.0%
Taylor expanded in x around 0 54.6%
neg-mul-154.6%
Simplified54.6%
if 1 < x Initial program 74.9%
Taylor expanded in n around inf 74.6%
log1p-def74.6%
Simplified74.6%
log1p-udef74.6%
diff-log74.8%
Applied egg-rr74.8%
Taylor expanded in x around inf 74.9%
Final simplification64.2%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -20000.0) (/ 0.0 n) (if (<= (/ 1.0 n) 5e+180) (/ 1.0 (* n (+ x 0.5))) (/ 1.0 (* n x)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= 5e+180) {
tmp = 1.0 / (n * (x + 0.5));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-20000.0d0)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= 5d+180) then
tmp = 1.0d0 / (n * (x + 0.5d0))
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -20000.0) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= 5e+180) {
tmp = 1.0 / (n * (x + 0.5));
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -20000.0: tmp = 0.0 / n elif (1.0 / n) <= 5e+180: tmp = 1.0 / (n * (x + 0.5)) else: tmp = 1.0 / (n * x) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -20000.0) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= 5e+180) tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -20000.0) tmp = 0.0 / n; elseif ((1.0 / n) <= 5e+180) tmp = 1.0 / (n * (x + 0.5)); else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -20000.0], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+180], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -20000:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+180}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e4Initial program 100.0%
Taylor expanded in n around inf 61.0%
log1p-def61.0%
Simplified61.0%
log1p-udef61.0%
diff-log61.0%
Applied egg-rr61.0%
Taylor expanded in x around inf 63.4%
if -2e4 < (/.f64 1 n) < 4.9999999999999996e180Initial program 39.9%
Taylor expanded in n around inf 69.6%
log1p-def69.6%
Simplified69.6%
clear-num69.6%
inv-pow69.6%
Applied egg-rr69.6%
unpow-169.6%
Simplified69.6%
Taylor expanded in x around inf 46.8%
*-commutative46.8%
distribute-lft-out46.8%
Simplified46.8%
if 4.9999999999999996e180 < (/.f64 1 n) Initial program 24.7%
Taylor expanded in n around inf 6.7%
log1p-def6.7%
Simplified6.7%
Taylor expanded in x around inf 68.2%
*-commutative68.2%
Simplified68.2%
Final simplification52.6%
(FPCore (x n) :precision binary64 (if (<= n 3.7e-181) (/ (/ -1.0 n) (- x)) (/ 1.0 (* n (+ x 0.5)))))
double code(double x, double n) {
double tmp;
if (n <= 3.7e-181) {
tmp = (-1.0 / n) / -x;
} else {
tmp = 1.0 / (n * (x + 0.5));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 3.7d-181) then
tmp = ((-1.0d0) / n) / -x
else
tmp = 1.0d0 / (n * (x + 0.5d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= 3.7e-181) {
tmp = (-1.0 / n) / -x;
} else {
tmp = 1.0 / (n * (x + 0.5));
}
return tmp;
}
def code(x, n): tmp = 0 if n <= 3.7e-181: tmp = (-1.0 / n) / -x else: tmp = 1.0 / (n * (x + 0.5)) return tmp
function code(x, n) tmp = 0.0 if (n <= 3.7e-181) tmp = Float64(Float64(-1.0 / n) / Float64(-x)); else tmp = Float64(1.0 / Float64(n * Float64(x + 0.5))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= 3.7e-181) tmp = (-1.0 / n) / -x; else tmp = 1.0 / (n * (x + 0.5)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, 3.7e-181], N[(N[(-1.0 / n), $MachinePrecision] / (-x)), $MachinePrecision], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.7 \cdot 10^{-181}:\\
\;\;\;\;\frac{\frac{-1}{n}}{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\
\end{array}
\end{array}
if n < 3.69999999999999984e-181Initial program 66.4%
Taylor expanded in n around inf 62.9%
log1p-def62.9%
Simplified62.9%
Taylor expanded in x around inf 37.1%
*-commutative37.1%
Simplified37.1%
associate-/l/38.0%
frac-2neg38.0%
distribute-frac-neg38.0%
Applied egg-rr38.0%
if 3.69999999999999984e-181 < n Initial program 44.5%
Taylor expanded in n around inf 67.7%
log1p-def67.7%
Simplified67.7%
clear-num67.6%
inv-pow67.6%
Applied egg-rr67.6%
unpow-167.6%
Simplified67.6%
Taylor expanded in x around inf 41.1%
*-commutative41.1%
distribute-lft-out41.1%
Simplified41.1%
Final simplification39.2%
(FPCore (x n) :precision binary64 (/ (/ -1.0 n) (- x)))
double code(double x, double n) {
return (-1.0 / n) / -x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((-1.0d0) / n) / -x
end function
public static double code(double x, double n) {
return (-1.0 / n) / -x;
}
def code(x, n): return (-1.0 / n) / -x
function code(x, n) return Float64(Float64(-1.0 / n) / Float64(-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 57.7%
Taylor expanded in n around inf 64.8%
log1p-def64.8%
Simplified64.8%
Taylor expanded in x around inf 36.8%
*-commutative36.8%
Simplified36.8%
associate-/l/37.6%
frac-2neg37.6%
distribute-frac-neg37.6%
Applied egg-rr37.6%
Final simplification37.6%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 57.7%
Taylor expanded in n around inf 64.8%
log1p-def64.8%
Simplified64.8%
Taylor expanded in x around inf 36.8%
*-commutative36.8%
Simplified36.8%
Final simplification36.8%
(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 57.7%
Taylor expanded in n around inf 64.8%
log1p-def64.8%
Simplified64.8%
Taylor expanded in x around inf 37.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 57.7%
Taylor expanded in x around 0 31.6%
Taylor expanded in x around inf 4.6%
Final simplification4.6%
herbie shell --seed 2023192
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))