
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-44)
(* (/ 1.0 n) (/ t_0 x))
(if (<= (/ 1.0 n) 1e-85)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 2e-13)
(/ (/ t_0 n) x)
(- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-44) {
tmp = (1.0 / n) * (t_0 / x);
} else if ((1.0 / n) <= 1e-85) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 2e-13) {
tmp = (t_0 / n) / x;
} 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) <= -4e-44) {
tmp = (1.0 / n) * (t_0 / x);
} else if ((1.0 / n) <= 1e-85) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 2e-13) {
tmp = (t_0 / n) / x;
} 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) <= -4e-44: tmp = (1.0 / n) * (t_0 / x) elif (1.0 / n) <= 1e-85: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 2e-13: tmp = (t_0 / n) / x 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) <= -4e-44) tmp = Float64(Float64(1.0 / n) * Float64(t_0 / x)); elseif (Float64(1.0 / n) <= 1e-85) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 2e-13) tmp = Float64(Float64(t_0 / n) / x); else tmp = Float64(exp(Float64(log1p(x) / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-44], N[(N[(1.0 / n), $MachinePrecision] * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-85], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-13], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-44}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{t_0}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-85}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -3.99999999999999981e-44Initial program 89.1%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
log-rec96.6%
mul-1-neg96.6%
distribute-neg-frac96.6%
mul-1-neg96.6%
remove-double-neg96.6%
*-commutative96.6%
Simplified96.6%
associate-/r*96.6%
div-inv96.6%
div-inv96.6%
pow-to-exp96.6%
Applied egg-rr96.6%
if -3.99999999999999981e-44 < (/.f64 1 n) < 9.9999999999999998e-86Initial program 31.8%
Taylor expanded in n around inf 80.2%
log1p-def80.2%
Simplified80.2%
if 9.9999999999999998e-86 < (/.f64 1 n) < 2.0000000000000001e-13Initial program 13.9%
Taylor expanded in x around inf 75.3%
mul-1-neg75.3%
log-rec75.3%
mul-1-neg75.3%
distribute-neg-frac75.3%
mul-1-neg75.3%
remove-double-neg75.3%
*-commutative75.3%
Simplified75.3%
associate-/r*75.6%
div-inv75.6%
div-inv75.6%
pow-to-exp75.6%
Applied egg-rr75.6%
un-div-inv75.6%
associate-/l/75.3%
associate-/r*75.7%
Applied egg-rr75.7%
if 2.0000000000000001e-13 < (/.f64 1 n) Initial program 65.4%
Taylor expanded in n around 0 65.4%
log1p-def96.8%
Simplified96.8%
Final simplification88.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-44)
(* (/ 1.0 n) (/ t_0 x))
(if (<= (/ 1.0 n) 1e-85)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 2e-13) (/ (/ t_0 n) x) (- (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) <= -4e-44) {
tmp = (1.0 / n) * (t_0 / x);
} else if ((1.0 / n) <= 1e-85) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 2e-13) {
tmp = (t_0 / n) / x;
} else {
tmp = exp((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) <= -4e-44) {
tmp = (1.0 / n) * (t_0 / x);
} else if ((1.0 / n) <= 1e-85) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 2e-13) {
tmp = (t_0 / n) / x;
} 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) <= -4e-44: tmp = (1.0 / n) * (t_0 / x) elif (1.0 / n) <= 1e-85: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 2e-13: tmp = (t_0 / n) / x 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) <= -4e-44) tmp = Float64(Float64(1.0 / n) * Float64(t_0 / x)); elseif (Float64(1.0 / n) <= 1e-85) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 2e-13) tmp = Float64(Float64(t_0 / n) / x); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-44], N[(N[(1.0 / n), $MachinePrecision] * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-85], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-13], N[(N[(t$95$0 / n), $MachinePrecision] / x), $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 -4 \cdot 10^{-44}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{t_0}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-85}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -3.99999999999999981e-44Initial program 89.1%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
log-rec96.6%
mul-1-neg96.6%
distribute-neg-frac96.6%
mul-1-neg96.6%
remove-double-neg96.6%
*-commutative96.6%
Simplified96.6%
associate-/r*96.6%
div-inv96.6%
div-inv96.6%
pow-to-exp96.6%
Applied egg-rr96.6%
if -3.99999999999999981e-44 < (/.f64 1 n) < 9.9999999999999998e-86Initial program 31.8%
Taylor expanded in n around inf 80.2%
log1p-def80.2%
Simplified80.2%
if 9.9999999999999998e-86 < (/.f64 1 n) < 2.0000000000000001e-13Initial program 13.9%
Taylor expanded in x around inf 75.3%
mul-1-neg75.3%
log-rec75.3%
mul-1-neg75.3%
distribute-neg-frac75.3%
mul-1-neg75.3%
remove-double-neg75.3%
*-commutative75.3%
Simplified75.3%
associate-/r*75.6%
div-inv75.6%
div-inv75.6%
pow-to-exp75.6%
Applied egg-rr75.6%
un-div-inv75.6%
associate-/l/75.3%
associate-/r*75.7%
Applied egg-rr75.7%
if 2.0000000000000001e-13 < (/.f64 1 n) Initial program 65.4%
Taylor expanded in n around 0 65.4%
log1p-def96.8%
Simplified96.8%
Taylor expanded in x around 0 96.7%
Final simplification88.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -4e-44)
(* (/ 1.0 n) (/ t_0 x))
(if (<= (/ 1.0 n) 1e-85)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 2e-13)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e+234)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ 1.0 t_0) (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -4e-44) {
tmp = (1.0 / n) * (t_0 / x);
} else if ((1.0 / n) <= 1e-85) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 2e-13) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e+234) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / t_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) <= -4e-44) {
tmp = (1.0 / n) * (t_0 / x);
} else if ((1.0 / n) <= 1e-85) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 2e-13) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e+234) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / t_0) / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -4e-44: tmp = (1.0 / n) * (t_0 / x) elif (1.0 / n) <= 1e-85: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 2e-13: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e+234: tmp = (1.0 + (x / n)) - t_0 else: tmp = (1.0 / t_0) / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-44) tmp = Float64(Float64(1.0 / n) * Float64(t_0 / x)); elseif (Float64(1.0 / n) <= 1e-85) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 2e-13) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e+234) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(1.0 / t_0) / Float64(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], -4e-44], N[(N[(1.0 / n), $MachinePrecision] * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-85], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-13], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+234], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / 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 -4 \cdot 10^{-44}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{t_0}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-85}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+234}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{t_0}}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -3.99999999999999981e-44Initial program 89.1%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
log-rec96.6%
mul-1-neg96.6%
distribute-neg-frac96.6%
mul-1-neg96.6%
remove-double-neg96.6%
*-commutative96.6%
Simplified96.6%
associate-/r*96.6%
div-inv96.6%
div-inv96.6%
pow-to-exp96.6%
Applied egg-rr96.6%
if -3.99999999999999981e-44 < (/.f64 1 n) < 9.9999999999999998e-86Initial program 31.8%
Taylor expanded in n around inf 80.2%
log1p-def80.2%
Simplified80.2%
if 9.9999999999999998e-86 < (/.f64 1 n) < 2.0000000000000001e-13Initial program 13.9%
Taylor expanded in x around inf 75.3%
mul-1-neg75.3%
log-rec75.3%
mul-1-neg75.3%
distribute-neg-frac75.3%
mul-1-neg75.3%
remove-double-neg75.3%
*-commutative75.3%
Simplified75.3%
associate-/r*75.6%
div-inv75.6%
div-inv75.6%
pow-to-exp75.6%
Applied egg-rr75.6%
un-div-inv75.6%
associate-/l/75.3%
associate-/r*75.7%
Applied egg-rr75.7%
if 2.0000000000000001e-13 < (/.f64 1 n) < 1.00000000000000002e234Initial program 75.1%
Taylor expanded in x around 0 77.0%
if 1.00000000000000002e234 < (/.f64 1 n) Initial program 17.0%
Taylor expanded in x around inf 0.2%
mul-1-neg0.2%
log-rec0.2%
mul-1-neg0.2%
distribute-neg-frac0.2%
mul-1-neg0.2%
remove-double-neg0.2%
*-commutative0.2%
Simplified0.2%
add-sqr-sqrt0.0%
add-sqr-sqrt0.2%
add-sqr-sqrt0.0%
sqrt-unprod86.2%
sqr-neg86.2%
sqrt-unprod86.2%
add-sqr-sqrt86.2%
distribute-frac-neg86.2%
exp-neg86.2%
div-inv86.2%
pow-to-exp86.2%
Applied egg-rr86.2%
Final simplification85.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 1.14e-303)
(/ (- (log x)) n)
(if (<= x 6.2e-155)
(- 1.0 t_0)
(if (or (<= x 3.9e-125) (and (not (<= x 1.25e-91)) (<= x 6.6e-9)))
(/ 1.0 (- 0.5 (/ n (log x))))
(/ (/ t_0 n) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 1.14e-303) {
tmp = -log(x) / n;
} else if (x <= 6.2e-155) {
tmp = 1.0 - t_0;
} else if ((x <= 3.9e-125) || (!(x <= 1.25e-91) && (x <= 6.6e-9))) {
tmp = 1.0 / (0.5 - (n / log(x)));
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 1.14d-303) then
tmp = -log(x) / n
else if (x <= 6.2d-155) then
tmp = 1.0d0 - t_0
else if ((x <= 3.9d-125) .or. (.not. (x <= 1.25d-91)) .and. (x <= 6.6d-9)) then
tmp = 1.0d0 / (0.5d0 - (n / log(x)))
else
tmp = (t_0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 1.14e-303) {
tmp = -Math.log(x) / n;
} else if (x <= 6.2e-155) {
tmp = 1.0 - t_0;
} else if ((x <= 3.9e-125) || (!(x <= 1.25e-91) && (x <= 6.6e-9))) {
tmp = 1.0 / (0.5 - (n / Math.log(x)));
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 1.14e-303: tmp = -math.log(x) / n elif x <= 6.2e-155: tmp = 1.0 - t_0 elif (x <= 3.9e-125) or (not (x <= 1.25e-91) and (x <= 6.6e-9)): tmp = 1.0 / (0.5 - (n / math.log(x))) else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 1.14e-303) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 6.2e-155) tmp = Float64(1.0 - t_0); elseif ((x <= 3.9e-125) || (!(x <= 1.25e-91) && (x <= 6.6e-9))) tmp = Float64(1.0 / Float64(0.5 - Float64(n / log(x)))); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 1.14e-303) tmp = -log(x) / n; elseif (x <= 6.2e-155) tmp = 1.0 - t_0; elseif ((x <= 3.9e-125) || (~((x <= 1.25e-91)) && (x <= 6.6e-9))) tmp = 1.0 / (0.5 - (n / log(x))); else tmp = (t_0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.14e-303], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 6.2e-155], N[(1.0 - t$95$0), $MachinePrecision], If[Or[LessEqual[x, 3.9e-125], And[N[Not[LessEqual[x, 1.25e-91]], $MachinePrecision], LessEqual[x, 6.6e-9]]], N[(1.0 / N[(0.5 - N[(n / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 1.14 \cdot 10^{-303}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-155}:\\
\;\;\;\;1 - t_0\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-125} \lor \neg \left(x \leq 1.25 \cdot 10^{-91}\right) \land x \leq 6.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{0.5 - \frac{n}{\log x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\end{array}
\end{array}
if x < 1.14e-303Initial program 5.2%
Taylor expanded in x around 0 5.2%
Taylor expanded in n around inf 99.7%
associate-*r/99.7%
mul-1-neg99.7%
Simplified99.7%
if 1.14e-303 < x < 6.2e-155Initial program 59.2%
Taylor expanded in x around 0 59.2%
if 6.2e-155 < x < 3.89999999999999982e-125 or 1.24999999999999999e-91 < x < 6.60000000000000037e-9Initial program 28.3%
Taylor expanded in x around 0 28.3%
flip--14.3%
clear-num14.3%
metadata-eval14.3%
pow-sqr14.6%
div-inv14.6%
Applied egg-rr14.6%
Taylor expanded in n around inf 58.9%
associate-*r/58.9%
neg-mul-158.9%
Simplified58.9%
if 3.89999999999999982e-125 < x < 1.24999999999999999e-91 or 6.60000000000000037e-9 < x Initial program 66.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-commutative94.3%
Simplified94.3%
associate-/r*95.4%
div-inv95.3%
div-inv95.3%
pow-to-exp95.3%
Applied egg-rr95.3%
un-div-inv95.4%
associate-/l/94.3%
associate-/r*95.3%
Applied egg-rr95.3%
Final simplification78.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= x 4.2e-303)
(/ (- (log x)) n)
(if (<= x 4.7e-150)
(- (+ 1.0 (/ x n)) t_0)
(if (or (<= x 3.4e-125) (and (not (<= x 2.1e-91)) (<= x 0.000122)))
(/ 1.0 (- 0.5 (/ n (log x))))
(/ (/ t_0 n) x))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if (x <= 4.2e-303) {
tmp = -log(x) / n;
} else if (x <= 4.7e-150) {
tmp = (1.0 + (x / n)) - t_0;
} else if ((x <= 3.4e-125) || (!(x <= 2.1e-91) && (x <= 0.000122))) {
tmp = 1.0 / (0.5 - (n / log(x)));
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if (x <= 4.2d-303) then
tmp = -log(x) / n
else if (x <= 4.7d-150) then
tmp = (1.0d0 + (x / n)) - t_0
else if ((x <= 3.4d-125) .or. (.not. (x <= 2.1d-91)) .and. (x <= 0.000122d0)) then
tmp = 1.0d0 / (0.5d0 - (n / log(x)))
else
tmp = (t_0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if (x <= 4.2e-303) {
tmp = -Math.log(x) / n;
} else if (x <= 4.7e-150) {
tmp = (1.0 + (x / n)) - t_0;
} else if ((x <= 3.4e-125) || (!(x <= 2.1e-91) && (x <= 0.000122))) {
tmp = 1.0 / (0.5 - (n / Math.log(x)));
} else {
tmp = (t_0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if x <= 4.2e-303: tmp = -math.log(x) / n elif x <= 4.7e-150: tmp = (1.0 + (x / n)) - t_0 elif (x <= 3.4e-125) or (not (x <= 2.1e-91) and (x <= 0.000122)): tmp = 1.0 / (0.5 - (n / math.log(x))) else: tmp = (t_0 / n) / x return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (x <= 4.2e-303) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 4.7e-150) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); elseif ((x <= 3.4e-125) || (!(x <= 2.1e-91) && (x <= 0.000122))) tmp = Float64(1.0 / Float64(0.5 - Float64(n / log(x)))); else tmp = Float64(Float64(t_0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if (x <= 4.2e-303) tmp = -log(x) / n; elseif (x <= 4.7e-150) tmp = (1.0 + (x / n)) - t_0; elseif ((x <= 3.4e-125) || (~((x <= 2.1e-91)) && (x <= 0.000122))) tmp = 1.0 / (0.5 - (n / log(x))); else tmp = (t_0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 4.2e-303], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 4.7e-150], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[Or[LessEqual[x, 3.4e-125], And[N[Not[LessEqual[x, 2.1e-91]], $MachinePrecision], LessEqual[x, 0.000122]]], N[(1.0 / N[(0.5 - N[(n / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 4.2 \cdot 10^{-303}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-150}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-125} \lor \neg \left(x \leq 2.1 \cdot 10^{-91}\right) \land x \leq 0.000122:\\
\;\;\;\;\frac{1}{0.5 - \frac{n}{\log x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{n}}{x}\\
\end{array}
\end{array}
if x < 4.2e-303Initial program 5.2%
Taylor expanded in x around 0 5.2%
Taylor expanded in n around inf 99.7%
associate-*r/99.7%
mul-1-neg99.7%
Simplified99.7%
if 4.2e-303 < x < 4.6999999999999999e-150Initial program 59.2%
Taylor expanded in x around 0 59.6%
if 4.6999999999999999e-150 < x < 3.39999999999999975e-125 or 2.0999999999999999e-91 < x < 1.21999999999999997e-4Initial program 28.3%
Taylor expanded in x around 0 28.3%
flip--14.3%
clear-num14.3%
metadata-eval14.3%
pow-sqr14.6%
div-inv14.6%
Applied egg-rr14.6%
Taylor expanded in n around inf 58.9%
associate-*r/58.9%
neg-mul-158.9%
Simplified58.9%
if 3.39999999999999975e-125 < x < 2.0999999999999999e-91 or 1.21999999999999997e-4 < x Initial program 66.2%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
log-rec94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
mul-1-neg94.3%
remove-double-neg94.3%
*-commutative94.3%
Simplified94.3%
associate-/r*95.4%
div-inv95.3%
div-inv95.3%
pow-to-exp95.3%
Applied egg-rr95.3%
un-div-inv95.4%
associate-/l/94.3%
associate-/r*95.3%
Applied egg-rr95.3%
Final simplification78.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ 1.0 (- 0.5 (/ n (log x))))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 2.8e-303)
(/ (- (log x)) n)
(if (<= x 2.05e-154)
t_1
(if (<= x 3.9e-125)
t_0
(if (<= x 1.35e-91)
t_1
(if (<= x 0.03) t_0 (* (/ 1.0 n) (/ 1.0 x)))))))))
double code(double x, double n) {
double t_0 = 1.0 / (0.5 - (n / log(x)));
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 2.8e-303) {
tmp = -log(x) / n;
} else if (x <= 2.05e-154) {
tmp = t_1;
} else if (x <= 3.9e-125) {
tmp = t_0;
} else if (x <= 1.35e-91) {
tmp = t_1;
} else if (x <= 0.03) {
tmp = t_0;
} else {
tmp = (1.0 / n) * (1.0 / 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 / (0.5d0 - (n / log(x)))
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 2.8d-303) then
tmp = -log(x) / n
else if (x <= 2.05d-154) then
tmp = t_1
else if (x <= 3.9d-125) then
tmp = t_0
else if (x <= 1.35d-91) then
tmp = t_1
else if (x <= 0.03d0) then
tmp = t_0
else
tmp = (1.0d0 / n) * (1.0d0 / x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 / (0.5 - (n / Math.log(x)));
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (x <= 2.8e-303) {
tmp = -Math.log(x) / n;
} else if (x <= 2.05e-154) {
tmp = t_1;
} else if (x <= 3.9e-125) {
tmp = t_0;
} else if (x <= 1.35e-91) {
tmp = t_1;
} else if (x <= 0.03) {
tmp = t_0;
} else {
tmp = (1.0 / n) * (1.0 / x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 / (0.5 - (n / math.log(x))) t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 2.8e-303: tmp = -math.log(x) / n elif x <= 2.05e-154: tmp = t_1 elif x <= 3.9e-125: tmp = t_0 elif x <= 1.35e-91: tmp = t_1 elif x <= 0.03: tmp = t_0 else: tmp = (1.0 / n) * (1.0 / x) return tmp
function code(x, n) t_0 = Float64(1.0 / Float64(0.5 - Float64(n / log(x)))) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 2.8e-303) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.05e-154) tmp = t_1; elseif (x <= 3.9e-125) tmp = t_0; elseif (x <= 1.35e-91) tmp = t_1; elseif (x <= 0.03) tmp = t_0; else tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 / (0.5 - (n / log(x))); t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 2.8e-303) tmp = -log(x) / n; elseif (x <= 2.05e-154) tmp = t_1; elseif (x <= 3.9e-125) tmp = t_0; elseif (x <= 1.35e-91) tmp = t_1; elseif (x <= 0.03) tmp = t_0; else tmp = (1.0 / n) * (1.0 / x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 / N[(0.5 - N[(n / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.8e-303], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.05e-154], t$95$1, If[LessEqual[x, 3.9e-125], t$95$0, If[LessEqual[x, 1.35e-91], t$95$1, If[LessEqual[x, 0.03], t$95$0, N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{0.5 - \frac{n}{\log x}}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 2.8 \cdot 10^{-303}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-125}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-91}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 0.03:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\end{array}
\end{array}
if x < 2.8e-303Initial program 5.2%
Taylor expanded in x around 0 5.2%
Taylor expanded in n around inf 99.7%
associate-*r/99.7%
mul-1-neg99.7%
Simplified99.7%
if 2.8e-303 < x < 2.05e-154 or 3.89999999999999982e-125 < x < 1.3499999999999999e-91Initial program 60.4%
Taylor expanded in x around 0 60.4%
if 2.05e-154 < x < 3.89999999999999982e-125 or 1.3499999999999999e-91 < x < 0.029999999999999999Initial program 28.3%
Taylor expanded in x around 0 28.3%
flip--14.3%
clear-num14.3%
metadata-eval14.3%
pow-sqr14.6%
div-inv14.6%
Applied egg-rr14.6%
Taylor expanded in n around inf 58.9%
associate-*r/58.9%
neg-mul-158.9%
Simplified58.9%
if 0.029999999999999999 < x Initial program 66.2%
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%
associate-/r*98.8%
div-inv98.8%
div-inv98.8%
pow-to-exp98.8%
Applied egg-rr98.8%
Taylor expanded in n around inf 61.5%
Final simplification61.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- (log x)) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 1.9e-303)
t_0
(if (<= x 6.2e-155)
t_1
(if (<= x 2.6e-125)
t_0
(if (<= x 2.6e-81)
t_1
(if (<= x 0.03) t_0 (* (/ 1.0 n) (/ 1.0 x)))))))))
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 <= 1.9e-303) {
tmp = t_0;
} else if (x <= 6.2e-155) {
tmp = t_1;
} else if (x <= 2.6e-125) {
tmp = t_0;
} else if (x <= 2.6e-81) {
tmp = t_1;
} else if (x <= 0.03) {
tmp = t_0;
} else {
tmp = (1.0 / n) * (1.0 / 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 = -log(x) / n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 1.9d-303) then
tmp = t_0
else if (x <= 6.2d-155) then
tmp = t_1
else if (x <= 2.6d-125) then
tmp = t_0
else if (x <= 2.6d-81) then
tmp = t_1
else if (x <= 0.03d0) then
tmp = t_0
else
tmp = (1.0d0 / n) * (1.0d0 / x)
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 <= 1.9e-303) {
tmp = t_0;
} else if (x <= 6.2e-155) {
tmp = t_1;
} else if (x <= 2.6e-125) {
tmp = t_0;
} else if (x <= 2.6e-81) {
tmp = t_1;
} else if (x <= 0.03) {
tmp = t_0;
} else {
tmp = (1.0 / n) * (1.0 / x);
}
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 <= 1.9e-303: tmp = t_0 elif x <= 6.2e-155: tmp = t_1 elif x <= 2.6e-125: tmp = t_0 elif x <= 2.6e-81: tmp = t_1 elif x <= 0.03: tmp = t_0 else: tmp = (1.0 / n) * (1.0 / x) 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 <= 1.9e-303) tmp = t_0; elseif (x <= 6.2e-155) tmp = t_1; elseif (x <= 2.6e-125) tmp = t_0; elseif (x <= 2.6e-81) tmp = t_1; elseif (x <= 0.03) tmp = t_0; else tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); 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 <= 1.9e-303) tmp = t_0; elseif (x <= 6.2e-155) tmp = t_1; elseif (x <= 2.6e-125) tmp = t_0; elseif (x <= 2.6e-81) tmp = t_1; elseif (x <= 0.03) tmp = t_0; else tmp = (1.0 / n) * (1.0 / x); 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, 1.9e-303], t$95$0, If[LessEqual[x, 6.2e-155], t$95$1, If[LessEqual[x, 2.6e-125], t$95$0, If[LessEqual[x, 2.6e-81], t$95$1, If[LessEqual[x, 0.03], t$95$0, N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $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 1.9 \cdot 10^{-303}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-155}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-125}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-81}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 0.03:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\end{array}
\end{array}
if x < 1.90000000000000005e-303 or 6.2e-155 < x < 2.60000000000000006e-125 or 2.5999999999999999e-81 < x < 0.029999999999999999Initial program 23.9%
Taylor expanded in x around 0 23.9%
Taylor expanded in n around inf 65.2%
associate-*r/65.2%
mul-1-neg65.2%
Simplified65.2%
if 1.90000000000000005e-303 < x < 6.2e-155 or 2.60000000000000006e-125 < x < 2.5999999999999999e-81Initial program 58.9%
Taylor expanded in x around 0 58.9%
if 0.029999999999999999 < x Initial program 66.2%
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%
associate-/r*98.8%
div-inv98.8%
div-inv98.8%
pow-to-exp98.8%
Applied egg-rr98.8%
Taylor expanded in n around inf 61.5%
Final simplification61.3%
(FPCore (x n) :precision binary64 (if (<= x 0.03) (/ (- (log x)) n) (* (/ 1.0 n) (/ 1.0 x))))
double code(double x, double n) {
double tmp;
if (x <= 0.03) {
tmp = -log(x) / n;
} else {
tmp = (1.0 / n) * (1.0 / x);
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.03d0) then
tmp = -log(x) / n
else
tmp = (1.0d0 / n) * (1.0d0 / x)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.03) {
tmp = -Math.log(x) / n;
} else {
tmp = (1.0 / n) * (1.0 / x);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.03: tmp = -math.log(x) / n else: tmp = (1.0 / n) * (1.0 / x) return tmp
function code(x, n) tmp = 0.0 if (x <= 0.03) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.03) tmp = -log(x) / n; else tmp = (1.0 / n) * (1.0 / x); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.03], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.03:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\
\end{array}
\end{array}
if x < 0.029999999999999999Initial program 46.6%
Taylor expanded in x around 0 46.6%
Taylor expanded in n around inf 49.8%
associate-*r/49.8%
mul-1-neg49.8%
Simplified49.8%
if 0.029999999999999999 < x Initial program 66.2%
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%
associate-/r*98.8%
div-inv98.8%
div-inv98.8%
pow-to-exp98.8%
Applied egg-rr98.8%
Taylor expanded in n around inf 61.5%
Final simplification55.3%
(FPCore (x n) :precision binary64 (* (/ 1.0 n) (/ 1.0 x)))
double code(double x, double n) {
return (1.0 / n) * (1.0 / x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) * (1.0d0 / x)
end function
public static double code(double x, double n) {
return (1.0 / n) * (1.0 / x);
}
def code(x, n): return (1.0 / n) * (1.0 / x)
function code(x, n) return Float64(Float64(1.0 / n) * Float64(1.0 / x)) end
function tmp = code(x, n) tmp = (1.0 / n) * (1.0 / x); end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n} \cdot \frac{1}{x}
\end{array}
Initial program 55.7%
Taylor expanded in x around inf 59.5%
mul-1-neg59.5%
log-rec59.5%
mul-1-neg59.5%
distribute-neg-frac59.5%
mul-1-neg59.5%
remove-double-neg59.5%
*-commutative59.5%
Simplified59.5%
associate-/r*60.2%
div-inv60.2%
div-inv60.2%
pow-to-exp60.2%
Applied egg-rr60.2%
Taylor expanded in n around inf 39.2%
Final simplification39.2%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(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 55.7%
Taylor expanded in x around inf 59.5%
mul-1-neg59.5%
log-rec59.5%
mul-1-neg59.5%
distribute-neg-frac59.5%
mul-1-neg59.5%
remove-double-neg59.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in n around inf 38.6%
Final simplification38.6%
herbie shell --seed 2023305
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))