
(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 12 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-59)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2e-21)
(/ (- (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-59) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-21) {
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-59) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2e-21) {
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-59: tmp = (t_0 / n) / x elif (1.0 / n) <= 2e-21: 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-59) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2e-21) 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-59], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], 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^{-59}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\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-59Initial program 89.1%
Taylor expanded in x around inf 94.8%
mul-1-neg94.8%
log-rec94.8%
mul-1-neg94.8%
distribute-neg-frac94.8%
mul-1-neg94.8%
remove-double-neg94.8%
*-commutative94.8%
Simplified94.8%
div-inv94.9%
div-inv94.9%
pow-to-exp94.9%
Applied egg-rr94.9%
div-inv94.9%
*-commutative94.9%
associate-/r*94.9%
Applied egg-rr94.9%
if -2.0000000000000001e-59 < (/.f64 1 n) < 1.99999999999999982e-21Initial program 30.0%
Taylor expanded in n around inf 79.7%
log1p-def79.7%
Simplified79.7%
log1p-udef79.7%
diff-log79.7%
+-commutative79.7%
Applied egg-rr79.7%
clear-num79.7%
log-rec79.8%
Applied egg-rr79.8%
if 1.99999999999999982e-21 < (/.f64 1 n) Initial program 49.7%
Taylor expanded in n around 0 49.7%
log1p-def90.9%
Simplified90.9%
Final simplification87.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-59)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-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-59) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-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-59)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-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-59) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-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-59: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-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-59) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-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-59) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-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-59], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-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^{-59}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \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-59Initial program 89.1%
Taylor expanded in x around inf 94.8%
mul-1-neg94.8%
log-rec94.8%
mul-1-neg94.8%
distribute-neg-frac94.8%
mul-1-neg94.8%
remove-double-neg94.8%
*-commutative94.8%
Simplified94.8%
div-inv94.9%
div-inv94.9%
pow-to-exp94.9%
Applied egg-rr94.9%
div-inv94.9%
*-commutative94.9%
associate-/r*94.9%
Applied egg-rr94.9%
if -2.0000000000000001e-59 < (/.f64 1 n) < 5.00000000000000024e-5Initial program 29.6%
Taylor expanded in n around inf 78.5%
log1p-def78.5%
Simplified78.5%
log1p-udef78.5%
diff-log78.5%
+-commutative78.5%
Applied egg-rr78.5%
clear-num78.5%
log-rec78.5%
Applied egg-rr78.5%
if 5.00000000000000024e-5 < (/.f64 1 n) Initial program 51.9%
Taylor expanded in n around 0 51.9%
log1p-def95.1%
Simplified95.1%
Taylor expanded in x around 0 95.1%
Final simplification87.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -2e+67)
t_1
(if (<= (/ 1.0 n) -0.1)
t_0
(if (<= (/ 1.0 n) 5e-5)
t_1
(if (<= (/ 1.0 n) 1e+237) t_0 (/ 1.0 (* n x))))))))
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 tmp;
if ((1.0 / n) <= -2e+67) {
tmp = t_1;
} else if ((1.0 / n) <= -0.1) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+237) {
tmp = 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-2d+67)) then
tmp = t_1
else if ((1.0d0 / n) <= (-0.1d0)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d-5) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+237) then
tmp = 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 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -2e+67) {
tmp = t_1;
} else if ((1.0 / n) <= -0.1) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-5) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+237) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
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 tmp = 0 if (1.0 / n) <= -2e+67: tmp = t_1 elif (1.0 / n) <= -0.1: tmp = t_0 elif (1.0 / n) <= 5e-5: tmp = t_1 elif (1.0 / n) <= 1e+237: tmp = t_0 else: tmp = 1.0 / (n * x) 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) tmp = 0.0 if (Float64(1.0 / n) <= -2e+67) tmp = t_1; elseif (Float64(1.0 / n) <= -0.1) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-5) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+237) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); 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; tmp = 0.0; if ((1.0 / n) <= -2e+67) tmp = t_1; elseif ((1.0 / n) <= -0.1) tmp = t_0; elseif ((1.0 / n) <= 5e-5) tmp = t_1; elseif ((1.0 / n) <= 1e+237) tmp = t_0; else tmp = 1.0 / (n * x); 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]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+67], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+237], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]
\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}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+67}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+237}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.99999999999999997e67 or -0.10000000000000001 < (/.f64 1 n) < 5.00000000000000024e-5Initial program 50.3%
Taylor expanded in n around inf 74.1%
log1p-def74.1%
Simplified74.1%
log1p-udef74.1%
diff-log74.1%
+-commutative74.1%
Applied egg-rr74.1%
if -1.99999999999999997e67 < (/.f64 1 n) < -0.10000000000000001 or 5.00000000000000024e-5 < (/.f64 1 n) < 9.9999999999999994e236Initial program 80.4%
Taylor expanded in x around 0 67.3%
if 9.9999999999999994e236 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in x around inf 0.0%
mul-1-neg0.0%
log-rec0.0%
mul-1-neg0.0%
distribute-neg-frac0.0%
mul-1-neg0.0%
remove-double-neg0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in n around inf 100.0%
Final simplification73.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -2e+67)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) -0.1)
t_0
(if (<= (/ 1.0 n) 5e-5)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e+237) t_0 (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+67) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -0.1) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-5) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+237) {
tmp = 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 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-2d+67)) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= (-0.1d0)) then
tmp = t_0
else if ((1.0d0 / n) <= 5d-5) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d+237) then
tmp = 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 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e+67) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -0.1) {
tmp = t_0;
} else if ((1.0 / n) <= 5e-5) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+237) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e+67: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= -0.1: tmp = t_0 elif (1.0 / n) <= 5e-5: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e+237: tmp = t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -2e+67) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= -0.1) tmp = t_0; elseif (Float64(1.0 / n) <= 5e-5) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e+237) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -2e+67) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= -0.1) tmp = t_0; elseif ((1.0 / n) <= 5e-5) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e+237) tmp = t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+67], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-5], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+237], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+67}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+237}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.99999999999999997e67Initial program 100.0%
Taylor expanded in n around inf 72.0%
log1p-def72.0%
Simplified72.0%
log1p-udef72.0%
diff-log72.0%
+-commutative72.0%
Applied egg-rr72.0%
if -1.99999999999999997e67 < (/.f64 1 n) < -0.10000000000000001 or 5.00000000000000024e-5 < (/.f64 1 n) < 9.9999999999999994e236Initial program 80.4%
Taylor expanded in x around 0 67.3%
if -0.10000000000000001 < (/.f64 1 n) < 5.00000000000000024e-5Initial program 29.6%
Taylor expanded in n around inf 75.0%
log1p-def75.0%
Simplified75.0%
log1p-udef75.0%
diff-log75.0%
+-commutative75.0%
Applied egg-rr75.0%
clear-num75.0%
log-rec75.1%
Applied egg-rr75.1%
if 9.9999999999999994e236 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in x around inf 0.0%
mul-1-neg0.0%
log-rec0.0%
mul-1-neg0.0%
distribute-neg-frac0.0%
mul-1-neg0.0%
remove-double-neg0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in n around inf 100.0%
Final simplification73.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-59)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-7)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e+237) (- (+ 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-59) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-7) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+237) {
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-59)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-7) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d+237) 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-59) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-7) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+237) {
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-59: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-7: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e+237: 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-59) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-7) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e+237) 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-59) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-7) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e+237) 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-59], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-7], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+237], 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^{-59}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+237}:\\
\;\;\;\;\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-59Initial program 89.1%
Taylor expanded in x around inf 94.8%
mul-1-neg94.8%
log-rec94.8%
mul-1-neg94.8%
distribute-neg-frac94.8%
mul-1-neg94.8%
remove-double-neg94.8%
*-commutative94.8%
Simplified94.8%
div-inv94.9%
div-inv94.9%
pow-to-exp94.9%
Applied egg-rr94.9%
div-inv94.9%
*-commutative94.9%
associate-/r*94.9%
Applied egg-rr94.9%
if -2.0000000000000001e-59 < (/.f64 1 n) < 4.99999999999999977e-7Initial program 29.8%
Taylor expanded in n around inf 79.1%
log1p-def79.1%
Simplified79.1%
log1p-udef79.1%
diff-log79.1%
+-commutative79.1%
Applied egg-rr79.1%
clear-num79.1%
log-rec79.1%
Applied egg-rr79.1%
if 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999994e236Initial program 65.7%
Taylor expanded in x around 0 65.2%
if 9.9999999999999994e236 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in x around inf 0.0%
mul-1-neg0.0%
log-rec0.0%
mul-1-neg0.0%
distribute-neg-frac0.0%
mul-1-neg0.0%
remove-double-neg0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in n around inf 100.0%
Final simplification83.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-59)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 5e-5)
(/ (- (log (/ x (+ 1.0 x)))) n)
(if (<= (/ 1.0 n) 1e+237) (- 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-59) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-5) {
tmp = -log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+237) {
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-59)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 5d-5) then
tmp = -log((x / (1.0d0 + x))) / n
else if ((1.0d0 / n) <= 1d+237) 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-59) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 5e-5) {
tmp = -Math.log((x / (1.0 + x))) / n;
} else if ((1.0 / n) <= 1e+237) {
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-59: tmp = (t_0 / n) / x elif (1.0 / n) <= 5e-5: tmp = -math.log((x / (1.0 + x))) / n elif (1.0 / n) <= 1e+237: 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-59) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 5e-5) tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n); elseif (Float64(1.0 / n) <= 1e+237) 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-59) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 5e-5) tmp = -log((x / (1.0 + x))) / n; elseif ((1.0 / n) <= 1e+237) 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-59], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-5], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+237], 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^{-59}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+237}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-59Initial program 89.1%
Taylor expanded in x around inf 94.8%
mul-1-neg94.8%
log-rec94.8%
mul-1-neg94.8%
distribute-neg-frac94.8%
mul-1-neg94.8%
remove-double-neg94.8%
*-commutative94.8%
Simplified94.8%
div-inv94.9%
div-inv94.9%
pow-to-exp94.9%
Applied egg-rr94.9%
div-inv94.9%
*-commutative94.9%
associate-/r*94.9%
Applied egg-rr94.9%
if -2.0000000000000001e-59 < (/.f64 1 n) < 5.00000000000000024e-5Initial program 29.6%
Taylor expanded in n around inf 78.5%
log1p-def78.5%
Simplified78.5%
log1p-udef78.5%
diff-log78.5%
+-commutative78.5%
Applied egg-rr78.5%
clear-num78.5%
log-rec78.5%
Applied egg-rr78.5%
if 5.00000000000000024e-5 < (/.f64 1 n) < 9.9999999999999994e236Initial program 67.6%
Taylor expanded in x around 0 64.5%
if 9.9999999999999994e236 < (/.f64 1 n) Initial program 3.1%
Taylor expanded in x around inf 0.0%
mul-1-neg0.0%
log-rec0.0%
mul-1-neg0.0%
distribute-neg-frac0.0%
mul-1-neg0.0%
remove-double-neg0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in n around inf 100.0%
Final simplification83.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 7e-255)
t_0
(if (<= x 5.2e-119)
(/ (- (log x)) n)
(if (<= x 1.2e-81)
t_0
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (<= x 2.85e+43)
(* (/ 1.0 n) (/ 1.0 x))
(if (<= x 1.35e+74)
0.0
(if (<= x 2.1e+95) (/ (/ 1.0 n) x) 0.0)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 7e-255) {
tmp = t_0;
} else if (x <= 5.2e-119) {
tmp = -log(x) / n;
} else if (x <= 1.2e-81) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 2.85e+43) {
tmp = (1.0 / n) * (1.0 / x);
} else if (x <= 1.35e+74) {
tmp = 0.0;
} else if (x <= 2.1e+95) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.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 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 7d-255) then
tmp = t_0
else if (x <= 5.2d-119) then
tmp = -log(x) / n
else if (x <= 1.2d-81) then
tmp = t_0
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 2.85d+43) then
tmp = (1.0d0 / n) * (1.0d0 / x)
else if (x <= 1.35d+74) then
tmp = 0.0d0
else if (x <= 2.1d+95) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 7e-255) {
tmp = t_0;
} else if (x <= 5.2e-119) {
tmp = -Math.log(x) / n;
} else if (x <= 1.2e-81) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.85e+43) {
tmp = (1.0 / n) * (1.0 / x);
} else if (x <= 1.35e+74) {
tmp = 0.0;
} else if (x <= 2.1e+95) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 7e-255: tmp = t_0 elif x <= 5.2e-119: tmp = -math.log(x) / n elif x <= 1.2e-81: tmp = t_0 elif x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 2.85e+43: tmp = (1.0 / n) * (1.0 / x) elif x <= 1.35e+74: tmp = 0.0 elif x <= 2.1e+95: tmp = (1.0 / n) / x else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 7e-255) tmp = t_0; elseif (x <= 5.2e-119) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.2e-81) tmp = t_0; elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.85e+43) tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); elseif (x <= 1.35e+74) tmp = 0.0; elseif (x <= 2.1e+95) tmp = Float64(Float64(1.0 / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 7e-255) tmp = t_0; elseif (x <= 5.2e-119) tmp = -log(x) / n; elseif (x <= 1.2e-81) tmp = t_0; elseif (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 2.85e+43) tmp = (1.0 / n) * (1.0 / x); elseif (x <= 1.35e+74) tmp = 0.0; elseif (x <= 2.1e+95) tmp = (1.0 / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 7e-255], t$95$0, If[LessEqual[x, 5.2e-119], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.2e-81], t$95$0, If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.85e+43], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+74], 0.0, If[LessEqual[x, 2.1e+95], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 7 \cdot 10^{-255}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-119}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-81}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.85 \cdot 10^{+43}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+74}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+95}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 6.99999999999999958e-255 or 5.20000000000000023e-119 < x < 1.2e-81Initial program 61.6%
Taylor expanded in x around 0 61.6%
if 6.99999999999999958e-255 < x < 5.20000000000000023e-119Initial program 38.0%
Taylor expanded in x around 0 38.0%
Taylor expanded in n around inf 53.4%
neg-mul-153.4%
distribute-neg-frac53.4%
Simplified53.4%
if 1.2e-81 < x < 1Initial program 26.7%
Taylor expanded in n around inf 59.4%
log1p-def59.4%
Simplified59.4%
Taylor expanded in x around 0 58.9%
neg-mul-158.9%
unsub-neg58.9%
Simplified58.9%
if 1 < x < 2.8499999999999999e43Initial program 29.6%
Taylor expanded in x around inf 91.9%
mul-1-neg91.9%
log-rec91.9%
mul-1-neg91.9%
distribute-neg-frac91.9%
mul-1-neg91.9%
remove-double-neg91.9%
*-commutative91.9%
Simplified91.9%
Taylor expanded in n around inf 67.5%
associate-/r*67.5%
div-inv67.6%
Applied egg-rr67.6%
if 2.8499999999999999e43 < x < 1.3499999999999999e74 or 2.1e95 < x Initial program 81.2%
Taylor expanded in x around 0 39.4%
Taylor expanded in n around inf 81.3%
if 1.3499999999999999e74 < x < 2.1e95Initial program 21.8%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in n around inf 66.6%
associate-/r*66.8%
Simplified66.8%
Final simplification66.9%
(FPCore (x n)
:precision binary64
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (<= x 3.25e+43)
(* (/ 1.0 n) (/ 1.0 x))
(if (<= x 1.5e+74) 0.0 (if (<= x 1.82e+93) (/ (/ 1.0 n) x) 0.0)))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 3.25e+43) {
tmp = (1.0 / n) * (1.0 / x);
} else if (x <= 1.5e+74) {
tmp = 0.0;
} else if (x <= 1.82e+93) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 3.25d+43) then
tmp = (1.0d0 / n) * (1.0d0 / x)
else if (x <= 1.5d+74) then
tmp = 0.0d0
else if (x <= 1.82d+93) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 3.25e+43) {
tmp = (1.0 / n) * (1.0 / x);
} else if (x <= 1.5e+74) {
tmp = 0.0;
} else if (x <= 1.82e+93) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 3.25e+43: tmp = (1.0 / n) * (1.0 / x) elif x <= 1.5e+74: tmp = 0.0 elif x <= 1.82e+93: tmp = (1.0 / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 3.25e+43) tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); elseif (x <= 1.5e+74) tmp = 0.0; elseif (x <= 1.82e+93) tmp = Float64(Float64(1.0 / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 3.25e+43) tmp = (1.0 / n) * (1.0 / x); elseif (x <= 1.5e+74) tmp = 0.0; elseif (x <= 1.82e+93) tmp = (1.0 / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3.25e+43], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.5e+74], 0.0, If[LessEqual[x, 1.82e+93], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3.25 \cdot 10^{+43}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+74}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1.82 \cdot 10^{+93}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 41.9%
Taylor expanded in n around inf 50.5%
log1p-def50.5%
Simplified50.5%
Taylor expanded in x around 0 50.4%
neg-mul-150.4%
unsub-neg50.4%
Simplified50.4%
if 1 < x < 3.2499999999999999e43Initial program 29.6%
Taylor expanded in x around inf 91.9%
mul-1-neg91.9%
log-rec91.9%
mul-1-neg91.9%
distribute-neg-frac91.9%
mul-1-neg91.9%
remove-double-neg91.9%
*-commutative91.9%
Simplified91.9%
Taylor expanded in n around inf 67.5%
associate-/r*67.5%
div-inv67.6%
Applied egg-rr67.6%
if 3.2499999999999999e43 < x < 1.5e74 or 1.82000000000000009e93 < x Initial program 81.2%
Taylor expanded in x around 0 39.4%
Taylor expanded in n around inf 81.3%
if 1.5e74 < x < 1.82000000000000009e93Initial program 21.8%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in n around inf 66.6%
associate-/r*66.8%
Simplified66.8%
Final simplification63.4%
(FPCore (x n)
:precision binary64
(if (<= x 0.55)
(/ (- (log x)) n)
(if (<= x 2.35e+43)
(* (/ 1.0 n) (/ 1.0 x))
(if (<= x 1.35e+74) 0.0 (if (<= x 5.2e+95) (/ (/ 1.0 n) x) 0.0)))))
double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -log(x) / n;
} else if (x <= 2.35e+43) {
tmp = (1.0 / n) * (1.0 / x);
} else if (x <= 1.35e+74) {
tmp = 0.0;
} else if (x <= 5.2e+95) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.55d0) then
tmp = -log(x) / n
else if (x <= 2.35d+43) then
tmp = (1.0d0 / n) * (1.0d0 / x)
else if (x <= 1.35d+74) then
tmp = 0.0d0
else if (x <= 5.2d+95) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -Math.log(x) / n;
} else if (x <= 2.35e+43) {
tmp = (1.0 / n) * (1.0 / x);
} else if (x <= 1.35e+74) {
tmp = 0.0;
} else if (x <= 5.2e+95) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.55: tmp = -math.log(x) / n elif x <= 2.35e+43: tmp = (1.0 / n) * (1.0 / x) elif x <= 1.35e+74: tmp = 0.0 elif x <= 5.2e+95: tmp = (1.0 / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 0.55) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.35e+43) tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); elseif (x <= 1.35e+74) tmp = 0.0; elseif (x <= 5.2e+95) tmp = Float64(Float64(1.0 / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.55) tmp = -log(x) / n; elseif (x <= 2.35e+43) tmp = (1.0 / n) * (1.0 / x); elseif (x <= 1.35e+74) tmp = 0.0; elseif (x <= 5.2e+95) tmp = (1.0 / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.55], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.35e+43], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+74], 0.0, If[LessEqual[x, 5.2e+95], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.55:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{+43}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+74}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+95}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.55000000000000004Initial program 41.9%
Taylor expanded in x around 0 41.1%
Taylor expanded in n around inf 50.2%
neg-mul-150.2%
distribute-neg-frac50.2%
Simplified50.2%
if 0.55000000000000004 < x < 2.34999999999999999e43Initial program 29.6%
Taylor expanded in x around inf 91.9%
mul-1-neg91.9%
log-rec91.9%
mul-1-neg91.9%
distribute-neg-frac91.9%
mul-1-neg91.9%
remove-double-neg91.9%
*-commutative91.9%
Simplified91.9%
Taylor expanded in n around inf 67.5%
associate-/r*67.5%
div-inv67.6%
Applied egg-rr67.6%
if 2.34999999999999999e43 < x < 1.3499999999999999e74 or 5.19999999999999981e95 < x Initial program 81.2%
Taylor expanded in x around 0 39.4%
Taylor expanded in n around inf 81.3%
if 1.3499999999999999e74 < x < 5.19999999999999981e95Initial program 21.8%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in n around inf 66.6%
associate-/r*66.8%
Simplified66.8%
Final simplification63.3%
(FPCore (x n) :precision binary64 (if (or (<= n -2.5e-8) (not (<= n -7.5e-256))) (/ 1.0 (* n x)) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -2.5e-8) || !(n <= -7.5e-256)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-2.5d-8)) .or. (.not. (n <= (-7.5d-256)))) then
tmp = 1.0d0 / (n * x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -2.5e-8) || !(n <= -7.5e-256)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -2.5e-8) or not (n <= -7.5e-256): tmp = 1.0 / (n * x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -2.5e-8) || !(n <= -7.5e-256)) tmp = Float64(1.0 / Float64(n * x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -2.5e-8) || ~((n <= -7.5e-256))) tmp = 1.0 / (n * x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -2.5e-8], N[Not[LessEqual[n, -7.5e-256]], $MachinePrecision]], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.5 \cdot 10^{-8} \lor \neg \left(n \leq -7.5 \cdot 10^{-256}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -2.4999999999999999e-8 or -7.50000000000000005e-256 < n Initial program 40.0%
Taylor expanded in x around inf 45.8%
mul-1-neg45.8%
log-rec45.8%
mul-1-neg45.8%
distribute-neg-frac45.8%
mul-1-neg45.8%
remove-double-neg45.8%
*-commutative45.8%
Simplified45.8%
Taylor expanded in n around inf 45.0%
if -2.4999999999999999e-8 < n < -7.50000000000000005e-256Initial program 100.0%
Taylor expanded in x around 0 35.9%
Taylor expanded in n around inf 66.7%
Final simplification50.2%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -200000000000.0) 0.0 (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -200000000000.0) {
tmp = 0.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) :: tmp
if ((1.0d0 / n) <= (-200000000000.0d0)) then
tmp = 0.0d0
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) <= -200000000000.0) {
tmp = 0.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -200000000000.0: tmp = 0.0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -200000000000.0) tmp = 0.0; else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -200000000000.0) tmp = 0.0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -200000000000.0], 0.0, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -200000000000:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e11Initial program 100.0%
Taylor expanded in x around 0 38.1%
Taylor expanded in n around inf 64.5%
if -2e11 < (/.f64 1 n) Initial program 36.7%
Taylor expanded in x around inf 42.9%
mul-1-neg42.9%
log-rec42.9%
mul-1-neg42.9%
distribute-neg-frac42.9%
mul-1-neg42.9%
remove-double-neg42.9%
*-commutative42.9%
Simplified42.9%
Taylor expanded in n around inf 44.6%
associate-/r*45.6%
Simplified45.6%
Final simplification50.9%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 54.5%
Taylor expanded in x around 0 36.7%
Taylor expanded in n around inf 34.2%
Final simplification34.2%
herbie shell --seed 2024020
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))