
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-58)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-14)
(+
(/ (- (log1p x) (log x)) n)
(*
0.5
(-
(/ (pow (log1p x) 2.0) (pow n 2.0))
(/ (pow (log x) 2.0) (pow n 2.0)))))
(- (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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
tmp = ((log1p(x) - log(x)) / n) + (0.5 * ((pow(log1p(x), 2.0) / pow(n, 2.0)) - (pow(log(x), 2.0) / pow(n, 2.0))));
} 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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
tmp = ((Math.log1p(x) - Math.log(x)) / n) + (0.5 * ((Math.pow(Math.log1p(x), 2.0) / Math.pow(n, 2.0)) - (Math.pow(Math.log(x), 2.0) / Math.pow(n, 2.0))));
} 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) <= -2e-58: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-14: tmp = ((math.log1p(x) - math.log(x)) / n) + (0.5 * ((math.pow(math.log1p(x), 2.0) / math.pow(n, 2.0)) - (math.pow(math.log(x), 2.0) / math.pow(n, 2.0)))) 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) <= -2e-58) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(Float64(Float64(log1p(x) - log(x)) / n) + Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) / (n ^ 2.0)) - Float64((log(x) ^ 2.0) / (n ^ 2.0))))); 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], -2e-58], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n} + 0.5 \cdot \left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{{n}^{2}} - \frac{{\log x}^{2}}{{n}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-58Initial program 86.6%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
log-rec97.7%
mul-1-neg97.7%
distribute-neg-frac97.7%
mul-1-neg97.7%
remove-double-neg97.7%
*-commutative97.7%
Simplified97.7%
div-inv97.7%
div-inv97.7%
pow-to-exp97.7%
Applied egg-rr97.7%
associate-*r/97.7%
*-rgt-identity97.7%
Simplified97.7%
if -2.0000000000000001e-58 < (/.f64 1 n) < 2e-14Initial program 38.2%
Taylor expanded in n around inf 87.5%
associate--l+78.6%
+-commutative78.6%
associate--r+87.5%
div-sub87.6%
remove-double-neg87.6%
mul-1-neg87.6%
distribute-lft-out--87.6%
mul-1-neg87.6%
associate-*r/87.6%
Simplified87.6%
if 2e-14 < (/.f64 1 n) Initial program 45.1%
Taylor expanded in n around 0 45.1%
log1p-def95.1%
Simplified95.1%
Final simplification92.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-58)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-14)
(/ (- (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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
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) <= -2e-58: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-14: 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) <= -2e-58) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-14) 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], -2e-58], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], 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 -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\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) < -2.0000000000000001e-58Initial program 86.6%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
log-rec97.7%
mul-1-neg97.7%
distribute-neg-frac97.7%
mul-1-neg97.7%
remove-double-neg97.7%
*-commutative97.7%
Simplified97.7%
div-inv97.7%
div-inv97.7%
pow-to-exp97.7%
Applied egg-rr97.7%
associate-*r/97.7%
*-rgt-identity97.7%
Simplified97.7%
if -2.0000000000000001e-58 < (/.f64 1 n) < 2e-14Initial program 38.2%
Taylor expanded in n around inf 87.3%
log1p-def87.3%
Simplified87.3%
log1p-udef87.3%
diff-log87.3%
Applied egg-rr87.3%
clear-num87.3%
log-rec87.4%
Applied egg-rr87.4%
if 2e-14 < (/.f64 1 n) Initial program 45.1%
Taylor expanded in n around 0 45.1%
log1p-def95.1%
Simplified95.1%
Final simplification92.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-58)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-14)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 6e+109)
(- (+ 1.0 (/ x n)) t_0)
(log1p (expm1 (/ (/ 1.0 n) x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 6e+109) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = log1p(expm1(((1.0 / n) / x)));
}
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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 6e+109) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.log1p(Math.expm1(((1.0 / n) / x)));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-58: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-14: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 6e+109: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.log1p(math.expm1(((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) <= -2e-58) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 6e+109) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = log1p(expm1(Float64(Float64(1.0 / n) / x))); 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], -2e-58], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 6e+109], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 6 \cdot 10^{+109}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{n}}{x}\right)\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-58Initial program 86.6%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
log-rec97.7%
mul-1-neg97.7%
distribute-neg-frac97.7%
mul-1-neg97.7%
remove-double-neg97.7%
*-commutative97.7%
Simplified97.7%
div-inv97.7%
div-inv97.7%
pow-to-exp97.7%
Applied egg-rr97.7%
associate-*r/97.7%
*-rgt-identity97.7%
Simplified97.7%
if -2.0000000000000001e-58 < (/.f64 1 n) < 2e-14Initial program 38.2%
Taylor expanded in n around inf 87.3%
log1p-def87.3%
Simplified87.3%
log1p-udef87.3%
diff-log87.3%
Applied egg-rr87.3%
clear-num87.3%
log-rec87.4%
Applied egg-rr87.4%
if 2e-14 < (/.f64 1 n) < 6.00000000000000031e109Initial program 72.3%
Taylor expanded in x around 0 74.8%
if 6.00000000000000031e109 < (/.f64 1 n) Initial program 24.0%
Taylor expanded in n around inf 6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 44.4%
*-commutative44.4%
Simplified44.4%
log1p-expm1-u78.0%
*-commutative78.0%
associate-/r*78.0%
Applied egg-rr78.0%
Final simplification89.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-58)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-14)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 6e+109)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 6e+109) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-58)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d-14) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 6d+109) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = sqrt(((n * x) ** (-2.0d0)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 6e+109) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-58: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-14: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 6e+109: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-58) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 6e+109) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-58) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e-14) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 6e+109) tmp = (1.0 + (x / n)) - t_0; else tmp = sqrt(((n * x) ^ -2.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-58], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 6e+109], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 6 \cdot 10^{+109}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-58Initial program 86.6%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
log-rec97.7%
mul-1-neg97.7%
distribute-neg-frac97.7%
mul-1-neg97.7%
remove-double-neg97.7%
*-commutative97.7%
Simplified97.7%
div-inv97.7%
div-inv97.7%
pow-to-exp97.7%
Applied egg-rr97.7%
associate-*r/97.7%
*-rgt-identity97.7%
Simplified97.7%
if -2.0000000000000001e-58 < (/.f64 1 n) < 2e-14Initial program 38.2%
Taylor expanded in n around inf 87.3%
log1p-def87.3%
Simplified87.3%
log1p-udef87.3%
diff-log87.3%
Applied egg-rr87.3%
clear-num87.3%
log-rec87.4%
Applied egg-rr87.4%
if 2e-14 < (/.f64 1 n) < 6.00000000000000031e109Initial program 72.3%
Taylor expanded in x around 0 74.8%
if 6.00000000000000031e109 < (/.f64 1 n) Initial program 24.0%
Taylor expanded in n around inf 6.4%
log1p-def6.4%
Simplified6.4%
Taylor expanded in x around inf 44.4%
*-commutative44.4%
Simplified44.4%
add-sqr-sqrt44.4%
sqrt-unprod73.6%
inv-pow73.6%
inv-pow73.6%
pow-prod-up73.6%
metadata-eval73.6%
Applied egg-rr73.6%
Final simplification89.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-58)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-5)
(/ (- (log (/ x (+ 1.0 x)))) n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-5) {
tmp = -log((x / (1.0 + x))) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-58)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d-5) then
tmp = -log((x / (1.0d0 + x))) / n
else
tmp = exp((x / n)) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-5) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-58: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-5: tmp = -math.log((x / (1.0 + x))) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-58) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-5) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-58) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e-5) tmp = -log((x / (1.0 + x))) / n; else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-58], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-5], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-58Initial program 86.6%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
log-rec97.7%
mul-1-neg97.7%
distribute-neg-frac97.7%
mul-1-neg97.7%
remove-double-neg97.7%
*-commutative97.7%
Simplified97.7%
div-inv97.7%
div-inv97.7%
pow-to-exp97.7%
Applied egg-rr97.7%
associate-*r/97.7%
*-rgt-identity97.7%
Simplified97.7%
if -2.0000000000000001e-58 < (/.f64 1 n) < 2.00000000000000016e-5Initial program 37.6%
Taylor expanded in n around inf 85.8%
log1p-def85.8%
Simplified85.8%
log1p-udef85.8%
diff-log85.9%
Applied egg-rr85.9%
clear-num85.9%
log-rec86.0%
Applied egg-rr86.0%
if 2.00000000000000016e-5 < (/.f64 1 n) Initial program 47.3%
Taylor expanded in n around 0 47.3%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification92.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n))))
(t_1 (/ (log (/ (+ 1.0 x) x)) n))
(t_2 (/ 1.0 (* n x))))
(if (<= (/ 1.0 n) -5e+201)
t_1
(if (<= (/ 1.0 n) -5e+140)
t_0
(if (<= (/ 1.0 n) -5e+66)
(/ 0.0 n)
(if (<= (/ 1.0 n) -2e-11)
t_0
(if (<= (/ 1.0 n) -2e-58)
t_2
(if (<= (/ 1.0 n) 2e-5)
t_1
(if (<= (/ 1.0 n) 5e+190) t_0 t_2)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double t_2 = 1.0 / (n * x);
double tmp;
if ((1.0 / n) <= -5e+201) {
tmp = t_1;
} else if ((1.0 / n) <= -5e+140) {
tmp = t_0;
} else if ((1.0 / n) <= -5e+66) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -2e-11) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-58) {
tmp = t_2;
} else if ((1.0 / n) <= 2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+190) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
t_2 = 1.0d0 / (n * x)
if ((1.0d0 / n) <= (-5d+201)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d+140)) then
tmp = t_0
else if ((1.0d0 / n) <= (-5d+66)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= (-2d-11)) then
tmp = t_0
else if ((1.0d0 / n) <= (-2d-58)) then
tmp = t_2
else if ((1.0d0 / n) <= 2d-5) then
tmp = t_1
else if ((1.0d0 / n) <= 5d+190) then
tmp = t_0
else
tmp = t_2
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 t_1 = Math.log(((1.0 + x) / x)) / n;
double t_2 = 1.0 / (n * x);
double tmp;
if ((1.0 / n) <= -5e+201) {
tmp = t_1;
} else if ((1.0 / n) <= -5e+140) {
tmp = t_0;
} else if ((1.0 / n) <= -5e+66) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -2e-11) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-58) {
tmp = t_2;
} else if ((1.0 / n) <= 2e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+190) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(((1.0 + x) / x)) / n t_2 = 1.0 / (n * x) tmp = 0 if (1.0 / n) <= -5e+201: tmp = t_1 elif (1.0 / n) <= -5e+140: tmp = t_0 elif (1.0 / n) <= -5e+66: tmp = 0.0 / n elif (1.0 / n) <= -2e-11: tmp = t_0 elif (1.0 / n) <= -2e-58: tmp = t_2 elif (1.0 / n) <= 2e-5: tmp = t_1 elif (1.0 / n) <= 5e+190: tmp = t_0 else: tmp = t_2 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) t_2 = Float64(1.0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -5e+201) tmp = t_1; elseif (Float64(1.0 / n) <= -5e+140) tmp = t_0; elseif (Float64(1.0 / n) <= -5e+66) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -2e-11) tmp = t_0; elseif (Float64(1.0 / n) <= -2e-58) tmp = t_2; elseif (Float64(1.0 / n) <= 2e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+190) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(((1.0 + x) / x)) / n; t_2 = 1.0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -5e+201) tmp = t_1; elseif ((1.0 / n) <= -5e+140) tmp = t_0; elseif ((1.0 / n) <= -5e+66) tmp = 0.0 / n; elseif ((1.0 / n) <= -2e-11) tmp = t_0; elseif ((1.0 / n) <= -2e-58) tmp = t_2; elseif ((1.0 / n) <= 2e-5) tmp = t_1; elseif ((1.0 / n) <= 5e+190) tmp = t_0; else tmp = t_2; 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]}, Block[{t$95$1 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+201], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+140], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+66], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-11], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-58], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+190], t$95$0, t$95$2]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
t_2 := \frac{1}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+201}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+140}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+66}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-58}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+190}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999995e201 or -2.0000000000000001e-58 < (/.f64 1 n) < 2.00000000000000016e-5Initial program 47.1%
Taylor expanded in n around inf 82.6%
log1p-def82.6%
Simplified82.6%
log1p-udef82.6%
diff-log82.7%
Applied egg-rr82.7%
if -4.9999999999999995e201 < (/.f64 1 n) < -5.00000000000000008e140 or -4.99999999999999991e66 < (/.f64 1 n) < -1.99999999999999988e-11 or 2.00000000000000016e-5 < (/.f64 1 n) < 5.00000000000000036e190Initial program 85.1%
Taylor expanded in x around 0 66.5%
if -5.00000000000000008e140 < (/.f64 1 n) < -4.99999999999999991e66Initial program 100.0%
Taylor expanded in n around inf 63.0%
log1p-def63.0%
Simplified63.0%
log1p-udef63.0%
diff-log63.0%
Applied egg-rr63.0%
Taylor expanded in x around inf 69.7%
if -1.99999999999999988e-11 < (/.f64 1 n) < -2.0000000000000001e-58 or 5.00000000000000036e190 < (/.f64 1 n) Initial program 4.3%
Taylor expanded in n around inf 12.8%
log1p-def12.8%
Simplified12.8%
Taylor expanded in x around inf 90.3%
*-commutative90.3%
Simplified90.3%
Final simplification77.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ 1.0 (* n x))))
(if (<= (/ 1.0 n) -5e+201)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) -5e+140)
t_0
(if (<= (/ 1.0 n) -5e+66)
(/ 0.0 n)
(if (<= (/ 1.0 n) -2e-11)
t_0
(if (<= (/ 1.0 n) -2e-58)
t_1
(if (<= (/ 1.0 n) 2e-5)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 5e+190) t_0 t_1)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = 1.0 / (n * x);
double tmp;
if ((1.0 / n) <= -5e+201) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -5e+140) {
tmp = t_0;
} else if ((1.0 / n) <= -5e+66) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -2e-11) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-58) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-5) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 5e+190) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = 1.0d0 / (n * x)
if ((1.0d0 / n) <= (-5d+201)) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= (-5d+140)) then
tmp = t_0
else if ((1.0d0 / n) <= (-5d+66)) then
tmp = 0.0d0 / n
else if ((1.0d0 / n) <= (-2d-11)) then
tmp = t_0
else if ((1.0d0 / n) <= (-2d-58)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-5) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 5d+190) then
tmp = t_0
else
tmp = t_1
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 t_1 = 1.0 / (n * x);
double tmp;
if ((1.0 / n) <= -5e+201) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -5e+140) {
tmp = t_0;
} else if ((1.0 / n) <= -5e+66) {
tmp = 0.0 / n;
} else if ((1.0 / n) <= -2e-11) {
tmp = t_0;
} else if ((1.0 / n) <= -2e-58) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-5) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 5e+190) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = 1.0 / (n * x) tmp = 0 if (1.0 / n) <= -5e+201: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= -5e+140: tmp = t_0 elif (1.0 / n) <= -5e+66: tmp = 0.0 / n elif (1.0 / n) <= -2e-11: tmp = t_0 elif (1.0 / n) <= -2e-58: tmp = t_1 elif (1.0 / n) <= 2e-5: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 5e+190: tmp = t_0 else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(1.0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -5e+201) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= -5e+140) tmp = t_0; elseif (Float64(1.0 / n) <= -5e+66) tmp = Float64(0.0 / n); elseif (Float64(1.0 / n) <= -2e-11) tmp = t_0; elseif (Float64(1.0 / n) <= -2e-58) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-5) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 5e+190) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = 1.0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -5e+201) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= -5e+140) tmp = t_0; elseif ((1.0 / n) <= -5e+66) tmp = 0.0 / n; elseif ((1.0 / n) <= -2e-11) tmp = t_0; elseif ((1.0 / n) <= -2e-58) tmp = t_1; elseif ((1.0 / n) <= 2e-5) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 5e+190) tmp = t_0; else tmp = t_1; 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]}, Block[{t$95$1 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+201], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+140], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+66], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-11], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-58], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-5], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+190], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+201}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+140}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+66}:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-58}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+190}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.9999999999999995e201Initial program 100.0%
Taylor expanded in n around inf 64.6%
log1p-def64.6%
Simplified64.6%
log1p-udef64.6%
diff-log64.6%
Applied egg-rr64.6%
if -4.9999999999999995e201 < (/.f64 1 n) < -5.00000000000000008e140 or -4.99999999999999991e66 < (/.f64 1 n) < -1.99999999999999988e-11 or 2.00000000000000016e-5 < (/.f64 1 n) < 5.00000000000000036e190Initial program 85.1%
Taylor expanded in x around 0 66.5%
if -5.00000000000000008e140 < (/.f64 1 n) < -4.99999999999999991e66Initial program 100.0%
Taylor expanded in n around inf 63.0%
log1p-def63.0%
Simplified63.0%
log1p-udef63.0%
diff-log63.0%
Applied egg-rr63.0%
Taylor expanded in x around inf 69.7%
if -1.99999999999999988e-11 < (/.f64 1 n) < -2.0000000000000001e-58 or 5.00000000000000036e190 < (/.f64 1 n) Initial program 4.3%
Taylor expanded in n around inf 12.8%
log1p-def12.8%
Simplified12.8%
Taylor expanded in x around inf 90.3%
*-commutative90.3%
Simplified90.3%
if -2.0000000000000001e-58 < (/.f64 1 n) < 2.00000000000000016e-5Initial program 37.6%
Taylor expanded in n around inf 85.8%
log1p-def85.8%
Simplified85.8%
log1p-udef85.8%
diff-log85.9%
Applied egg-rr85.9%
clear-num85.9%
log-rec86.0%
Applied egg-rr86.0%
Final simplification77.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-58)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-14)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 5e+190) (- (+ 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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 5e+190) {
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) <= (-2d-58)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d-14) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 5d+190) 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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-14) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 5e+190) {
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) <= -2e-58: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-14: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 5e+190: 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) <= -2e-58) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-14) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 5e+190) 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) <= -2e-58) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e-14) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 5e+190) 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], -2e-58], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+190], 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 -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+190}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-58Initial program 86.6%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
log-rec97.7%
mul-1-neg97.7%
distribute-neg-frac97.7%
mul-1-neg97.7%
remove-double-neg97.7%
*-commutative97.7%
Simplified97.7%
div-inv97.7%
div-inv97.7%
pow-to-exp97.7%
Applied egg-rr97.7%
associate-*r/97.7%
*-rgt-identity97.7%
Simplified97.7%
if -2.0000000000000001e-58 < (/.f64 1 n) < 2e-14Initial program 38.2%
Taylor expanded in n around inf 87.3%
log1p-def87.3%
Simplified87.3%
log1p-udef87.3%
diff-log87.3%
Applied egg-rr87.3%
clear-num87.3%
log-rec87.4%
Applied egg-rr87.4%
if 2e-14 < (/.f64 1 n) < 5.00000000000000036e190Initial program 59.5%
Taylor expanded in x around 0 59.3%
if 5.00000000000000036e190 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 8.6%
log1p-def8.6%
Simplified8.6%
Taylor expanded in x around inf 91.7%
*-commutative91.7%
Simplified91.7%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 5.7e-216)
t_0
(if (<= x 1e-193)
t_1
(if (<= x 7e-181)
t_0
(if (<= x 2.1e-87)
t_1
(if (<= x 4.6e-49)
t_0
(if (<= x 31500.0)
t_1
(if (<= x 1.45e+100) (/ (/ 1.0 x) n) (/ 0.0 n))))))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 5.7e-216) {
tmp = t_0;
} else if (x <= 1e-193) {
tmp = t_1;
} else if (x <= 7e-181) {
tmp = t_0;
} else if (x <= 2.1e-87) {
tmp = t_1;
} else if (x <= 4.6e-49) {
tmp = t_0;
} else if (x <= 31500.0) {
tmp = t_1;
} else if (x <= 1.45e+100) {
tmp = (1.0 / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -log(x) / n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 5.7d-216) then
tmp = t_0
else if (x <= 1d-193) then
tmp = t_1
else if (x <= 7d-181) then
tmp = t_0
else if (x <= 2.1d-87) then
tmp = t_1
else if (x <= 4.6d-49) then
tmp = t_0
else if (x <= 31500.0d0) then
tmp = t_1
else if (x <= 1.45d+100) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 5.7e-216) {
tmp = t_0;
} else if (x <= 1e-193) {
tmp = t_1;
} else if (x <= 7e-181) {
tmp = t_0;
} else if (x <= 2.1e-87) {
tmp = t_1;
} else if (x <= 4.6e-49) {
tmp = t_0;
} else if (x <= 31500.0) {
tmp = t_1;
} else if (x <= 1.45e+100) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 5.7e-216: tmp = t_0 elif x <= 1e-193: tmp = t_1 elif x <= 7e-181: tmp = t_0 elif x <= 2.1e-87: tmp = t_1 elif x <= 4.6e-49: tmp = t_0 elif x <= 31500.0: tmp = t_1 elif x <= 1.45e+100: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 5.7e-216) tmp = t_0; elseif (x <= 1e-193) tmp = t_1; elseif (x <= 7e-181) tmp = t_0; elseif (x <= 2.1e-87) tmp = t_1; elseif (x <= 4.6e-49) tmp = t_0; elseif (x <= 31500.0) tmp = t_1; elseif (x <= 1.45e+100) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 5.7e-216) tmp = t_0; elseif (x <= 1e-193) tmp = t_1; elseif (x <= 7e-181) tmp = t_0; elseif (x <= 2.1e-87) tmp = t_1; elseif (x <= 4.6e-49) tmp = t_0; elseif (x <= 31500.0) tmp = t_1; elseif (x <= 1.45e+100) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5.7e-216], t$95$0, If[LessEqual[x, 1e-193], t$95$1, If[LessEqual[x, 7e-181], t$95$0, If[LessEqual[x, 2.1e-87], t$95$1, If[LessEqual[x, 4.6e-49], t$95$0, If[LessEqual[x, 31500.0], t$95$1, If[LessEqual[x, 1.45e+100], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 5.7 \cdot 10^{-216}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 10^{-193}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-181}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-87}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{-49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 31500:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+100}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 5.70000000000000004e-216 or 1e-193 < x < 6.99999999999999993e-181 or 2.10000000000000007e-87 < x < 4.5999999999999998e-49Initial program 28.3%
Taylor expanded in x around 0 28.3%
Taylor expanded in n around inf 65.6%
neg-mul-165.6%
distribute-neg-frac65.6%
Simplified65.6%
if 5.70000000000000004e-216 < x < 1e-193 or 6.99999999999999993e-181 < x < 2.10000000000000007e-87 or 4.5999999999999998e-49 < x < 31500Initial program 63.5%
Taylor expanded in x around 0 58.7%
if 31500 < x < 1.45e100Initial program 37.3%
Taylor expanded in n around inf 40.4%
log1p-def40.4%
Simplified40.4%
Taylor expanded in x around inf 75.2%
if 1.45e100 < x Initial program 86.3%
Taylor expanded in n around inf 86.3%
log1p-def86.3%
Simplified86.3%
log1p-udef86.3%
diff-log86.3%
Applied egg-rr86.3%
Taylor expanded in x around inf 86.3%
Final simplification70.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-58)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-5)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 5e+190) (- 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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-5) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 5e+190) {
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) <= (-2d-58)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d-5) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 5d+190) 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) <= -2e-58) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-5) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 5e+190) {
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) <= -2e-58: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-5: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 5e+190: 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) <= -2e-58) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-5) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 5e+190) 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) <= -2e-58) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e-5) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 5e+190) 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], -2e-58], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-5], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+190], 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 -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+190}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-58Initial program 86.6%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
log-rec97.7%
mul-1-neg97.7%
distribute-neg-frac97.7%
mul-1-neg97.7%
remove-double-neg97.7%
*-commutative97.7%
Simplified97.7%
div-inv97.7%
div-inv97.7%
pow-to-exp97.7%
Applied egg-rr97.7%
associate-*r/97.7%
*-rgt-identity97.7%
Simplified97.7%
if -2.0000000000000001e-58 < (/.f64 1 n) < 2.00000000000000016e-5Initial program 37.6%
Taylor expanded in n around inf 85.8%
log1p-def85.8%
Simplified85.8%
log1p-udef85.8%
diff-log85.9%
Applied egg-rr85.9%
clear-num85.9%
log-rec86.0%
Applied egg-rr86.0%
if 2.00000000000000016e-5 < (/.f64 1 n) < 5.00000000000000036e190Initial program 63.7%
Taylor expanded in x around 0 60.1%
if 5.00000000000000036e190 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in n around inf 8.6%
log1p-def8.6%
Simplified8.6%
Taylor expanded in x around inf 91.7%
*-commutative91.7%
Simplified91.7%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(if (<= x 5.5e-166)
(/ (- (log x)) n)
(if (<= x 3.8e-140)
(/ 1.0 (* n x))
(if (<= x 1.8e-9)
(/ (- x (log x)) n)
(if (<= x 5.3e+99) (/ (/ 1.0 x) n) (/ 0.0 n))))))
double code(double x, double n) {
double tmp;
if (x <= 5.5e-166) {
tmp = -log(x) / n;
} else if (x <= 3.8e-140) {
tmp = 1.0 / (n * x);
} else if (x <= 1.8e-9) {
tmp = (x - log(x)) / n;
} else if (x <= 5.3e+99) {
tmp = (1.0 / 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 <= 5.5d-166) then
tmp = -log(x) / n
else if (x <= 3.8d-140) then
tmp = 1.0d0 / (n * x)
else if (x <= 1.8d-9) then
tmp = (x - log(x)) / n
else if (x <= 5.3d+99) then
tmp = (1.0d0 / 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 <= 5.5e-166) {
tmp = -Math.log(x) / n;
} else if (x <= 3.8e-140) {
tmp = 1.0 / (n * x);
} else if (x <= 1.8e-9) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 5.3e+99) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 5.5e-166: tmp = -math.log(x) / n elif x <= 3.8e-140: tmp = 1.0 / (n * x) elif x <= 1.8e-9: tmp = (x - math.log(x)) / n elif x <= 5.3e+99: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 5.5e-166) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 3.8e-140) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 1.8e-9) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 5.3e+99) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 5.5e-166) tmp = -log(x) / n; elseif (x <= 3.8e-140) tmp = 1.0 / (n * x); elseif (x <= 1.8e-9) tmp = (x - log(x)) / n; elseif (x <= 5.3e+99) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 5.5e-166], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 3.8e-140], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.8e-9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 5.3e+99], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{-166}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-140}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-9}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{+99}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 5.4999999999999997e-166Initial program 41.9%
Taylor expanded in x around 0 41.9%
Taylor expanded in n around inf 57.7%
neg-mul-157.7%
distribute-neg-frac57.7%
Simplified57.7%
if 5.4999999999999997e-166 < x < 3.79999999999999998e-140Initial program 66.1%
Taylor expanded in n around inf 13.1%
log1p-def13.1%
Simplified13.1%
Taylor expanded in x around inf 56.2%
*-commutative56.2%
Simplified56.2%
if 3.79999999999999998e-140 < x < 1.8e-9Initial program 45.3%
Taylor expanded in n around inf 44.0%
log1p-def44.0%
Simplified44.0%
Taylor expanded in x around 0 44.0%
neg-mul-144.0%
unsub-neg44.0%
Simplified44.0%
if 1.8e-9 < x < 5.30000000000000034e99Initial program 46.8%
Taylor expanded in n around inf 34.8%
log1p-def34.8%
Simplified34.8%
Taylor expanded in x around inf 64.3%
if 5.30000000000000034e99 < x Initial program 86.3%
Taylor expanded in n around inf 86.3%
log1p-def86.3%
Simplified86.3%
log1p-udef86.3%
diff-log86.3%
Applied egg-rr86.3%
Taylor expanded in x around inf 86.3%
Final simplification63.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)))
(if (<= x 3.8e-167)
t_0
(if (<= x 3.8e-140)
(/ 1.0 (* n x))
(if (<= x 1.8e-9)
t_0
(if (<= x 2.2e+100) (/ (/ 1.0 x) n) (/ 0.0 n)))))))
double code(double x, double n) {
double t_0 = -log(x) / n;
double tmp;
if (x <= 3.8e-167) {
tmp = t_0;
} else if (x <= 3.8e-140) {
tmp = 1.0 / (n * x);
} else if (x <= 1.8e-9) {
tmp = t_0;
} else if (x <= 2.2e+100) {
tmp = (1.0 / 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) :: t_0
real(8) :: tmp
t_0 = -log(x) / n
if (x <= 3.8d-167) then
tmp = t_0
else if (x <= 3.8d-140) then
tmp = 1.0d0 / (n * x)
else if (x <= 1.8d-9) then
tmp = t_0
else if (x <= 2.2d+100) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = -Math.log(x) / n;
double tmp;
if (x <= 3.8e-167) {
tmp = t_0;
} else if (x <= 3.8e-140) {
tmp = 1.0 / (n * x);
} else if (x <= 1.8e-9) {
tmp = t_0;
} else if (x <= 2.2e+100) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = -math.log(x) / n tmp = 0 if x <= 3.8e-167: tmp = t_0 elif x <= 3.8e-140: tmp = 1.0 / (n * x) elif x <= 1.8e-9: tmp = t_0 elif x <= 2.2e+100: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 3.8e-167) tmp = t_0; elseif (x <= 3.8e-140) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 1.8e-9) tmp = t_0; elseif (x <= 2.2e+100) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = -log(x) / n; tmp = 0.0; if (x <= 3.8e-167) tmp = t_0; elseif (x <= 3.8e-140) tmp = 1.0 / (n * x); elseif (x <= 1.8e-9) tmp = t_0; elseif (x <= 2.2e+100) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 3.8e-167], t$95$0, If[LessEqual[x, 3.8e-140], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.8e-9], t$95$0, If[LessEqual[x, 2.2e+100], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 3.8 \cdot 10^{-167}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-140}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+100}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 3.79999999999999967e-167 or 3.79999999999999998e-140 < x < 1.8e-9Initial program 43.7%
Taylor expanded in x around 0 43.7%
Taylor expanded in n around inf 50.3%
neg-mul-150.3%
distribute-neg-frac50.3%
Simplified50.3%
if 3.79999999999999967e-167 < x < 3.79999999999999998e-140Initial program 66.1%
Taylor expanded in n around inf 13.1%
log1p-def13.1%
Simplified13.1%
Taylor expanded in x around inf 56.2%
*-commutative56.2%
Simplified56.2%
if 1.8e-9 < x < 2.2000000000000001e100Initial program 46.8%
Taylor expanded in n around inf 34.8%
log1p-def34.8%
Simplified34.8%
Taylor expanded in x around inf 64.3%
if 2.2000000000000001e100 < x Initial program 86.3%
Taylor expanded in n around inf 86.3%
log1p-def86.3%
Simplified86.3%
log1p-udef86.3%
diff-log86.3%
Applied egg-rr86.3%
Taylor expanded in x around inf 86.3%
Final simplification63.7%
(FPCore (x n) :precision binary64 (if (<= x 9e+100) (/ (/ 1.0 x) n) (/ 0.0 n)))
double code(double x, double n) {
double tmp;
if (x <= 9e+100) {
tmp = (1.0 / 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 <= 9d+100) then
tmp = (1.0d0 / 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 <= 9e+100) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 9e+100: tmp = (1.0 / x) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 9e+100) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 9e+100) tmp = (1.0 / x) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 9e+100], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9 \cdot 10^{+100}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 9.00000000000000073e100Initial program 45.9%
Taylor expanded in n around inf 44.7%
log1p-def44.7%
Simplified44.7%
Taylor expanded in x around inf 31.9%
if 9.00000000000000073e100 < x Initial program 86.3%
Taylor expanded in n around inf 86.3%
log1p-def86.3%
Simplified86.3%
log1p-udef86.3%
diff-log86.3%
Applied egg-rr86.3%
Taylor expanded in x around inf 86.3%
Final simplification48.9%
(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 58.5%
Taylor expanded in n around inf 57.7%
log1p-def57.7%
Simplified57.7%
Taylor expanded in x around inf 39.9%
*-commutative39.9%
Simplified39.9%
Final simplification39.9%
(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 58.5%
Taylor expanded in n around inf 57.7%
log1p-def57.7%
Simplified57.7%
Taylor expanded in x around inf 39.9%
*-commutative39.9%
Simplified39.9%
log1p-expm1-u52.0%
*-commutative52.0%
associate-/r*52.5%
Applied egg-rr52.5%
log1p-expm1-u40.4%
Applied egg-rr40.4%
Final simplification40.4%
(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 58.5%
Taylor expanded in n around inf 57.7%
log1p-def57.7%
Simplified57.7%
Taylor expanded in x around inf 40.4%
Final simplification40.4%
(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 58.5%
Taylor expanded in x around 0 33.9%
Taylor expanded in x around inf 4.3%
Final simplification4.3%
herbie shell --seed 2023320
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))